raise q_exc.NetworkNotFound(net_id=net_id)
+def validate_network_ownership(tenant_id, net_id):
+ session = get_session()
+ try:
+ return session.query(models.Network).\
+ filter_by(uuid=net_id).\
+ filter_by(tenant_id=tenant_id).\
+ one()
+ except exc.NoResultFound, e:
+ raise q_exc.NetworkNotFound(net_id=net_id)
+
+
def port_create(net_id, state=None):
# confirm network exists
network_get(net_id)
session.merge(port)
session.flush()
return port
+
+
+def validate_port_ownership(tenant_id, net_id, port_id, session=None):
+ validate_network_ownership(tenant_id, net_id)
+ port_get(port_id, net_id)
belonging to the specified tenant.
"""
LOG.debug("delete_network() called\n")
+ db.validate_network_ownership(tenant_id, net_id)
net = db.network_get(net_id)
if net:
if len(net[const.NETWORKPORTS]) > 0:
Gets the details of a particular network
"""
LOG.debug("get_network_details() called\n")
+ db.validate_network_ownership(tenant_id, net_id)
network = db.network_get(net_id)
self._invoke_device_plugins(self._func_name(), [tenant_id, net_id])
ports_list = network[const.NETWORKPORTS]
Virtual Network.
"""
LOG.debug("update_network() called\n")
+ db.validate_network_ownership(tenant_id, net_id)
network = db.network_update(net_id, tenant_id, **kwargs)
self._invoke_device_plugins(self._func_name(), [tenant_id, net_id,
kwargs])
specified Virtual Network.
"""
LOG.debug("get_all_ports() called\n")
+ db.validate_network_ownership(tenant_id, net_id)
network = db.network_get(net_id)
self._invoke_device_plugins(self._func_name(), [tenant_id, net_id])
ports_list = network[const.NETWORKPORTS]
"""
LOG.debug("create_port() called\n")
+ db.validate_network_ownership(tenant_id, net_id)
port = db.port_create(net_id, port_state)
unique_port_id_string = port[const.UUID]
self._invoke_device_plugins(self._func_name(), [tenant_id, net_id,
then the port can be deleted.
"""
LOG.debug("delete_port() called\n")
+ db.validate_port_ownership(tenant_id, net_id, port_id)
network = db.network_get(net_id)
port = db.port_get(net_id, port_id)
attachment_id = port[const.INTERFACEID]
Updates the state of a port on the specified Virtual Network.
"""
LOG.debug("update_port() called\n")
+ db.validate_port_ownership(tenant_id, net_id, port_id)
network = db.network_get(net_id)
self._invoke_device_plugins(self._func_name(), [tenant_id, net_id,
port_id, kwargs])
that is attached to this particular port.
"""
LOG.debug("get_port_details() called\n")
+ db.validate_port_ownership(tenant_id, net_id, port_id)
network = db.network_get(net_id)
self._invoke_device_plugins(self._func_name(), [tenant_id, net_id,
port_id])
specified Virtual Network.
"""
LOG.debug("plug_interface() called\n")
+ db.validate_port_ownership(tenant_id, net_id, port_id)
network = db.network_get(net_id)
port = db.port_get(net_id, port_id)
attachment_id = port[const.INTERFACEID]
specified Virtual Network.
"""
LOG.debug("unplug_interface() called\n")
+ db.validate_port_ownership(tenant_id, net_id, port_id)
network = db.network_get(net_id)
port = db.port_get(net_id, port_id)
attachment_id = port[const.INTERFACEID]
ports_dict_list = []
for net_id in net_id_list:
+ db.validate_network_ownership(tenant_id, net_id)
port = db.port_create(net_id, port_state)
ports_id_list.append(port[const.UUID])
port_dict = {const.PORT_ID: port[const.UUID]}