def __init__(self, db: ResourceDB, cfg: dict): super().__init__(db, cfg) rt = db.get_subnet_routetable(cfg) self.route_table = RouteTable(db, rt) if rt else None nsg = db.get_subnet_nsg(cfg) self.nsg = NSG(db, nsg) if nsg else None self.interfaces = [ Interface(db, i) for i in db.get_subnet_interfaces(cfg) ]
def list_vnets(db: ResourceDB): log.info('Fetching available vnets') for vnet in db.get_vnets(list(db._by_id.values())): group = vnet['id'].split('/')[4] print('Group:', group) print('VNet:', vnet['name']) print()
async def get_db(args) -> ResourceDB: # Read resources for subscription resources = [] if args.file: with open(args.file) as f: resources = json.load(f) else: api = await AzureAPI.new(args.subscription) resources = await api.get_resources() return ResourceDB(resources)
def validate_group(db: ResourceDB, group: str, summary_only=False): # Validate resource group rg = ResourceGroup(db, db.get_resource_group(group), group) if summary_only: # Temporarily disable console logging for summary only log.enabled = False res = rg.validate() log.enabled = True else: res = rg.validate() # Disable noise if res.valid: log.debug(f'Resource group {group} is ready for migration.') else: log.debug(f'Resource group {group} failed validation.')
def validate_vnet(db: ResourceDB, name: str, summary_only=False): matched = False for cfg in db.get_vnets(list(db._by_id.values())): vnet = VNet(db, cfg) if vnet.name == name: matched = True if summary_only: # Temporarily disable console logging for summary only log.enabled = False res = vnet.validate() log.enabled = True else: res = vnet.validate() # Disable noise if res.valid: log.info(f'VNet {name} is ready for migration.') else: log.warning(f'VNet {name} failed validation.') if not matched: log.warning(f'VNet {name} not found.')
def __init__(self, db: ResourceDB, resources: list[dict], group: str): self.db = db self.vnets = [VNet(db, c) for c in db.get_vnets(resources)] self.name = group
def list_groups(db: ResourceDB): log.info('Fetching available groups') for group in db.list_groups(): print(group)
def __init__(self, db: ResourceDB, cfg: dict): super().__init__(db, cfg) self.peers = [Peer(db, c) for c in db.get_vnet_peers(cfg) if c] self.subnets = [Subnet(db, c) for c in db.get_vnet_subnets(cfg) if c]