def catalog_entries(self, tenant_id): """ List catalog entries for the Cinder API. """ return [ Entry(tenant_id, "volume", "cinder", [ Endpoint(tenant_id, region, text_type(uuid4()), prefix="v2") for region in self._regions ]), Entry(tenant_id, "volumev2", "cinderv2", [ Endpoint(tenant_id, region, text_type(uuid4()), prefix="v2") for region in self._regions ]) ]
def catalog_entries(self, tenant_id): """ Return an Entry object with a couple of sample Endpoints. """ if tenant_id is not None: modified = "dummy_" + tenant_id else: modified = None return [ Entry(modified, "dummy", "Not Real", [ Endpoint(modified, "Luna", "4321", "v3k"), Endpoint(modified, "Mars", "5432", "v3k"), ]) ]
def test_unversioned_entry(self): """ An L{Endpoint} created without a 'prefix' returns a URI without a version. """ self.assertEqual( get_endpoints(tenant_id="1234", entry_generator=lambda t_id: [ Entry(tenant_id=t_id, type="compute", name="compute_name", endpoints=[ Endpoint(tenant_id=t_id, region="None", endpoint_id="eid") ]) ], prefix_for_endpoint=lambda ep: "http://prefix/"), { "endpoints": [{ "id": "eid", "name": "compute_name", "type": "compute", "region": "None", "tenantId": "1234", "publicURL": "http://prefix/1234" }] })
def catalog_entries(self, tenant_id): """ List catalog entries for the Nova API. """ return [ Entry(tenant_id, "serviceType", "serviceName", [Endpoint(tenant_id, "ORD", 'uuid')]) ]
def catalog_entries(self, tenant_id): """ List catalog entries for the Nova API. """ endpoints = [ Endpoint(tenant_id, each[0], 'uuid', each[1]) for each in self.regions_and_versions ] return [Entry(tenant_id, "serviceType", "serviceName", endpoints)]
def catalog_entries(self, tenant_id): """ List catalog entries for the Nova API. """ return [ Entry( tenant_id, "compute", "cloudServersOpenStack", [Endpoint(tenant_id, "ORD", text_type(uuid4()), prefix="v2")]) ]
def catalog_entries(self, tenant_id): """ List catalog entries for the Glance API. """ return [ Entry(tenant_id, "image", "cloudImages", [ Endpoint(tenant_id, region, text_type(uuid4()), prefix="v2") for region in self._regions ]) ]
def catalog_entries(self, tenant_id): """ List catalog entries for the Nova API. """ return [ Entry(tenant_id, "compute", "cloudServersBehavior", [ Endpoint(tenant_id, region, text_type(uuid4()), prefix="v2") for region in self.nova_api._regions ]) ]
def catalog_entries(self, tenant_id): """ Cloud load balancer controller endpoints. """ return [ Entry(tenant_id, "rax:load-balancer", "cloudLoadBalancerControl", [ Endpoint(tenant_id, region, text_type(uuid4()), prefix="v2") for region in self.lb_api._regions ]) ]
def catalog_entries(self, tenant_id): """ Catalog entry for RackConnect V3 endpoints. """ return [ Entry(tenant_id, "rax:rackconnect", "rackconnect", [ Endpoint(tenant_id, region, text_type(uuid4()), prefix="v3") for region in self.regions ]) ]
def catalog_entries(self, tenant_id): """ List catalog entries for the DNS API. """ return [ Entry(tenant_id, "rax:dns", "cloudDNS", [ Endpoint(tenant_id, region, text_type(uuid4()), prefix="v1.0") for region in self._regions ]) ]
def catalog_entries(self, tenant_id): """ List catalog entries for the Nova API. """ return [ Entry(tenant_id, "rax: monitor", "cloudMonitoring", [ Endpoint(tenant_id, region, text_type(uuid4()), "v1.0") for region in self._regions ]) ]
def catalog_entries(self, tenant_id): """ Cloud feeds controller endpoints. """ return [ Entry(tenant_id, "rax:feeds", "cloudFeedsControl", [ Endpoint(tenant_id, region, text_type(uuid4())) for region in self.cf_api._regions ]) ]
def catalog_entries(self, tenant_id): """ Catalog entry for Swift endpoints. """ modified = self.translate_tenant(tenant_id) return [ Entry(modified, "object-store", "cloudFiles", [ Endpoint(modified, "ORD", text_type(uuid4()), prefix="v1"), ]) ]
def catalog_entries(self, tenant_id): """ List catalog entries for the Neutron API. """ return [ Entry(tenant_id, "network", "cloudNetworks", [ Endpoint(tenant_id, region, text_type(uuid4()), prefix="v2") for region in self._regions ]) ]
def catalog_entries(self, tenant_id): """ Cloud load balancer entries. """ # TODO: actually add some entries so load balancers show up in the # service catalog. return [ Entry( tenant_id, "rax:load-balancer", "cloudLoadBalancers", [Endpoint(tenant_id, "ORD", text_type(uuid4()), prefix="v2")]) ]
def test_internal_endpoint(self): """ Validate creating an :obj:`Endpoint` for an internal API. In addition to the tenant, region, and endpoint id the prefix must also be specified. """ endpoint = Endpoint( self.tenant, self.region, self.endpointid, prefix=self.internal_api_prefix ) self.assertEqual(self.tenant, endpoint.tenant_id) self.assertEqual(self.region, endpoint.region) self.assertEqual(self.endpointid, endpoint.endpoint_id) self.assertEqual(self.internal_api_prefix, endpoint.prefix) self.assertFalse(endpoint.external) self.assertIsNone(endpoint.complete_url) uri = endpoint.url_with_prefix(self.request_prefix) self.assertTrue(uri.startswith(self.request_prefix))
def catalog_entries(self, tenant_id): """ Catalog entry for Heat endpoints. """ return [ Entry(tenant_id, "orchestration", "cloudOrchestration", [ Endpoint(tenant_id, region, text_type(uuid4()), prefix="v1") for region in self._regions ]) ]
def catalog_entries(self, tenant_id): """ Returns a list of cloud feeds entries. Note that these are not cloud feeds product endpoints; this is one step removed from those. You'll need to GET from one of these URLs to see the catalog of product endpoints. """ return [ Entry(tenant_id, "rax:feeds", "cloudFeeds", [ Endpoint(tenant_id, region, text_type(uuid4())) for region in self._regions ]) ]
def test_external_endpoint(self): """ Validate creating an :obj:`Endpoint` for an external API. In addition to the tenant, region, and endpoint id both `external` must be set to `True` and the `complete_url` must be set. """ endpoint = Endpoint( self.tenant, self.region, self.endpointid, external=True, complete_url=self.external_api_url ) self.assertEqual(self.tenant, endpoint.tenant_id) self.assertEqual(self.region, endpoint.region) self.assertEqual(self.endpointid, endpoint.endpoint_id) self.assertIsNone(endpoint.prefix) self.assertTrue(endpoint.external) self.assertIsNotNone(endpoint.complete_url) self.assertEqual(endpoint.complete_url, self.external_api_url) uri = endpoint.url_with_prefix(self.request_prefix) self.assertEqual(uri, self.external_api_url)
def list_tenant_endpoints(self, tenant_id): """ List the tenant specific endpoints. :param six.text_type tenant_id: tenant id to operate on :returns: an iterable of the endpoints available for the specified tenant id :rtype: iterable """ # List of template IDs that should be provided for a template # regardless of the enabled/disabled status of the template itself tenant_specific_templates = [] if tenant_id in self.endpoints_for_tenants: for template_id in self.endpoints_for_tenants[tenant_id]: tenant_specific_templates.append(template_id) # provide an Endpoint Entry for every template that is either # (a) enabled or (b) in the list of endpoints specifically # enabled for the tenant endpoints = [] for _, endpoint_template in self.endpoint_templates.items(): if (endpoint_template.enabled_key or endpoint_template.id_key in tenant_specific_templates): endpoints.append( Endpoint( tenant_id, endpoint_template.region_key, endpoint_template.id_key, endpoint_template.version_id, external=True, complete_url=endpoint_template.get_url( endpoint_template.public_url, tenant_id ), internal_url=endpoint_template.get_url( endpoint_template.internal_url, tenant_id ) ) ) return endpoints