Added vmpassword type (does nothing yet)

Fixed tests to use /var/cache/cloud
Added some test files but will remove them when tests are properly completed
Fixed a bug in configure that did not deal well with databags with empty dev sections
This commit is contained in:
Ian Southam 2014-08-12 15:13:13 +02:00 committed by wilderrodrigues
parent daf6c33507
commit 4c5f4a1f9f
5 changed files with 23 additions and 11 deletions

View File

@ -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)

View File

@ -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):

View File

@ -0,0 +1 @@
Json file used to test the provisioning scripts on virtual appliances

View File

@ -0,0 +1 @@
{"ip_address":"172.16.1.102","password":"fnirq_cnffjbeq","type":"vmpassword"}

View File

@ -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,