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")
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:
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)
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()
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
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)
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)
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()
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
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)
self.vlan_used = False
def __repr__(self):
- return "<VlanBinding(%d,%s)>" % \
+ return "<VlanID(%d,%s)>" % \
(self.vlan_id, self.vlan_used)
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)
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():