예제 #1
0
    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)
예제 #2
0
    parser.add_option(
        '-v',
        '--debug',
        '--verbose',
        dest='verbosity',
        action='count',
        default=defaults.VERBOSITY,
        help='Increase verbosity level for debugging (multiple allowed)')
    options, args = parser.parse_args()
    return options, args


parser = OptionParser()
options, args = parse_args(parser)

ch = ConfigHolder(config_file_name=options.config_file,
                  verbosity=options.verbosity)
initialize_logger(ch.get(defaults.CONFIG_MAIN_SECTION, 'log_direction'),
                  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()
예제 #3
0
    parser.add_option('--config', dest='config_file', action='store', 
                      default=defaults.CONFIG_FILE_NAME, 
                      help='Name of the configuration file to use (D: %s)' %\
                                                        defaults.CONFIG_FILE_NAME)
    parser.add_option('--action', dest='action', action='store', default='', 
                      help='Action to execute. Valid actions: %s' % VALID_ACTIONS_STR)
    parser.add_option('-v', '--debug', '--verbose', dest='verbosity',
                      action='count', default=defaults.VERBOSITY, 
                      help='Increase verbosity level for debugging (multiple allowed)')
    options, args = parser.parse_args()
    return options, args

parser = OptionParser()
options, args = parse_args(parser)

ch = ConfigHolder(config_file_name=options.config_file, 
                  verbosity=options.verbosity)
initialize_logger(ch.get(defaults.CONFIG_MAIN_SECTION, 'log_direction'),
                  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("")
예제 #4
0
 def testInit(self):
     ch = ConfigHolder(self.cfg_fname)
     ch.get_proxy_name = Mock(return_value='foo')
     self.assertRaises(SystemExit, 
                       PdiskBackendProxyFactory.createBackendProxy, ch)
예제 #5
0
 def testInit(self):
     ch = ConfigHolder(self.cfg_fname)
     assert defaults.CONFIG_LOG_DIRECTION == ch.get(defaults.CONFIG_MAIN_SECTION, 'log_direction')