示例#1
0
    def _get_conn_params(self):
        host_ng = self.instance.node_group
        cluster = host_ng.cluster
        access_instance = self.instance
        proxy_gateway_node = cluster.get_proxy_gateway_node()

        gateway_host = None
        gateway_image_username = None
        if proxy_gateway_node and not host_ng.is_proxy_gateway:

            # tmckay-fp in other words, if we are going to connect
            # through the proxy instead of the node we are actually
            # trying to reach

            # okay, the node group that supplies the proxy gateway
            # must have fps, but if a proxy is used the other
            # nodes are not required to have an fp.

            # so, this instance is assumed not to have a floating
            # ip and we are going to get to it through the proxy
            access_instance = proxy_gateway_node
            gateway_host = proxy_gateway_node.management_ip
            ng = proxy_gateway_node.node_group
            gateway_image_username = ng.image_username

        proxy_command = None
        if CONF.proxy_command:
            # Build a session through a user-defined socket
            proxy_command = CONF.proxy_command

        # tmckay-fp we have the node_group for the instance right here
        # okay, this test here whether access_instance.management_ip is an
        # fp -- just compare to internal?
        # in the neutron case, we check the node group for the
        # access_instance and look for fp
        elif CONF.use_namespaces and not net_utils.has_floating_ip(
                access_instance):
            # Build a session through a netcat socket in the Neutron namespace
            proxy_command = (
                'ip netns exec qrouter-{router_id} nc {host} {port}')
        # proxy_command is currently a template, turn it into a real command
        # i.e. dereference {host}, {port}, etc.
        if proxy_command:
            rootwrap = CONF.rootwrap_command if CONF.use_rootwrap else ''
            proxy_command = self._build_proxy_command(
                proxy_command,
                instance=access_instance,
                port=22,
                info=None,
                rootwrap_command=rootwrap)

        host_ip = _get_access_ip(self.instance)

        return (host_ip, host_ng.image_username,
                cluster.management_private_key, proxy_command, gateway_host,
                gateway_image_username)
示例#2
0
    def _get_conn_params(self):
        host_ng = self.instance.node_group
        cluster = host_ng.cluster
        access_instance = self.instance
        proxy_gateway_node = cluster.get_proxy_gateway_node()

        gateway_host = None
        gateway_image_username = None
        if proxy_gateway_node and not host_ng.is_proxy_gateway:

            # tmckay-fp in other words, if we are going to connect
            # through the proxy instead of the node we are actually
            # trying to reach

            # okay, the node group that supplies the proxy gateway
            # must have fps, but if a proxy is used the other
            # nodes are not required to have an fp.

            # so, this instance is assumed not to have a floating
            # ip and we are going to get to it through the proxy
            access_instance = proxy_gateway_node
            gateway_host = proxy_gateway_node.management_ip
            ng = proxy_gateway_node.node_group
            gateway_image_username = ng.image_username

        proxy_command = None
        if CONF.proxy_command:
            # Build a session through a user-defined socket
            proxy_command = CONF.proxy_command

        # tmckay-fp we have the node_group for the instance right here
        # okay, this test here whether access_instance.management_ip is an
        # fp -- just compare to internal?
        # in the neutron case, we check the node group for the
        # access_instance and look for fp
        # in the nova case, we compare management_ip to internal_ip or even
        # use the nova interface
        elif CONF.use_namespaces and not net_utils.has_floating_ip(
                access_instance):
            # Build a session through a netcat socket in the Neutron namespace
            proxy_command = (
                'ip netns exec qrouter-{router_id} nc {host} {port}')
        # proxy_command is currently a template, turn it into a real command
        # i.e. dereference {host}, {port}, etc.
        if proxy_command:
            rootwrap = CONF.rootwrap_command if CONF.use_rootwrap else ''
            proxy_command = self._build_proxy_command(
                proxy_command, instance=access_instance, port=22,
                info=None, rootwrap_command=rootwrap)

        return (self.instance.management_ip,
                host_ng.image_username,
                cluster.management_private_key,
                proxy_command,
                gateway_host,
                gateway_image_username)
示例#3
0
    def get_http_client(self, port, info=None):
        self._log_command('Retrieving HTTP session for {0}:{1}'.format(
            self.instance.management_ip, port))

        host_ng = self.instance.node_group
        cluster = host_ng.cluster
        access_instance = self.instance
        access_port = port
        proxy_gateway_node = cluster.get_proxy_gateway_node()

        gateway_host = None
        gateway_username = None
        gateway_private_key = None
        if proxy_gateway_node and not host_ng.is_proxy_gateway:
            access_instance = proxy_gateway_node
            access_port = 22
            gateway_host = proxy_gateway_node.management_ip
            gateway_username = proxy_gateway_node.node_group.image_username
            gateway_private_key = cluster.management_private_key

        proxy_command = None
        if CONF.proxy_command:
            # Build a session through a user-defined socket
            proxy_command = CONF.proxy_command

        # tmckay-fp again we can check the node group for the instance
        # what are the implications for nova here? None, because use_namespaces
        # is synonomous with use_neutron
        # this is a test on whether access_instance has a floating_ip
        # in the neutron case, we check the node group for the
        # access_instance and look for fp
        # in the nova case, we compare management_ip to internal_ip or even
        # use the nova interface
        elif (CONF.use_namespaces
              and not net_utils.has_floating_ip(access_instance)):
            # need neutron info
            if not info:
                info = self.get_neutron_info(access_instance)
            # Build a session through a netcat socket in the Neutron namespace
            proxy_command = (
                'ip netns exec qrouter-{router_id} nc {host} {port}')
        # proxy_command is currently a template, turn it into a real command
        # i.e. dereference {host}, {port}, etc.
        if proxy_command:
            rootwrap = CONF.rootwrap_command if CONF.use_rootwrap else ''
            proxy_command = self._build_proxy_command(
                proxy_command,
                instance=access_instance,
                port=access_port,
                info=info,
                rootwrap_command=rootwrap)

        return _get_http_client(self.instance.management_ip, port,
                                proxy_command, gateway_host, gateway_username,
                                gateway_private_key)
示例#4
0
    def get_http_client(self, port, info=None):
        self._log_command('Retrieving HTTP session for {0}:{1}'.format(
            self.instance.management_ip, port))

        host_ng = self.instance.node_group
        cluster = host_ng.cluster
        access_instance = self.instance
        access_port = port
        proxy_gateway_node = cluster.get_proxy_gateway_node()

        gateway_host = None
        gateway_username = None
        gateway_private_key = None
        if proxy_gateway_node and not host_ng.is_proxy_gateway:
            access_instance = proxy_gateway_node
            access_port = 22
            gateway_host = proxy_gateway_node.management_ip
            gateway_username = proxy_gateway_node.node_group.image_username
            gateway_private_key = cluster.management_private_key

        proxy_command = None
        if CONF.proxy_command:
            # Build a session through a user-defined socket
            proxy_command = CONF.proxy_command

        # tmckay-fp again we can check the node group for the instance
        # what are the implications for nova here? None, because use_namespaces
        # is synonomous with use_neutron
        # this is a test on whether access_instance has a floating_ip
        # in the neutron case, we check the node group for the
        # access_instance and look for fp
        # in the nova case, we compare management_ip to internal_ip or even
        # use the nova interface
        elif (CONF.use_namespaces and not net_utils.has_floating_ip(
                access_instance)):
            # need neutron info
            if not info:
                info = self.get_neutron_info(access_instance)
            # Build a session through a netcat socket in the Neutron namespace
            proxy_command = (
                'ip netns exec qrouter-{router_id} nc {host} {port}')
        # proxy_command is currently a template, turn it into a real command
        # i.e. dereference {host}, {port}, etc.
        if proxy_command:
            rootwrap = CONF.rootwrap_command if CONF.use_rootwrap else ''
            proxy_command = self._build_proxy_command(
                proxy_command, instance=access_instance, port=access_port,
                info=info, rootwrap_command=rootwrap)

        return _get_http_client(self.instance.management_ip, port,
                                proxy_command, gateway_host,
                                gateway_username,
                                gateway_private_key)