Example #1
0
def wait_for_corp():
    """
    wait_for_corp()

    Returns when connected to the corp net
    """
    while True:
        if check_corp_network():
            return
        else:
            sys_tools.sleep(secs=3)
Example #2
0
def wait_for_corp():
    """
    wait_for_corp()

    Returns when connected to the corp net
    """
    while True:
        if check_corp_network():
            return
        else:
            sys_tools.sleep(secs=3)
Example #3
0
def bind_to_ad(loaner=False, hostname=None):
    """
    bind_to_ad()

    Bind the machine to Active Directory
    Unbinds if bound, then binds machine to Active Directory
    """
    def __bind():
        return shell_tools.run("""
      dsconfigad -f -a %s -u "%s" -p %s -domain %s -ou %s,%s
    """ % (bind_name[:13], config.LDAP_USER, config.LDAP_PASSWORD,
           config.BIND_DOMAIN, config.BIND_OU, config.BIND_DC))

    # If we're bound to AD...unbind from AD before rebinding
    shell_tools.run(
        "dsconfigad -f -r -force -u '%s' -p '%s'"
        % (config.LDAP_USER, config.LDAP_PASSWORD)
    )

    # Set the time before binding because process relies on synced time
    # between the client and the AD server
    sys_tools.configure_time()
    bind_name = sys_tools.get_computer_name()

    if hostname:
        bind_name = hostname

    bind = __bind()
    if bind['status'] == 70:
        sys_tools.log("account_tools-bind_to_ad", "Restarting opendirectoryd")
        shell_tools.run("killall opendirectoryd")
        sys_tools.sleep(secs=3)
        bind = __bind()

    if not bind['success']:
        sys_tools.log("account_tools-bind_to_ad", "Unable to bind to AD")
        raise Exception("Unable to bind to Active Directory")

    # Set additional AD settings
    bind_settings = [
        "dsconfigad -mobile enable",
        "dsconfigad -mobileconfirm disable",
    ]

    for setting in bind_settings:
        shell_tools.run("%s" % setting)
Example #4
0
def wait_until_off_vpn():
    """
    wait_until_off_vpn()

    Will wait for junos to not be active, checks every 5 minutes for 9hrs
    """
    count = 0

    # Loop until junos is not active 108 times * 5 minutes = 9 hrs
    while count < 108:
        if is_active():
            print "Junos is active, waiting 5 minutes"
            count += 1
            sys_tools.sleep(mins=5)

            if count == 108:
                print "Junos timeout hit"
                sys.exit(0)
        break
Example #5
0
def wait_until_off_vpn():
    """
    wait_until_off_vpn()

    Will wait for junos to not be active, checks every 5 minutes for 9hrs
    """
    count = 0

    # Loop until junos is not active 108 times * 5 minutes = 9 hrs
    while count < 108:
        if is_active():
            print "Junos is active, waiting 5 minutes"
            count += 1
            sys_tools.sleep(mins=5)

            if count == 108:
                print "Junos timeout hit"
                sys.exit(0)
        break