Skip to content

Commit 4c5f4a1

Browse files
Ian Southamwilderrodrigues
authored andcommitted
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
1 parent daf6c33 commit 4c5f4a1

File tree

5 files changed

+23
-11
lines changed

5 files changed

+23
-11
lines changed

systemvm/patches/debian/config/opt/cloud/bin/configure.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def addifmissing(self, filename, val):
5959

6060
def execute(self, command):
6161
""" Execute command """
62-
p = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True)
62+
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
6363
result = p.communicate()[0]
6464
return result.splitlines()
6565

@@ -604,10 +604,11 @@ def compare(self, bag):
604604
self.delete("all")
605605
for ip in self.iplist:
606606
found = False
607-
for address in bag[self.dev]:
608-
self.setAddress(address)
609-
if self.hasIP(ip):
610-
found = True
607+
if self.dev in bag.keys():
608+
for address in bag[self.dev]:
609+
self.setAddress(address)
610+
if self.hasIP(ip):
611+
found = True
611612
if not found:
612613
self.delete(ip)
613614

systemvm/patches/debian/config/opt/cloud/bin/merge.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import cs_ip
88
import cs_guestnetwork
99
import cs_cmdline
10+
import cs_vmp
1011

1112
from pprint import pprint
1213

@@ -70,6 +71,10 @@ def process(self):
7071
dbag = self.processGuestNetwork(self.db.getDataBag())
7172
if self.qFile.type == 'cmdline':
7273
dbag = self.processCL(self.db.getDataBag())
74+
if self.qFile.type == 'cmdline':
75+
dbag = self.processCL(self.db.getDataBag())
76+
if self.qFile.type == 'vmpassword':
77+
dbag = self.processVMpassword(self.db.getDataBag())
7378
self.db.save(dbag)
7479

7580
def processGuestNetwork(self, dbag):
@@ -89,6 +94,9 @@ def processGuestNetwork(self, dbag):
8994
d['domain_name'] = "cloudnine.internal"
9095
return cs_guestnetwork.merge(dbag, self.qFile.data)
9196

97+
def processVMpassword(self, dbag):
98+
dbag = cs_vmp.merge(dbag, self.qFile.data)
99+
92100
def processIP(self, dbag):
93101
for ip in self.qFile.data["ip_address"]:
94102
dbag = cs_ip.merge(dbag, ip)
@@ -125,7 +133,6 @@ def processCLItem(self, num):
125133
class loadQueueFile:
126134

127135
fileName = ''
128-
dpath = "/etc/cloudstack"
129136
configCache = "/var/cache/cloud"
130137
keep = True
131138
data = {}
@@ -161,7 +168,7 @@ def getData(self):
161168
return self.data
162169

163170
def setPath(self, path):
164-
self.dpath = path
171+
self.configCache = path
165172

166173
def __moveFile(self, origPath, path):
167174
if not os.path.exists(path):
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Json file used to test the provisioning scripts on virtual appliances
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"ip_address":"172.16.1.102","password":"fnirq_cnffjbeq","type":"vmpassword"}

test/systemvm/test_update_config.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class UpdateConfigTestCase(SystemVMTestCase):
5959
def update_config(self, config):
6060
config_json = json.dumps(config, indent=2)
6161
print_doc('config.json', config_json)
62-
file_write('/etc/cloudstack/update_config_test.json', config_json)
62+
file_write('/var/cache/cloud/update_config_test.json', config_json)
6363
with hide("everything"):
6464
result = run("python /opt/cloud/bin/update_config.py update_config_test.json",
6565
timeout=600, warn_only=True)
@@ -112,14 +112,16 @@ def test_various_random_ip_addresses(self):
112112
ip_address["add"] = False
113113
buffer.append(copy.deepcopy(ip_address))
114114
self.check_no_errors()
115-
self.clear_log()
116-
assert ip.has_ip("%s/24" % ip_address["public_ip"], "eth%s" % ip_address["nic_dev_id"])
115+
#self.clear_log()
116+
assert ip.has_ip("%s/24" % ip_address["public_ip"], "eth%s" % ip_address["nic_dev_id"]), \
117+
"Configure %s on eth%s failed" % (ip_address["public_ip"], ip_address["nic_dev_id"])
117118
# Now delete all the IPs we just made
118119
for ips in buffer:
119120
config = copy.deepcopy(self.basic_config)
120121
config["ip_address"].append(ips)
121122
self.update_config(config)
122-
assert ip.has_ip("%s/24" % ips["public_ip"], "eth%s" % ips["nic_dev_id"]) is False
123+
assert not ip.has_ip("%s/24" % ips["public_ip"], "eth%s" % ips["nic_dev_id"]), \
124+
"Delete %s on eth%s failed" % (ips["public_ip"], ips["nic_dev_id"])
123125

124126
def test_create_guest_network(self):
125127
config = { "add":True,

0 commit comments

Comments
 (0)