diff --git a/azure/misc/azure_ha_test.py b/azure/misc/azure_ha_test.py index b09bed98..48fcac18 100755 --- a/azure/misc/azure_ha_test.py +++ b/azure/misc/azure_ha_test.py @@ -35,6 +35,7 @@ def set_arm_versions(): + """#TODO fixDocstring""" global ARM_VERSIONS log('Setting api versions for "%s" solution\n' % templateName) if templateName == 'stack-ha': @@ -47,14 +48,17 @@ def set_arm_versions(): def is_azure(): + """#TODO fixDocstring""" return os.path.isfile('/etc/in-azure') def log(msg): + """#TODO fixDocstring""" sys.stderr.write(msg) -def test_rw(rid, allow_not_found=False): +def test_rw(rid, allow_not_found=False, test_write=True): + """#TODO fixDocstring""" components = rid.split('/') log('Id : %s\n' % rid) log('Subscription : %s\n' % components[2]) @@ -69,18 +73,19 @@ def test_rw(rid, allow_not_found=False): log('Attempting to read - [%s]\n' % e.reason) raise log('Attempting to read - [OK]\n') - - log('Attempting to write ') - try: - azure.arm('PUT', rid + ARM_VERSIONS['resources'], json.dumps(obj)) - except rest.RequestException as e: - log('- [%s]\n' % e.reason) - raise - log('- [OK]\n') + if test_write: + log('Attempting to write ') + try: + azure.arm('PUT', rid + ARM_VERSIONS['resources'], json.dumps(obj)) + except rest.RequestException as e: + log('- [%s]\n' % e.reason) + raise + log('- [OK]\n') return obj def get_vm_primary_nic(vm): + """#TODO fixDocstring""" nis = vm['properties']['networkProfile']['networkInterfaces'] if len(nis) == 1: ni = nis[0] @@ -92,13 +97,14 @@ def get_vm_primary_nic(vm): def test_cluster_ip(): + """#TODO fixDocstring""" def test_vip(vip_resource): if '/' in vip_resource: cluster_ip_id = vip_resource else: cluster_ip_id = conf['baseId'] + \ 'Microsoft.Network/publicIPAddresses/' + vip_resource - test_rw(cluster_ip_id, allow_not_found=True) + test_rw(cluster_ip_id, allow_not_found=True, test_write=False) for interface in conf['clusterNetworkInterfaces']: if isinstance(conf['clusterNetworkInterfaces'][interface][0], dict): @@ -110,6 +116,7 @@ def test_vip(vip_resource): def test_load_balancer(): + """#TODO fixDocstring""" load_balancer_nm = conf.get('lbName', '') if not load_balancer_nm: log('An external load balancer name is not configured.\n') @@ -122,6 +129,7 @@ def test_load_balancer(): def vnet_rg(): + """#TODO fixDocstring""" local_vm = azure.arm('GET', conf['baseId'] + 'microsoft.compute/virtualmachines/' + conf['hostname'])[1] @@ -132,6 +140,7 @@ def vnet_rg(): def get_route_table_ids_for_vnet(vnet): + """#TODO fixDocstring""" route_table_ids = set() for subnet in vnet['properties'].get('subnets', []): if subnet['properties'].get('routeTable'): @@ -140,6 +149,7 @@ def get_route_table_ids_for_vnet(vnet): def get_vnet_id(): + """#TODO fixDocstring""" vnet_id = conf.get('vnetId') if vnet_id: return vnet_id @@ -154,6 +164,7 @@ def get_vnet_id(): def get_route_table_ids_for_peering(vnet): + """#TODO fixDocstring""" route_table_ids = set() for peering in vnet['properties'].get('virtualNetworkPeerings', []): @@ -174,6 +185,7 @@ def get_route_table_ids_for_peering(vnet): def get_route_table_ids(): + """#TODO fixDocstring""" route_table_ids = set() vnet_id = get_vnet_id() @@ -186,6 +198,7 @@ def get_route_table_ids(): def interfaces_test_rw(interface_id): + """#TODO fixDocstring""" interface = test_rw(interface_id['id']) if not interface['properties'].get('enableIPForwarding'): raise Exception( @@ -194,6 +207,7 @@ def interfaces_test_rw(interface_id): def test_cluster_parameters(): + """#TODO fixDocstring""" path = "/var/opt/fw.boot/modules/fwkern.conf" text1 = "fwha_dead_timeout_multiplier=20" text2 = "fwha_if_problem_tolerance=200" @@ -234,6 +248,7 @@ def test_cluster_parameters(): def test(): + """#TODO fixDocstring""" global conf if not is_azure(): @@ -375,7 +390,7 @@ def test(): else: interfaces_test_rw(interface_id) - if templateName != 'ha': + if templateName not in ['ha', 'ha_terraform']: log('Testing authorization on routing tables...\n') for route_table in get_route_table_ids(): test_rw(route_table) @@ -397,6 +412,7 @@ def test(): def main(): + """#TODO fixDocstring""" try: test() except Exception: