From: kate Date: Wed, 6 Sep 2017 06:26:28 +0000 (-0700) Subject: Merge branch 'vio' into v2.0 X-Git-Tag: v3.0.0~17^2~3 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=5461675ac6705ee92916ed741da1914bd2162482;p=osm%2FRO.git Merge branch 'vio' into v2.0 Change-Id: I380d554f9e9f03b0c4425fd998123fda300b81ff Signed-off-by: kate --- 5461675ac6705ee92916ed741da1914bd2162482 diff --cc osm_ro/vimconn_openstack.py index 3eb2990b,b280da89..319f8c1a --- a/osm_ro/vimconn_openstack.py +++ b/osm_ro/vimconn_openstack.py @@@ -35,7 -35,7 +35,8 @@@ import netadd import time import yaml import random +import sys + import re from novaclient import client as nClient, exceptions as nvExceptions from keystoneauth1.identity import v2, v3 @@@ -97,10 -102,22 +107,22 @@@ class vimconnector(vimconn.vimconnector 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)) ++ self.logger.setLevel( getattr(logging, log_level)) def __getitem__(self, index): """Get individuals parameters. @@@ -150,29 -167,24 +172,36 @@@ 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, endpoint_type=self.endpoint_type) + # In order to enable microversion functionality an explicit microversion must be specified in 'config'. + # This implementation approach is due to the warning message in + # https://developer.openstack.org/api-guide/compute/microversions.html + # where it is stated that microversion backwards compatibility is not guaranteed and clients should + # always require an specific microversion. + # To be able to use 'device role tagging' functionality define 'microversion: 2.32' in datacenter config + version = self.config.get("microversion") + if not version: + version = "2.1" - self.nova = self.session['nova'] = nClient.Client(str(version), 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.glancev1 = self.session['glancev1'] = glClient.Client('1', session=sess) ++ self.nova = self.session['nova'] = nClient.Client(str(version), 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 + # add availablity zone info inside self.persistent_info + self._set_availablity_zones() + self.persistent_info['availability_zone'] = self.availability_zone def __net_os2mano(self, net_list_dict): '''Transform the net openstack format to mano format @@@ -542,14 -567,14 +587,14 @@@ # 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"="