def modify_endpoint_template(self, admin_token, endpoint_template_id, endpoint_template): self.__validate_service_or_keystone_admin_token(admin_token) if not isinstance(endpoint_template, EndpointTemplate): raise fault.BadRequestFault("Expecting a EndpointTemplate") dendpoint_template = api.ENDPOINT_TEMPLATE.get(endpoint_template_id) if not dendpoint_template: raise fault.ItemNotFoundFault( "The endpoint template could not be found") #Check if the passed service exist. if endpoint_template.service != None and\ len(endpoint_template.service.strip()) > 0 and\ api.SERVICE.get(endpoint_template.service) == None: raise fault.BadRequestFault( "A service with that id doesn't exist.") dendpoint_template.region = endpoint_template.region dendpoint_template.service_id = endpoint_template.service dendpoint_template.public_url = endpoint_template.public_url dendpoint_template.admin_url = endpoint_template.admin_url dendpoint_template.internal_url = endpoint_template.internal_url dendpoint_template.enabled = endpoint_template.enabled dendpoint_template.is_global = endpoint_template.is_global dendpoint_template = api.ENDPOINT_TEMPLATE.update( endpoint_template_id, dendpoint_template) return EndpointTemplate( dendpoint_template.id, dendpoint_template.region, dendpoint_template.service_id, dendpoint_template.public_url, dendpoint_template.admin_url, dendpoint_template.internal_url, dendpoint_template.enabled, dendpoint_template.is_global)
def get_endpoint_template(self, admin_token, endpoint_template_id): self.__validate_service_or_keystone_admin_token(admin_token) dendpoint_template = api.ENDPOINT_TEMPLATE.get(endpoint_template_id) if not dendpoint_template: raise fault.ItemNotFoundFault( "The endpoint template could not be found") return EndpointTemplate( dendpoint_template.id, dendpoint_template.region, dendpoint_template.service_id, dendpoint_template.public_url, dendpoint_template.admin_url, dendpoint_template.internal_url, dendpoint_template.enabled, dendpoint_template.is_global)
def get_endpoint_templates(self, admin_token, marker, limit, url): self.__validate_service_or_keystone_admin_token(admin_token) ts = [] dendpoint_templates = api.ENDPOINT_TEMPLATE.get_page(marker, limit) for dendpoint_template in dendpoint_templates: ts.append( EndpointTemplate(dendpoint_template.id, dendpoint_template.region, dendpoint_template.service_id, dendpoint_template.public_url, dendpoint_template.admin_url, dendpoint_template.internal_url, dendpoint_template.enabled, dendpoint_template.is_global)) prev, next = api.ENDPOINT_TEMPLATE.get_page_markers(marker, limit) links = [] if prev: links.append(atom.Link('prev', "%s?'marker=%s&limit=%s'" \ % (url, prev, limit))) if next: links.append(atom.Link('next', "%s?'marker=%s&limit=%s'" \ % (url, next, limit))) return EndpointTemplates(ts, links)