def test_crud(self): iface = factory.create_interface(tenant_id=self.tenant_id) self.assertShows("interface", iface, parameters="vif_id=%s" % iface['id']) self.command("interface delete", is_tenanted=False, vif_id=iface['id']) self.assertResourceNotFound("interface", iface, parameters="vif_id=%s" % iface['id'])
def test_crud(self): network_id = uuid.uuid4() iface = factory.create_interface(network_id=network_id, tenant_id=self.tenant_id) block = factory.create_block(cidr="20.1.1.0/24", network_id=network_id, tenant_id=self.tenant_id) ip = factory.create_ip(address="20.1.1.2", block_id=block['id'], used_by_tenant=self.tenant_id, tenant_id=self.tenant_id) another_ip = factory.create_ip(address="20.1.1.3", block_id=block['id'], used_by_tenant=self.tenant_id, tenant_id=self.tenant_id) ip_res = self.command("allowed_ip create", interface_id=iface['id'], network_id=network_id, ip_address=ip['address']) allowed_ip = factory.model("ip_address", ip_res) self.assertShows("ip_address", allowed_ip, parameters="interface_id=%s ip_address=%s" % (iface['id'], ip['address']), command_name="allowed_ip") another_ip_res = self.command("allowed_ip create", interface_id=iface['id'], network_id=network_id, ip_address=another_ip['address']) another_allowed_ip = factory.model('ip_address', another_ip_res) list_res = self.command("allowed_ip list", interface_id=iface['id']) actual_allowed_ips = yaml.load(list_res['out'])['ip_addresses'] self.assertTrue(allowed_ip in actual_allowed_ips) self.assertTrue(another_allowed_ip in actual_allowed_ips) self.command("allowed_ip delete", interface_id=iface['id'], ip_address=ip['address']) show_res = self.command("allowed_ip show", interface_id=iface['id'], ip_address=ip['address'], raise_error=False) expected_error = ("Ip Address %s hasnt been allowed on interface %s" % (ip['address'], iface['id'])) self.assertTrue(expected_error in show_res['out'])