Ejemplo n.º 1
0
 def set_connection_mode_automatic_with_command():
     run_command(
         "mclient --quiet set root/Network/Wired/Method 'Automatic' &&"
         "mclient --quiet set root/Network/Wired/IPAddress '' &&"
         "mclient --quiet set root/Network/Wired/DefaultGateway '' &&"
         "mclient --quiet set root/Network/Wired/SubnetMask '' &&"
         "mclient commit")
Ejemplo n.º 2
0
 def __set_vdi(self):
     front_command = "mclient --quiet set root/ConnectionType/"
     command = ""
     if not self.vdi_id:
         raise CaseRunningError("No VDI Select")
     if self.settings:
         for key, values in self.settings.items():
             joined_command = front_command + "{}/connections/{}/{} '{}' && ".format(
                 self.vdi, self.vdi_id, key, values)
             command += joined_command
     command += "mclient commit"
     run_command(commands=command, timeout=30)
Ejemplo n.º 3
0
 def delete_vdi(cls, vdi):
     log.info("start delete {} uuid".format(vdi))
     citrix_id = cls.vdi_connection_id(vdi)
     if len(citrix_id) > 0:
         for c_id in citrix_id:
             run_command(
                 "mclient --quiet delete root/ConnectionType/{}/connections/{} && "
                 "mclient commit".format(vdi, c_id))
             time.sleep(0.2)
         if len(cls.vdi_connection_id('vdi')) == 0:
             log.info("delete {} uuid success".format(vdi))
     else:
         log.info("not exist {}, not need to delete".format(vdi))
         pass
 def check_dns_info_after_reboot(self):
     """
     Index: 1
     """
     domains = run_command(
         "mclient --quiet get root/Network/SearchDomains").strip()
     servers = run_command(
         "mclient --quiet get root/Network/DNSServers").strip()
     if domains != self.format_search_domains:
         raise CaseRunningError(
             f"Chcek SearchDomains Fail! Expect: {self.format_search_domains} Actual: {domains}"
         )
     if servers != self.format_dns_server:
         raise CaseRunningError(
             f"Chcek DNSServers Fail! Expect: {self.format_dns_server} Actual: {servers}"
         )
Ejemplo n.º 5
0
 def check_frequency(freq=2.4):
     response = run_command("sudo iwlist wlan0 channel")
     result = re.search(r"(?i)Current Frequency.*?([\d\.]+).*?GHZ.*?",
                        response)
     if result:
         frequency = float(result.group(1))
         if abs(frequency - freq) < 1:
             return
         raise CaseRunningError(
             f"Check Frequency Fail! Current: {frequency} Expect: {freq}")
     raise CaseRunningError("Wireless Connect Fail")
 def close_Cert_Window(self):
     run_command("wmctrl -c 'Certificate Authority Certificate' ")
Ejemplo n.º 7
0
 def force_logoff(self):
     command = f'sudo connection-mgr kill {self.vdi_id}'
     run_command(command)
Ejemplo n.º 8
0
 def logoff(self):
     command = f'sudo connection-mgr stop {self.vdi_id}'
     run_command(command)
     time.sleep(5)
     if self.is_active():
         self.force_logoff()
Ejemplo n.º 9
0
 def is_active(self):
     command_list_active = f'connection-mgr listActive'
     response = run_command(command_list_active)
     if self.vdi_id not in response:
         return False
     return True
Ejemplo n.º 10
0
def ping(ip, count=10):
    result = run_command(f"ping {ip} -c {count}", timeout=30)
    fail_rate = re.search(r",.*?(\d+)% packet loss", result)
    if fail_rate and int(fail_rate.group(1)) < 99:
        return True
    return False
Ejemplo n.º 11
0
 def wired_wireless_switch_off():
     run_command(
         "mclient set root/Network/WiredWirelessSwitch 0 && mclient commit")
Ejemplo n.º 12
0
 def disabled_wired():
     run_command(
         "sudo /usr/lib/hptc-network-mgr/common/netmgr_wired --down eth0 && ifconfig eth0 down"
     )
Ejemplo n.º 13
0
 def enable_wired():
     run_command(
         "sudo /usr/lib/hptc-network-mgr/common/netmgr_wired --up eth0 && ifconfig eth0 up"
     )
 def restore_dns_callback(self):
     run_command("mclient --quiet set root/Network/SearchDomains '' && "
                 "mclient --quiet set root/Network/DNSServers '' && "
                 "mclient commit")