From 721d79b1f7efe56ee3ff72f9884ae7f3db671c89 Mon Sep 17 00:00:00 2001 From: kate Date: Sat, 24 Jun 2017 04:21:38 -0700 Subject: [PATCH] 1.Created new file for VIO connector as vimconn_vio.py that extends the existing openstack connector 2.Changes in vimconn_openstack.py: Modified __reload_connection() to incorporate Internal URL endpoint for VIO and added glancev1 as object attribute to avoid code duplication at VIO connector 3.Changes in vimconn_vio.py: Removed __reload_connection() , new_image() and unused imports 4.Addressed code review comments for patch set 3 5.Changes in vimconn_openstack.py: Added new helper method _create_net_dict() to create network dict 6.Changes in vimconn_vio.py: Removed implementation of SRIOV Nova workflow for VIO 3 and implemented SRIOV Neutron workflow for VIO 4. 7.Removed vimconn_vio.py file for VIO connector 8.Changes in vimconn_openstack.py: Merged VIO related changes in main openstack connector file 9.Changes in vimconn_openstack.py: Addressed code review comments for patch set 6 and modified EPA parameters in flavor for VIO 10.Changes in vimconn_openstack.py: Addressed code review comments for patch set 7 Change-Id: Iac4ea48acfd1fccd5fa81651e12058a3a0965c1c Signed-off-by: kate --- osm_ro/vimconn_openstack.py | 176 ++++++++++++++++++++++++++++++------ 1 file changed, 147 insertions(+), 29 deletions(-) diff --git a/osm_ro/vimconn_openstack.py b/osm_ro/vimconn_openstack.py index 6ac70ba6..b280da89 100644 --- a/osm_ro/vimconn_openstack.py +++ b/osm_ro/vimconn_openstack.py @@ -35,6 +35,7 @@ import netaddr import time import yaml import random +import re from novaclient import client as nClient, exceptions as nvExceptions from keystoneauth1.identity import v2, v3 @@ -77,6 +78,15 @@ class vimconnector(vimconn.vimconnector): if api_version and api_version not in ('v3.3', 'v2.0', '2', '3'): raise vimconn.vimconnException("Invalid value '{}' for config:APIversion. " "Allowed values are 'v3.3', 'v2.0', '2' or '3'".format(api_version)) + vim_type = config.get('vim_type') + if vim_type and vim_type not in ('vio', 'VIO'): + raise vimconn.vimconnException("Invalid value '{}' for config:vim_type." + "Allowed values are 'vio' or 'VIO'".format(vim_type)) + + if config.get('dataplane_net_vlan_range') is not None: + #validate vlan ranges provided by user + self._validate_vlan_ranges(config.get('dataplane_net_vlan_range')) + vimconn.vimconnector.__init__(self, uuid, name, tenant_id, tenant_name, url, url_admin, user, passwd, log_level, config) @@ -89,12 +99,25 @@ class vimconnector(vimconn.vimconnector): self.neutron = self.session.get('neutron') self.cinder = self.session.get('cinder') self.glance = self.session.get('glance') + self.glancev1 = self.session.get('glancev1') self.keystone = self.session.get('keystone') self.api_version3 = self.session.get('api_version3') + self.vim_type = self.config.get("vim_type") + if self.vim_type: + self.vim_type = self.vim_type.upper() + if self.config.get("use_internal_endpoint"): + self.endpoint_type = "internalURL" + else: + self.endpoint_type = None self.logger = logging.getLogger('openmano.vim.openstack') + + ####### VIO Specific Changes ######### + if self.vim_type == "VIO": + self.logger = logging.getLogger('openmano.vim.vio') + if log_level: - self.logger.setLevel( getattr(logging, log_level) ) + self.logger.setLevel(getattr(logging, log_level)) def __getitem__(self, index): """Get individuals parameters. @@ -144,14 +167,22 @@ class vimconnector(vimconn.vimconnector): tenant_id=self.tenant_id) sess = session.Session(auth=auth, verify=not self.insecure) if self.api_version3: - self.keystone = ksClient_v3.Client(session=sess) + self.keystone = ksClient_v3.Client(session=sess, endpoint_type=self.endpoint_type) else: - self.keystone = ksClient_v2.Client(session=sess) + self.keystone = ksClient_v2.Client(session=sess, endpoint_type=self.endpoint_type) self.session['keystone'] = self.keystone - self.nova = self.session['nova'] = nClient.Client("2.1", session=sess) - self.neutron = self.session['neutron'] = neClient.Client('2.0', session=sess) - self.cinder = self.session['cinder'] = cClient.Client(2, session=sess) - self.glance = self.session['glance'] = glClient.Client(2, session=sess) + self.nova = self.session['nova'] = nClient.Client("2.1", session=sess, endpoint_type=self.endpoint_type) + self.neutron = self.session['neutron'] = neClient.Client('2.0', session=sess, endpoint_type=self.endpoint_type) + self.cinder = self.session['cinder'] = cClient.Client(2, session=sess, endpoint_type=self.endpoint_type) + if self.endpoint_type == "internalURL": + glance_service_id = self.keystone.services.list(name="glance")[0].id + glance_endpoint = self.keystone.endpoints.list(glance_service_id, interface="internal")[0].url + else: + glance_endpoint = None + self.glance = self.session['glance'] = glClient.Client(2, session=sess, endpoint=glance_endpoint) + #using version 1 of glance client in new_image() + self.glancev1 = self.session['glancev1'] = glClient.Client('1', session=sess, + endpoint=glance_endpoint) self.session['reload_client'] = False self.persistent_info['session'] = self.session @@ -169,9 +200,7 @@ class vimconnector(vimconn.vimconnector): net['type']='data' else: net['type']='bridge' - - - + def _format_exception(self, exception): '''Transform a keystone, nova, neutron exception into a vimconn exception''' if isinstance(exception, (HTTPException, gl1Exceptions.HTTPException, gl1Exceptions.CommunicationError, @@ -254,6 +283,19 @@ class vimconnector(vimconn.vimconnector): network_dict["provider:network_type"] = "vlan" if vlan!=None: network_dict["provider:network_type"] = vlan + + ####### VIO Specific Changes ######### + if self.vim_type == "VIO": + if vlan is not None: + network_dict["provider:segmentation_id"] = vlan + else: + if self.config.get('dataplane_net_vlan_range') is None: + raise vimconn.vimconnConflictException("You must provide "\ + "'dataplane_net_vlan_range' in format [start_ID - end_ID]"\ + "at config value before creating sriov network with vlan tag") + + network_dict["provider:segmentation_id"] = self._genrate_vlanID() + network_dict["shared"]=shared new_net=self.neutron.create_network({'network':network_dict}) #print new_net @@ -483,7 +525,7 @@ class vimconnector(vimconn.vimconnector): while name in fl_names: name_suffix += 1 name = flavor_data['name']+"-" + str(name_suffix) - + ram = flavor_data.get('ram',64) vcpus = flavor_data.get('vcpus',1) numa_properties=None @@ -499,6 +541,9 @@ class vimconnector(vimconn.vimconnector): numa_properties["hw:mem_page_size"] = "large" numa_properties["hw:cpu_policy"] = "dedicated" numa_properties["hw:numa_mempolicy"] = "strict" + if self.vim_type == "VIO": + numa_properties["vmware:extra_config"] = '{"numa.nodeAffinity":"0"}' + numa_properties["vmware:latency_sensitivity_level"] = "high" for numa in numas: #overwrite ram and vcpus ram = numa['memory']*1024 @@ -522,14 +567,14 @@ class vimconnector(vimconn.vimconnector): # if interface["dedicated"]=="yes": # raise vimconn.vimconnException("Passthrough interfaces are not supported for the openstack connector", http_code=vimconn.HTTP_Service_Unavailable) # #TODO, add the key 'pci_passthrough:alias"="