diff --git a/SoftLayer/CLI/subnet/detail.py b/SoftLayer/CLI/subnet/detail.py index 4fd82ba5d..b62cc1525 100644 --- a/SoftLayer/CLI/subnet/detail.py +++ b/SoftLayer/CLI/subnet/detail.py @@ -26,9 +26,17 @@ def cli(env, identifier, no_vs, no_hardware): subnet_id = helpers.resolve_id(mgr.resolve_subnet_ids, identifier, name='subnet') - mask = 'mask[ipAddresses[id, ipAddress, note, isBroadcast, isGateway, isNetwork, isReserved, ' \ - 'hardware, virtualGuest], datacenter, virtualGuests, hardware,' \ - ' networkVlan[networkSpace,primaryRouter]]' + mask = """mask[ +networkIdentifier, cidr, subnetType, gateway, broadcastAddress, usableIpAddressCount, note, id, +ipAddresses[ + id, ipAddress, note, isBroadcast, isGateway, isNetwork, isReserved, + hardware[id, fullyQualifiedDomainName], + virtualGuest[id, fullyQualifiedDomainName] +], +datacenter[name], networkVlan[networkSpace], tagReferences, +virtualGuests[id, fullyQualifiedDomainName, hostname, domain, primaryIpAddress, primaryBackendIpAddress], +hardware[id, fullyQualifiedDomainName, hostname, domain, primaryIpAddress, primaryBackendIpAddress] +]""" subnet = mgr.get_subnet(subnet_id, mask=mask) @@ -37,22 +45,15 @@ def cli(env, identifier, no_vs, no_hardware): table.align['value'] = 'l' table.add_row(['id', subnet['id']]) - table.add_row(['identifier', - '%s/%s' % (subnet['networkIdentifier'], - str(subnet['cidr']))]) + table.add_row(['identifier', f"{subnet['networkIdentifier']}/{subnet['cidr']}"]) table.add_row(['subnet type', subnet.get('subnetType', formatting.blank())]) - table.add_row(['network space', - utils.lookup(subnet, 'networkVlan', 'networkSpace')]) + table.add_row(['network space', utils.lookup(subnet, 'networkVlan', 'networkSpace')]) table.add_row(['gateway', subnet.get('gateway', formatting.blank())]) - table.add_row(['broadcast', - subnet.get('broadcastAddress', formatting.blank())]) + table.add_row(['broadcast', subnet.get('broadcastAddress', formatting.blank())]) table.add_row(['datacenter', subnet['datacenter']['name']]) - table.add_row(['usable ips', - subnet.get('usableIpAddressCount', formatting.blank())]) - table.add_row(['note', - subnet.get('note', formatting.blank())]) - table.add_row(['tags', - formatting.tags(subnet.get('tagReferences'))]) + table.add_row(['usable ips', subnet.get('usableIpAddressCount', formatting.blank())]) + table.add_row(['note', subnet.get('note', formatting.blank())]) + table.add_row(['tags', formatting.tags(subnet.get('tagReferences'))]) ip_address = subnet.get('ipAddresses') @@ -72,8 +73,9 @@ def cli(env, identifier, no_vs, no_hardware): elif address.get('virtualGuest') is not None: description = address['virtualGuest']['fullyQualifiedDomainName'] status = 'In use' - ip_table.add_row([address.get('id'), status, - address.get('ipAddress') + '/' + description, address.get('note', '-')]) + ip_table.add_row([ + address.get('id'), status, f"{address.get('ipAddress')}/{description}", address.get('note', '-') + ]) table.add_row(['ipAddresses', ip_table]) diff --git a/SoftLayer/CLI/vlan/detail.py b/SoftLayer/CLI/vlan/detail.py index 8c772d8bf..250461813 100644 --- a/SoftLayer/CLI/vlan/detail.py +++ b/SoftLayer/CLI/vlan/detail.py @@ -26,7 +26,7 @@ def cli(env, identifier, no_vs, no_hardware, no_trunks): vlan_id = helpers.resolve_id(mgr.resolve_vlan_ids, identifier, 'VLAN') mask = """mask[ -firewallInterfaces, primaryRouter[id, fullyQualifiedDomainName, datacenter[longName]], +firewallInterfaces, datacenter[name, longName], primaryRouter[fullyQualifiedDomainName], totalPrimaryIpAddressCount, networkSpace, id, vlanNumber, fullyQualifiedName, name, hardware[id, hostname, domain, primaryIpAddress, primaryBackendIpAddress, tagReferences], @@ -52,7 +52,7 @@ def cli(env, identifier, no_vs, no_hardware, no_trunks): table.add_row(['id', vlan.get('id')]) table.add_row(['number', vlan.get('vlanNumber')]) - table.add_row(['datacenter', utils.lookup(vlan, 'primaryRouter', 'datacenter', 'longName')]) + table.add_row(['datacenter', utils.lookup(vlan, 'datacenter', 'longName')]) table.add_row(['primary_router', utils.lookup(vlan, 'primaryRouter', 'fullyQualifiedDomainName')]) table.add_row(['Gateway/Firewall', get_gateway_firewall(vlan)]) diff --git a/SoftLayer/CLI/vlan/list.py b/SoftLayer/CLI/vlan/list.py index 918d58988..9a8df890b 100644 --- a/SoftLayer/CLI/vlan/list.py +++ b/SoftLayer/CLI/vlan/list.py @@ -46,15 +46,9 @@ def cli(env, sortby, datacenter, number, name, limit): table = formatting.Table(COLUMNS) table.sortby = sortby - vlans = mgr.list_vlans(datacenter=datacenter, - vlan_number=number, - name=name, - limit=limit) + vlans = mgr.list_vlans(datacenter=datacenter, vlan_number=number, name=name, limit=limit) - pod_mask = """mask[ -name, datacenterLongName, capabilities, datacenterId, -backendRouterId, backendRouterName, frontendRouterName, frontendRouterId -]""" + pod_mask = """mask[name, capabilities]""" pods = mgr.get_pods(mask=pod_mask) for vlan in vlans: @@ -66,7 +60,7 @@ def cli(env, sortby, datacenter, number, name, limit): vlan.get('fullyQualifiedName'), vlan.get('name') or formatting.blank(), vlan.get('networkSpace', 'Direct Link').capitalize(), - utils.lookup(vlan, 'primaryRouter', 'datacenter', 'name'), + utils.lookup(vlan, 'datacenter', 'name'), get_pod_with_closed_announcement(vlan, pods), get_gateway_firewall(vlan), vlan.get('hardwareCount'), @@ -82,8 +76,7 @@ def cli(env, sortby, datacenter, number, name, limit): def get_pod_with_closed_announcement(vlan, pods): """Gets pods with announcement to close""" for pod in pods: - if utils.lookup(pod, 'backendRouterId') == utils.lookup(vlan, 'primaryRouter', 'id') \ - or utils.lookup(pod, 'frontendRouterId') == utils.lookup(vlan, 'primaryRouter', 'id'): + if utils.lookup(pod, 'name') == utils.lookup(vlan, 'podName'): if 'CLOSURE_ANNOUNCED' in utils.lookup(pod, 'capabilities'): name_pod = utils.lookup(pod, 'name').split('.')[1] + '*' return "[red]" + name_pod.capitalize() + "[/red]" diff --git a/SoftLayer/managers/network.py b/SoftLayer/managers/network.py index 6ac46a741..fa8172b42 100644 --- a/SoftLayer/managers/network.py +++ b/SoftLayer/managers/network.py @@ -517,11 +517,10 @@ def list_vlans(self, datacenter=None, vlan_number=None, name=None, limit=100, ma """ vlan_mask = """mask[ -networkSpace, id, vlanNumber, fullyQualifiedName, name, +networkSpace, id, vlanNumber, fullyQualifiedName, name, datacenter[name], podName, networkVlanFirewall[id,fullyQualifiedDomainName], attachedNetworkGateway[id,name], -firewallInterfaces, primaryRouter[id, fullyQualifiedDomainName, datacenter[name]], -hardwareCount, subnetCount, totalPrimaryIpAddressCount, virtualGuestCount, -billingItem[id], tagReferences[tag[name]] +firewallInterfaces, billingItem[id], tagReferences[tag[name]], +hardwareCount, subnetCount, totalPrimaryIpAddressCount, virtualGuestCount ]""" _filter = utils.NestedDict(_filter or {})