X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_ro%2Fvimconn_openstack.py;h=b7bcda23005e265ac5d1ddc6b0bca73d8c2b5fa3;hb=ff168193a05678df3ee1879095b9c49a1e897154;hp=cfeeae0ddc898219b6569d01724ba870e050b1d0;hpb=ebd66721b39fda2bf315102db63ea7e0dcf7becc;p=osm%2FRO.git diff --git a/osm_ro/vimconn_openstack.py b/osm_ro/vimconn_openstack.py index cfeeae0d..b7bcda23 100644 --- a/osm_ro/vimconn_openstack.py +++ b/osm_ro/vimconn_openstack.py @@ -398,23 +398,31 @@ class vimconnector(vimconn.vimconnector): def _format_exception(self, exception): '''Transform a keystone, nova, neutron exception into a vimconn exception''' - if isinstance(exception, (neExceptions.NetworkNotFoundClient, nvExceptions.NotFound, ksExceptions.NotFound, gl1Exceptions.HTTPNotFound)): - raise vimconn.vimconnNotFoundException(type(exception).__name__ + ": " + str(exception)) + + # Fixing bug 665 https://osm.etsi.org/bugzilla/show_bug.cgi?id=665 + # There are some openstack versions that message error are unicode with non English + message_error = exception.message + if isinstance(message_error, unicode): + message_error = message_error.encode("utf") + + if isinstance(exception, (neExceptions.NetworkNotFoundClient, nvExceptions.NotFound, ksExceptions.NotFound, + gl1Exceptions.HTTPNotFound)): + raise vimconn.vimconnNotFoundException(type(exception).__name__ + ": " + message_error) elif isinstance(exception, (HTTPException, gl1Exceptions.HTTPException, gl1Exceptions.CommunicationError, ConnectionError, ksExceptions.ConnectionError, neExceptions.ConnectionFailed)): - raise vimconn.vimconnConnectionException(type(exception).__name__ + ": " + str(exception)) + raise vimconn.vimconnConnectionException(type(exception).__name__ + ": " + message_error) elif isinstance(exception, (KeyError, nvExceptions.BadRequest, ksExceptions.BadRequest)): - raise vimconn.vimconnException(type(exception).__name__ + ": " + str(exception)) + raise vimconn.vimconnException(type(exception).__name__ + ": " + message_error) elif isinstance(exception, (nvExceptions.ClientException, ksExceptions.ClientException, neExceptions.NeutronException)): - raise vimconn.vimconnUnexpectedResponse(type(exception).__name__ + ": " + str(exception)) + raise vimconn.vimconnUnexpectedResponse(type(exception).__name__ + ": " + message_error) elif isinstance(exception, nvExceptions.Conflict): - raise vimconn.vimconnConflictException(type(exception).__name__ + ": " + str(exception)) + raise vimconn.vimconnConflictException(type(exception).__name__ + ": " + message_error) elif isinstance(exception, vimconn.vimconnException): raise exception else: # () - self.logger.error("General Exception " + str(exception), exc_info=True) - raise vimconn.vimconnConnectionException(type(exception).__name__ + ": " + str(exception)) + self.logger.error("General Exception " + message_error, exc_info=True) + raise vimconn.vimconnConnectionException(type(exception).__name__ + ": " + message_error) def _get_ids_from_name(self): """ @@ -563,6 +571,8 @@ class vimconnector(vimconn.vimconnector): network_dict["provider:segmentation_id"] = self._generate_vlanID() network_dict["shared"] = shared + if self.config.get("disable_network_port_security"): + network_dict["port_security_enabled"] = False new_net = self.neutron.create_network({'network':network_dict}) # print new_net # create subnetwork, even if there is no profile