def test_remove_known_hosts_no_file(self, mock_exists, mock_check_call):

        mock_exists.return_value = False

        utils.remove_known_hosts('192.168.0.1')

        mock_check_call.assert_not_called()
Ejemplo n.º 2
0
    def _deploy_postconfig(self, stack, parsed_args):
        self.log.debug("_deploy_postconfig(%s)" % parsed_args)

        passwords = self.passwords

        overcloud_endpoint = self._get_overcloud_endpoint(stack)
        overcloud_ip = six.moves.urllib.parse.urlparse(
            overcloud_endpoint).hostname

        no_proxy = [os.environ.get('no_proxy'), overcloud_ip]
        os.environ['no_proxy'] = ','.join(
            [x for x in no_proxy if x is not None])

        service_ips = self._get_service_ips(stack)

        utils.remove_known_hosts(overcloud_ip)

        keystone_ip = service_ips.get('KeystoneInternalVip')
        if not keystone_ip:
            keystone_ip = overcloud_ip

        keystone.initialize(keystone_ip,
                            passwords['OVERCLOUD_ADMIN_TOKEN'],
                            '*****@*****.**',
                            passwords['OVERCLOUD_ADMIN_PASSWORD'],
                            public=overcloud_ip,
                            user='******')

        # NOTE(bcrochet): Bad hack. Remove the ssl_port info from the
        # os_cloud_config.SERVICES dictionary
        for service_name, data in keystone.SERVICES.iteritems():
            data.pop('ssl_port', None)

        services = {}
        for service, data in six.iteritems(utils.SERVICE_LIST):
            service_data = data.copy()
            service_data.pop('password_field', None)
            password_field = data.get('password_field')
            if password_field:
                service_data['password'] = passwords[password_field]

            service_name = re.sub('v[0-9]+', '',
                                  service.capitalize() + 'InternalVip')
            internal_vip = service_ips.get(service_name)
            if internal_vip:
                service_data['internal_host'] = internal_vip
            services.update({service: service_data})

        keystone_client = clients.get_keystone_client(
            'admin', passwords['OVERCLOUD_ADMIN_PASSWORD'], 'admin',
            overcloud_endpoint)
        keystone.setup_endpoints(services,
                                 client=keystone_client,
                                 os_auth_url=overcloud_endpoint,
                                 public_host=overcloud_ip)

        compute_client = clients.get_nova_bm_client(
            'admin', passwords['OVERCLOUD_ADMIN_PASSWORD'], 'admin',
            overcloud_endpoint)
        compute_client.flavors.create('m1.demo', 512, 1, 10, 'auto')
    def test_remove_known_hosts(self, mock_exists, mock_check_call):

        mock_exists.return_value = True

        utils.remove_known_hosts('192.168.0.1')

        mock_check_call.assert_called_with(['ssh-keygen', '-R', '192.168.0.1'])
    def test_remove_known_hosts_no_file(self, mock_exists, mock_check_call):

        mock_exists.return_value = False

        utils.remove_known_hosts('192.168.0.1')

        mock_check_call.assert_not_called()
    def test_remove_known_hosts(self, mock_exists, mock_check_call):

        mock_exists.return_value = True

        utils.remove_known_hosts('192.168.0.1')

        mock_check_call.assert_called_with(['ssh-keygen', '-R', '192.168.0.1'])
Ejemplo n.º 6
0
    def test_remove_known_hosts(self, mock_exists, mock_check_call):

        mock_exists.return_value = True

        utils.remove_known_hosts('192.168.0.1')
        known_hosts = os.path.expanduser("~/.ssh/known_hosts")

        mock_check_call.assert_called_with(
            ['ssh-keygen', '-R', '192.168.0.1', '-f', known_hosts])
    def test_remove_known_hosts(self, mock_exists, mock_check_call):

        mock_exists.return_value = True

        utils.remove_known_hosts('192.168.0.1')
        known_hosts = os.path.expanduser("~/.ssh/known_hosts")

        mock_check_call.assert_called_with(
            ['ssh-keygen', '-R', '192.168.0.1', '-f', known_hosts])
    def _deploy_postconfig(self, stack, parsed_args):
        self.log.debug("_deploy_postconfig(%s)" % parsed_args)

        passwords = self.passwords

        overcloud_endpoint = self._get_overcloud_endpoint(stack)
        overcloud_ip = six.moves.urllib.parse.urlparse(
            overcloud_endpoint).hostname

        no_proxy = [os.environ.get('no_proxy'), overcloud_ip]
        os.environ['no_proxy'] = ','.join(
            [x for x in no_proxy if x is not None])

        service_ips = self._get_service_ips(stack)

        utils.remove_known_hosts(overcloud_ip)

        keystone_ip = service_ips.get('KeystoneInternalVip')
        if not keystone_ip:
            keystone_ip = overcloud_ip

        keystone.initialize(
            keystone_ip,
            passwords['OVERCLOUD_ADMIN_TOKEN'],
            '*****@*****.**',
            passwords['OVERCLOUD_ADMIN_PASSWORD'],
            public=overcloud_ip,
            user='******')

        # NOTE(bcrochet): Bad hack. Remove the ssl_port info from the
        # os_cloud_config.SERVICES dictionary
        for service_name, data in keystone.SERVICES.iteritems():
            data.pop('ssl_port', None)

        services = {}
        for service, data in six.iteritems(utils.SERVICE_LIST):
            service_data = data.copy()
            service_data.pop('password_field', None)
            password_field = data.get('password_field')
            if password_field:
                service_data['password'] = passwords[password_field]

            service_name = re.sub('v[0-9]+', '',
                                  service.capitalize() + 'InternalVip')
            internal_vip = service_ips.get(service_name)
            if internal_vip:
                service_data['internal_host'] = internal_vip
            services.update({service: service_data})

        keystone_client = clients.get_keystone_client(
            'admin',
            passwords['OVERCLOUD_ADMIN_PASSWORD'],
            'admin',
            overcloud_endpoint)
        keystone.setup_endpoints(
            services,
            client=keystone_client,
            os_auth_url=overcloud_endpoint,
            public_host=overcloud_ip)

        compute_client = clients.get_nova_bm_client(
            'admin',
            passwords['OVERCLOUD_ADMIN_PASSWORD'],
            'admin',
            overcloud_endpoint)
        compute_client.flavors.create('m1.demo', 512, 1, 10, 'auto')