def mangle_url(orig_url, url):
    try:
        endpoint_url = urlparse.urlparse(url)
    except Exception as e:
        utils.unknown("you must provide an endpoint_url in the form"
                      "<scheme>://<url>/ (%s)\n" % e)
    scheme = endpoint_url.scheme
    if scheme is None:
        utils.unknown("you must provide an endpoint_url in the form"
                      "<scheme>://<url>/ (%s)\n" % e)
    catalog_url = urlparse.urlparse(orig_url)

    port = endpoint_url.port
    if port is None:
        if catalog_url.port is None:
            port = DAEMON_DEFAULT_PORT
        else:
            port = catalog_url.port

    netloc = "%s:%i" % (endpoint_url.hostname, port)
    url = urlparse.urlunparse([
        scheme, netloc, catalog_url.path, catalog_url.params,
        catalog_url.query, catalog_url.fragment
    ])
    return url
def mangle_url(orig_url, url):
    try:
        endpoint_url = urlparse.urlparse(url)
    except Exception as e:
        utils.unknown("you must provide an endpoint_url in the form"
                      + "<scheme>://<url>/ (%s)\n" % e)
    scheme = endpoint_url.scheme
    if scheme is None:
        utils.unknown("you must provide an endpoint_url in the form"
                      + "<scheme>://<url>/ (%s)\n" % e)
    catalog_url = urlparse.urlparse(orig_url)

    port = endpoint_url.port
    if port is None:
        if catalog_url.port is None:
            port = DAEMON_DEFAULT_PORT
        else:
            port = catalog_url.port

    netloc = "%s:%i" % (endpoint_url.hostname, port)
    url = urlparse.urlunparse([scheme,
                               netloc,
                               catalog_url.path,
                               catalog_url.params,
                               catalog_url.query,
                               catalog_url.fragment])
    return url
    def mangle_url(self, url):
        self.check_connection()

        try:
            endpoint_url = urllib.parse.urlparse(url)
        except Exception as e:
            utils.unknown("you must provide an endpoint_url in the form"
                          "<scheme>://<url>/ (%s)\n" % e)
        scheme = endpoint_url.scheme
        if scheme is None:
            utils.unknown("you must provide an endpoint_url in the form"
                          "<scheme>://<url>/ (%s)\n" % e)
        catalog_url = None
        try:
            catalog_url = urllib.parse.urlparse(
                self.nova_client.client.management_url)
        except Exception as e:
            utils.unknown("unknown error parsing the catalog url : %s\n" % e)

        port = endpoint_url.port
        if port is None:
            if catalog_url.port is None:
                port = 8774
            else:
                port = catalog_url.port

        netloc = "%s:%i" % (endpoint_url.hostname, port)
        url = urllib.parse.urlunparse([
            scheme, netloc, catalog_url.path, catalog_url.params,
            catalog_url.query, catalog_url.fragment
        ])
        self.nova_client.client.set_management_url(url)
示例#4
0
    def mangle_url(self, url):
        # This first connection populate the structure we need inside
        # the object.  This does not cost anything if a connection has
        # already been made.
        self.check_connection()
        try:
            endpoint_url = urlparse.urlparse(url)
        except Exception as e:
            utils.unknown("you must provide an endpoint_url in the form"
                          "<scheme>://<url>/ (%s)" % e)
        scheme = endpoint_url.scheme
        if scheme is None:
            utils.unknown("you must provide an endpoint_url in the form"
                          "<scheme>://<url>/ (%s)" % e)
        catalog_url = None
        try:
            catalog_url = urlparse.urlparse(
                self.nova_client.client.management_url)
        except Exception as e:
            utils.unknown("unknown error parsing the catalog url : %s" % e)

        port = endpoint_url.port
        if port is None:
            if catalog_url.port is None:
                port = self.DAEMON_DEFAULT_PORT
            else:
                port = catalog_url.port

        netloc = "%s:%i" % (endpoint_url.hostname, port)
        url = urlparse.urlunparse([
            scheme, netloc, catalog_url.path, catalog_url.params,
            catalog_url.query, catalog_url.fragment
        ])
        self.nova_client.client.management_url = url
示例#5
0
    def mangle_url(self, url):
        self.check_connection()

        try:
            endpoint_url = urllib.parse.urlparse(url)
        except Exception as e:
            utils.unknown("you must provide an endpoint_url in the form"
                          + "<scheme>://<url>/ (%s)\n" % e)
        scheme = endpoint_url.scheme
        if scheme is None:
            utils.unknown("you must provide an endpoint_url in the form"
                          + "<scheme>://<url>/ (%s)\n" % e)
        catalog_url = None
        try:
            catalog_url = urllib.parse.urlparse(
                self.nova_client.client.management_url)
        except Exception as e:
            utils.unknown("unknown error parsing the catalog url : %s\n" % e)

        port = endpoint_url.port
        if port is None:
            if catalog_url.port is None:
                port = 8774
            else:
                port = catalog_url.port

        netloc = "%s:%i" % (endpoint_url.hostname, port)
        url = urllib.parse.urlunparse([scheme,
                                       netloc,
                                       catalog_url.path,
                                       catalog_url.params,
                                       catalog_url.query,
                                       catalog_url.fragment])
        self.nova_client.client.set_management_url(url)
    def mangle_url(self, url):
        # This first connection populate the structure we need inside
        # the object.  This does not cost anything if a connection has
        # already been made.
        self.check_connection()
        try:
            endpoint_url = urlparse.urlparse(url)
        except Exception as e:
            utils.unknown("you must provide an endpoint_url in the form"
                          + "<scheme>://<url>/ (%s)" % e)
        scheme = endpoint_url.scheme
        if scheme is None:
            utils.unknown("you must provide an endpoint_url in the form"
                          + "<scheme>://<url>/ (%s)" % e)
        catalog_url = None
        try:
            catalog_url = urlparse.urlparse(
                self.nova_client.client.management_url)
        except Exception as e:
            utils.unknown("unknown error parsing the catalog url : %s" % e)

        port = endpoint_url.port
        if port is None:
            if catalog_url.port is None:
                port = self.DAEMON_DEFAULT_PORT
            else:
                port = catalog_url.port

        netloc = "%s:%i" % (endpoint_url.hostname, port)
        url = urlparse.urlunparse([scheme,
                                   netloc,
                                   catalog_url.path,
                                   catalog_url.params,
                                   catalog_url.query,
                                   catalog_url.fragment])
        self.nova_client.client.management_url = url