Exemple #1
0
 def test_validate_enabled_non_zero(self):
     """
     test validate_enabled function
     test non zero
     """
     for x in range(1, 179, 3):
         self.assertEqual(mac_utils.validate_enabled(x), "on")
Exemple #2
0
 def test_validate_enabled_0(self):
     '''
     test validate_enabled function
     test 0
     '''
     self.assertEqual(mac_utils.validate_enabled(0),
                      'off')
Exemple #3
0
 def test_validate_enabled_off(self):
     '''
     test validate_enabled function
     test off
     '''
     self.assertEqual(mac_utils.validate_enabled('Off'),
                      'off')
Exemple #4
0
 def test_validate_enabled_on(self):
     '''
     test validate_enabled function
     test on
     '''
     self.assertEqual(mac_utils.validate_enabled('On'),
                      'on')
Exemple #5
0
 def test_validate_enabled_false(self):
     '''
     test validate_enabled function
     test False
     '''
     self.assertEqual(mac_utils.validate_enabled(False),
                      'off')
Exemple #6
0
 def test_validate_enabled_on(self):
     '''
     test validate_enabled function
     test on
     '''
     self.assertEqual(mac_utils.validate_enabled('On'),
                      'on')
Exemple #7
0
 def test_validate_enabled_false(self):
     '''
     test validate_enabled function
     test False
     '''
     self.assertEqual(mac_utils.validate_enabled(False),
                      'off')
Exemple #8
0
 def test_validate_enabled_off(self):
     '''
     test validate_enabled function
     test off
     '''
     self.assertEqual(mac_utils.validate_enabled('Off'),
                      'off')
Exemple #9
0
 def test_validate_enabled_non_zero(self):
     '''
     test validate_enabled function
     test non zero
     '''
     for x in range(1, 179, 3):
         self.assertEqual(mac_utils.validate_enabled(x), 'on')
Exemple #10
0
 def test_validate_enabled_true(self):
     '''
     test validate_enabled function
     test True
     '''
     self.assertEqual(mac_utils.validate_enabled(True),
                      'on')
Exemple #11
0
 def test_validate_enabled_true(self):
     '''
     test validate_enabled function
     test True
     '''
     self.assertEqual(mac_utils.validate_enabled(True),
                      'on')
Exemple #12
0
 def test_validate_enabled_0(self):
     '''
     test validate_enabled function
     test 0
     '''
     self.assertEqual(mac_utils.validate_enabled(0),
                      'off')
Exemple #13
0
 def test_validate_enabled_non_zero(self):
     '''
     test validate_enabled function
     test non zero
     '''
     for x in range(1, 179, 3):
         self.assertEqual(mac_utils.validate_enabled(x),
                          'on')
Exemple #14
0
def set_remote_login(enable):
    '''
    Set the remote login (SSH) to either on or off.

    :param bool enable: True to enable, False to disable. "On" and "Off" are
    also acceptable values. Additionally you can pass 1 and 0 to represent True
    and False respectively

    :return: True if successful, False if not
    :rtype: bool

    CLI Example:

    .. code-block:: bash

        salt '*' system.set_remote_login True
    '''
    state = validate_enabled(enable)
    cmd = 'systemsetup -f -setremotelogin {0}'.format(state)
    return execute_return_success(cmd)
Exemple #15
0
def set_sleep_on_power_button(enabled):
    '''
    Set whether or not the power button can sleep the computer.

    :param bool enabled: True to enable, False to disable. "On" and "Off" are
    also acceptable values. Additionally you can pass 1 and 0 to represent True
    and False respectively

    :return: True if successful, False if not
    :rtype: bool

    CLI Example:

    .. code-block:: bash

        salt '*' power.set_sleep_on_power_button True
    '''
    state = validate_enabled(enabled)
    cmd = 'systemsetup -setallowpowerbuttontosleepcomputer {0}'.format(state)
    return execute_return_success(cmd)
Exemple #16
0
def set_restart_power_failure(enabled):
    '''
    Set whether or not the computer will automatically restart after a power
    failure.

    :param bool enabled: True to enable, False to disable. "On" and "Off" are
    also acceptable values. Additionally you can pass 1 and 0 to represent True
    and False respectively

    :return: True if successful, False if not
    :rtype: bool

    CLI Example:

    .. code-block:: bash

        salt '*' power.set_restart_power_failure True
    '''
    state = validate_enabled(enabled)
    cmd = 'systemsetup -setrestartpowerfailure {0}'.format(state)
    return execute_return_success(cmd)
Exemple #17
0
def set_wake_on_network(enabled):
    '''
    Set whether or not the computer will wake from sleep when network activity
    is detected.

    :param bool enabled: True to enable, False to disable. "On" and "Off" are
    also acceptable values. Additionally you can pass 1 and 0 to represent True
    and False respectively

    :return: True if successful, False if not
    :rtype: bool

    CLI Example:

    .. code-block:: bash

        salt '*' power.set_wake_on_network True
    '''
    state = validate_enabled(enabled)
    cmd = 'systemsetup -setwakeonnetworkaccess {0}'.format(state)
    return execute_return_success(cmd)
Exemple #18
0
def set_remote_events(enable):
    '''
    Set whether the server responds to events sent by other computers (such as
    AppleScripts)

    :param bool enable: True to enable, False to disable. "On" and "Off" are
    also acceptable values. Additionally you can pass 1 and 0 to represent True
    and False respectively

    :return: True if successful, False if not
    :rtype: bool

    CLI Example:

    .. code-block:: bash

        salt '*' system.set_remote_events On
    '''
    state = validate_enabled(enable)
    cmd = 'systemsetup -setremoteappleevents {0}'.format(state)
    return execute_return_success(cmd)
Exemple #19
0
def set_restart_freeze(enabled):
    '''
    Specifies whether the server restarts automatically after a system freeze.
    This setting doesn't seem to be editable. The command completes successfully
    but the setting isn't actually updated. This is probably an OS X bug. The
    functions remains in case they ever fix the bug.

    :param bool enabled: True to enable, False to disable. "On" and "Off" are
    also acceptable values. Additionally you can pass 1 and 0 to represent True
    and False respectively

    :return: True if successful, False if not
    :rtype: bool

    CLI Example:

    .. code-block:: bash

        salt '*' power.set_restart_freeze True
    '''
    state = validate_enabled(enabled)
    cmd = 'systemsetup -setrestartfreeze {0}'.format(state)
    return execute_return_success(cmd)
Exemple #20
0
def set_disable_keyboard_on_lock(enable):
    '''
    Get whether or not the keyboard should be disabled when the X Serve
    enclosure lock is engaged.

    :param bool enable: True to enable, False to disable. "On" and "Off" are
    also acceptable values. Additionally you can pass 1 and 0 to represent True
    and False respectively

    :return: True if successful, False if not
    :rtype: bool

    CLI Example:

    .. code-block:: bash

        salt '*' system.set_disable_keyboard_on_lock False
    '''

    state = validate_enabled(enable)
    cmd = 'systemsetup -setdisablekeyboardwhenenclosurelockisengaged ' \
          'k{0}'.format(state)
    return execute_return_success(cmd)
Exemple #21
0
 def test_validate_enabled_false(self):
     """
     test validate_enabled function
     test False
     """
     self.assertEqual(mac_utils.validate_enabled(False), "off")
Exemple #22
0
 def test_validate_enabled_true(self):
     """
     test validate_enabled function
     test True
     """
     self.assertEqual(mac_utils.validate_enabled(True), "on")
Exemple #23
0
 def test_validate_enabled_0(self):
     """
     test validate_enabled function
     test 0
     """
     self.assertEqual(mac_utils.validate_enabled(0), "off")
Exemple #24
0
 def test_validate_enabled_off(self):
     """
     test validate_enabled function
     test off
     """
     self.assertEqual(mac_utils.validate_enabled("Off"), "off")
Exemple #25
0
 def test_validate_enabled_on(self):
     """
     test validate_enabled function
     test on
     """
     self.assertEqual(mac_utils.validate_enabled("On"), "on")