Esempio n. 1
0
    def set_admin_keystone_password(self):
        try:
            self.fuel_web.client.get_releases()
        # TODO(akostrikov) CENTOS7 except exceptions.Unauthorized:
        except:
            self.ssh_manager.execute_on_remote(
                ip=self.ssh_manager.admin_ip,
                cmd='fuel user --newpass {0} --change-password'.format(
                    settings.KEYSTONE_CREDS['password'])
            )
            config_file = self.ssh_manager.execute_on_remote(
                ip=self.ssh_manager.admin_ip,
                cmd='ls -1 $HOME/.config/fuel/fuel_client.yaml')['stdout_str']

            with YamlEditor(config_file, ip=self.admin_node_ip) as editor:
                editor.content["OS_USERNAME"] = \
                    settings.KEYSTONE_CREDS['username']
                editor.content["OS_PASSWORD"] = \
                    settings.KEYSTONE_CREDS['password']

            with YamlEditor(settings.FUEL_SETTINGS_YAML,
                            ip=self.admin_node_ip) as editor:
                editor.content["FUEL_ACCESS"]['user'] = \
                    settings.KEYSTONE_CREDS['username']
                editor.content["FUEL_ACCESS"]['password'] = \
                    settings.KEYSTONE_CREDS['password']

            logger.info(
                'New Fuel UI (keystone) username: "******", password: "******"'
                .format(settings.KEYSTONE_CREDS['username'],
                        settings.KEYSTONE_CREDS['password']))
Esempio n. 2
0
    def prepare_liberty_mirror(self):
        """Create local mirror with Liberty packages"""

        self.add_proposed_to_fuel_mirror_config()
        admin_remote = self.env.d_env.get_admin_remote()
        admin_remote.check_call(
            "cp {cfg}{{,.backup}}".format(cfg=self.FUEL_MIRROR_CFG_FILE))

        with YamlEditor(self.FUEL_MIRROR_CFG_FILE,
                        ip=self.env.get_admin_node_ip()) as editor:
            editor.content["mos_baseurl"] = (
                editor.content["mos_baseurl"].replace("$mos_version", "8.0"))
            editor.content["fuel_release_match"]["version"] = "liberty-8.0"
            for repo in editor.content["groups"]["mos"]:
                repo["suite"] = repo["suite"].replace("$mos_version", "8.0")
                repo["uri"] = repo["uri"].replace("$mos_version", "8.0")
            for repo in editor.content["groups"]["ubuntu"]:
                if repo.get("main"):
                    repo["name"] = "ubuntu-0"
                elif repo["suite"] == "trusty-updates":
                    repo["name"] = "ubuntu-1"
                elif repo["suite"] == "trusty-security":
                    repo["name"] = "ubuntu-2"

        cmds = [
            "fuel-mirror create -P ubuntu -G mos > mirror-mos.log 2>&1",
            "fuel-mirror create -P ubuntu -G ubuntu > mirror-ubuntu.log 2>&1",
            "fuel-mirror apply --default -P ubuntu -G mos",
            "fuel-mirror apply --default -P ubuntu -G ubuntu",
            "mv {cfg}{{,.liberty.yaml}}".format(cfg=self.FUEL_MIRROR_CFG_FILE),
            "mv {cfg}.backup {cfg}".format(cfg=self.FUEL_MIRROR_CFG_FILE)
        ]
        for cmd in cmds:
            admin_remote.check_call(cmd)
Esempio n. 3
0
    def update_nailgun_settings(self, settings):
        cfg_file = '/etc/nailgun/settings.yaml'
        with YamlEditor(file_path=cfg_file, ip=self.admin_ip) as ng_settings:
            ng_settings.content.update(settings)

            logger.debug('Uploading new nailgun settings: {}'.format(
                ng_settings))
        self.restart_service("nailgun")
Esempio n. 4
0
 def fpb_change_package_version(self, plugin_name, new_version):
     """
     Changes plugin's package version
     :param plugin_name: plugin to be used for changing version
     :param new_version: version to be changed at
     :return: nothing
     """
     with YamlEditor('/root/{}/metadata.yaml'.format(plugin_name),
                     ip=self.admin_ip) as editor:
         editor.content['package_version'] = new_version
Esempio n. 5
0
 def fpb_change_plugin_version(self, plugin_name, new_version):
     """
     Changes plugin version with given one
     :param plugin_name: plugin name
     :param new_version: new version to be used for plugin
     :return: nothing
     """
     with YamlEditor('/root/{}/metadata.yaml'.format(plugin_name),
                     ip=self.admin_ip) as editor:
         editor.content['version'] = new_version
Esempio n. 6
0
def update_bootstrap_cli_yaml():
    actions = BaseActions()
    path = "/etc/fuel-bootstrap-cli/fuel_bootstrap_cli.yaml"
    astute_yaml_path = "/etc/fuel/astute.yaml"

    with YamlEditor(astute_yaml_path, ip=actions.admin_ip) as editor:
        repos = editor.content["BOOTSTRAP"]["repos"]

    repos.append({
        'name': 'auxiliary',
        'priority': "1200",
        'section': 'main restricted',
        'suite': 'auxiliary',
        'type': 'deb',
        'uri': 'http://127.0.0.1:8080/ubuntu/auxiliary/'
    })

    with YamlEditor(path, ip=actions.admin_ip) as editor:
        editor.content['repos'] = repos
Esempio n. 7
0
 def add_proposed_to_fuel_mirror_config(self):
     with YamlEditor(self.FUEL_MIRROR_CFG_FILE,
                     ip=self.env.get_admin_node_ip()) as editor:
         proposed_desc = {
             str("name"): "mos-proposed",
             "uri": editor.content['mos_baseurl'],
             "suite": "mos$mos_version-proposed",
             "section": "main restricted",
             "type": "deb",
             "priority": 1050
         }
         editor.content["groups"]["mos"].append(proposed_desc)
         editor.content["repos"].append(proposed_desc)
Esempio n. 8
0
    def fpb_update_release_in_metadata(self, path):
        """Update fuel version and openstack release version

        :param path: path to plugin's dir on master node
        """
        metadata_path = os.path.join(path, 'metadata.yaml')
        output = self.ssh_manager.execute_on_remote(
            ip=self.admin_ip, cmd="fuel2 fuel-version -f json",
            jsonify=True)['stdout_json']
        fuel_version = [str(output['release'])]
        openstack_version = str(output['openstack_version'])
        with YamlEditor(metadata_path, ip=self.admin_ip) as editor:
            editor.content['fuel_version'] = fuel_version
            editor.content['releases'][0]['version'] = openstack_version
Esempio n. 9
0
 def save_fuel_settings(self, settings):
     with YamlEditor(
             file_path=FUEL_SETTINGS_YAML,
             ip=self.admin_ip
     ) as data:
         data.content = settings
Esempio n. 10
0
 def get_fuel_settings(self):
     return YamlEditor(
         file_path=FUEL_SETTINGS_YAML,
         ip=self.admin_ip
     ).get_content()
    def vip_reservation_for_plugin_custom_ns(self):
        """Check vip reservation for custom ns plugin

        Scenario:
        1. Revert snapshot with 3 nodes
        2. Download and install fuel-plugin-builder
        3. Create plugin with predefined network_roles.yaml
        4. Build and copy plugin to /var
        5. Install plugin to fuel
        6. Create cluster and enable plugin
        7. Deploy cluster
        8. Check vip reservation

        Duration 40m
        """
        plugin_name = 'vip_reservation_plugin'
        source_plugin_path = os.path.join('/root/', plugin_name)
        plugin_path = '/var'
        task_path = os.path.dirname(os.path.abspath(__file__))
        tasks_file = 'tasks.yaml'
        net_role_file = 'network_roles.yaml'
        metadata_file = 'metadata.yaml'
        namespace = 'custom_ns'
        self.show_step(1, initialize=True)
        self.env.revert_snapshot("ready_with_3_slaves")

        self.show_step(2)
        # initiate fuel plugin builder instance
        fpb = FuelPluginBuilder()
        # install fuel_plugin_builder on master node
        fpb.fpb_install()
        # create plugin template on the master node
        self.show_step(3)
        fpb.fpb_create_plugin(source_plugin_path)
        # replace plugin tasks, metadata, network_roles
        fpb.fpb_replace_plugin_content(
            os.path.join(task_path, net_role_file),
            os.path.join(source_plugin_path, net_role_file))
        fpb.fpb_replace_plugin_content(
            os.path.join(task_path, tasks_file),
            os.path.join(source_plugin_path, tasks_file))
        fpb.fpb_replace_plugin_content(
            os.path.join(task_path, metadata_file),
            os.path.join(source_plugin_path, metadata_file))

        with YamlEditor(os.path.join(source_plugin_path, net_role_file),
                        ip=fpb.admin_ip) as editor:
            editor.content[0]['properties']['vip'][0]['namespace'] = namespace
            editor.content[1]['properties']['vip'][0]['namespace'] = namespace
        # build plugin
        self.show_step(4)
        packet_name = fpb.fpb_build_plugin(source_plugin_path)
        # copy plugin archive file
        # to the /var directory on the master node
        fpb.fpb_copy_plugin(os.path.join(source_plugin_path, packet_name),
                            plugin_path)
        self.show_step(5)
        # let's install plugin
        utils.install_plugin_check_code(ip=self.ssh_manager.admin_ip,
                                        plugin=os.path.join(
                                            plugin_path, packet_name))
        self.show_step(6)
        cluster_id = self.fuel_web.create_cluster(
            name=self.__class__.__name__,
            mode=DEPLOYMENT_MODE,
        )
        # get plugins from fuel and enable our one
        msg = "Plugin couldn't be enabled. Check plugin version. Test aborted"
        asserts.assert_true(
            self.fuel_web.check_plugin_exists(cluster_id, plugin_name), msg)
        options = {'metadata/enabled': True}
        self.fuel_web.update_plugin_data(cluster_id, plugin_name, options)

        logger.info('Cluster is {!s}'.format(cluster_id))

        self.fuel_web.update_nodes(cluster_id, {
            'slave-01': ['controller'],
            'slave-02': ['compute']
        })
        self.show_step(7)
        self.fuel_web.deploy_cluster_wait(cluster_id)

        self.fuel_web.run_ostf(cluster_id=cluster_id)

        self.show_step(8)
        with self.fuel_web.get_ssh_for_node('slave-01') as remote:
            hiera_json_out = "ruby -rhiera -rjson -e \"h = Hiera.new(); " \
                             "Hiera.logger = 'noop'; " \
                             "puts JSON.dump(h.lookup('network_metadata', " \
                             "[], {}, nil, nil))\""
            for vip in ('reserved_pub', 'reserved_mng'):
                # get vips from hiera
                vip_hiera = json.loads(
                    remote.execute(hiera_json_out)['stdout']
                    [0])["vips"][vip]["ipaddr"]
                # get vips from database
                vip_db = self.env.postgres_actions.run_query(
                    db='nailgun',
                    query="select ip_addr from ip_addrs where "
                    "vip_name = '\"'\"'{0}'\"'\"';".format(vip))
                # get vips from corosync
                vip_crm = remote.execute(
                    'crm_resource --resource {0}{1} --get-parameter=ip'.format(
                        'vip__', vip))['stdout'][0].rstrip()
                # get vips from namespace
                vip_ns = remote.execute(
                    'ip netns exec {0} ip -4 a show {1}{2}'.format(
                        namespace, 'b_',
                        vip))['stdout'][1].split(' ')[5].split('/')[0]
                vip_array = [vip_hiera, vip_db, vip_crm, vip_ns]
                for ip in vip_array[1:]:
                    asserts.assert_equal(
                        vip_array[0], ip,
                        "Vip from hiera output {0} does not equal "
                        "to {1}".format(vip_array[0], ip))
Esempio n. 12
0
    def deploy_cluster_with_reboot_plugin_timeout(self):
        """Check deployment is failed by reboot task plugin.

        Scenario:
            1. Revert snapshot with 3 nodes
            2. Download and install fuel-plugin-builder
            3. Create plugin with reboot task,
               set timeout for reboot task as 1 second
            4. Build plugin
            5. Install plugin to fuel
            6. Create cluster and enable plugin
            7. Provision nodes
            8. Deploy cluster
            9. Check that deployment task failed
            10. Check error msg at the logs

        Duration 15m
        """
        # define some plugin related variables
        plugin_name = 'timeout_plugin'
        source_plugin_path = os.path.join('/root/', plugin_name)
        plugin_path = '/var'
        tasks_path = os.path.dirname(os.path.abspath(__file__))
        tasks_file = 'reboot_tasks.yaml'
        # start reverting snapshot
        self.show_step(1, initialize=True)
        self.env.revert_snapshot("ready_with_3_slaves")
        # let's get ssh client for the master node
        self.show_step(2)
        # initiate fuel plugin builder instance
        fpb = FuelPluginBuilder()
        # install fuel_plugin_builder on master node
        fpb.fpb_install()
        self.show_step(3)
        # create plugin template on the master node
        fpb.fpb_create_plugin(source_plugin_path)
        fpb.fpb_update_release_in_metadata(source_plugin_path)
        # replace plugin tasks with our file
        fpb.fpb_replace_plugin_content(
            os.path.join(tasks_path, tasks_file),
            os.path.join(source_plugin_path, 'deployment_tasks.yaml'))
        # change timeout to a new value '1'
        with YamlEditor(
                os.path.join(source_plugin_path, 'deployment_tasks.yaml'),
                fpb.admin_ip) as editor:
            editor.content[2]['parameters']['timeout'] = 1
        # build plugin
        self.show_step(4)
        packet_name = fpb.fpb_build_plugin(source_plugin_path)
        # copy plugin archive file
        # to the /var directory on the master node
        fpb.fpb_copy_plugin(os.path.join(source_plugin_path, packet_name),
                            plugin_path)
        # let's install plugin
        self.show_step(5)
        utils.install_plugin_check_code(ip=self.ssh_manager.admin_ip,
                                        plugin=os.path.join(
                                            plugin_path, packet_name))
        # create cluster
        self.show_step(6)
        cluster_id = self.fuel_web.create_cluster(
            name=self.__class__.__name__,
            mode=DEPLOYMENT_MODE,
        )
        # get plugins from fuel and enable it
        msg = "Plugin couldn't be enabled. Check plugin version. Test aborted"
        asserts.assert_true(
            self.fuel_web.check_plugin_exists(cluster_id, plugin_name), msg)
        options = {'metadata/enabled': True}
        self.fuel_web.update_plugin_data(cluster_id, plugin_name, options)

        logger.info('Cluster is {!s}'.format(cluster_id))

        self.fuel_web.update_nodes(cluster_id,
                                   {'slave-01': ['controller', 'cinder']})
        self.show_step(7)
        self.fuel_web.provisioning_cluster_wait(cluster_id)
        logger.info('Start cluster #%s deployment', cluster_id)
        self.show_step(8)
        task = self.fuel_web.client.deploy_nodes(cluster_id)
        self.show_step(9)
        self.fuel_web.assert_task_failed(task)

        msg = 'reboot_plugin-task failed becausereboot timeout 1 expired'
        cmd = 'grep "{0}" /var/log/astute/astute.log'.format(msg)
        self.show_step(10)
        self.ssh_manager.execute_on_remote(
            ip=self.ssh_manager.admin_ip,
            cmd=cmd,
            err_msg='Failed to find reboot plugin warning message in logs')