@classmethod
def get_resources(cls):
- """ Returns Ext Resource Name """
+ """ Returns Ext Resource """
parent_resource = dict(member_name="tenant",
collection_name="extensions/csco/tenants")
- member_actions = {'get_host': "PUT",
- 'get_instance_port': "PUT"}
+ member_actions = {'schedule_host': "PUT",
+ 'associate_port': "PUT"}
controller = NovatenantsController(QuantumManager.get_plugin())
return [extensions.ResourceExtension('novatenants', controller,
parent=parent_resource,
def __init__(self, plugin):
self._resource_name = 'novatenant'
self._plugin = plugin
- #super(NovatenantsController, self).__init__(plugin)
-
- def index(self, request, tenant_id):
- """ Returns a list of novatenant ids """
- return "novatenant is a dummy resource"
-
- def _items(self, request, tenant_id, is_detail):
- """ Returns a list of novatenants. """
- return "novatenant is a dummy resource"
-
+
+ #added for cisco's extension
# pylint: disable-msg=E1101,W0613
- def get_host(self, request, tenant_id, id):
+ def show(self, request, tenant_id, id):
+ """ Returns novatenant details for the given novatenant id """
+ return "novatenant is a dummy resource"
+
+ def create(self, request, tenant_id):
+ """ Creates a new novatenant for a given tenant """
+ return "novatenant is a dummy resource"
+
+ def update(self, request, tenant_id, id):
+ """ Updates the name for the novatenant with the given id """
+ return "novatenant is a dummy resource"
+
+ def delete(self, request, tenant_id, id):
+ """ Destroys the Novatenant with the given id """
+ return "novatenant is a dummy resource"
+
+ #added for cisco's extension
+ def schedule_host(self, request, tenant_id, id):
content_type = request.best_match_content_type()
print "Content type:%s" % content_type
change later.\r
Location quantum/plugins/cisco/tests/unit/test_cisco_extension.py\r
\r
-Additional installation required on Nova Compute\r
-------------------------------------------------\r
-1. Create a table in the "nova" database for ports. This can be \r
- accomplished with the following SQL statement:\r
-\r
-CREATE TABLE ports (\r
- port_id VARCHAR(255) PRIMARY KEY,\r
- profile_name VARCHAR(255),\r
- dynamic_vnic VARCHAR(255),\r
- host VARCHAR(255),\r
- instance_name VARCHAR(255),\r
- instance_nic_name VARCHAR(255),\r
- used TINYINT(1)\r
-);\r
-\r
- Assuming you're using MySQL, you can run the following command from a \r
- shell prompt on the Cloud Controller node to create the table:\r
-\r
-mysql -uroot -p nova -e 'create table ports (port_id VARCHAR(255) primary key, profile_name VARCHAR(255), dynamic_vnic VARCHAR(255), host VARCHAR(255), instance_name VARCHAR(255), instance_nic_name VARCHAR(255), used tinyint(1));'\r
-\r
-You'll be prompted for a password.\r
-\r
-2. A patch is available for the Cactus release in this branch:\r
- https://code.launchpad.net/~snaiksat/quantum/cactus-ucs-support \r
- replace the following file in your installation:\r
- /usr/lib/python2.6/site-packages/nova/virt/libvirt_conn.py\r
- with the file from the branch:\r
- nova/virt/libvirt_conn.py\r
-\r
-3. Add the following file from the Cisco Nova branch:\r
- nova/virt/cisco_ucs.py\r
- to:\r
- /usr/lib/python2.6/site-packages/nova/virt/cisco_ucs.py\r
-\r
-4. Add the 802.1Qbh specific libvirt template file, from:\r
- nova/virt/libvirt-qbh.xml.template\r
- to:\r
- /usr/share/nova/libvirt-qbh.xml.template\r
- \r
-5. Edit /etc/nova.conf to set the libvirt XML template to the above template:\r
- --libvirt_xml_template=/usr/share/nova/libvirt-qbh.xml.template\r
-\r
-6. Restart the nova-compute service.\r
-\r
- (Note that the requirement for the above patch is temporary and will go away\r
- with the integration with OpenStack Diablo. A 802.1Qbh-specific VIF driver \r
- will be made available as per the specification here:\r
- http://wiki.openstack.org/network-refactoring#VIF_driver)\r
-\r
+ The script can be executed by :\r
+ ./run_tests.sh quantum.plugins.cisco.tests.unit.test_cisco_extension\r
+ \r
+ or\r
+ \r
+ python run_tests.py quantum.plugins.cisco.tests.unit.test_cisco_extension\r
+ \r
Bingo bango bongo! That's it! Thanks for taking the leap into Quantum.\r
\r
...Oh, boy!\r
import logging as LOG
import os
- from quantum.plugins.cisco.common import cisco_constants as const
from quantum.plugins.cisco.common import cisco_configparser as confp
+ from quantum.plugins.cisco.common import cisco_constants as const
+from quantum.plugins.cisco.common import cisco_exceptions as cexc
+from quantum.plugins.cisco.db import l2network_db as cdb
LOG.basicConfig(level=LOG.WARN)
LOG.getLogger(const.LOGGER_COMPONENT_NAME)
"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"""
+ """Credential with this ID cannot be found"""
message = _("Credential %(credential_id)s could not be found " \
"for tenant %(tenant_id)s")
"""
code = 450
title = 'Portprofile Not Found'
-- explanation = ('Unable to find a Portprofile with'
++ explanation = ('Unable to find a Portprofile with'
+ ' the specified identifier.')
code = 430
title = 'Port not Found'
explanation = ('Unable to find a port with the specified identifier.')
--
--
++
++
class CredentialNotFound(webob.exc.HTTPClientError):
"""
subclass of :class:`~HTTPClientError`
"""
code = 451
title = 'Credential Not Found'
-- explanation = ('Unable to find a Credential with'
++ explanation = ('Unable to find a Credential with'
+ ' the specified identifier.')
--
--
++
++
class QosNotFound(webob.exc.HTTPClientError):
"""
subclass of :class:`~HTTPClientError`
"""
code = 452
title = 'QoS Not Found'
-- explanation = ('Unable to find a QoS with'
++ explanation = ('Unable to find a QoS with'
+ ' the specified identifier.')
--
--
++
++
class NovatenantNotFound(webob.exc.HTTPClientError):
"""
subclass of :class:`~HTTPClientError`
"""
code = 453
title = 'Nova tenant Not Found'
-- explanation = ('Unable to find a Novatenant with'
++ explanation = ('Unable to find a Novatenant with'
+ ' the specified identifier.')
from quantum.common import exceptions as q_exc
from quantum.plugins.cisco import l2network_plugin_configuration as conf
from quantum.plugins.cisco.common import cisco_exceptions as c_exc
+ from quantum.plugins.cisco.db import l2network_models
- import l2network_models
import logging as LOG
import quantum.plugins.cisco.db.api as db
+import quantum.plugins.cisco.db.nexus_db as ndb
+import quantum.plugins.cisco.db.ucs_db as udb
def initialize():
def __repr__(self):
return "<PortProfile Binding(%s,%s,%s,%s)>" % \
(self.tenant_id, self.port_id, self.portprofile_id, self.default)
- return "<Credentials(%s,%s,%s,%s)>" % \
+
+
+class QoS(BASE, L2NetworkBase):
+ """Represents QoS for a tenant"""
+ __tablename__ = 'qoss'
+
+ 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.qos_id = str(uuid.uuid4())
+ self.tenant_id = tenant_id
+ self.qos_name = qos_name
+ self.qos_desc = qos_desc
+
+ def __repr__(self):
+ 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__ = 'credentials'
+
+ credential_id = Column(String(255))
+ tenant_id = 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, credential_name, user_name, password):
+ self.credential_id = str(uuid.uuid4())
+ self.tenant_id = tenant_id
+ self.credential_name = credential_name
+ self.user_name = user_name
+ self.password = password
+
+ def __repr__(self):
++ return "<Credentials(%s,%s,%s,%s,%s)>" % \
+ (self.credential_id, self.tenant_id, self.credential_name,
+ self.user_name, self.password)
from quantum.common import exceptions as exc
from quantum.common import utils
from quantum.quantum_plugin_base import QuantumPluginBase
++
from quantum.plugins.cisco import l2network_plugin_configuration as conf
-from quantum.plugins.cisco.common import cisco_exceptions as cexc
from quantum.plugins.cisco.common import cisco_constants as const
- from quantum.plugins.cisco.common import cisco_exceptions as cexc
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_utils as cutil
from quantum.plugins.cisco.db import api as db
from quantum.plugins.cisco.db import l2network_db as cdb
except Exception, excp:
raise cexc.CredentialNotFound(tenant_id=tenant_id,
credential_id=credential_id)
- self._credentials.pop(credential_id)
- cred.Store.deleteCredential(credential_id)
+ credential = cdb.remove_credential(tenant_id, credential_id)
+ return credential
def rename_credential(self, tenant_id, credential_id, new_name):
- """Do nothing for this resource"""
+ """Rename the particular credential resource"""
LOG.debug("rename_credential() called\n")
try:
- credential = self._get_credential(tenant_id, credential_id)
+ credential = cdb.get_credential(tenant_id, credential_id)
except Exception, excp:
raise cexc.CredentialNotFound(tenant_id=tenant_id,
credential_id=credential_id)
class NovatenantExtensionTest(unittest.TestCase):
def setUp(self):
+
+ """ Set up function"""
+
parent_resource = dict(member_name="tenant",
collection_name="extensions/csco/tenants")
- member_actions = {'get_host': "PUT",
- 'get_instance_port': "PUT"}
+ member_actions = {'schedule_host': "PUT",
+ 'associate_port': "PUT"}
controller = novatenant.NovatenantsController(
QuantumManager.get_plugin())
res_ext = extensions.ResourceExtension('novatenants', controller,
SimpleExtensionManager(res_ext))
self.contenttype = 'application/json'
self.novatenants_path = '/extensions/csco/tenants/tt/novatenants/'
-- self.test_instance_data = {'novatenant': {'instance_id': 1,
++ self.test_associate_data = {'novatenant': {'instance_id': 1,
'instance_desc': {'key1': '1',
'key2': '2'}}}
- def test_get_host(self):
-
+ def test_schedule_host(self):
+ """ Test get host"""
-
- LOG.debug("test_get_host - START")
- req_body = json.dumps(self.test_instance_data)
- host_path = self.novatenants_path + "001/get_host"
+ LOG.debug("test_schedule_host - START")
- req_body = json.dumps(self.test_instance_data)
++ req_body = json.dumps(self.test_associate_data)
+ host_path = self.novatenants_path + "001/schedule_host"
host_response = self.test_app.put(
- host_path, req_body,
- content_type=self.contenttype)
+ host_path, req_body,
+ content_type=self.contenttype)
self.assertEqual(200, host_response.status_int)
- LOG.debug("test_get_host - END")
-
- def test_get_hostBADRequest(self):
+ LOG.debug("test_schedule_host - END")
-
- LOG.debug("test_get_hostBADRequest - START")
- host_path = self.novatenants_path + "001/get_host"
+ def test_schedule_hostBADRequest(self):
+ """ Test get host bad request"""
+ LOG.debug("test_schedule_hostBADRequest - START")
+ host_path = self.novatenants_path + "001/schedule_host"
host_response = self.test_app.put(
- host_path, 'BAD_REQUEST',
- content_type=self.contenttype, status='*')
+ host_path, 'BAD_REQUEST',
+ content_type=self.contenttype, status='*')
self.assertEqual(400, host_response.status_int)
- LOG.debug("test_get_hostBADRequest - END")
-
- def test_instance_port(self):
-
- """ Test get instance port """
-
- LOG.debug("test_instance_port - START")
- req_body = json.dumps(self.test_instance_data)
- instance_port_path = self.novatenants_path + "001/get_instance_port"
- instance_port_response = self.test_app.put(
- instance_port_path, req_body,
+ LOG.debug("test_schedule_hostBADRequest - END")
+
- def test_instance_port(self):
- LOG.debug("test_instance_port - START")
- req_body = json.dumps(self.test_instance_data)
- instance_port_path = self.novatenants_path + "001/associate_port"
- instance_port_response = self.test_app.put(
- instance_port_path, req_body,
++ def test_associate_port(self):
++ """ Test get associate port """
++ LOG.debug("test_associate_port - START")
++ req_body = json.dumps(self.test_associate_data)
++ associate_port_path = self.novatenants_path + "001/associate_port"
++ associate_port_response = self.test_app.put(
++ associate_port_path, req_body,
content_type=self.contenttype)
-- self.assertEqual(200, instance_port_response.status_int)
-- LOG.debug("test_instance_port - END")
++ self.assertEqual(200, associate_port_response.status_int)
++ LOG.debug("test_associate_port - END")
class QosExtensionTest(unittest.TestCase):
from quantum.common import exceptions as exc
from quantum.common import utils
+ from quantum.plugins.cisco.common import cisco_exceptions as cexc
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_exceptions as cexc
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 l2network_db as cdb
+from quantum.plugins.cisco.db import ucs_db as udb
from quantum.plugins.cisco.l2device_plugin_base import L2DevicePluginBase
from quantum.plugins.cisco.ucs import cisco_ucs_configuration as conf