Merging fixes from Sumit's branch for extension API version number and to UCS inventory to associated VIF-ID with ports.
This commit is contained in:
commit
ae21237bf1
@ -252,3 +252,46 @@ def port_destroy(net_id, port_id):
|
|||||||
return port
|
return port
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
raise q_exc.PortNotFound(port_id=port_id)
|
raise q_exc.PortNotFound(port_id=port_id)
|
||||||
|
|
||||||
|
|
||||||
|
#methods using just port_id
|
||||||
|
def port_get_by_id(port_id):
|
||||||
|
session = get_session()
|
||||||
|
try:
|
||||||
|
return session.query(models.Port).\
|
||||||
|
filter_by(uuid=port_id).one()
|
||||||
|
except exc.NoResultFound:
|
||||||
|
raise q_exc.PortNotFound(port_id=port_id)
|
||||||
|
|
||||||
|
|
||||||
|
def port_set_attachment_by_id(port_id, new_interface_id):
|
||||||
|
session = get_session()
|
||||||
|
port = port_get_by_id(port_id)
|
||||||
|
|
||||||
|
if new_interface_id != "":
|
||||||
|
if port['interface_id']:
|
||||||
|
raise q_exc.PortInUse(port_id=port_id,
|
||||||
|
att_id=port['interface_id'])
|
||||||
|
|
||||||
|
try:
|
||||||
|
port = session.query(models.Port).\
|
||||||
|
filter_by(interface_id=new_interface_id).\
|
||||||
|
one()
|
||||||
|
raise q_exc.AlreadyAttached(port_id=port_id,
|
||||||
|
att_id=new_interface_id,
|
||||||
|
att_port_id=port['uuid'])
|
||||||
|
except exc.NoResultFound:
|
||||||
|
pass
|
||||||
|
port.interface_id = new_interface_id
|
||||||
|
session.merge(port)
|
||||||
|
session.flush()
|
||||||
|
return port
|
||||||
|
|
||||||
|
|
||||||
|
def port_unset_attachment_by_id(port_id):
|
||||||
|
session = get_session()
|
||||||
|
port = port_get_by_id(port_id)
|
||||||
|
port.interface_id = None
|
||||||
|
session.merge(port)
|
||||||
|
session.flush()
|
||||||
|
return port
|
||||||
|
@ -35,7 +35,7 @@ flags.DEFINE_integer('quantum_port', 9696,
|
|||||||
HOST = FLAGS.quantum_host
|
HOST = FLAGS.quantum_host
|
||||||
PORT = FLAGS.quantum_port
|
PORT = FLAGS.quantum_port
|
||||||
USE_SSL = False
|
USE_SSL = False
|
||||||
ACTION_PREFIX_EXT = '/v0.1'
|
ACTION_PREFIX_EXT = '/v1.0'
|
||||||
ACTION_PREFIX_CSCO = ACTION_PREFIX_EXT + \
|
ACTION_PREFIX_CSCO = ACTION_PREFIX_EXT + \
|
||||||
'/extensions/csco/tenants/{tenant_id}'
|
'/extensions/csco/tenants/{tenant_id}'
|
||||||
TENANT_ID = 'nova'
|
TENANT_ID = 'nova'
|
||||||
|
@ -40,7 +40,7 @@ HOST = FLAGS.quantum_host
|
|||||||
PORT = FLAGS.quantum_port
|
PORT = FLAGS.quantum_port
|
||||||
USE_SSL = False
|
USE_SSL = False
|
||||||
TENANT_ID = 'nova'
|
TENANT_ID = 'nova'
|
||||||
ACTION_PREFIX_EXT = '/v0.1'
|
ACTION_PREFIX_EXT = '/v1.0'
|
||||||
ACTION_PREFIX_CSCO = ACTION_PREFIX_EXT + \
|
ACTION_PREFIX_CSCO = ACTION_PREFIX_EXT + \
|
||||||
'/extensions/csco/tenants/{tenant_id}'
|
'/extensions/csco/tenants/{tenant_id}'
|
||||||
TENANT_ID = 'nova'
|
TENANT_ID = 'nova'
|
||||||
|
@ -28,6 +28,7 @@ from quantum.plugins.cisco.common import cisco_constants as const
|
|||||||
from quantum.plugins.cisco.common import cisco_credentials as cred
|
from quantum.plugins.cisco.common import cisco_credentials as cred
|
||||||
from quantum.plugins.cisco.common import cisco_exceptions as cexc
|
from quantum.plugins.cisco.common import cisco_exceptions as cexc
|
||||||
from quantum.plugins.cisco.common import cisco_utils as cutil
|
from quantum.plugins.cisco.common import cisco_utils as cutil
|
||||||
|
from quantum.plugins.cisco.db import api as db
|
||||||
from quantum.plugins.cisco.db import ucs_db as udb
|
from quantum.plugins.cisco.db import ucs_db as udb
|
||||||
from quantum.plugins.cisco.ucs \
|
from quantum.plugins.cisco.ucs \
|
||||||
import cisco_ucs_inventory_configuration as conf
|
import cisco_ucs_inventory_configuration as conf
|
||||||
@ -268,7 +269,68 @@ class UCSInventory(L2NetworkDeviceInventoryBase):
|
|||||||
tenant_id)
|
tenant_id)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _get_instance_port(self, tenant_id, instance_id, vif_id=None):
|
def _get_instance_port(self, tenant_id, instance_id, vif_id):
|
||||||
|
"""
|
||||||
|
Return the device name for a reserved interface
|
||||||
|
"""
|
||||||
|
found_blade_intf_data = None
|
||||||
|
for ucsm_ip in self._inventory_state.keys():
|
||||||
|
ucsm = self._inventory_state[ucsm_ip]
|
||||||
|
for chassis_id in ucsm.keys():
|
||||||
|
for blade_id in ucsm[chassis_id]:
|
||||||
|
blade_data = ucsm[chassis_id][blade_id]
|
||||||
|
blade_intf_data = blade_data[const.BLADE_INTF_DATA]
|
||||||
|
for blade_intf in blade_intf_data.keys():
|
||||||
|
if blade_intf_data[blade_intf]\
|
||||||
|
[const.BLADE_INTF_RESERVATION] == \
|
||||||
|
const.BLADE_INTF_RESERVED and \
|
||||||
|
blade_intf_data[blade_intf]\
|
||||||
|
[const.TENANTID] == tenant_id and \
|
||||||
|
blade_intf_data[blade_intf]\
|
||||||
|
[const.INSTANCE_ID] == instance_id:
|
||||||
|
found_blade_intf_data = blade_intf_data
|
||||||
|
LOG.debug("Found blade %s associated with this" \
|
||||||
|
" instance: %s" % \
|
||||||
|
(blade_id,
|
||||||
|
instance_id))
|
||||||
|
break
|
||||||
|
|
||||||
|
if found_blade_intf_data:
|
||||||
|
blade_intf_data = found_blade_intf_data
|
||||||
|
for blade_intf in blade_intf_data.keys():
|
||||||
|
if blade_intf_data[blade_intf]\
|
||||||
|
[const.BLADE_INTF_RESERVATION] == \
|
||||||
|
const.BLADE_INTF_RESERVED and \
|
||||||
|
blade_intf_data[blade_intf]\
|
||||||
|
[const.TENANTID] == tenant_id and \
|
||||||
|
(not blade_intf_data[blade_intf][const.VIF_ID]):
|
||||||
|
blade_intf_data[blade_intf][const.VIF_ID] = \
|
||||||
|
vif_id
|
||||||
|
blade_intf_data[blade_intf]\
|
||||||
|
[const.INSTANCE_ID] = instance_id
|
||||||
|
port_binding = udb.get_portbinding_dn(blade_intf)
|
||||||
|
port_id = port_binding[const.PORTID]
|
||||||
|
udb.update_portbinding(port_id, instance_id=instance_id,
|
||||||
|
vif_id=vif_id)
|
||||||
|
db.port_set_attachment_by_id(port_id, vif_id)
|
||||||
|
device_name = blade_intf_data[blade_intf]\
|
||||||
|
[const.BLADE_INTF_RHEL_DEVICE_NAME]
|
||||||
|
profile_name = port_binding[const.PORTPROFILENAME]
|
||||||
|
dynamicnic_details = \
|
||||||
|
{const.DEVICENAME: device_name,
|
||||||
|
const.UCSPROFILE: profile_name}
|
||||||
|
LOG.debug("Found reserved dynamic nic: %s" \
|
||||||
|
"associated with port %s" %
|
||||||
|
(blade_intf_data[blade_intf], port_id))
|
||||||
|
LOG.debug("Returning dynamic nic details: %s" %
|
||||||
|
dynamicnic_details)
|
||||||
|
return dynamicnic_details
|
||||||
|
|
||||||
|
LOG.warn("Could not find a reserved dynamic nic for tenant: %s" %
|
||||||
|
tenant_id)
|
||||||
|
return None
|
||||||
|
|
||||||
|
def _disassociate_vifid_from_port(self, tenant_id, port_id):
|
||||||
"""
|
"""
|
||||||
Return the device name for a reserved interface
|
Return the device name for a reserved interface
|
||||||
"""
|
"""
|
||||||
@ -284,28 +346,24 @@ class UCSInventory(L2NetworkDeviceInventoryBase):
|
|||||||
const.BLADE_INTF_RESERVED and \
|
const.BLADE_INTF_RESERVED and \
|
||||||
blade_intf_data[blade_intf]\
|
blade_intf_data[blade_intf]\
|
||||||
[const.TENANTID] == tenant_id and \
|
[const.TENANTID] == tenant_id and \
|
||||||
blade_intf_data[blade_intf]\
|
blade_intf_data[blade_intf][const.PORTID] == \
|
||||||
[const.INSTANCE_ID] == instance_id:
|
port_id:
|
||||||
|
vif_id = blade_intf_data[blade_intf][const.VIF_ID]
|
||||||
blade_intf_data[blade_intf][const.VIF_ID] = \
|
blade_intf_data[blade_intf][const.VIF_ID] = \
|
||||||
vif_id
|
None
|
||||||
port_binding = udb.get_portbinding_dn(blade_intf)
|
blade_intf_data[blade_intf][const.INSTANCE_ID] = \
|
||||||
port_id = port_binding[const.PORTID]
|
None
|
||||||
udb.update_portbinding(port_id,
|
udb.update_portbinding(port_id, instance_id=None,
|
||||||
vif_id=vif_id)
|
vif_id=None)
|
||||||
device_name = blade_intf_data[blade_intf]\
|
LOG.debug("Disassociated VIF-ID: %s " \
|
||||||
[const.BLADE_INTF_RHEL_DEVICE_NAME]
|
"from port: %s" \
|
||||||
profile_name = port_binding[const.PORTPROFILENAME]
|
"in UCS inventory state for blade: %s" %
|
||||||
dynamicnic_details = \
|
(vif_id, port_id,
|
||||||
{const.DEVICENAME: device_name,
|
blade_intf_data[blade_intf]))
|
||||||
const.UCSPROFILE: profile_name}
|
return
|
||||||
LOG.debug("Found reserved dynamic nic: %s" \
|
LOG.warn("Disassociating VIF-ID %s in UCS inventory failed. " \
|
||||||
"associated with port %s" %
|
"Could not find a reserved dynamic nic for tenant: %s" %
|
||||||
(blade_intf_data[blade_intf], port_id))
|
(vif_id, tenant_id))
|
||||||
LOG.debug("Returning dynamic nic details: %s" %
|
|
||||||
dynamicnic_details)
|
|
||||||
return dynamicnic_details
|
|
||||||
LOG.warn("Could not find a reserved dynamic nic for tenant: %s" %
|
|
||||||
tenant_id)
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def reload_inventory(self):
|
def reload_inventory(self):
|
||||||
@ -595,6 +653,9 @@ class UCSInventory(L2NetworkDeviceInventoryBase):
|
|||||||
on which a dynamic vnic was reserved for this port
|
on which a dynamic vnic was reserved for this port
|
||||||
"""
|
"""
|
||||||
LOG.debug("unplug_interface() called\n")
|
LOG.debug("unplug_interface() called\n")
|
||||||
|
tenant_id = args[0]
|
||||||
|
port_id = args[2]
|
||||||
|
self._disassociate_vifid_from_port(tenant_id, port_id)
|
||||||
return self._get_blade_for_port(args)
|
return self._get_blade_for_port(args)
|
||||||
|
|
||||||
def schedule_host(self, args):
|
def schedule_host(self, args):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user