コード例 #1
0
def main():
    if mounted(device_name):
        print('Preparation.')
        print('device_dismount(', device_name, sep='', end=')\n')
        device_dismount(device_name)
        time.sleep(1)
        print()

    print('Verify absence of unreachable device.')
    in_inventory = device_name in inventory()
    in_mounted = device_name in inventory_mounted()
    print(device_name + ' in inventory', in_inventory, sep=': ')
    print(device_name + ' is mounted', in_mounted, sep=': ')
    assert not in_inventory
    assert not in_mounted
    del in_inventory, in_mounted

    print()

    print('Discover effect of mounting unreachable device.')
    print('device_mount(' + device_name,
          device_address,
          device_port,
          sep=', ',
          end=')\n')
    device_mount(device_name, device_address, device_port, device_username,
                 device_password)
    time.sleep(1)
    in_connected = device_name in inventory_connected()
    in_mounted = device_name in inventory_mounted()
    print(device_name + ' is connected', in_connected, sep=': ')
    print(device_name + ' is mounted', in_mounted, sep=': ')
    assert not in_connected
    assert in_mounted
コード例 #2
0
def main():
    if mounted(device_name):
        print('Preparation.')     
        print('device_dismount(', device_name, sep='', end=')\n')
        device_dismount(device_name)
        time.sleep(1)
        print()
        
    print('Verify absence of unreachable device.')     
    in_inventory = device_name in inventory()
    in_mounted = device_name in inventory_mounted()
    print(device_name + ' in inventory', in_inventory, sep=': ')
    print(device_name + ' is mounted', in_mounted, sep=': ')
    assert not in_inventory
    assert not in_mounted
    del in_inventory, in_mounted

    print()
    
    print('Discover effect of mounting unreachable device.')     
    print('device_mount(' + device_name, device_address, device_port, sep=', ', end=')\n')
    device_mount(device_name, device_address, device_port, device_username, device_password)
    time.sleep(1)
    in_connected = device_name in inventory_connected()
    in_mounted = device_name in inventory_mounted()
    print(device_name + ' is connected', in_connected, sep=': ')
    print(device_name + ' is mounted', in_mounted, sep=': ')
    assert not in_connected
    assert in_mounted
コード例 #3
0
def demonstrate(device_name):
    device_config = config['network_device'][device_name]
    print('device_mount(' + device_name,
          *device_config.values(),
          sep=', ',
          end=')\n')
    device_mount(device_name, device_config['address'], device_config['port'],
                 device_config['username'], device_config['password'])
コード例 #4
0
def mount_from_settings(device_name):
    """Mount the specified device with the configured settings."""
    device_config = config['network_device'][device_name]
    print('device_mount(' + device_name,
          *device_config.values(),
          sep=', ',
          end=')\n')
    device_mount(device_name, device_config['address'], device_config['port'],
                 device_config['username'], device_config['password'])
コード例 #5
0
def demonstrate(device_name):
    device_config = config['network_device'][device_name]
    print('device_mount(' + device_name, *device_config.values(), sep=', ', end=')\n')
    device_mount(
        device_name,
        device_config['address'],
        device_config['port'],
        device_config['username'],
        device_config['password'])
コード例 #6
0
def mount_from_settings(device_name):
    """Mount the specified device with the configured settings."""
    device_config = config['network_device'][device_name]
    print('device_mount(' + device_name, *device_config.values(), sep=', ', end=')\n')
    device_mount(
        device_name,
        device_config['address'],
        device_config['port'],
        device_config['username'],
        device_config['password'])
コード例 #7
0
def mount_from_settings(device_name):
    """
    Mount the specified device using the configured settings.
    
    Return a DeviceControl representation of the configured settings.
    """
    device_config = network_device_dict[device_name]
    control = DeviceControl(device_name=device_name, **device_config)
    device_mount(control.device_name, control.address, control.port,
                 control.username, control.password)
    return control
コード例 #8
0
def mount_from_settings(device_name):
    """
    Mount the specified device using the configured settings.
    
    Return a DeviceControl representation of the configured settings.
    """
    device_config = network_device_dict[device_name]
    control = DeviceControl(device_name=device_name, **device_config)
    device_mount(
        control.device_name,
        control.address,
        control.port,
        control.username,
        control.password)
    return control
コード例 #9
0
 def setUp(self):
     unmounted_list = inventory_unmounted()
     for device_name in unmounted_list:
         device_config = self.network_device_config[device_name]
         print('setup: device_mount(' + device_name, *device_config.values(), sep=', ', end=')\n')
         device_mount(
             device_name,
             device_config['address'],
             device_config['port'],
             device_config['username'],
             device_config['password'])
     
     if unmounted_list:
         print('Sleep to allow Controller to update...')
         time.sleep(2)
         self.assertTrue(inventory_mounted(), 'Not mounted: ' + str(inventory_unmounted()))
コード例 #10
0
def main():
    print(plain(doc(device_mount)))
    unmounted_list = inventory_unmounted()
    if not unmounted_list:
        print('There are no (configured) devices unmounted.')
    else:
        configured = settings.config['network_device']
        for device_name in unmounted_list:
            device_config = configured[device_name]
            print('device_mount(' + device_name, *device_config.values(), sep=', ', end=')\n')
            device_mount(
                device_name,
                device_config['address'],
                device_config['port'],
                device_config['username'],
                device_config['password'])
コード例 #11
0
    def setUp(self):
        unmounted_list = inventory_unmounted()
        for device_name in unmounted_list:
            device_config = self.network_device_config[device_name]
            print('setup: device_mount(' + device_name,
                  *device_config.values(),
                  sep=', ',
                  end=')\n')
            device_mount(device_name, device_config['address'],
                         device_config['port'], device_config['username'],
                         device_config['password'])

        if unmounted_list:
            print('Sleep to allow Controller to update...')
            time.sleep(2)
            self.assertTrue(inventory_mounted(),
                            'Not mounted: ' + str(inventory_unmounted()))
コード例 #12
0
    def test_mount_device(self):
        self.assertTrue(self.network_device_config, 'One or more devices must be configured.')

        unmounted_list = inventory_unmounted()
        self.assertTrue(unmounted_list, 'One or more devices must be unmounted.')
        for device_name in unmounted_list:
            device_config = self.network_device_config[device_name]
            print('test: device_mount(' + device_name, *device_config.values(), sep=', ', end=')\n')
            device_mount(
                device_name,
                device_config['address'],
                device_config['port'],
                device_config['username'],
                device_config['password'])
            
        print('Sleep to allow Controller to update...')
        time.sleep(2)
        for device_name in unmounted_list:
            self.assertTrue(mounted(device_name), 'Not mounted: ' + device_name)
コード例 #13
0
    def test_mount_device(self):
        self.assertTrue(self.network_device_config,
                        'One or more devices must be configured.')

        unmounted_list = inventory_unmounted()
        self.assertTrue(unmounted_list,
                        'One or more devices must be unmounted.')
        for device_name in unmounted_list:
            device_config = self.network_device_config[device_name]
            print('test: device_mount(' + device_name,
                  *device_config.values(),
                  sep=', ',
                  end=')\n')
            device_mount(device_name, device_config['address'],
                         device_config['port'], device_config['username'],
                         device_config['password'])

        print('Sleep to allow Controller to update...')
        time.sleep(2)
        for device_name in unmounted_list:
            self.assertTrue(mounted(device_name),
                            'Not mounted: ' + device_name)