From: rohitagarwalla Date: Wed, 24 Aug 2011 22:23:56 +0000 (-0700) Subject: integration with l2network_plugin.py X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=25560fd74e8466d51b4602203f10a03b53562792;p=openstack-build%2Fneutron-build.git integration with l2network_plugin.py --- diff --git a/quantum/plugins/cisco/common/cisco_exceptions.py b/quantum/plugins/cisco/common/cisco_exceptions.py index 0ef83528c..02f4078da 100644 --- a/quantum/plugins/cisco/common/cisco_exceptions.py +++ b/quantum/plugins/cisco/common/cisco_exceptions.py @@ -91,31 +91,31 @@ class VlanIDNotAvailable(exceptions.QuantumException): class QosNotFound(exceptions.QuantumException): + """QoS ID could not be found""" message = _("QoS level %(qos_id)s could not be found " \ "for tenant %(tenant_id)s") class QoSLevelInvalidDelete(exceptions.QuantumException): + """QoS ID could not be deleted""" message = _("QoS level %(qos_id)s could not be deleted " \ "for tenant %(tenant_id)s since association exists") class QosNameAlreadyExists(exceptions.QuantumException): + """QoS Name already exists""" message = _("QoS level with name %(qos_name)s already exists " \ "for tenant %(tenant_id)s") class CredentialNotFound(exceptions.QuantumException): + """Credential ID could not be found""" message = _("Credential %(credential_id)s could not be found " \ "for tenant %(tenant_id)s") -class CredentialNameNotFound(exceptions.QuantumException): - message = _("Credential %(credential_name)s could not be found " \ - "for tenant %(tenant_id)s") - - class CredentialAlreadyExists(exceptions.QuantumException): + """Credential ID already exists""" message = _("Credential %(credential_id)s already exists " \ "for tenant %(tenant_id)s") diff --git a/quantum/plugins/cisco/db/l2network_db.py b/quantum/plugins/cisco/db/l2network_db.py index 4626fcd0d..b97ce5efa 100644 --- a/quantum/plugins/cisco/db/l2network_db.py +++ b/quantum/plugins/cisco/db/l2network_db.py @@ -404,7 +404,7 @@ def get_qos(tenant_id, qos_id): try: qos = session.query(l2network_models.QoS).\ filter_by(tenant_id=tenant_id).\ - filter_by(uuid=qos_id).\ + filter_by(qos_id=qos_id).\ one() return qos except exc.NoResultFound: @@ -419,7 +419,7 @@ def add_qos(tenant_id, qos_name, qos_desc): try: qos = session.query(l2network_models.QoS).\ filter_by(tenant_id=tenant_id).\ - filter_by(name=qos_name).\ + filter_by(qos_name=qos_name).\ one() raise c_exc.QosNameAlreadyExists(qos_name=qos_name, tenant_id=tenant_id) @@ -436,7 +436,7 @@ def remove_qos(tenant_id, qos_id): try: qos = session.query(l2network_models.QoS).\ filter_by(tenant_id=tenant_id).\ - filter_by(uuid=qos_id).\ + filter_by(qos_id=qos_id).\ one() session.delete(qos) session.flush() @@ -451,10 +451,10 @@ def update_qos(tenant_id, qos_id, new_qos_name=None): try: qos = session.query(l2network_models.QoS).\ filter_by(tenant_id=tenant_id).\ - filter_by(uuid=qos_id).\ + filter_by(qos_id=qos_id).\ one() if new_qos_name: - qos["name"] = new_qos_name + qos["qos_name"] = new_qos_name session.merge(qos) session.flush() return qos @@ -475,17 +475,17 @@ def get_all_credentials(tenant_id): return [] -def get_credential(tenant_id, credential_name): +def get_credential(tenant_id, credential_id): """Lists the creds for given a cred_id and tenant_id""" session = db.get_session() try: cred = session.query(l2network_models.Credential).\ filter_by(tenant_id=tenant_id).\ - filter_by(name=credential_name).\ + filter_by(credential_id=credential_id).\ one() return cred except exc.NoResultFound: - raise c_exc.CredentialNameNotFound(credential_name=credential_name, + raise c_exc.CredentialNotFound(credential_id=credential_id, tenant_id=tenant_id) @@ -495,7 +495,7 @@ def add_credential(tenant_id, credential_name, user_name, password): try: cred = session.query(l2network_models.Credential).\ filter_by(tenant_id=tenant_id).\ - filter_by(name=credential_name).\ + filter_by(credential_name=credential_name).\ one() raise c_exc.CredentialAlreadyExists(credential_name=credential_name, tenant_id=tenant_id) @@ -507,13 +507,13 @@ def add_credential(tenant_id, credential_name, user_name, password): return cred -def remove_credential(tenant_id, credential_name): +def remove_credential(tenant_id, credential_id): """Removes a credential from a tenant""" session = db.get_session() try: cred = session.query(l2network_models.Credential).\ filter_by(tenant_id=tenant_id).\ - filter_by(name=credential_name).\ + filter_by(credential_id=credential_id).\ one() session.delete(cred) session.flush() @@ -522,14 +522,14 @@ def remove_credential(tenant_id, credential_name): pass -def update_credential(tenant_id, credential_name, +def update_credential(tenant_id, credential_id, new_user_name=None, new_password=None): """Updates a credential for a tenant""" session = db.get_session() try: cred = session.query(l2network_models.Credential).\ filter_by(tenant_id=tenant_id).\ - filter_by(name=credential_name).\ + filter_by(credential_id=credential_id).\ one() if new_user_name: cred["user_name"] = new_user_name @@ -539,5 +539,5 @@ def update_credential(tenant_id, credential_name, session.flush() return cred except exc.NoResultFound: - raise c_exc.CredentialNameNotFound(credential_name=credential_name, + raise c_exc.CredentialNotFound(credential_id=credential_id, tenant_id=tenant_id) diff --git a/quantum/plugins/cisco/db/l2network_models.py b/quantum/plugins/cisco/db/l2network_models.py index bcfdd7768..53c0d3c7d 100644 --- a/quantum/plugins/cisco/db/l2network_models.py +++ b/quantum/plugins/cisco/db/l2network_models.py @@ -77,7 +77,7 @@ class VlanID(BASE, L2NetworkBase): self.vlan_used = False def __repr__(self): - return "" % \ + return "" % \ (self.vlan_id, self.vlan_used) @@ -149,41 +149,42 @@ class PortProfileBinding(BASE, L2NetworkBase): class QoS(BASE, L2NetworkBase): """Represents QoS for a tenant""" - __tablename__ = 'QoS' + __tablename__ = 'qoss' - uuid = Column(String(255), primary_key=True) - tenant_id = Column(String(255)) - name = Column(String(255)) - desc = Column(String(255)) + qos_id = Column(String(255)) + tenant_id = Column(String(255), primary_key=True) + qos_name = Column(String(255), primary_key=True) + qos_desc = Column(String(255)) def __init__(self, tenant_id, qos_name, qos_desc): - self.uuid = uuid.uuid4() + self.qos_id = uuid.uuid4() self.tenant_id = tenant_id - self.name = qos_name - self.desc = qos_desc + self.qos_name = qos_name + self.qos_desc = qos_desc def __repr__(self): - return "" % \ - (self.tenant_id, self.name, self.desc) + return "" % \ + (self.qos_id, self.tenant_id, self.qos_name, self.qos_desc) class Credential(BASE, L2NetworkBase): """Represents credentials for a tenant""" - __tablename__ = 'QoS' + __tablename__ = 'credentials' - uuid = Column(String(255)) + credential_id = Column(String(255)) tenant_id = Column(String(255), primary_key=True) - name = Column(String(255), primary_key=True) + credential_name = Column(String(255), primary_key=True) user_name = Column(String(255)) password = Column(String(255)) - def __init__(self, tenant_id, name, user_name, password): - self.uuid = uuid.uuid4() + def __init__(self, tenant_id, credential_name, user_name, password): + self.credential_id = uuid.uuid4() self.tenant_id = tenant_id - self.name = name + self.credential_name = credential_name self.user_name = user_name self.password = password def __repr__(self): return "" % \ - (self.tenant_id, self.name, self.user_name, self.password) + (self.credential_id, self.tenant_id, self.credential_name, + self.user_name, self.password) diff --git a/quantum/plugins/cisco/db/ucs_db.py b/quantum/plugins/cisco/db/ucs_db.py index 49ff512ef..14b09ad42 100644 --- a/quantum/plugins/cisco/db/ucs_db.py +++ b/quantum/plugins/cisco/db/ucs_db.py @@ -20,9 +20,9 @@ import logging as LOG from sqlalchemy.orm import exc import quantum.plugins.cisco.db.api as db -import ucs_models from quantum.plugins.cisco.common import cisco_exceptions as c_exc +from quantum.plugins.cisco.db import ucs_models def get_all_ucsmbinding():