def testCreateBackends(self):
        ch = ConfigHolder(self.cfg_fname)
        ch._set_backend_proxy_specific_attributes = Mock()

        for netapp_type in ['netapp.com', '7mode.netapp.com', 'cluster.netapp.com']:
            ch.get_proxy_name = Mock(return_value=netapp_type)
            assert isinstance(PdiskBackendProxyFactory.createBackendProxy(ch), 
                              NetAppBackend)
        
        ch.get_proxy_name = Mock(return_value='ceph.org')
        assert isinstance(PdiskBackendProxyFactory.createBackendProxy(ch), 
                          CephBackend)
        
        ch.get_proxy_name = Mock(return_value='file.org')
        assert isinstance(PdiskBackendProxyFactory.createBackendProxy(ch), 
                          FileBackend)
        
        ch.get_proxy_name = Mock(return_value='lvm.org')
        assert isinstance(PdiskBackendProxyFactory.createBackendProxy(ch), 
                          LVMBackend)
Example #2
0
if options.action in VALID_ACTIONS:
    if len(args) < VALID_ACTIONS[options.action]:
        print_detail("Insufficient argument provided (%d required)" %
                     VALID_ACTIONS[options.action])
        parser.print_help()
        abort("")
else:
    if options.action:
        print_detail("Invalid action requested (%s)\n" % options.action)
    else:
        print_detail("No action specified\n")
    parser.print_help()
    abort("")

backend_proxy = PdiskBackendProxyFactory.createBackendProxy(ch)

# Execute requested action

status = 0

if options.action == 'check':
    print_detail("Checking LUN existence...", 1)
    lun = LUN(args[0], proxy=backend_proxy)
    status = lun.check()
elif options.action == 'create':
    print_detail("Creating LUN...", 1)
    lun = LUN(args[0], size=args[1], proxy=backend_proxy)
    status = lun.create()
elif options.action == 'delete':
    print_detail("Deleting LUN...", 1)
                  ch.verbosity)
            
if options.action in VALID_ACTIONS:
    if len(args) < VALID_ACTIONS[options.action]:
        print_detail("Insufficient argument provided (%d required)" % VALID_ACTIONS[options.action])  
        parser.print_help()
        abort("")
else:
    if options.action:
        print_detail("Invalid action requested (%s)\n" % options.action)
    else:
        print_detail("No action specified\n")
    parser.print_help()
    abort("")

backend_proxy = PdiskBackendProxyFactory.createBackendProxy(ch)

# Execute requested action

status = 0

if options.action == 'check':
    print_detail("Checking LUN existence...", 1)
    lun = LUN(args[0], proxy=backend_proxy)
    status = lun.check()
elif options.action == 'create':
    print_detail("Creating LUN...", 1)
    lun = LUN(args[0], size=args[1], proxy=backend_proxy)
    status = lun.create()
elif options.action == 'delete':
    print_detail("Deleting LUN...", 1)