From: rohitagarwalla Date: Sun, 21 Aug 2011 00:02:47 +0000 (-0700) Subject: added new columns to models for ucs plugin multi blade support X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=a570af2974bb4908266ce73eef60dc780519f6fd;p=openstack-build%2Fneutron-build.git added new columns to models for ucs plugin multi blade support updated methods in ucs_db for newly added columns changed column dynamic_vnic_id in port binding table to blade_intf_dn updated tests to handle new column name --- diff --git a/quantum/plugins/cisco/db/ucs_db.py b/quantum/plugins/cisco/db/ucs_db.py index 4cb96b2d2..2f5402795 100644 --- a/quantum/plugins/cisco/db/ucs_db.py +++ b/quantum/plugins/cisco/db/ucs_db.py @@ -155,7 +155,10 @@ def remove_dynamicvnic(vnic_id): def update_dynamicvnic(vnic_id, new_device_name=None, new_blade_id=None, - vnic_state=None): + vnic_state=None, blade_intf_dn=None, + blade_intf_order=None, blade_int_link_state=None, + blade_intf_oper_state=None, blade_intf_inst_type=None, + blade_intf_reservation=None): """Updates dynamic vnic""" LOG.debug("update_dynamicvnic() called") session = db.get_session() @@ -169,6 +172,18 @@ def update_dynamicvnic(vnic_id, new_device_name=None, new_blade_id=None, vnic.blade_id = new_blade_id if vnic_state: vnic.vnic_state = vnic_state + if blade_intf_dn: + vnic.blade_intf_dn = blade_intf_dn + if blade_intf_order: + vnic.blade_intf_order = blade_intf_order + if blade_int_link_state: + vnic.blade_int_link_state = blade_int_link_state + if blade_intf_oper_state: + vnic.blade_intf_oper_state = blade_intf_oper_state + if blade_intf_inst_type: + vnic.blade_intf_inst_type = blade_intf_inst_type + if blade_intf_reservation: + vnic.blade_intf_reservation = blade_intf_reservation session.merge(vnic) session.flush() return vnic @@ -291,7 +306,7 @@ def get_portbinding(port_id): raise c_exc.PortVnicNotFound(port_id=port_id) -def add_portbinding(port_id, dynamic_vnic_id, portprofile_name, +def add_portbinding(port_id, blade_intf_dn, portprofile_name, vlan_name, vlan_id, qos): """Adds a port binding""" LOG.debug("add_portbinding() called") @@ -302,7 +317,7 @@ def add_portbinding(port_id, dynamic_vnic_id, portprofile_name, one() raise c_exc.PortVnicBindingAlreadyExists(port_id=port_id) except exc.NoResultFound: - port_binding = ucs_models.PortBinding(port_id, dynamic_vnic_id, \ + port_binding = ucs_models.PortBinding(port_id, blade_intf_dn, \ portprofile_name, vlan_name, vlan_id, qos) session.add(port_binding) session.flush() @@ -324,8 +339,10 @@ def remove_portbinding(port_id): pass -def update_portbinding(port_id, dynamic_vnic_id=None, portprofile_name=None, - vlan_name=None, vlan_id=None, qos=None): +def update_portbinding(port_id, blade_intf_dn=None, portprofile_name=None, + vlan_name=None, vlan_id=None, qos=None, + tenant_id=None, instance_id=None, + vif_id=None): """Updates port binding""" LOG.debug("db update_portbinding() called") session = db.get_session() @@ -333,8 +350,8 @@ def update_portbinding(port_id, dynamic_vnic_id=None, portprofile_name=None, port_binding = session.query(ucs_models.PortBinding).\ filter_by(port_id=port_id).\ one() - if dynamic_vnic_id: - port_binding.dynamic_vnic_id = dynamic_vnic_id + if blade_intf_dn: + port_binding.blade_intf_dn = blade_intf_dn if portprofile_name: port_binding.portprofile_name = portprofile_name if vlan_name: @@ -343,6 +360,12 @@ def update_portbinding(port_id, dynamic_vnic_id=None, portprofile_name=None, port_binding.vlan_id = vlan_id if qos: port_binding.qos = qos + if tenant_id: + port_binding.tenant_id = tenant_id + if instance_id: + port_binding.instance_id = instance_id + if vif_id: + port_binding.vif_id = vif_id session.merge(port_binding) session.flush() return port_binding diff --git a/quantum/plugins/cisco/db/ucs_models.py b/quantum/plugins/cisco/db/ucs_models.py index a146ac828..be7c18aab 100644 --- a/quantum/plugins/cisco/db/ucs_models.py +++ b/quantum/plugins/cisco/db/ucs_models.py @@ -53,6 +53,12 @@ class DynamicVnic(BASE, L2NetworkBase): blade_id = Column(String(255), ForeignKey("ucs_blades.uuid"), nullable=False) vnic_state = Column(String(255)) + blade_intf_dn = Column(String(255)) + blade_intf_order = Column(String(255)) + blade_int_link_state = Column(String(255)) + blade_intf_oper_state = Column(String(255)) + blade_intf_inst_type = Column(String(255)) + blade_intf_reservation = Column(String(255)) def __init__(self, device_name, blade_id, vnic_state): self.uuid = uuid.uuid4() @@ -105,19 +111,20 @@ class PortBinding(BASE, L2NetworkBase): id = Column(Integer, primary_key=True, autoincrement=True) port_id = Column(String(255), ForeignKey("ports.uuid"), nullable=False) - dynamic_vnic_id = Column(String(255), ForeignKey("dynamic_vnics.uuid"), - nullable=False) + blade_intf_dn = Column(String(255), nullable=False) portprofile_name = Column(String(255)) vlan_name = Column(String(255)) vlan_id = Column(Integer) qos = Column(String(255)) + tenant_id = Column(String(255)) + instance_id = Column(String(255)) + vif_id = Column(String(255)) ports = relation(models.Port, uselist=False) - dynamic_vnics = relation(DynamicVnic, uselist=False) - def __init__(self, port_id, dynamic_vnic_id, portprofile_name, + def __init__(self, port_id, blade_intf_dn, portprofile_name, vlan_name, vlan_id, qos): self.port_id = port_id - self.dynamic_vnic_id = dynamic_vnic_id + self.blade_intf_dn = blade_intf_dn self.portprofile_name = portprofile_name self.vlan_name = vlan_name self.vlan_id = vlan_id @@ -125,5 +132,5 @@ class PortBinding(BASE, L2NetworkBase): def __repr__(self): return "" % \ - (self.port_id, self.dynamic_vnic_id, self.portprofile_name, + (self.port_id, self.blade_intf_dn, self.portprofile_name, self.vlan_name, self.vlan_id, self.qos) diff --git a/quantum/plugins/cisco/tests/unit/test_database.py b/quantum/plugins/cisco/tests/unit/test_database.py index d97592b56..8e3b7b6b8 100644 --- a/quantum/plugins/cisco/tests/unit/test_database.py +++ b/quantum/plugins/cisco/tests/unit/test_database.py @@ -272,7 +272,7 @@ class UcsDB(object): LOG.debug("Getting port binding for port: %s" % bind.port_id) port_bind_dict = {} port_bind_dict["port-id"] = bind.port_id - port_bind_dict["dynamic-vnic-id"] = str(bind.dynamic_vnic_id) + port_bind_dict["blade-intf-dn"] = str(bind.blade_intf_dn) port_bind_dict["portprofile-name"] = bind.portprofile_name port_bind_dict["vlan-name"] = bind.vlan_name port_bind_dict["vlan-id"] = str(bind.vlan_id) @@ -290,7 +290,7 @@ class UcsDB(object): LOG.debug("Getting port binding for port: %s" % bind.port_id) port_bind_dict = {} port_bind_dict["port-id"] = bind.port_id - port_bind_dict["dynamic-vnic-id"] = str(bind.dynamic_vnic_id) + port_bind_dict["blade-intf-dn"] = str(bind.blade_intf_dn) port_bind_dict["portprofile-name"] = bind.portprofile_name port_bind_dict["vlan-name"] = bind.vlan_name port_bind_dict["vlan-id"] = str(bind.vlan_id) @@ -300,16 +300,16 @@ class UcsDB(object): LOG.error("Failed to get port binding: %s" % str(exc)) return port_binding - def create_port_binding(self, port_id, dynamic_vnic_id, portprofile_name, \ + def create_port_binding(self, port_id, blade_intf_dn, portprofile_name, \ vlan_name, vlan_id, qos): """create port binding""" port_bind_dict = {} try: - res = ucs_db.add_portbinding(port_id, dynamic_vnic_id, \ + res = ucs_db.add_portbinding(port_id, blade_intf_dn, \ portprofile_name, vlan_name, vlan_id, qos) LOG.debug("Created port binding: %s" % res.port_id) port_bind_dict["port-id"] = res.port_id - port_bind_dict["dynamic-vnic-id"] = str(res.dynamic_vnic_id) + port_bind_dict["blade-intf-dn"] = str(res.blade_intf_dn) port_bind_dict["portprofile-name"] = res.portprofile_name port_bind_dict["vlan-name"] = res.vlan_name port_bind_dict["vlan-id"] = str(res.vlan_id) @@ -329,16 +329,16 @@ class UcsDB(object): except Exception, exc: raise Exception("Failed to delete port profile: %s" % str(exc)) - def update_port_binding(self, port_id, dynamic_vnic_id, \ + def update_port_binding(self, port_id, blade_intf_dn, \ portprofile_name, vlan_name, vlan_id, qos): """update port binding""" try: - res = ucs_db.update_portbinding(port_id, dynamic_vnic_id, \ + res = ucs_db.update_portbinding(port_id, blade_intf_dn, \ portprofile_name, vlan_name, vlan_id, qos) LOG.debug("Updating port binding: %s" % res.port_id) port_bind_dict = {} port_bind_dict["port-id"] = res.port_id - port_bind_dict["dynamic-vnic-id"] = str(res.dynamic_vnic_id) + port_bind_dict["dynamic-vnic-id"] = str(res.blade_intf_dn) port_bind_dict["portprofile-name"] = res.portprofile_name port_bind_dict["vlan-name"] = res.vlan_name port_bind_dict["vlan-id"] = str(res.vlan_id)