]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
integration with l2network_plugin.py
authorrohitagarwalla <roagarwa@cisco.com>
Wed, 24 Aug 2011 22:23:56 +0000 (15:23 -0700)
committerrohitagarwalla <roagarwa@cisco.com>
Wed, 24 Aug 2011 22:23:56 +0000 (15:23 -0700)
quantum/plugins/cisco/common/cisco_exceptions.py
quantum/plugins/cisco/db/l2network_db.py
quantum/plugins/cisco/db/l2network_models.py
quantum/plugins/cisco/db/ucs_db.py

index 0ef83528c5373acdc4300e5697583e0793a18fa1..02f4078daa1a80c9ff40229f9ca9d3836c6167f3 100644 (file)
@@ -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")
 
index 4626fcd0d4f5954450bbf0cc5a82ef07082667b6..b97ce5efaba4ba6a84379421c52d18e9855126aa 100644 (file)
@@ -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)
index bcfdd776800b58c39e43d46b1f57e472036a14e5..53c0d3c7db98ae58ea231b0f50738549f7576239 100644 (file)
@@ -77,7 +77,7 @@ class VlanID(BASE, L2NetworkBase):
         self.vlan_used = False
 
     def __repr__(self):
-        return "<VlanBinding(%d,%s)>" % \
+        return "<VlanID(%d,%s)>" % \
           (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 "<QoS(%s,%s,%s)>" % \
-          (self.tenant_id, self.name, self.desc)
+        return "<QoS(%s,%s,%s,%s)>" % \
+          (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 "<Credentials(%s,%s,%s,%s)>" % \
-          (self.tenant_id, self.name, self.user_name, self.password)
+          (self.credential_id, self.tenant_id, self.credential_name,
+           self.user_name, self.password)
index 49ff512efd9d876d4ab174fd93dfcf33563c7284..14b09ad42e12d850ce66777c43217bc6fd48b240 100644 (file)
@@ -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():