Beispiel #1
0
 def install_rpm(self, host, rpm_name):
     LOG.info('{time} {fqdn}: installing {rpm}'
              .format(time=utils.timestamp(),
                      fqdn=host.fqdn,
                      rpm=rpm_name))
     host.run_bash_command('yum install -y --nogpgcheck {rpm}'
                           .format(rpm=rpm_name))
Beispiel #2
0
 def yum_disable_repo(self, host, repo_name):
     LOG.info('{time} {fqdn}: disabling {repo}'
              .format(time=utils.timestamp(),
                      fqdn=host.fqdn,
                      repo=repo_name))
     host.run_bash_command('yum-config-manager --disable {repo}'
                           .format(repo=repo_name))
Beispiel #3
0
 def disable_and_persist_selinux(self, host):
     LOG.info('{time} {fqdn}: disabling SELinux'
              .format(time=utils.timestamp(), fqdn=host.fqdn))
     host.run_bash_command('setenforce 0')
     host.run_bash_command('sed -i "s/^SELINUX=.*/SELINUX=permissive/g" '
                           '/etc/selinux/config')
     host.run_bash_command('sed -i "s/^SELINUX=.*/SELINUX=permissive/g" '
                           '/etc/sysconfig/selinux')
Beispiel #4
0
 def disable_nm(self, host):
     """
     Disable NetworkManager due to a known issue.
     """
     LOG.info('{time} {fqdn}: Switching off NetworkManager'
              .format(time=utils.timestamp(), fqdn=host.fqdn))
     host.run_bash_command('systemctl disable NetworkManager')
     host.run_bash_command('systemctl stop NetworkManager')
     host.run_bash_command('systemctl restart network')
Beispiel #5
0
 def prep_for_robot(self, host):
     """
     This function is a preparation for Robot tests.
     That test system expects to find the answer file at: /root/ANSWER_FILE
     :param host: a host which holds the packstack answer file
     """
     LOG.info('{time} {fqdn}: Changing answer file name to ANSWER_FILE'
              .format(time=utils.timestamp(), fqdn=host.fqdn))
     robot_file = 'ANSWER_FILE'
     host.run_bash_command('mv {answer_file} {robot_file}'
                           .format(answer_file=self.answer_file,
                                   robot_file=robot_file))
Beispiel #6
0
    def run_bash_command(self, bash_command):
        ssh_stdin, ssh_stdout, ssh_stderr = self.ssh.exec_command(bash_command)

        stdout = (ssh_stdout.read()).strip()
        stderr = ssh_stdout.channel.recv_exit_status()

        LOG.info('{time} {fqdn}: cmd:    {bash_command}'
                 .format(time=utils.timestamp(),
                         fqdn=self.fqdn,
                         bash_command=bash_command))

        LOG.info('{time} {fqdn}: stdout: {ssh_stdout}'
                 .format(time=utils.timestamp(),
                         fqdn=self.fqdn,
                         ssh_stdout=stdout))

        LOG.info('{time} {fqdn}: stderr: {ssh_stderr}'
                 .format(time=utils.timestamp(),
                         fqdn=self.fqdn,
                         ssh_stderr=stderr))

        return stdout, stderr
Beispiel #7
0
 def register_to_rhn(self, host):
     """
     :param host: the host that will be registered to rhn
     """
     LOG.info('{time} {fqdn}: registering to rhn'
              .format(time=utils.timestamp(), fqdn=host.fqdn))
     host.run_bash_command('rhnreg_ks --serverUrl='
                           'https://xmlrpc.rhn.redhat.com/XMLRPC '
                           '--username={rhn_user} --password={rhn_pass} '
                           '--profilename={fqdn} --nohardware --novirtinfo '
                           '--nopackages --use-eus-channel --force'
                           .format(fqdn=host.fqdn,
                                   rhn_user=self.rhn_user,
                                   rhn_pass=self.rhn_pass))
Beispiel #8
0
    def restart_linux_service(self, host, service_name):
        LOG.info('{time} {fqdn}: restarting {service_name}'
                 .format(time=utils.timestamp(),
                         fqdn=host.fqdn,
                         service_name=service_name))
        if 'rhel6' in host.os_name:
            cmd = ('service {service} restart'
                   .format(service_name=service_name))

        else:  # rhel7 or fedora
            cmd = ('systemctl restart {service}.service'
                   .format(service_name=service_name))

        host.run_bash_command(cmd)
Beispiel #9
0
    def create_sub_interface(self, host):
        """This function will read the vlan range from config file

        following format: 'x:y' where the x is that start and the y is the end
        of that range.
        it will create a sub interface for each vlan in the given range.
        the function does support a single vlan as follows (example): '100:100'
        :param host: the host that will be added with sub interfaces
        :return: nothing
        """
        if not host.host_type == 'vm':
            ext_vlan_range = self.ext_vlan.split(':')
            sub_interfaces = list(xrange(int(ext_vlan_range[0]),
                                         int(ext_vlan_range[-1]) + 1))
            for sub_interface in sub_interfaces:
                iface_file_name = ('ifcfg-{name}.{vlan}'
                                   .format(name=host.tenant_interface,
                                           vlan=sub_interface))
                interface_file_location = '/etc/sysconfig/network-scripts'
                interface_file_path = os.path.join(interface_file_location,
                                                   iface_file_name)
                LOG.info('{time} {fqdn}: Creating sub interface: '
                         '{interface_file_name}'
                         .format(time=utils.timestamp(), fqdn=host.fqdn,
                                 interface_file_name=iface_file_name))
                bootproto = 'none' if 'rhel7' in host.os_name else 'dhcp'
                host.run_bash_command('echo DEVICE="{name}.{vlan}" > '
                                      '{file_path}'
                                      .format(name=host.tenant_interface,
                                              vlan=sub_interface,
                                              file_path=interface_file_path))
                host.run_bash_command('echo BOOTPROTO={bootproto} >> '
                                      '{file_path}'
                                      .format(file_path=interface_file_path,
                                              bootproto=bootproto))
                host.run_bash_command('echo ONBOOT=yes >> {file_path}'
                                      .format(file_path=interface_file_path))
                host.run_bash_command('echo USERCTL=no >> {file_path}'
                                      .format(file_path=interface_file_path))
                host.run_bash_command('echo VLAN=yes >> {file_path}'
                                      .format(file_path=interface_file_path))
                host.run_bash_command('echo NM_CONTROLLED=no >> {file_path}'
                                      .format(file_path=interface_file_path))
                host.run_bash_command('ifdown {iface_file_name}'
                                      .format(iface_file_name=iface_file_name))
                host.run_bash_command('ifup {iface_file_name}'
                                      .format(iface_file_name=iface_file_name))
Beispiel #10
0
    def create_yum_repo(self, host, repo_name, build):
        LOG.info('{time} {fqdn}: Creating yum repo {repo_name}'
                 .format(time=utils.timestamp(),
                         fqdn=host.fqdn,
                         repo_name=repo_name))

        repo_url = self.repositories[repo_name]
        if '{build}' in repo_url:  # check if there is a build number to inject
            repo_url = str(repo_url).format(build=build)

        host.run_bash_command('echo [{name}] > /etc/yum.repos.d/'
                              '{name}.repo'.format(name=repo_name))
        host.run_bash_command(('echo name={name} >> /etc/yum.repos.d/'
                               '{name}.repo'.format(name=repo_name)))
        host.run_bash_command(('echo baseurl={base_url} >> /etc/yum.repos.d/'
                               '{name}.repo'.format(base_url=repo_url,
                                                    name=repo_name)))
        host.run_bash_command(('echo enabled=1 >> /etc/yum.repos.d/'
                               '{name}.repo'.format(name=repo_name)))
        host.run_bash_command(('echo gpgcheck=0 >> /etc/yum.repos.d/'
                               '{name}.repo'.format(name=repo_name)))
Beispiel #11
0
 def tlv_openstack_repo(self, host):
     LOG.info('{time} {fqdn}: updating OpenStack repo path'
              .format(time=utils.timestamp(), fqdn=host.fqdn))
     host.run_bash_command("sed -i s/lab.bos/eng.tlv/g "
                           "/etc/yum.repos.d/rhos-release*")
Beispiel #12
0
 def uninstall_rpm(self, host, rpm_name):
     LOG.info('{time} {fqdn}: removing {rpm}'.format(time=utils.timestamp(),
                                                     fqdn=host.fqdn,
                                                     rpm=rpm_name))
     host.run_bash_command('yum remove -y {rpm}'.format(rpm=rpm_name))
Beispiel #13
0
 def yum_update(self, host):
     LOG.info('{time} {fqdn}: updating all packages'
              .format(time=utils.timestamp(), fqdn=host.fqdn))
     host.run_bash_command('yum update -y --nogpgcheck')
Beispiel #14
0
 def remove_all_yum_repos(self, host):
     LOG.info('{time} {fqdn}: Removing all yum repos'
              .format(time=utils.timestamp(), fqdn=host.fqdn))
     host.run_bash_command('mv /etc/yum.repos.d/*.repo /tmp')
Beispiel #15
0
 def clean_yum_cache(self, host):
     LOG.info('{time} {fqdn}: Cleaning yum cache'
              .format(time=utils.timestamp(), fqdn=host.fqdn))
     host.run_bash_command('yum clean all')
Beispiel #16
0
 def ovs_add_port_to_br(self, host, br_name, port_name):
     LOG.info('{time} {fqdn}: adding {port_name} to {br_name}'
              .format(time=utils.timestamp(), fqdn=host.fqdn,
                      port_name=port_name, br_name=br_name))
     host.run_bash_command('ovs-vsctl add-port {br_name} {port_name}'
                           .format(br_name=br_name, port_name=port_name))