def _verify_show_network_details(self): # Verification - get raw result from db nw = db.network_list(self.tenant_id)[0] network = {'id': nw.uuid, 'name': nw.name, 'op-status': nw.op_status} port_list = db.port_list(nw.uuid) if not port_list: network['ports'] = [{'id': '<none>', 'state': '<none>', 'attachment': {'id': '<none>'}}] else: network['ports'] = [] for port in port_list: network['ports'].append({'id': port.uuid, 'state': port.state, 'attachment': {'id': port.interface_id or '<none>'}}) # Fill CLI template output = cli.prepare_output('show_net_detail', self.tenant_id, dict(network=network), self.version) # Verify! # Must add newline at the end to match effect of print call self.assertEquals(self.fake_stdout.make_string(), output + '\n')
def _verify_show_network(self): # Verification - get raw result from db nw = db.network_list(self.tenant_id)[0] network = dict(id=nw.uuid, name=nw.name) # Fill CLI template output = cli.prepare_output('show_net', self.tenant_id, dict(network=network)) # Verify! # Must add newline at the end to match effect of print call self.assertEquals(self.fake_stdout.make_string(), output + '\n')
def _verify_list_networks(self): # Verification - get raw result from db nw_list = db.network_list(self.tenant_id) networks = [dict(id=nw.uuid, name=nw.name) for nw in nw_list] # Fill CLI template output = cli.prepare_output('list_nets', self.tenant_id, dict(networks=networks)) # Verify! # Must add newline at the end to match effect of print call self.assertEquals(self.fake_stdout.make_string(), output + '\n')
def _verify_unplug_iface(self, network_id, port_id): # Verification - get raw result from db port = db.port_get(port_id, network_id) # Fill CLI template output = cli.prepare_output( "unplug_iface", self.tenant_id, dict(network_id=network_id, port_id=port['uuid'])) # Verify! # Must add newline at the end to match effect of print call self.assertEquals(self.fake_stdout.make_string(), output + '\n')
def _verify_unplug_iface(self, network_id, port_id): # Verification - get raw result from db port = db.port_get(port_id, network_id) # Fill CLI template output = cli.prepare_output("unplug_iface", self.tenant_id, dict(network_id=network_id, port_id=port['uuid'])) # Verify! # Must add newline at the end to match effect of print call self.assertEquals(self.fake_stdout.make_string(), output + '\n')
def _verify_list_ports(self, network_id): # Verification - get raw result from db port_list = db.port_list(network_id) ports = [dict(id=port.uuid, state=port.state) for port in port_list] # Fill CLI template output = cli.prepare_output('list_ports', self.tenant_id, dict(network_id=network_id, ports=ports)) # Verify! # Must add newline at the end to match effect of print call self.assertEquals(self.fake_stdout.make_string(), output + '\n')
def _verify_update_network(self): # Verification - get raw result from db nw_list = db.network_list(self.tenant_id) network_data = {'id': nw_list[0].uuid, 'name': nw_list[0].name} # Fill CLI template output = cli.prepare_output('update_net', self.tenant_id, dict(network=network_data)) # Verify! # Must add newline at the end to match effect of print call self.assertEquals(self.fake_stdout.make_string(), output + '\n')
def _verify_update_port(self, network_id, port_id): # Verification - get raw result from db port = db.port_get(port_id, network_id) port_data = {'id': port.uuid, 'state': port.state} # Fill CLI template output = cli.prepare_output( 'update_port', self.tenant_id, dict(network_id=network_id, port=port_data)) # Verify! # Must add newline at the end to match effect of print call self.assertEquals(self.fake_stdout.make_string(), output + '\n')
def _verify_delete_network(self, network_id): # Verification - get raw result from db nw_list = db.network_list(self.tenant_id) if len(nw_list) != 0: self.fail("DB should not contain any network") # Fill CLI template output = cli.prepare_output('delete_net', self.tenant_id, dict(network_id=network_id)) # Verify! # Must add newline at the end to match effect of print call self.assertEquals(self.fake_stdout.make_string(), output + '\n')
def _verify_update_port(self, network_id, port_id): # Verification - get raw result from db port = db.port_get(port_id, network_id) port_data = {'id': port.uuid, 'state': port.state} # Fill CLI template output = cli.prepare_output('update_port', self.tenant_id, dict(network_id=network_id, port=port_data)) # Verify! # Must add newline at the end to match effect of print call self.assertEquals(self.fake_stdout.make_string(), output + '\n')
def _verify_create_network(self): # Verification - get raw result from db nw_list = db.network_list(self.tenant_id) if len(nw_list) != 1: self.fail("No network created") network_id = nw_list[0].uuid # Fill CLI template output = cli.prepare_output('create_net', self.tenant_id, dict(network_id=network_id)) # Verify! # Must add newline at the end to match effect of print call self.assertEquals(self.fake_stdout.make_string(), output + '\n')
def _verify_show_iface(self, network_id, port_id): # Verification - get raw result from db port = db.port_get(port_id, network_id) iface = {'id': port.interface_id or '<none>'} # Fill CLI template output = cli.prepare_output('show_iface', self.tenant_id, dict(network_id=network_id, port_id=port.uuid, iface=iface), self.version) # Verify! # Must add newline at the end to match effect of print call self.assertEquals(self.fake_stdout.make_string(), output + '\n')
def _verify_show_port(self, network_id, port_id): # Verification - get raw result from db # TODO(salvatore-orlando): Must resolve this issue with # attachment in separate bug fix. port = db.port_get(port_id, network_id) port_data = {'id': port.uuid, 'state': port.state, 'attachment': "<none>"} if port.interface_id is not None: port_data['attachment'] = port.interface_id # Fill CLI template output = cli.prepare_output('show_port', self.tenant_id, dict(network_id=network_id, port=port_data)) # Verify! # Must add newline at the end to match effect of print call self.assertEquals(self.fake_stdout.make_string(), output + '\n')
def _verify_show_port(self, network_id, port_id): # Verification - get raw result from db port = db.port_get(port_id, network_id) port_data = {'id': port.uuid, 'state': port.state, 'attachment': {'id': port.interface_id or '<none>'}, 'op-status': port.op_status} # Fill CLI template output = cli.prepare_output('show_port', self.tenant_id, dict(network_id=network_id, port=port_data), self.version) # Verify! # Must add newline at the end to match effect of print call self.assertEquals(self.fake_stdout.make_string(), output + '\n')
def _verify_show_port(self, network_id, port_id): # Verification - get raw result from db # TODO(salvatore-orlando): Must resolve this issue with # attachment in separate bug fix. port = db.port_get(port_id, network_id) port_data = { 'id': port.uuid, 'state': port.state, 'attachment': "<none>" } if port.interface_id is not None: port_data['attachment'] = port.interface_id # Fill CLI template output = cli.prepare_output( 'show_port', self.tenant_id, dict(network_id=network_id, port=port_data)) # Verify! # Must add newline at the end to match effect of print call self.assertEquals(self.fake_stdout.make_string(), output + '\n')