Пример #1
0
 def _build_opt_dict(self, inventory_file, **kwargs):
     args = {
         'check': None, 'listtasks': None, 'listhosts': None,
         'listtags': None, 'syntax': None, 'module_path': None,
         'skip_tags': [], 'ssh_common_args': '',
         'sftp_extra_args': '', 'scp_extra_args': '',
         'ssh_extra_args': '', 'become': constants.DEFAULT_BECOME,
         'become_user': constants.DEFAULT_BECOME_USER,
         'become_ask_pass': constants.DEFAULT_BECOME_ASK_PASS,
         'become_method': constants.DEFAULT_BECOME_METHOD,
         'forks': constants.DEFAULT_FORKS,
         'inventory': inventory_file,
         'private_key_file': constants.DEFAULT_PRIVATE_KEY_FILE,
         'extra_vars': {}, 'subset': constants.DEFAULT_SUBSET,
         'tags': [], 'verbosity': 0,
         'connection': constants.DEFAULT_TRANSPORT,
         'timeout': constants.DEFAULT_TIMEOUT
     }
     args.update(self.custom_opts)
     args.update(kwargs)
     # In ansible 2.2, tags can be a string or a list, but only a list
     # is supported in 2.3.
     if isinstance(args['tags'], str):
         args['tags'] = args['tags'].split(',')
     elif not isinstance(args['tags'], list):
         raise exceptions.InvalidParameter(name=type(args['tags']).__name__,
                                           param='tag')
     return Namespace(**args)
Пример #2
0
 def test_invalid_parameter_custom_msg(self):
     e = exceptions.InvalidParameter(msg='%(name)s + %(param)s = c',
                                     name='a', param='b')
     self.assertEqual('a + b = c', e.msg)
Пример #3
0
 def test_invalid_parameter_wrong_params(self):
     e = exceptions.InvalidParameter(foo='a', bar='b')
     self.assertEqual('Invalid type of %(name)s on parameter %(param)s',
                      e.msg)
Пример #4
0
 def test_invalid_parameter_no_params(self):
     e = exceptions.InvalidParameter()
     self.assertEqual('Invalid type of %(name)s on parameter %(param)s',
                      e.msg)
Пример #5
0
 def test_invalid_parameter(self):
     e = exceptions.InvalidParameter(name='a', param='b')
     self.assertEqual('Invalid type of a on parameter b', e.msg)