コード例 #1
0
 def setUp(self):
     account = AzureAccount(self.params)
     account.login()
     cloud = Setup(self.params, self.name)
     self.vm = cloud.vm
     pre_delete = False
     pre_stop = False
     self.case_short_name = re.findall(r"Test.(.*)", self.name.name)[0]
     if self.case_short_name == "test_create_vm_all":
         cloud.vm.vm_name += "-all"
         cloud.vm.authentication_type = "all"
         self.vm.create()
         self.session = cloud.init_session()
         return
     if self.case_short_name == "test_create_vm_password":
         self.vm.vm_name += "-password"
         self.vm.authentication_type = "password"
         self.vm.generate_ssh_keys = False
         self.vm.ssh_key_value = None
         self.vm.create()
         self.session = cloud.init_session()
         return
     if self.case_short_name == "test_create_vm_sshkey":
         if self.vm.exists():
             self.vm.delete(wait=True)
         self.vm.create(wait=True)
         self.session = cloud.init_session()
     if self.case_short_name == "test_start_vm":
         pre_stop = True
     self.session = cloud.init_vm(pre_delete=pre_delete, pre_stop=pre_stop)
コード例 #2
0
 def setUp(self):
     self.casestatus = False
     account = AzureAccount(self.params)
     account.login()
     cloud = Setup(self.params, self.name)
     self.vm = cloud.vm
     self.session = cloud.init_vm()
     status, output = self.session.cmd_status_output('sudo su -')
     self.assertEqual(status, 0,
                      "User [root] login failed\n{}".format(str(output)))
     if self.name.name.endswith("test_chrony"):
         status, output = self.session.cmd_status_output(
             'systemctl is-enabled chronyd')
         self.assertEqual(status, 0, "There isn't chrony installed")
         self.assertEqual(output.strip(), "enabled", "Chrony isn't enabled")
     elif self.name.name.endswith("test_clocksource_performance"):
         status, output = self.session.cmd_status_output('which gcc')
         if status != 0:
             status, output = self.session.cmd_status_output(
                 'rpm -qa | grep rhui-azure')
             if status != 0:
                 status, output = self.session.cmd_status_output(
                     'rpm -ivh `ls /root/rhui-azure*`')
                 self.assertEqual(status, 0, "Failed to install rhui-azure")
             status, output = self.session.cmd_status_output(
                 'yum -y install gcc', timeout=400)
             self.assertEqual(status, 0, "Failed to install gcc")
コード例 #3
0
 def setUp(self):
     account = AzureAccount(self.params)
     account.login()
     self.case_short_name = re.findall(r"Test.(.*)", self.name.name)[0]
     self.project = self.params.get("rhel_ver", "*/VM/*")
     cloud = Setup(self.params, self.name, size="D2_v2")
     self.vm = cloud.vm
     self.session = cloud.init_vm()
     self.session.cmd_output("sudo su -")
     self.username = self.vm.vm_username
コード例 #4
0
 def setUp(self):
     self.casestatus = False
     account = AzureAccount(self.params)
     account.login()
     self.pwd = os.path.abspath(os.path.dirname(__file__))
     cloud = Setup(self.params, self.name)
     self.vm = cloud.vm
     self.session = cloud.init_vm(pre_delete=True)
     self.packages = self.params.get("packages", "*/Other/*")
     self.package_list = self.packages.split(',')
     self.log.debug("Package list: {}".format(self.package_list))
     self.with_wala = self.params.get("with_wala", "*/others/*", False)
コード例 #5
0
 def setUp(self):
     account = AzureAccount(self.params)
     account.login()
     self.case_short_name = re.findall(r"Test.(.*)", self.name.name)[0]
     cloud = Setup(self.params, self.name)
     self.vm = cloud.vm
     self.session = cloud.init_vm()
     if "interrupt_ctrl_c" in self.name.name:
         self.session1 = cloud.init_session()
         self.session1.connect()
     status, output = self.session.cmd_status_output('sudo su -')
     self.assertEqual(status, 0,
                      "User [root] login failed\n{}".format(str(output)))
コード例 #6
0
 def setUp(self):
     account = AzureAccount(self.params)
     account.login()
     self.case_short_name = re.findall(r"Test.(.*)", self.name.name)[0]
     self.project = self.params.get("rhel_ver", "*/VM/*")
     if LooseVersion(self.project) == LooseVersion("8.0.0") or \
             LooseVersion(self.project) == LooseVersion("8.0"):
         self.cancel(
             "Azure Linux Extensions are not supported in RHEL-8.0. Skip.")
     cloud = Setup(self.params, self.name)
     self.vm = cloud.vm
     self.session = cloud.init_vm()
     self.session.cmd_output("sudo su -")
     self.username = self.vm.vm_username
     self.new_username = self.username + "new"
コード例 #7
0
 def setUp(self):
     account = AzureAccount(self.params)
     account.login()
     self.case_short_name = re.findall(r"Test.(.*)", self.name.name)[0]
     cloud = Setup(self.params, self.name)
     self.vm = cloud.vm
     self.session = cloud.init_vm()
     if "interrupt_ctrl_c" in self.name.name:
         self.session1 = cloud.init_session()
         self.session1.connect()
     status, output = self.session.cmd_status_output('sudo su -')
     self.assertEqual(status, 0,
                      "User [root] login failed\n{}".format(str(output)))
     # Must stop NetworkManager or it will regenerate /etc/resolv.conf in RHEL-8.4
     if "test_waagent_depro" in self.case_short_name:
         self.session.cmd_output("systemctl stop NetworkManager")
コード例 #8
0
 def setUp(self):
     account = AzureAccount(self.params)
     account.login()
     self.case_short_name = re.findall(r"Test.(.*)", self.name.name)[0]
     self.project = self.params.get("rhel_ver", "*/VM/*")
     if self.case_short_name == "test_verify_storage_rule_gen2":
         # cloud.vm.vm_name += "-gen2"
         # self.image = AzureImage(self.params, generation="V2")
         # if not self.image.exists():
         #     self.image.create()
         # cloud.vm.image = self.image.name
         # cloud.vm.use_unmanaged_disk = False
         size = "DC2s"
     else:
         size = "DS2_v2"
     cloud = Setup(self.params, self.name, size=size)
     self.vm = cloud.vm
     self.session = cloud.init_vm()
     self.session.cmd_output("sudo su -")
     self.username = self.vm.vm_username
コード例 #9
0
 def setUp(self):
     account = AzureAccount(self.params)
     account.login()
     self.project = self.params.get("rhel_ver", "*/VM/*")
     self.case_short_name = re.findall(r"Test.(.*)", self.name.name)[0]
     if self.case_short_name == "test_provision_gen2_vm":
         if LooseVersion(self.project) < LooseVersion('7.8'):
             self.cancel(
                 "Skip case because RHEL-{} ondemand image doesn't support gen2".format(self.project))
         cloud = Setup(self.params, self.name, size="DC2s")
     else:
         cloud = Setup(self.params, self.name)
     self.vm = cloud.vm
     pre_delete = False
     if self.case_short_name == "test_provision_with_2_keys":
         pre_delete = True
         self.vm.vm_name += "-2keys"
         key1 = "{}/.ssh/id_rsa.pub".format(os.path.expanduser('~'))
         key2 = "/tmp/newkey.pub"
         if not os.path.exists(key2):
             command("ssh-keygen -f {} -q -N ''".format(key2.split('.')[0]))
         self.assertTrue(os.path.exists(key1),
                         "Key {} doesn't exist".format(key1))
         self.assertTrue(os.path.exists(key2),
                         "Key {} doesn't exist".format(key2))
         self.vm.ssh_key_value = "{} {}".format(key1, key2)
         with open(key1) as f:
             self.key1_value = f.read().rsplit(' ', 1)[0]
         with open(key2) as f:
             self.key2_value = f.read().rsplit(' ', 1)[0]
     self.session = cloud.init_vm(pre_delete=pre_delete)
     self.username = self.vm.vm_username
     self.package = self.params.get("packages", "*/Other/*")
     if self.case_short_name == "test_install_uninstall_package":
         if self.session.cmd_status_output("ls /tmp/{}".format(self.package))[0] != 0:
             self.cancel("Package doesn't exist. Skip case.")
     if self.case_short_name.startswith("test_host_plugin"):
         self.session.cmd_output(
             "sudo /usr/bin/cp /etc/waagent.conf{,-bak}")
     if self.case_short_name == "test_upgrade_downgrade_package":
         rhel7_old_pkg_url = "http://download.eng.bos.redhat.com/brewroot/vol/rhel-7/packages/WALinuxAgent/2.2.32/1.el7/noarch/WALinuxAgent-2.2.32-1.el7.noarch.rpm"
         rhel8_old_pkg_url = "http://download.eng.bos.redhat.com/brewroot/vol/rhel-8/packages/WALinuxAgent/2.2.32/1.el8/noarch/WALinuxAgent-2.2.32-1.el8.noarch.rpm"
         try:
             self.assertEqual(0, self.session.cmd_status_output("ls /tmp/{}".format(self.package))[0],
                              "No new pakcage in guest VM")
             import requests
             if str(self.project).startswith('7'):
                 old_pkg_url = rhel7_old_pkg_url
             elif str(self.project).startswith('8'):
                 old_pkg_url = rhel8_old_pkg_url
             self.old_pkg = old_pkg_url.split('/')[-1]
             if not os.path.exists("/tmp/{}".format(self.old_pkg)):
                 r = requests.get(old_pkg_url, allow_redirects=True)
                 open("/tmp/{}".format(self.old_pkg), 'wb').write(r.content)
             self.session.copy_files_to(
                 local_path="/tmp/{}".format(self.old_pkg),
                 remote_path="/tmp/{}".format(self.old_pkg))
             self.assertEqual(0, self.session.cmd_status_output("ls /tmp/{}".format(self.old_pkg))[0],
                              "No old pakcage in guest VM")
         except:
             self.cancel(
                 "No old or new package in guest VM. Skip this case.")
コード例 #10
0
 def setUp(self):
     account = AzureAccount(self.params)
     account.login()
     self.case_short_name = re.findall(r"Test.(.*)", self.name.name)[0]
     self.project = self.params.get("rhel_ver", "*/VM/*")
     if self.case_short_name == "test_connectivity_check":
         if LooseVersion(self.project) >= LooseVersion("8.0"):
             self.cancel("RHEL-8 doesn't have network service. Skip.")
     cloud = Setup(self.params, self.name)
     self.vm = cloud.vm
     if self.case_short_name == "test_provision_vm_with_multiple_nics":
         self.vm.vm_name += "2nics"
         if self.vm.exists():
             self.vm.delete()
         publicip_name = self.vm.vm_name + "publicip"
         publicip = AzurePublicIP(self.params, name=publicip_name)
         if not publicip.exists():
             publicip.create()
         nic_name_list = []
         for n in range(0, 2):
             nic_name = "{}nic{}".format(self.vm.vm_name, n)
             subnet = self.vm.subnet if n == 0 else self.vm.subnet + str(n)
             n_publicip = publicip_name if n == 0 else None
             nic = AzureNIC(self.params,
                            name=nic_name,
                            subnet=subnet,
                            vnet=self.vm.vnet_name,
                            publicip=n_publicip)
             if not nic.exists():
                 nic.create()
             nic_name_list.append(nic_name)
         self.vm.nics = ' '.join(nic_name_list)
         self.session = cloud.init_session()
         return
     if self.case_short_name == "test_provision_vm_with_sriov_nic":
         self.vm.vm_name += "sriov"
         if self.vm.exists():
             self.vm.delete()
         publicip_name = self.vm.vm_name + "publicip"
         publicip = AzurePublicIP(self.params, name=publicip_name)
         if not publicip.exists():
             publicip.create()
         self.vm.nics = "{}nic".format(self.vm.vm_name)
         nic = AzureNIC(self.params,
                        name=self.vm.nics,
                        subnet=self.vm.subnet,
                        vnet=self.vm.vnet_name,
                        publicip=publicip_name,
                        sriov=True)
         if not nic.exists():
             nic.create()
         self.session = cloud.init_session()
         self.vm.size = "Standard_D3_v2"
         return
     if self.name.name.endswith("test_provision_vm_with_ipv6"):
         self.vm.vm_name += "ipv6"
         # if self.vm.exists():
         #     self.vm.delete()
         publicip_name = self.vm.vm_name + "publicip"
         publicip = AzurePublicIP(self.params,
                                  name=publicip_name)
         if not publicip.exists():
             publicip.create()
         self.vm.nics = "{}nic".format(self.vm.vm_name)
         nic = AzureNIC(self.params,
                        name=self.vm.nics,
                        subnet=self.vm.subnet,
                        vnet=self.vm.vnet_name,
                        publicip=publicip_name)
         if not nic.exists():
             nic.create()
         ipv6_config = AzureNicIpConfig(self.params,
                                        name=self.vm.nics+"ipv6",
                                        nic_name=self.vm.nics,
                                        ip_version="IPv6")
         if not ipv6_config.exists():
             ipv6_config.create()
         self.session = cloud.init_session()
         return
     self.session = cloud.init_vm()
     self.session.cmd_output("sudo su -")
     self.username = self.vm.vm_username
コード例 #11
0
 def setUp(self):
     account = AzureAccount(self.params)
     account.login()
     self.project = self.params.get("rhel_ver", "*/VM/*")
     self.case_short_name = re.findall(r"Test.(.*)", self.name.name)[0]
     self.pwd = os.path.abspath(os.path.dirname(__file__))
     if self.case_short_name == "test_cloudinit_provision_gen2_vm":
         if LooseVersion(self.project) < LooseVersion('7.8'):
             self.cancel(
                 "Skip case because RHEL-{} ondemand image doesn't support gen2".format(self.project))
         cloud = Setup(self.params, self.name, size="DS2_v2")
     else:
         cloud = Setup(self.params, self.name)
     if self.case_short_name == "test_cloudinit_provision_gen2_vm":
         self.image = AzureImage(self.params, generation="V2")
         self.image.create()
         cloud.vm.image = self.image.name
         cloud.vm.vm_name += "-gen2"
         cloud.vm.use_unmanaged_disk = False
     self.vm = cloud.vm
     self.package = self.params.get("packages", "*/Other/*")
     if self.case_short_name in [
             "test_cloudinit_login_with_password",
             "test_cloudinit_login_with_publickey",
             "test_cloudinit_save_and_handle_customdata_script",
             "test_cloudinit_save_and_handle_customdata_cloudinit_config",
             "test_cloudinit_assign_identity",
     ]:
         if self.vm.exists():
             self.vm.delete()
         self.session = cloud.init_session()
         return
     if self.case_short_name == \
             "test_cloudinit_provision_vm_with_multiple_nics":
         self.vm.vm_name += "2nics"
         if self.vm.exists():
             self.vm.delete()
         publicip_name = self.vm.vm_name + "publicip"
         publicip = AzurePublicIP(self.params, name=publicip_name)
         if not publicip.exists():
             publicip.create()
         nic_name_list = []
         for n in range(0, 2):
             nic_name = "{}nic{}".format(self.vm.vm_name, n)
             subnet = self.vm.subnet if n == 0 else self.vm.subnet + str(n)
             n_publicip = publicip_name if n == 0 else None
             nic = AzureNIC(self.params,
                            name=nic_name,
                            subnet=subnet,
                            vnet=self.vm.vnet_name,
                            publicip=n_publicip)
             if not nic.exists():
                 nic.create()
             nic_name_list.append(nic_name)
         self.vm.nics = ' '.join(nic_name_list)
         self.session = cloud.init_session()
         return
     if self.case_short_name == "test_cloudinit_provision_vm_with_sriov_nic":
         self.vm.vm_name += "sriov"
         if self.vm.exists():
             self.vm.delete()
         publicip_name = self.vm.vm_name + "publicip"
         publicip = AzurePublicIP(self.params, name=publicip_name)
         if not publicip.exists():
             publicip.create()
         self.vm.nics = "{}nic".format(self.vm.vm_name)
         nic = AzureNIC(self.params,
                        name=self.vm.nics,
                        subnet=self.vm.subnet,
                        vnet=self.vm.vnet_name,
                        publicip=publicip_name,
                        sriov=True)
         if not nic.exists():
             nic.create()
         self.session = cloud.init_session()
         self.vm.size = "Standard_D3_v2"
         return
     if self.name.name.endswith("test_cloudinit_provision_vm_with_ipv6"):
         self.vm.vm_name += "ipv6"
         if self.vm.exists():
             self.vm.delete()
         publicip_name = self.vm.vm_name + "publicip"
         publicip = AzurePublicIP(self.params,
                                  name=publicip_name)
         if not publicip.exists():
             publicip.create()
         self.vm.nics = "{}nic".format(self.vm.vm_name)
         nic = AzureNIC(self.params,
                        name=self.vm.nics,
                        subnet=self.vm.subnet,
                        vnet=self.vm.vnet_name,
                        publicip=publicip_name)
         if not nic.exists():
             nic.create()
         ipv6_config = AzureNicIpConfig(self.params,
                                        name=self.vm.nics+"ipv6",
                                        nic_name=self.vm.nics,
                                        ip_version="IPv6")
         if not ipv6_config.exists():
             ipv6_config.create()
         self.session = cloud.init_session()
         return
     self.session = cloud.init_vm()
     if self.case_short_name == "test_cloudinit_upgrade_downgrade_package":
         rhel7_old_pkg_url = "http://download.eng.bos.redhat.com/brewroot/vol/rhel-7/packages/cloud-init/18.2/1.el7/x86_64/cloud-init-18.2-1.el7.x86_64.rpm"
         rhel8_old_pkg_url = "http://download.eng.bos.redhat.com/brewroot/vol/rhel-8/packages/cloud-init/18.2/1.el8/noarch/cloud-init-18.2-1.el8.noarch.rpm"
         try:
             self.assertEqual(0, self.session.cmd_status_output("ls /tmp/{}".format(self.package))[0],
                              "No new pakcage in guest VM")
             import requests
             if str(self.project).startswith('7'):
                 old_pkg_url = rhel7_old_pkg_url
             elif str(self.project).startswith('8'):
                 old_pkg_url = rhel8_old_pkg_url
             self.old_pkg = old_pkg_url.split('/')[-1]
             if not os.path.exists("/tmp/{}".format(self.old_pkg)):
                 r = requests.get(old_pkg_url, allow_redirects=True)
                 open("/tmp/{}".format(self.old_pkg), 'wb').write(r.content)
             self.session.copy_files_to(
                 local_path="/tmp/{}".format(self.old_pkg),
                 remote_path="/tmp/{}".format(self.old_pkg))
             self.assertEqual(0, self.session.cmd_status_output("ls /tmp/{}".format(self.old_pkg))[0],
                              "No old pakcage in guest VM")
         except:
             self.cancel(
                 "No old or new package in guest VM. Skip this case.")