Ejemplo n.º 1
0
 def _initialize_keystone(self, version, auth):
     try:
         ks_client = self.keystone.initialize_client(version=version,
                                                     **auth)
     except Exception as e:
         LOG.error(_('VIM authentication failed'))
         raise nfvo.VimUnauthorizedException(message=e.message)
     return ks_client
Ejemplo n.º 2
0
    def discover_placement_attr(self, vim_obj, ks_client):
        """Fetch VIM placement information

        Attributes can include regions, AZ.
        """
        try:
            regions_list = self._find_regions(ks_client)
        except (exceptions.Unauthorized, exceptions.BadRequest) as e:
            LOG.warning("Authorization failed for user")
            raise nfvo.VimUnauthorizedException(message=e.message)
        vim_obj['placement_attr'] = {'regions': regions_list}
        return vim_obj
Ejemplo n.º 3
0
 def _validate_vim(self, auth, file_descriptor):
     # If Tacker can get k8s_info, Kubernetes authentication is valid
     # if not, it is invalid
     auth_dict = dict(auth)
     try:
         core_api_client = \
             self.kubernetes.get_core_api_client(auth_dict)
         k8s_info = core_api_client.get_api_versions()
         LOG.info(k8s_info)
     except Exception as e:
         LOG.info('VIM Kubernetes authentication is wrong.')
         # delete temp file
         self.clean_authenticate_vim(auth_dict, file_descriptor)
         raise nfvo.VimUnauthorizedException(message=str(e))