コード例 #1
0
ファイル: snfinv.py プロジェクト: vinilios/snfinv
    def get_cli(self, name):
        name = self.clients_override.get(name, name)
        if not self.endpoints:
            self.fill_endpoints()

        ns = name.split("_")[0].lower()
        normalized = name.replace("_", " ").title().replace(" ", "")
        import_path = self.clients_map_override.get(name, {}).get('module',
                                                                  None)
        if not import_path:
            import_path = 'kamaki.clients.%s.%s' % (ns, normalized + 'Client')

        module_name = ".".join(import_path.split(".")[:-1])
        cli_name = import_path.split(".")[-1]
        module = importlib.import_module(module_name)

        endpoint_type = self.clients_map_override.get(
            name, {}).get('endpoint', ns)
        try:
            catalog = parse_endpoints(self.endpoints, ep_type=endpoint_type)
        except NoEndpoints as e:
            if "_" not in name:
                raise e
            endpoint_type = name.split("_")[1]
            catalog = parse_endpoints(self.endpoints, ep_type=endpoint_type)

        endpoint = catalog[0]['endpoints'][0]['publicURL']
        return module.__dict__[cli_name](endpoint, self.token)
コード例 #2
0
ファイル: utils.py プロジェクト: salsa-dev/synnefo
def get_endpoint_url(endpoints, endpoint_type):
    """Get the publicURL for the specified endpoint"""

    service_catalog = parse_endpoints(endpoints, ep_type=endpoint_type)
    return service_catalog[0]['endpoints'][0]['publicURL']
コード例 #3
0
ファイル: common.py プロジェクト: antonis-m/synnefo
def _get_endpoint_url(endpoints, endpoint_type):
    """Get the publicURL for the specified endpoint"""

    service_catalog = parse_endpoints(endpoints, ep_type=endpoint_type)
    return service_catalog[0]['endpoints'][0]['publicURL']