nimbusdisplay.py
def VPCandSubnets(self):
        """ Gets a list of VPCs and the subnets that are within them."""
        logger.debug("vpcs and subnets")
        allowedKeys = ["InstanceId", "Tags", "State", "SecurityGroups"]

        # get list of vpcid and subnetid pairs
        vpcsubnetpairs = self.anb.getVPCandSubnetPairs()
        logger.debug(vpcsubnetpairs)

        for (vpcid, vpccidr, subnetid, subnetcidr) in vpcsubnetpairs:
            originalList = self.anb.displayInstanceView(vpcid, subnetid)
            displayList = []

            # this dict helps flatten dictionaries that are values to keys.
            # Key: Flatten Key

            flattenDictTags = {
                "Tags": "Value",
                "State": "Name",
                "SecurityGroups": "GroupId",
            }

            print(
                "VPC: {} {} Subnet: {} {} ".format(vpcid, vpccidr, subnetid, subnetcidr)
            )
            print("________________________________________________________")
            for originalitem in originalList:
                displayitem = {
                    key: value
                    for (key, value) in originalitem.items()
                    if key in allowedKeys
                }
                for (fdkey, fdvalue) in flattenDictTags.items():
                    if fdkey in displayitem:
                        displayitem[fdkey] = utils.flattenItem(
                            displayitem, fdkey, fdvalue
                        )
                displayList.append(displayitem)
            finalDisplay = tabulate.tabulate(displayList, headers="keys")
            if finalDisplay:
                print(finalDisplay)
            else:
                print("No Instances Found")
            print("\n")
 Gets a list of VPCs and the subnets that are within them.
Gets a list of VPCs and the subnets that are within them.
Gets a list of VPCs and the subnets that are within them .
def VPCandSubnets(self):
        logger.debug("vpcs and subnets")
        allowedKeys = ["InstanceId", "Tags", "State", "SecurityGroups"]
        vpcsubnetpairs = self.anb.getVPCandSubnetPairs()
        logger.debug(vpcsubnetpairs)
        for (vpcid, vpccidr, subnetid, subnetcidr) in vpcsubnetpairs:
            originalList = self.anb.displayInstanceView(vpcid, subnetid)
            displayList = []
            flattenDictTags = {
                "Tags": "Value",
                "State": "Name",
                "SecurityGroups": "GroupId",
            }
            print(
                "VPC: {} {} Subnet: {} {} ".format(vpcid, vpccidr, subnetid, subnetcidr)
            )
            print("________________________________________________________")
            for originalitem in originalList:
                displayitem = {
                    key: value
                    for (key, value) in originalitem.items()
                    if key in allowedKeys
                }
                for (fdkey, fdvalue) in flattenDictTags.items():
                    if fdkey in displayitem:
                        displayitem[fdkey] = utils.flattenItem(
                            displayitem, fdkey, fdvalue
                        )
                displayList.append(displayitem)
            finalDisplay = tabulate.tabulate(displayList, headers="keys")
            if finalDisplay:
                print(finalDisplay)
            else:
                print("No Instances Found")
            print("\n")
def VPCandSubnets ( self ) : logger . debug ( "vpcs and subnets" ) allowedKeys = [ "InstanceId" , "Tags" , "State" , "SecurityGroups" ] vpcsubnetpairs = self . anb . getVPCandSubnetPairs ( ) logger . debug ( vpcsubnetpairs ) for ( vpcid , vpccidr , subnetid , subnetcidr ) in vpcsubnetpairs : originalList = self . anb . displayInstanceView ( vpcid , subnetid ) displayList = [ ] flattenDictTags = { "Tags" : "Value" , "State" : "Name" , "SecurityGroups" : "GroupId" , } print ( "VPC: {} {} Subnet: {} {} " . format ( vpcid , vpccidr , subnetid , subnetcidr ) ) print ( "________________________________________________________" ) for originalitem in originalList : displayitem = { key : value for ( key , value ) in originalitem . items ( ) if key in allowedKeys } for ( fdkey , fdvalue ) in flattenDictTags . items ( ) : if fdkey in displayitem : displayitem [ fdkey ] = utils . flattenItem ( displayitem , fdkey , fdvalue ) displayList . append ( displayitem ) finalDisplay = tabulate . tabulate ( displayList , headers = "keys" ) if finalDisplay : print ( finalDisplay ) else : print ( "No Instances Found" ) print ( "\n" )
Gets a list of VPCs and the subnets that are within them.
Gets a list of VPCs and the subnets that are within them .
""" Gets a list of VPCs and the subnets that are within them.""" # get list of vpcid and subnetid pairs # this dict helps flatten dictionaries that are values to keys. # Key: Flatten Key
self