diff --git a/systemvm/patches/debian/config/opt/cloud/bin/configure.py b/systemvm/patches/debian/config/opt/cloud/bin/configure.py index d7754d58061..e4c23e57a88 100755 --- a/systemvm/patches/debian/config/opt/cloud/bin/configure.py +++ b/systemvm/patches/debian/config/opt/cloud/bin/configure.py @@ -59,7 +59,7 @@ class CsHelper: def execute(self, command): """ Execute command """ - p = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True) + p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) result = p.communicate()[0] return result.splitlines() @@ -604,10 +604,11 @@ class CsIP: self.delete("all") for ip in self.iplist: found = False - for address in bag[self.dev]: - self.setAddress(address) - if self.hasIP(ip): - found = True + if self.dev in bag.keys(): + for address in bag[self.dev]: + self.setAddress(address) + if self.hasIP(ip): + found = True if not found: self.delete(ip) diff --git a/systemvm/patches/debian/config/opt/cloud/bin/merge.py b/systemvm/patches/debian/config/opt/cloud/bin/merge.py index 8196089b44d..db222416edb 100755 --- a/systemvm/patches/debian/config/opt/cloud/bin/merge.py +++ b/systemvm/patches/debian/config/opt/cloud/bin/merge.py @@ -7,6 +7,7 @@ import logging import cs_ip import cs_guestnetwork import cs_cmdline +import cs_vmp from pprint import pprint @@ -70,6 +71,10 @@ class updateDataBag: dbag = self.processGuestNetwork(self.db.getDataBag()) if self.qFile.type == 'cmdline': dbag = self.processCL(self.db.getDataBag()) + if self.qFile.type == 'cmdline': + dbag = self.processCL(self.db.getDataBag()) + if self.qFile.type == 'vmpassword': + dbag = self.processVMpassword(self.db.getDataBag()) self.db.save(dbag) def processGuestNetwork(self, dbag): @@ -89,6 +94,9 @@ class updateDataBag: d['domain_name'] = "cloudnine.internal" return cs_guestnetwork.merge(dbag, self.qFile.data) + def processVMpassword(self, dbag): + dbag = cs_vmp.merge(dbag, self.qFile.data) + def processIP(self, dbag): for ip in self.qFile.data["ip_address"]: dbag = cs_ip.merge(dbag, ip) @@ -125,7 +133,6 @@ class updateDataBag: class loadQueueFile: fileName = '' - dpath = "/etc/cloudstack" configCache = "/var/cache/cloud" keep = True data = {} @@ -161,7 +168,7 @@ class loadQueueFile: return self.data def setPath(self, path): - self.dpath = path + self.configCache = path def __moveFile(self, origPath, path): if not os.path.exists(path): diff --git a/systemvm/patches/debian/config/opt/cloud/testdata/README b/systemvm/patches/debian/config/opt/cloud/testdata/README new file mode 100644 index 00000000000..047e4426afc --- /dev/null +++ b/systemvm/patches/debian/config/opt/cloud/testdata/README @@ -0,0 +1 @@ +Json file used to test the provisioning scripts on virtual appliances diff --git a/systemvm/patches/debian/config/opt/cloud/testdata/vmp0001.json b/systemvm/patches/debian/config/opt/cloud/testdata/vmp0001.json new file mode 100644 index 00000000000..39ee78d0929 --- /dev/null +++ b/systemvm/patches/debian/config/opt/cloud/testdata/vmp0001.json @@ -0,0 +1 @@ +{"ip_address":"172.16.1.102","password":"fnirq_cnffjbeq","type":"vmpassword"} \ No newline at end of file diff --git a/test/systemvm/test_update_config.py b/test/systemvm/test_update_config.py index 33eaca59a6c..b39339433f2 100644 --- a/test/systemvm/test_update_config.py +++ b/test/systemvm/test_update_config.py @@ -59,7 +59,7 @@ class UpdateConfigTestCase(SystemVMTestCase): def update_config(self, config): config_json = json.dumps(config, indent=2) print_doc('config.json', config_json) - file_write('/etc/cloudstack/update_config_test.json', config_json) + file_write('/var/cache/cloud/update_config_test.json', config_json) with hide("everything"): result = run("python /opt/cloud/bin/update_config.py update_config_test.json", timeout=600, warn_only=True) @@ -112,14 +112,16 @@ class UpdateConfigTestCase(SystemVMTestCase): ip_address["add"] = False buffer.append(copy.deepcopy(ip_address)) self.check_no_errors() - self.clear_log() - assert ip.has_ip("%s/24" % ip_address["public_ip"], "eth%s" % ip_address["nic_dev_id"]) + #self.clear_log() + assert ip.has_ip("%s/24" % ip_address["public_ip"], "eth%s" % ip_address["nic_dev_id"]), \ + "Configure %s on eth%s failed" % (ip_address["public_ip"], ip_address["nic_dev_id"]) # Now delete all the IPs we just made for ips in buffer: config = copy.deepcopy(self.basic_config) config["ip_address"].append(ips) self.update_config(config) - assert ip.has_ip("%s/24" % ips["public_ip"], "eth%s" % ips["nic_dev_id"]) is False + assert not ip.has_ip("%s/24" % ips["public_ip"], "eth%s" % ips["nic_dev_id"]), \ + "Delete %s on eth%s failed" % (ips["public_ip"], ips["nic_dev_id"]) def test_create_guest_network(self): config = { "add":True,