Exemple #1
0
 def _ensure_endpoint_set(self, cxt, service):
     handle = self.service_handle_map[service]
     if not handle.is_endpoint_url_set():
         pod_filters = [{
             'key': 'region_name',
             'comparator': 'eq',
             'value': self.region_name
         }]
         pod_list = api.list_pods(cxt, pod_filters)
         if len(pod_list) == 0:
             raise exceptions.ResourceNotFound(models.Pod, self.region_name)
         # region_name is unique key, safe to get the first element
         pod_id = pod_list[0]['pod_id']
         config_filters = [{
             'key': 'pod_id',
             'comparator': 'eq',
             'value': pod_id
         }, {
             'key': 'service_type',
             'comparator': 'eq',
             'value': service
         }]
         conf_list = self._get_config_with_retry(
             cxt, config_filters, pod_id, service,
             cfg.CONF.client.auto_refresh_endpoint)
         url = conf_list[0]['service_url']
         handle.update_endpoint_url(url)
Exemple #2
0
def check_resource_not_in_deleting(context, dict_para):
    t_ctx = t_context.get_context_from_neutron_context(context)
    with t_ctx.session.begin():
        resource_filters = []
        for key in dict_para.keys():
            resource_filters.append({'key': key,
                                     'comparator': 'eq',
                                     'value': dict_para[key]})

        deleting_resource = core.query_resource(t_ctx,
                                                models.DeletingResources,
                                                resource_filters, [])

        if len(deleting_resource):
            if hasattr(context, "USER_AGENT") and \
                    context.USER_AGENT == t_constants.LOCAL:
                raise t_exceptions.ResourceNotFound(
                    models.DeletingResources, dict_para['resource_id'])
            else:
                raise t_exceptions.ResourceIsInDeleting()
Exemple #3
0
def _get_resource(context, model, pk_value):
    res_obj = context.session.query(model).get(pk_value)
    if not res_obj:
        raise exceptions.ResourceNotFound(model, pk_value)
    return res_obj