def _validate_networks(self): # get_scalar(column, True) <- True == "distinct" modifier blocks_count = self.get_scalar(melange.IpBlocks.network_id, self.melange_session, [], True) networks_count = self.get_scalar(quarkmodels.Network.id, self.neutron_session) self._compare_after_migration("IP Blocks", blocks_count, "Networks", networks_count) _block = self.melange_session.query(melange.IpBlocks).first() _network = self.neutron_session.query(quarkmodels.Network).\ filter(quarkmodels.Network.id == _block.network_id).first() self.assertEqual(trim_br(_block.network_id), _network.id) self.assertEqual(_block.tenant_id, _network.tenant_id) self.assertEqual(_block.network_name, _network.name)
def _validate_ips(self): import netaddr addresses_count = self.get_scalar(melange.IpAddresses.id, self.melange_session) qaddresses_count = self.get_scalar(quarkmodels.IPAddress.id, self.neutron_session) self._compare_after_migration("IP Addresses", addresses_count, "IP Addresses", qaddresses_count) _ip_addr = self.melange_session.query(melange.IpAddresses).first() _ipblock = self.melange_session.query(melange.IpBlocks).\ filter(melange.IpBlocks.id == _ip_addr.ip_block_id).first() _q_ip_addr = self.neutron_session.query(quarkmodels.IPAddress).\ filter(quarkmodels.IPAddress.id == _ip_addr.id).first() _ip_address = netaddr.IPAddress(_ip_addr.address) self.assertEqual(_q_ip_addr.created_at, _ip_addr.created_at) self.assertEqual(_q_ip_addr.used_by_tenant_id, _ip_addr.used_by_tenant_id) self.assertEqual(_q_ip_addr.network_id, trim_br(_ipblock.network_id)) self.assertEqual(_q_ip_addr.subnet_id, _ipblock.id) self.assertEqual(_q_ip_addr.version, _ip_address.version) self.assertEqual(_q_ip_addr.address_readable, _ip_addr.address) self.assertTrue(_q_ip_addr.deallocated_at == None or _ip_addr.deallocated_at) self.assertEqual(int(_q_ip_addr.address), int(_ip_address.ipv6()))