mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
Fixed test (assert in guest check was wrong way around)
Also found condition inw hich apache would be miscobfigured and failed to run (I love tests!!) Fixed configure.py to cover this case Added a test to provoke this case!
This commit is contained in:
parent
d2e3b238ed
commit
9d73879061
@ -246,7 +246,7 @@ class CsProcess(object):
|
||||
class CsApp:
|
||||
def __init__(self, ip):
|
||||
self.dev = ip.getDevice()
|
||||
self.ip = ip.getAddress()['public_ip']
|
||||
self.ip = ip.get_ip_address()
|
||||
self.domain = "domain.local"
|
||||
self.type = ip.get_type()
|
||||
if self.type == "guest":
|
||||
@ -272,6 +272,13 @@ class CsPasswdSvc(CsApp):
|
||||
class CsApache(CsApp):
|
||||
""" Set up Apache """
|
||||
|
||||
def remove(self):
|
||||
file = "/etc/apache2/conf.d/vhost%s.conf" % self.dev
|
||||
if os.path.isfile(file):
|
||||
os.remove(file)
|
||||
CsHelper().service("apache2", "restart")
|
||||
|
||||
|
||||
def setup(self):
|
||||
CsHelper().copy_if_needed("/etc/apache2/vhostexample.conf",
|
||||
"/etc/apache2/conf.d/vhost%s.conf" % self.dev)
|
||||
@ -547,6 +554,15 @@ class CsIP:
|
||||
return self.address['nw_type']
|
||||
return "unknown"
|
||||
|
||||
def get_ip_address(self):
|
||||
"""
|
||||
Return ip address if known
|
||||
"""
|
||||
if "public_ip" in self.address:
|
||||
return self.address['public_ip']
|
||||
return "unknown"
|
||||
|
||||
|
||||
def post_config_change(self, method):
|
||||
route = CsRoute(self.dev)
|
||||
route.routeTable()
|
||||
@ -598,10 +614,21 @@ class CsIP:
|
||||
|
||||
# Delete any ips that are configured but not in the bag
|
||||
def compare(self, bag):
|
||||
if len(self.iplist) > 0 and not self.dev in bag.keys():
|
||||
if len(self.iplist) > 0 and (not self.dev in bag.keys() or len(bag[self.dev]) == 0):
|
||||
print "Gets here"
|
||||
# Remove all IPs on this device
|
||||
logging.info("Will remove all configured addresses on device %s", self.dev)
|
||||
self.delete("all")
|
||||
app = CsApache(self)
|
||||
app.remove()
|
||||
|
||||
# This condition should not really happen but did :)
|
||||
# It means an apache file got orphaned after a guest network address was deleted
|
||||
if len(self.iplist) == 0 and (not self.dev in bag.keys() or len(bag[self.dev]) == 0):
|
||||
print self.dev
|
||||
app = CsApache(self)
|
||||
app.remove()
|
||||
|
||||
for ip in self.iplist:
|
||||
found = False
|
||||
if self.dev in bag.keys():
|
||||
|
||||
@ -135,17 +135,33 @@ class UpdateConfigTestCase(SystemVMTestCase):
|
||||
"domain_name":"devcloud.local",
|
||||
"type":"guestnetwork"
|
||||
}
|
||||
self.guest_network(config)
|
||||
config = { "add":True,
|
||||
"mac_address":"02:00:56:36:00:02",
|
||||
"device":"eth4",
|
||||
"router_guest_ip":"172.16.2.1",
|
||||
"router_guest_gateway":"172.16.2.0",
|
||||
"router_guest_netmask":"255.255.255.0",
|
||||
"cidr":"24",
|
||||
"dns":"8.8.8.8,8.8.8.4",
|
||||
"domain_name":"devcloud2.local",
|
||||
"type":"guestnetwork"
|
||||
}
|
||||
self.guest_network(config)
|
||||
|
||||
def guest_network(self,config):
|
||||
self.update_config(config)
|
||||
assert ip.has_ip("172.16.1.1/24", "eth4")
|
||||
assert process.is_up("apache2") is True
|
||||
assert process.is_up("dnsmasq") is True
|
||||
assert ip.has_ip("%s/%s" % (config['router_guest_ip'], config['cidr']), config['device'])
|
||||
assert process.is_up("apache2"), "Apache2 should be running after adding a guest network"
|
||||
assert process.is_up("dnsmasq"), "Dnsmasq should be running after adding a guest network"
|
||||
assert port.is_listening(80)
|
||||
assert port.is_listening(53)
|
||||
assert port.is_listening(53)
|
||||
assert port.is_listening(67)
|
||||
config['add'] = False
|
||||
self.update_config(config)
|
||||
assert ip.has_ip("172.16.1.1/24", "eth4") is False
|
||||
assert not ip.has_ip("%s/%s" % (config['router_guest_ip'], config['cidr']), config['device'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import unittest
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user