Test floating IP attach/detach logs
Each time we have floating IP attached/detached from the VM we should get those event logged. Change-Id: I33235ec6af0ff9dc02722354d6d3876c89701f5f
This commit is contained in:
@@ -41,10 +41,15 @@ get_neutron_client = _client.get_neutron_client
|
||||
find_subnet = _client.find_subnet
|
||||
find_port = _client.find_port
|
||||
list_ports = _client.list_ports
|
||||
create_port = _client.create_port
|
||||
delete_port = _client.delete_port
|
||||
list_subnets = _client.list_subnets
|
||||
list_subnet_cidrs = _client.list_subnet_cidrs
|
||||
list_agents = _client.list_agents
|
||||
get_floating_ip = _client.get_floating_ip
|
||||
create_floating_ip = _client.create_floating_ip
|
||||
delete_floating_ip = _client.delete_floating_ip
|
||||
update_floating_ip = _client.update_floating_ip
|
||||
get_router = _client.get_router
|
||||
get_port = _client.get_port
|
||||
get_subnet = _client.get_subnet
|
||||
@@ -53,6 +58,7 @@ find_l3_agent_hosting_router = _client.find_l3_agent_hosting_router
|
||||
list_dhcp_agent_hosting_network = _client.list_dhcp_agent_hosting_network
|
||||
|
||||
NoSuchPort = _client.NoSuchPort
|
||||
NoSuchFIP = _client.NoSuchPort
|
||||
NoSuchRouter = _client.NoSuchRouter
|
||||
NoSuchSubnet = _client.NoSuchSubnet
|
||||
|
||||
|
||||
@@ -140,10 +140,39 @@ def list_subnet_cidrs(client=None, **params):
|
||||
|
||||
|
||||
def get_floating_ip(floating_ip, client=None, **params):
|
||||
floating_ip = neutron_client(client).show_floatingip(floating_ip, **params)
|
||||
try:
|
||||
floating_ip = neutron_client(client).show_floatingip(
|
||||
floating_ip, **params)
|
||||
except neutronclient.exceptions.NotFound as ex:
|
||||
raise NoSuchFIP(id=floating_ip) from ex
|
||||
return floating_ip['floatingip']
|
||||
|
||||
|
||||
def create_floating_ip(floating_network_id=None, client=None, **params):
|
||||
if floating_network_id is None:
|
||||
from tobiko.openstack import stacks
|
||||
floating_network_id = tobiko.setup_fixture(
|
||||
stacks.FloatingNetworkStackFixture).external_id
|
||||
if floating_network_id is not None:
|
||||
params['floating_network_id'] = floating_network_id
|
||||
floating_ip = neutron_client(client).create_floatingip(
|
||||
body={'floatingip': params})
|
||||
return floating_ip['floatingip']
|
||||
|
||||
|
||||
def delete_floating_ip(floating_ip, client=None):
|
||||
try:
|
||||
neutron_client(client).delete_floatingip(floating_ip)
|
||||
except neutronclient.exceptions.NotFound as ex:
|
||||
raise NoSuchFIP(id=floating_ip) from ex
|
||||
|
||||
|
||||
def update_floating_ip(floating_ip, client=None, **params):
|
||||
fip = neutron_client(client).update_floatingip(
|
||||
floating_ip, body={'floatingip': params})
|
||||
return fip['floatingip']
|
||||
|
||||
|
||||
def get_port(port, client=None, **params):
|
||||
try:
|
||||
return neutron_client(client).show_port(port, **params)['port']
|
||||
@@ -151,6 +180,18 @@ def get_port(port, client=None, **params):
|
||||
raise NoSuchPort(id=port) from ex
|
||||
|
||||
|
||||
def create_port(client=None, **params):
|
||||
port = neutron_client(client).create_port(body={'port': params})
|
||||
return port['port']
|
||||
|
||||
|
||||
def delete_port(port, client=None):
|
||||
try:
|
||||
neutron_client(client).delete_port(port)
|
||||
except neutronclient.exceptions.NotFound as ex:
|
||||
raise NoSuchPort(id=port) from ex
|
||||
|
||||
|
||||
def get_router(router, client=None, **params):
|
||||
try:
|
||||
return neutron_client(client).show_router(router, **params)['router']
|
||||
@@ -204,3 +245,7 @@ class NoSuchRouter(tobiko.ObjectNotFound):
|
||||
|
||||
class NoSuchSubnet(tobiko.ObjectNotFound):
|
||||
message = "No such subnet found for {id!r}"
|
||||
|
||||
|
||||
class NoSuchFIP(tobiko.ObjectNotFound):
|
||||
message = "No such floating IP found for {id!r}"
|
||||
|
||||
Reference in New Issue
Block a user