|
34 | 34 | NATRule, |
35 | 35 | FireWallRule, |
36 | 36 | Host, |
37 | | - StaticNATRule, Cluster) |
| 37 | + StaticNATRule) |
38 | 38 | from marvin.lib.common import (get_domain, |
39 | 39 | get_zone, |
40 | 40 | get_template, |
41 | 41 | verifyNetworkState, |
42 | 42 | add_netscaler, |
43 | | - wait_for_cleanup, list_routers, list_hosts, list_clusters) |
44 | | -from marvin.lib.vcenter import Vcenter |
| 43 | + wait_for_cleanup, list_routers, list_hosts) |
45 | 44 | from nose.plugins.attrib import attr |
46 | 45 | from marvin.codes import PASS, FAIL, FAILED |
47 | 46 | from marvin.sshClient import SshClient |
|
50 | 49 | from ddt import ddt, data |
51 | 50 | import time |
52 | 51 |
|
53 | | -import logging |
54 | | - |
55 | | -logger = logging.getLogger('TestPesistentNetwork') |
56 | | -stream_handler = logging.StreamHandler() |
57 | | -logger.setLevel(logging.DEBUG) |
58 | | -logger.addHandler(stream_handler) |
59 | | - |
60 | | -""" |
61 | | -class TestHelper(): |
62 | | - def __init__(self, api_client): |
63 | | - self.api_client = api_client |
64 | | -
|
65 | | - @staticmethod |
66 | | - def get_ssh_client(ip, username, password, retries=10): |
67 | | - try: |
68 | | - ssh_client = SshClient(ip, 22, username, password, retries) |
69 | | - except Exception as e: |
70 | | - raise unittest.SkipTest("Unable to create ssh connection: " % e) |
71 | | -
|
72 | | - # self.assertIsNotNone( |
73 | | - # ssh_client, "Failed to setup ssh connection to ip=%s" % ip) |
74 | | - return ssh_client |
75 | | -
|
76 | | - @staticmethod |
77 | | - def verify_vlan_network_creation(vlan_id, ssh_client): |
78 | | - try: |
79 | | - res = ssh_client.execute( |
80 | | - "xe vlan-list | grep -x \"^\s*tag ( RO): \"" + str(vlan_id) + "> /dev/null 2>&1; echo $?") |
81 | | - return res[0] |
82 | | - except Exception as e: |
83 | | - return False |
84 | | -
|
85 | | - @staticmethod |
86 | | - def verify_bridge_creation(vlan_id, ssh_client): |
87 | | - try: |
88 | | - res = ssh_client.execute("ip addr | grep breth0-" + str(vlan_id) + " > /dev/null 2>&1; echo $?") |
89 | | - return res[0] |
90 | | - except Exception as e: |
91 | | - return False |
92 | | -
|
93 | | - def validate_persistent_network_resources_created_on_host(self, network_vlan, zone_id, hypervisor): |
94 | | - hosts = self.list_all_hosts_in_zone(zone_id) |
95 | | -
|
96 | | - if hypervisor in "kvm": |
97 | | - for host in hosts: |
98 | | - result = self.verify_bridge_creation(host, network_vlan) |
99 | | - self.assertEqual( |
100 | | - int(result), |
101 | | - 0, |
102 | | - "Failed to find bridge on the breth0-" + str(network_vlan)) |
103 | | - elif self.hypervisor.lower() in ["xenserver", "vmware"]: |
104 | | - self.verify_network_setup_on_host_per_cluster(self.hypervisor.lower(), network_vlan) |
105 | | -
|
106 | | - def verify_network_setup_on_host_per_cluster(hypervisor, vlan_id): |
107 | | - clusters = Cluster.list( |
108 | | - self.apiclient, |
109 | | - zoneid=self.zone.id, |
110 | | - allocationstate="Enabled", |
111 | | - listall=True |
112 | | - ) |
113 | | - for cluster in clusters: |
114 | | - hosts = Host.list(self.apiclient, |
115 | | - clusterid=cluster.id, |
116 | | - type="Routing", |
117 | | - state="Up", |
118 | | - resourcestate="Enabled") |
119 | | - host = hosts[0] |
120 | | - if hypervisor == "xenserver": |
121 | | - result = self.verify_vlan_network_creation(host, vlan_id) |
122 | | - self.assertEqual( |
123 | | - int(result), |
124 | | - 0, |
125 | | - "Failed to find vlan on host: " + host.name + " in cluster: " + cluster.name) |
126 | | - # if hypervisor == "vmware": |
127 | | - # result = self.verify_port_group_creation(vlan_id) |
128 | | - # self.assertEqual( |
129 | | - # result, |
130 | | - # True, |
131 | | - # "Failed to find port group on hosts of cluster: " + cluster.name) |
132 | | -
|
133 | | - def list_all_hosts_in_zone(self, zone_id): |
134 | | - hosts = Host.list( |
135 | | - self.api_client, |
136 | | - type='Routing', |
137 | | - resourcestate='Enabled', |
138 | | - state='Up', |
139 | | - zoneid=zone_id |
140 | | - ) |
141 | | - return hosts |
142 | | -""" |
143 | | - |
144 | | - |
145 | 52 | @ddt |
146 | 53 | class TestPersistentNetworks(cloudstackTestCase): |
147 | 54 | ''' |
@@ -378,7 +285,6 @@ def test_newly_added_host_for_persistent_network_resources(self): |
378 | 285 | # 1. Persistent network state should be implemented before adding the host |
379 | 286 | # 2. Host should be added back in successfully |
380 | 287 | # 3. Host should have the persistent networks resources after being added |
381 | | - logger.info("pls goddammit") |
382 | 288 | l2_persistent_network_offering = self.createNetworkOffering("nw_off_L2_persistent") |
383 | 289 | hosts = list_hosts(self.apiclient, clusterid=self.cluster.id) |
384 | 290 | host = hosts[0] |
|
0 commit comments