Example #1
0
    def system_setup(self):
        """System setup will determine RHEL version and configure the correct services per release info.
        """
        banner(self.logger, ["Checking to see if Packstack will be run..."])
        to_install = self.config_gettr(self.system_info_obj,
                                       'install')['install']
        if 'n' in to_install:
            return True

        answerfile = self.config_gettr(self.system_info_obj,
                                       'packstack')['filename']
        call(['packstack', '--gen-answer-file', answerfile])

        if os.path.exists(answerfile) and os.stat(answerfile)[6] != 0:
            #check to see if the file exist and its not empty.
            self.logger.debug("Creating backup file for answerfile")
            try:
                self.adj_val('CONFIG_COMPUTE_HOSTS', self.nova_hosts_value,
                             answerfile, answerfile + '.bak')
            except IOError:
                raise IOError("Couldn't rename {0}".format(answerfile))

            banner(self.logger, [
                "Running packstack installer, using {0} file".format(
                    answerfile)
            ])
            call(['packstack', '--answer-file', answerfile])
        else:
            self.logger.error(
                "Couldn't find packstack answer file: {0}".format(answerfile))
            exit()

        return True
Example #2
0
    def libvirtd_setup(self):
        """ libvirtd setup will configure libvirtd to listen on the external network interface.

        :return: upon success zero is returned if not an exception is raised.
        """
        if os.path.isdir('/tmp/libvirtd_conf'):
            os.chdir('/tmp/libvirtd_conf')
        else:
            os.mkdir('/tmp/libvirtd_conf')
            os.chdir('/tmp/libvirtd_conf')

        _libvirtd_conf = dict(self.libvirtd_config_obj.items('libvirtd_conf'))
        _libvirtd_sysconf = dict(self.libvirtd_config_obj.items('libvirtd_sysconfig'))
        banner(self.logger, ["_libvirtd_conf: {0}".format(_libvirtd_conf),
                             "_libvirtd_sysconf: {0}".format(_libvirtd_sysconf)])

        for _dict_obj in [_libvirtd_conf, _libvirtd_sysconf]:
            self.rmt_copy(self.nova_hosts_list[0], username=self.ssh_uid, password=self.ssh_pass,
                          fname=_dict_obj['filename'], remote_path=_dict_obj['filepath'])

        # Edit the libvirtd
        for name, value in _libvirtd_conf.items():
            self.adj_val(name, value, 'libvirtd.conf', 'libvirtd.conf.bak')

        for name, value in _libvirtd_sysconf.items():
            self.adj_val(name, value, 'libvirtd', 'libvirtd.bak')

        for host in self.nova_hosts_list:
            for _obj in [_libvirtd_conf, _libvirtd_sysconf]:
                self.rmt_copy(host, username=self.ssh_uid, password=self.ssh_pass,
                              send=True, fname=_obj['filename'], remote_path=_obj['filepath'])

        return True
Example #3
0
    def system_setup(self):
        """System setup will determine RHEL version and configure the correct services per release info.
        """
        banner(self.logger, ["Checking to see if Packstack will be run..."])
        to_install = self.config_gettr(self.system_info_obj, 'install')['install']
        if 'n' in to_install:
            return True

        answerfile = self.config_gettr(self.system_info_obj, 'packstack')['filename']
        call(['packstack', '--gen-answer-file', answerfile])

        if os.path.exists(answerfile) and os.stat(answerfile)[6] != 0:
            #check to see if the file exist and its not empty.
            self.logger.debug("Creating backup file for answerfile")
            try:
                self.adj_val('CONFIG_COMPUTE_HOSTS', self.nova_hosts_value, answerfile, answerfile + '.bak')
            except IOError:
                raise IOError("Couldn't rename {0}".format(answerfile))

            banner(self.logger, ["Running packstack installer, using {0} file".format(answerfile)])
            call(['packstack', '--answer-file', answerfile])
        else:
            self.logger.error("Couldn't find packstack answer file: {0}".format(answerfile))
            exit()

        return True
Example #4
0
    def finalize_services(self):
        """Looks at the [services] section of system_info, and performs any necessary operations"""
        banner(self.logger, ["Finalizing services"])

        keys = ["nfs", "rpcbind", "libvirtd", "setenforce"]
        vals = dict(self.system_info_obj.items('services'))
        _nfs, _rpcbind, _libvirt, _setenforce = map(lambda x: vals[x], keys)

        # do the command for nfs
        def set_service(host, cmd, service_name, val):
            srv_cmd = {"command": val, "name": service_name}
            cmd = cmd.format(**srv_cmd)
            self.logger.info("Issuing {0} on host {1}".format(cmd, host))
            return self.rmt_exec(str(host),
                                 cmd,
                                 username=self.ssh_uid,
                                 password=self.ssh_pass)

        # Ughh, this is ugly.  This should be made polymorphic
        for host in self.nova_hosts_list:
            # NFS server
            srv_name = "nfs-server" if self.distro_type.nfs_ver == "nfs4" else "nfs"
            if host == self.nfs_server:
                for i in _rpcbind.split(","):
                    cmd = self.distro_type.service_enable if i in [
                        "on", "enable"
                    ] else self.distro_type.service_cmd
                    set_service(host, cmd, "rpcbind", i)
                for i in _nfs.split(","):
                    cmd = self.distro_type.service_enable if i in [
                        "on", "enable"
                    ] else self.distro_type.service_cmd
                    set_service(host, cmd, srv_name, i)

            for i in _libvirt.split(","):
                cmd = self.distro_type.service_enable if i in [
                    "on", "enable"
                ] else self.distro_type.service_cmd
                set_service(host, cmd, "libvirtd", i)

            # FIXME: this is a temporary workaround
            self.rmt_exec(str(host),
                          "setenforce {0}".format(_setenforce),
                          username=self.ssh_uid,
                          password=self.ssh_pass)
            self.logger.info("Calling setenforce {0}".format(_setenforce))
            out, _ = self.rmt_exec(str(host),
                                   "getenforce",
                                   username=self.ssh_uid,
                                   password=self.ssh_pass)
            self.logger.info("getenforce: {0}".format("".join(out)))

        return True
Example #5
0
    def nfs_server_setup(self):
        """ NFS_Server setup will create an export file and copy this file to the nfs server, it will also
        determine the release of RHEL and configure version 3 or 4 nfs service.

        """
        if os.path.isdir('/tmp/nfs_conf'):
            os.chdir('/tmp/nfs_conf')
        else:
            os.mkdir('/tmp/nfs_conf')
            os.chdir('/tmp/nfs_conf')

        _nfs_export = self.config_gettr(self.share_storage_config_obj, 'nfs_export')['export']
        _nfs_export_attribute = self.config_gettr(self.share_storage_config_obj, 'nfs_export')['attribute']
        _nfs_export_net = self.config_gettr(self.share_storage_config_obj, 'nfs_export')['network']
        _nfs_export_obj = dict(self.share_storage_config_obj.items('nfs_export'))

        vals = dict(self.config_gettr(self.share_storage_config_obj, 'nfs_ports'))
        fname, fpath = map(vals.pop, ("filename", "filepath"))  # pop them so we dont iterate on them later

        banner(self.logger, ["Doing NFS server setup"])

        # Copy the originals to our local machine.  we will use this for editing
        self.rmt_copy(self.nfs_server, fname=fname, remote_path=fpath, username=self.ssh_uid, password=self.ssh_pass)
        shutil.copyfile(fname, fname + ".bak")

        # Edit the files based on the values from share_storage config file
        for k, v in vals.items():
            self.adj_val(k, v, fname, fname + ".bak", not_found="append", delim="=")

        # Send the modified files back to the original host
        self.rmt_copy(self.nfs_server, username=self.ssh_uid, password=self.ssh_pass, send=True, fname=fname,
                      remote_path=fpath)

        if self.distro_type.family in ["RHEL", "Centos"] and self.distro_type.version >= 7:
            _nfs_idmapd_obj = dict(self.share_storage_config_obj.items('nfs_idmapd'))
            _nfs_idmapd_domain = self.config_gettr(self.share_storage_config_obj, 'nfs_idmapd')['domain']
            self.rmt_copy(self.nfs_server, fname=_nfs_idmapd_obj['filename'], username=self.ssh_uid,
                          password=self.ssh_pass, remote_path=_nfs_idmapd_obj['filepath'])
            self.adj_val('Domain', _nfs_idmapd_domain, _nfs_idmapd_obj['filename'],
                         _nfs_idmapd_obj['filename'] + '.bak')
            self.rmt_copy(self.nfs_server, username=self.ssh_uid, password=self.ssh_pass,
                          send=True, fname=_nfs_idmapd_obj['filename'], remote_path=_nfs_idmapd_obj['filepath'])

        nfs_exports_info = [_nfs_export, _nfs_export_net + _nfs_export_attribute]
        export_fn = self.gen_file(_nfs_export_obj['filename'], nfs_exports_info)
        self.rmt_copy(self.nfs_server, username=self.ssh_uid, password=self.ssh_pass,
                      send=True, fname=export_fn, remote_path=_nfs_export_obj['filepath'])

        return True
Example #6
0
    def nfs_client_setup(self):
        """NFS client function will append mount option for live migration to the compute nodes fstab file.

        """
        if os.path.isdir('/tmp/nfs_conf'):
            os.chdir('/tmp/nfs_conf')
        else:
            os.mkdir('/tmp/nfs_conf')
            os.chdir('/tmp/nfs_conf')

        banner(self.logger, ["Doing NFS client setup"])
        _fstab_filename = self.config_gettr(self.system_info_obj,
                                            'fstab')['filename']
        _nfs_server = self.config_gettr(self.system_info_obj,
                                        'fstab')['nfs_server']
        _nfs_mount_pt = self.config_gettr(self.system_info_obj,
                                          'fstab')['nfs_client_mount']
        _nfs_fstype = self.config_gettr(self.system_info_obj,
                                        'fstab')['fstype']
        _mnt_opts = self.config_gettr(self.system_info_obj,
                                      'fstab')['attribute']
        _fsck_opt = self.config_gettr(self.system_info_obj, 'fstab')['fsck']

        fstab_entry = [
            _nfs_server, _nfs_mount_pt, _nfs_fstype, _mnt_opts, _fsck_opt
        ]
        fstab_entry = "    ".join(fstab_entry)

        system_util = 'echo '

        system_util_operator = ' >> '

        cmd = [system_util, fstab_entry, system_util_operator, _fstab_filename]
        rmt_cmd = " ".join(cmd)

        for host in self.nova_hosts_list:
            ret = self.rmt_exec(str(host),
                                rmt_cmd,
                                username=self.ssh_uid,
                                password=self.ssh_pass)
            if ret[0].channel.recv_exit_status() == 0:
                continue
            else:
                raise EnvironmentError('The remote command failed {0}'.format(
                    ret[1].readlines()))

        return True
Example #7
0
    def remote_setup(self, install=True):
        banner(self.logger, ["Checking to see if Packstack will be run remotely..."])
        to_install = self.config_gettr(self.system_info_obj, 'install')['install']
        if 'n' in to_install:
            return True

        answer = self.config_gettr(self.system_info_obj, 'packstack')['filename']
        answerfile = os.path.basename(answer)
        answerpath = os.path.dirname(answer)

        for target in self.nova_hosts_list:
            res = self.copy_public_keys(host=self.controller, target=target, username=self.ssh_uid,
                                        password=self.ssh_pass)

        owd = os.getcwd()
        os.chdir("/tmp")  # When we copy, put it in /tmp

        # FIXME: Figure out a way to tell if this command was successful
        self.rmt_exec(self.controller, "packstack --gen-answer-file={0}".format(answer), username=self.ssh_uid,
                      password=self.ssh_pass)
        self.rmt_copy(self.controller, username=self.ssh_uid, password=self.ssh_pass, fname=answerfile,
                      remote_path=answerpath)

        if os.path.exists(answerfile) and os.stat(answerfile)[6] != 0:
            #check to see if the file exist and its not empty.
            self.logger.debug("Creating backup file for answerfile")
            try:
                self.adj_val('CONFIG_COMPUTE_HOSTS', self.nova_hosts_value, answerfile, answerfile + '.bak')
            except IOError:
                raise IOError("Couldn't rename {0}".format(answerfile))

            banner(self.logger, ["Running packstack installer, using {0} file".format(answerfile)])
            self.rmt_copy(self.controller, username=self.ssh_uid, password=self.ssh_pass, fname=answerfile,
                          remote_path=answerpath, send=True)
            if install:
                out, err = self.rmt_exec(self.controller, 'packstack --answer-file={0}'.format(answer),
                                         username=self.ssh_uid, password=self.ssh_pass)
                for line in out.readlines():
                    self.logger.info(line)

            os.chdir(owd)

            return True
        else:
            self.logger.error("Couldn't find packstack answer file: {0}".format(answer))
            exit()
Example #8
0
    def nova_setup(self):
        """Nova setup will configure all necessary files for nova to enable live migration."""

        if os.path.isdir('/tmp/nova_conf'):
            os.chdir('/tmp/nova_conf')
        else:
            os.mkdir('/tmp/nova_conf')
            os.chdir('/tmp/nova_conf')

        banner(self.logger, ["Doing nova.conf configuration"])

        def nova_adjust(nova_config_list):
            for _conf in nova_config_list:
                self.logger.info("Copying {0} to {1}".format(_conf['filename'], _conf['filepath']))
                self.rmt_copy(self.nova_hosts_list[0], username=self.ssh_uid, password=self.ssh_pass,
                              fname=_conf['filename'], remote_path=_conf['filepath'])
                for name, value in _conf.items():
                    self.adj_val(name, value, _conf['filename'], _conf['filename'] + '.bak', delim="=")

            return True

        _nova_conf = dict(self.nova_config_obj.items('nova_conf'))
        cmd = "mkdir -p {0}".format(_nova_conf['state_path'])

        if self.distro_type.family in ["RHEL", "Centos"] and self.distro_type.version >= 7:
            self.logger.info("Doing nova setup for {0} {1}".format(self.distro_type.family, self.distro_type.version))
            _nova_api_service = dict(self.nova_config_obj.items('nova_api_service'))
            _nova_cert_service = dict(self.nova_config_obj.items('nova_cert_service'))
            _nova_compute_service = dict(self.nova_config_obj.items('nova_compute_service'))
            _nova_config_list = [_nova_conf, _nova_api_service, _nova_cert_service, _nova_compute_service]

            nova_adjust(_nova_config_list)
        else:
            self.logger.info("Doing nova setup for RHEL 6")
            _nova_config_list = [_nova_conf]
            nova_adjust(_nova_config_list)

        for host in self.nova_hosts_list:
            for conf in _nova_config_list:
                self.rmt_copy(host, username=self.ssh_uid, password=self.ssh_pass,
                              send=True, fname=conf['filename'], remote_path=conf['filepath'])
            self.rmt_exec(host, cmd, username=self.ssh_uid, password=self.ssh_pass)

        return True
Example #9
0
    def libvirtd_setup(self):
        """ libvirtd setup will configure libvirtd to listen on the external network interface.

        :return: upon success zero is returned if not an exception is raised.
        """
        if os.path.isdir('/tmp/libvirtd_conf'):
            os.chdir('/tmp/libvirtd_conf')
        else:
            os.mkdir('/tmp/libvirtd_conf')
            os.chdir('/tmp/libvirtd_conf')

        _libvirtd_conf = dict(self.libvirtd_config_obj.items('libvirtd_conf'))
        _libvirtd_sysconf = dict(
            self.libvirtd_config_obj.items('libvirtd_sysconfig'))
        banner(self.logger, [
            "_libvirtd_conf: {0}".format(_libvirtd_conf),
            "_libvirtd_sysconf: {0}".format(_libvirtd_sysconf)
        ])

        for _dict_obj in [_libvirtd_conf, _libvirtd_sysconf]:
            self.rmt_copy(self.nova_hosts_list[0],
                          username=self.ssh_uid,
                          password=self.ssh_pass,
                          fname=_dict_obj['filename'],
                          remote_path=_dict_obj['filepath'])

        # Edit the libvirtd
        for name, value in _libvirtd_conf.items():
            self.adj_val(name, value, 'libvirtd.conf', 'libvirtd.conf.bak')

        for name, value in _libvirtd_sysconf.items():
            self.adj_val(name, value, 'libvirtd', 'libvirtd.bak')

        for host in self.nova_hosts_list:
            for _obj in [_libvirtd_conf, _libvirtd_sysconf]:
                self.rmt_copy(host,
                              username=self.ssh_uid,
                              password=self.ssh_pass,
                              send=True,
                              fname=_obj['filename'],
                              remote_path=_obj['filepath'])

        return True
Example #10
0
    def finalize_services(self):
        """Looks at the [services] section of system_info, and performs any necessary operations"""
        banner(self.logger, ["Finalizing services"])

        keys = ["nfs", "rpcbind", "libvirtd", "setenforce"]
        vals = dict(self.system_info_obj.items('services'))
        _nfs, _rpcbind, _libvirt, _setenforce = map(lambda x: vals[x], keys)

        # do the command for nfs
        def set_service(host, cmd, service_name, val):
            srv_cmd = {"command": val, "name": service_name}
            cmd = cmd.format(**srv_cmd)
            self.logger.info("Issuing {0} on host {1}".format(cmd, host))
            return self.rmt_exec(str(host), cmd, username=self.ssh_uid, password=self.ssh_pass)

        # Ughh, this is ugly.  This should be made polymorphic
        for host in self.nova_hosts_list:
            # NFS server
            srv_name = "nfs-server" if self.distro_type.nfs_ver == "nfs4" else "nfs"
            if host == self.nfs_server:
                for i in _rpcbind.split(","):
                    cmd = self.distro_type.service_enable if i in ["on", "enable"] else self.distro_type.service_cmd
                    set_service(host, cmd, "rpcbind", i)
                for i in _nfs.split(","):
                    cmd = self.distro_type.service_enable if i in ["on", "enable"] else self.distro_type.service_cmd
                    set_service(host, cmd, srv_name, i)

            for i in _libvirt.split(","):
                cmd = self.distro_type.service_enable if i in ["on", "enable"] else self.distro_type.service_cmd
                set_service(host, cmd, "libvirtd", i)

            # FIXME: this is a temporary workaround
            self.rmt_exec(str(host), "setenforce {0}".format(_setenforce), username=self.ssh_uid,
                          password=self.ssh_pass)
            self.logger.info("Calling setenforce {0}".format(_setenforce))
            out, _ = self.rmt_exec(str(host), "getenforce", username=self.ssh_uid, password=self.ssh_pass)
            self.logger.info("getenforce: {0}".format("".join(out)))

        return True
Example #11
0
    def nfs_client_setup(self):
        """NFS client function will append mount option for live migration to the compute nodes fstab file.

        """
        if os.path.isdir('/tmp/nfs_conf'):
            os.chdir('/tmp/nfs_conf')
        else:
            os.mkdir('/tmp/nfs_conf')
            os.chdir('/tmp/nfs_conf')

        banner(self.logger, ["Doing NFS client setup"])
        _fstab_filename = self.config_gettr(self.system_info_obj, 'fstab')['filename']
        _nfs_server = self.config_gettr(self.system_info_obj, 'fstab')['nfs_server']
        _nfs_mount_pt = self.config_gettr(self.system_info_obj, 'fstab')['nfs_client_mount']
        _nfs_fstype = self.config_gettr(self.system_info_obj, 'fstab')['fstype']
        _mnt_opts = self.config_gettr(self.system_info_obj, 'fstab')['attribute']
        _fsck_opt = self.config_gettr(self.system_info_obj, 'fstab')['fsck']

        fstab_entry = [_nfs_server, _nfs_mount_pt, _nfs_fstype, _mnt_opts, _fsck_opt]
        fstab_entry = "    ".join(fstab_entry)

        system_util = 'echo '

        system_util_operator = ' >> '

        cmd = [system_util, fstab_entry, system_util_operator, _fstab_filename]
        rmt_cmd = " ".join(cmd)

        for host in self.nova_hosts_list:
            ret = self.rmt_exec(str(host), rmt_cmd, username=self.ssh_uid, password=self.ssh_pass)
            if ret[0].channel.recv_exit_status() == 0:
                continue
            else:
                raise EnvironmentError('The remote command failed {0}'.format(ret[1].readlines()))

        return True
Example #12
0
    def nfs_server_setup(self):
        """ NFS_Server setup will create an export file and copy this file to the nfs server, it will also
        determine the release of RHEL and configure version 3 or 4 nfs service.

        """
        if os.path.isdir('/tmp/nfs_conf'):
            os.chdir('/tmp/nfs_conf')
        else:
            os.mkdir('/tmp/nfs_conf')
            os.chdir('/tmp/nfs_conf')

        _nfs_export = self.config_gettr(self.share_storage_config_obj,
                                        'nfs_export')['export']
        _nfs_export_attribute = self.config_gettr(
            self.share_storage_config_obj, 'nfs_export')['attribute']
        _nfs_export_net = self.config_gettr(self.share_storage_config_obj,
                                            'nfs_export')['network']
        _nfs_export_obj = dict(
            self.share_storage_config_obj.items('nfs_export'))

        vals = dict(
            self.config_gettr(self.share_storage_config_obj, 'nfs_ports'))
        fname, fpath = map(
            vals.pop,
            ("filename",
             "filepath"))  # pop them so we dont iterate on them later

        banner(self.logger, ["Doing NFS server setup"])

        # Copy the originals to our local machine.  we will use this for editing
        self.rmt_copy(self.nfs_server,
                      fname=fname,
                      remote_path=fpath,
                      username=self.ssh_uid,
                      password=self.ssh_pass)
        shutil.copyfile(fname, fname + ".bak")

        # Edit the files based on the values from share_storage config file
        for k, v in vals.items():
            self.adj_val(k,
                         v,
                         fname,
                         fname + ".bak",
                         not_found="append",
                         delim="=")

        # Send the modified files back to the original host
        self.rmt_copy(self.nfs_server,
                      username=self.ssh_uid,
                      password=self.ssh_pass,
                      send=True,
                      fname=fname,
                      remote_path=fpath)

        if self.distro_type.family in ["RHEL", "Centos"
                                       ] and self.distro_type.version >= 7:
            _nfs_idmapd_obj = dict(
                self.share_storage_config_obj.items('nfs_idmapd'))
            _nfs_idmapd_domain = self.config_gettr(
                self.share_storage_config_obj, 'nfs_idmapd')['domain']
            self.rmt_copy(self.nfs_server,
                          fname=_nfs_idmapd_obj['filename'],
                          username=self.ssh_uid,
                          password=self.ssh_pass,
                          remote_path=_nfs_idmapd_obj['filepath'])
            self.adj_val('Domain', _nfs_idmapd_domain,
                         _nfs_idmapd_obj['filename'],
                         _nfs_idmapd_obj['filename'] + '.bak')
            self.rmt_copy(self.nfs_server,
                          username=self.ssh_uid,
                          password=self.ssh_pass,
                          send=True,
                          fname=_nfs_idmapd_obj['filename'],
                          remote_path=_nfs_idmapd_obj['filepath'])

        nfs_exports_info = [
            _nfs_export, _nfs_export_net + _nfs_export_attribute
        ]
        export_fn = self.gen_file(_nfs_export_obj['filename'],
                                  nfs_exports_info)
        self.rmt_copy(self.nfs_server,
                      username=self.ssh_uid,
                      password=self.ssh_pass,
                      send=True,
                      fname=export_fn,
                      remote_path=_nfs_export_obj['filepath'])

        return True
Example #13
0
    def nova_setup(self):
        """Nova setup will configure all necessary files for nova to enable live migration."""

        if os.path.isdir('/tmp/nova_conf'):
            os.chdir('/tmp/nova_conf')
        else:
            os.mkdir('/tmp/nova_conf')
            os.chdir('/tmp/nova_conf')

        banner(self.logger, ["Doing nova.conf configuration"])

        def nova_adjust(nova_config_list):
            for _conf in nova_config_list:
                self.logger.info("Copying {0} to {1}".format(
                    _conf['filename'], _conf['filepath']))
                self.rmt_copy(self.nova_hosts_list[0],
                              username=self.ssh_uid,
                              password=self.ssh_pass,
                              fname=_conf['filename'],
                              remote_path=_conf['filepath'])
                for name, value in _conf.items():
                    self.adj_val(name,
                                 value,
                                 _conf['filename'],
                                 _conf['filename'] + '.bak',
                                 delim="=")

            return True

        _nova_conf = dict(self.nova_config_obj.items('nova_conf'))
        cmd = "mkdir -p {0}".format(_nova_conf['state_path'])

        if self.distro_type.family in ["RHEL", "Centos"
                                       ] and self.distro_type.version >= 7:
            self.logger.info("Doing nova setup for {0} {1}".format(
                self.distro_type.family, self.distro_type.version))
            _nova_api_service = dict(
                self.nova_config_obj.items('nova_api_service'))
            _nova_cert_service = dict(
                self.nova_config_obj.items('nova_cert_service'))
            _nova_compute_service = dict(
                self.nova_config_obj.items('nova_compute_service'))
            _nova_config_list = [
                _nova_conf, _nova_api_service, _nova_cert_service,
                _nova_compute_service
            ]

            nova_adjust(_nova_config_list)
        else:
            self.logger.info("Doing nova setup for RHEL 6")
            _nova_config_list = [_nova_conf]
            nova_adjust(_nova_config_list)

        for host in self.nova_hosts_list:
            for conf in _nova_config_list:
                self.rmt_copy(host,
                              username=self.ssh_uid,
                              password=self.ssh_pass,
                              send=True,
                              fname=conf['filename'],
                              remote_path=conf['filepath'])
            self.rmt_exec(host,
                          cmd,
                          username=self.ssh_uid,
                          password=self.ssh_pass)

        return True
Example #14
0
    def remote_setup(self, install=True):
        banner(self.logger,
               ["Checking to see if Packstack will be run remotely..."])
        to_install = self.config_gettr(self.system_info_obj,
                                       'install')['install']
        if 'n' in to_install:
            return True

        answer = self.config_gettr(self.system_info_obj,
                                   'packstack')['filename']
        answerfile = os.path.basename(answer)
        answerpath = os.path.dirname(answer)

        for target in self.nova_hosts_list:
            res = self.copy_public_keys(host=self.controller,
                                        target=target,
                                        username=self.ssh_uid,
                                        password=self.ssh_pass)

        owd = os.getcwd()
        os.chdir("/tmp")  # When we copy, put it in /tmp

        # FIXME: Figure out a way to tell if this command was successful
        self.rmt_exec(self.controller,
                      "packstack --gen-answer-file={0}".format(answer),
                      username=self.ssh_uid,
                      password=self.ssh_pass)
        self.rmt_copy(self.controller,
                      username=self.ssh_uid,
                      password=self.ssh_pass,
                      fname=answerfile,
                      remote_path=answerpath)

        if os.path.exists(answerfile) and os.stat(answerfile)[6] != 0:
            #check to see if the file exist and its not empty.
            self.logger.debug("Creating backup file for answerfile")
            try:
                self.adj_val('CONFIG_COMPUTE_HOSTS', self.nova_hosts_value,
                             answerfile, answerfile + '.bak')
            except IOError:
                raise IOError("Couldn't rename {0}".format(answerfile))

            banner(self.logger, [
                "Running packstack installer, using {0} file".format(
                    answerfile)
            ])
            self.rmt_copy(self.controller,
                          username=self.ssh_uid,
                          password=self.ssh_pass,
                          fname=answerfile,
                          remote_path=answerpath,
                          send=True)
            if install:
                out, err = self.rmt_exec(
                    self.controller,
                    'packstack --answer-file={0}'.format(answer),
                    username=self.ssh_uid,
                    password=self.ssh_pass)
                for line in out.readlines():
                    self.logger.info(line)

            os.chdir(owd)

            return True
        else:
            self.logger.error(
                "Couldn't find packstack answer file: {0}".format(answer))
            exit()