diff options
author | Scott Moser <smoser@ubuntu.com> | 2010-01-20 17:00:41 -0500 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2010-01-20 17:00:41 -0500 |
commit | 9dacf611aceb6979f51f05f1b938da4489d2dbc6 (patch) | |
tree | 2bc31c25a9ad0fd804d20301c6425eafaa20c72f | |
parent | 8ac737948622d97f43877dbc1c78707eb82fb273 (diff) | |
download | vyos-cloud-init-9dacf611aceb6979f51f05f1b938da4489d2dbc6.tar.gz vyos-cloud-init-9dacf611aceb6979f51f05f1b938da4489d2dbc6.zip |
support 'packages' in cloud-config
-rw-r--r-- | ec2init/CloudConfig.py | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/ec2init/CloudConfig.py b/ec2init/CloudConfig.py index 2b628edb..8a889a2b 100644 --- a/ec2init/CloudConfig.py +++ b/ec2init/CloudConfig.py @@ -69,14 +69,6 @@ class CloudConfig(): def get_handler_info(self, name): return(self.handlers[name]['handler'], self.handlers[name]['freq']) - def check_for_updates(self): - value = self.cfg['apt_update'] - return value - - def check_for_upgrade(self): - value = self.cfg['apt_upgrade'] - return value - def parse_ssh_keys(self): disableRoot = self.cfg['disable_root'] if disableRoot == 'true': @@ -127,16 +119,28 @@ class CloudConfig(): def h_apt_update_upgrade(self,name,args): update = util.get_cfg_option_bool(self.cfg, 'apt_update', False) upgrade = util.get_cfg_option_bool(self.cfg, 'apt_upgrade', False) + + pkglist = [] + if 'packages' in self.cfg: + if isinstance(self.cfg['packages'],list): + pkglist = self.cfg['packages'] + else: pkglist.append(self.cfg['packages']) - if update or upgrade: + if update or upgrade or pkglist: #retcode = subprocess.call(list) subprocess.Popen(['apt-get', 'update']).communicate() + e=os.environ.copy() + e['DEBIAN_FRONTEND']='noninteractive' + if upgrade: - e=os.environ.copy() - e['DEBIAN_FRONTEND']='noninteractive' subprocess.Popen(['apt-get', 'upgrade', '--assume-yes'], env=e).communicate() + if pkglist: + cmd=['apt-get', 'install', '--assume-yes'] + cmd.extend(pkglist) + subprocess.Popen(cmd, env=e).communicate() + return(True) def h_config_ssh(self,name,args): |