本文整理汇总了Python中littlechef_rackspace.runner.Runner类的典型用法代码示例。如果您正苦于以下问题:Python Runner类的具体用法?Python Runner怎么用?Python Runner使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Runner类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create_with_template_that_has_secrets_file_includes_values
def test_create_with_template_that_has_secrets_file_includes_values(self):
with mock.patch.multiple(
"littlechef_rackspace.runner",
RackspaceApi=self.api_class,
ChefDeployer=self.deploy_class,
RackspaceCreate=self.create_class):
r = Runner(options={
'templates': {
'preprod': {
'secrets-file': 'secrets-test.cfg',
'region': 'dfw'
}
}
})
r._read_secrets_file = mock.Mock(return_value={
'username': 'testuser',
'key': 'testuserkey'
})
r.main('{0} --name test preprod'.format(
self.create_base).split(' '))
call_args = self.create_command.execute.call_args_list[0][1]
r._read_secrets_file.assert_any_call('secrets-test.cfg')
self.assertEquals('testuser', call_args.get('username'))
self.assertEquals('testuserkey', call_args.get('key'))
示例2: test_create_fails_if_required_arguments_are_not_provided
def test_create_fails_if_required_arguments_are_not_provided(self):
with mock.patch.multiple('littlechef_rackspace.runner', abort=self.abort):
with self.assertRaises(AbortException):
self.create_command.validate_args.return_value = False
r = Runner(options={})
r.main("create --username username --key deadbeef --region dfw".split(" "))
self.abort.assert_any_call(FailureMessages.MISSING_REQUIRED_ARGUMENTS)
示例3: test_create_with_template_includes_template
def test_create_with_template_includes_template(self):
with mock.patch.multiple(
"littlechef_rackspace.runner",
RackspaceApi=self.api_class,
ChefDeployer=self.deploy_class,
RackspaceCreate=self.create_class):
r = Runner(options={
'templates': {
'preprod': {
'region': 'dfw'
},
'web': {
'image': 'Ubuntu 12.04-Image',
'flavor': 'performance1-2',
'runlist': [
'role[web]'
],
'networks': [
'00000000-0000-0000-0000-000000000000'
]
}
}
})
r.main('{0} --name test preprod web'.format(
self.create_base).split(' '))
call_args = self.create_command.execute.call_args_list[0][1]
self.assertEquals('performance1-2', call_args.get('flavor'))
self.assertEquals('Ubuntu 12.04-Image', call_args.get('image'))
self.assertEquals(['role[web]'], call_args.get('runlist'))
self.assertEquals('dfw', call_args.get('region'))
示例4: test_create_fails_if_configuration_is_not_provided
def test_create_fails_if_configuration_is_not_provided(self):
r = Runner(options={})
with mock.patch.multiple('littlechef_rackspace.runner',
abort=self.abort):
with self.assertRaises(AbortException):
r.main(["create"])
self.abort.assert_any_call(FailureMessages.NEED_API_KEY)
示例5: test_create_with_use_opscode_chef_not_specified
def test_create_with_use_opscode_chef_not_specified(self):
with mock.patch.multiple("littlechef_rackspace.runner", RackspaceApi=self.api_class,
ChefDeployer=self.deploy_class, RackspaceCreate=self.create_class):
r = Runner(options={})
r.main(self.create_args)
call_args = self.create_command.execute.call_args_list[0][1]
self.assertFalse("use_opscode_chef" in call_args)
示例6: test_create_with_use_opscode_chef_to_true
def test_create_with_use_opscode_chef_to_true(self):
with mock.patch.multiple("littlechef_rackspace.runner", RackspaceApi=self.api_class,
ChefDeployer=self.deploy_class, RackspaceCreate=self.create_class):
r = Runner(options={})
r.main(self.create_args + [ '--use-opscode-chef', '1'])
call_args = self.create_command.execute.call_args_list[0][1]
self.assertEquals(True, call_args.get("use_opscode_chef"))
示例7: test_create_instantiates_api_and_deploy_with_default_private_key
def test_create_instantiates_api_and_deploy_with_default_private_key(self):
with mock.patch.multiple("littlechef_rackspace.runner", RackspaceApi=self.api_class,
ChefDeployer=self.deploy_class, RackspaceCreate=self.create_class):
r = Runner(options={})
r.main(self.create_args)
self.api_class.assert_any_call(username="username", key="deadbeef", region=Regions.DFW)
self.deploy_class.assert_any_call(key_filename="~/.ssh/id_rsa")
示例8: test_list_images_fails_if_configuration_is_not_provided
def test_list_images_fails_if_configuration_is_not_provided(self):
with mock.patch.multiple("littlechef_rackspace.runner", RackspaceApi=self.api_class,
ChefDeployer=self.deploy_class, RackspaceListImages=self.list_images_class,
abort=self.abort):
with self.assertRaises(AbortException):
r = Runner(options={})
r.main(["list-images"])
self.abort.assert_any_call(FailureMessages.NEED_API_KEY)
示例9: test_create_with_template_does_not_pass_templates_to_create_command
def test_create_with_template_does_not_pass_templates_to_create_command(self):
with mock.patch.multiple("littlechef_rackspace.runner", RackspaceApi=self.api_class,
ChefDeployer=self.deploy_class, RackspaceCreate=self.create_class):
r = Runner(options={'templates': { 'web': { 'image': 'Ubuntu 13.10' }}})
r.main(self.create_args)
call_args = self.create_command.execute.call_args_list[0][1]
self.assertTrue('templates' not in call_args)
示例10: test_create_with_postplugins_parses_postplugins_into_array
def test_create_with_postplugins_parses_postplugins_into_array(self):
with mock.patch.multiple("littlechef_rackspace.runner", RackspaceApi=self.api_class,
ChefDeployer=self.deploy_class, RackspaceCreate=self.create_class):
r = Runner(options={})
post_plugins = 'plugin1,plugin2,plugin3'
r.main(self.create_args + [ '--post-plugins', post_plugins ])
call_args = self.create_command.execute.call_args_list[0][1]
self.assertEquals(post_plugins.split(','), call_args["post_plugins"])
示例11: test_create_with_runlist_parses_runlist_into_array
def test_create_with_runlist_parses_runlist_into_array(self):
with mock.patch.multiple("littlechef_rackspace.runner", RackspaceApi=self.api_class,
ChefDeployer=self.deploy_class, RackspaceCreate=self.create_class):
r = Runner(options={})
runlist = 'role[test],recipe[web],recipe[apache2]'
r.main(self.create_args + [ '--runlist', runlist ])
call_args = self.create_command.execute.call_args_list[0][1]
self.assertEquals(runlist.split(','), call_args["runlist"])
示例12: test_create_with_networks_without_publicnet_raises_exception
def test_create_with_networks_without_publicnet_raises_exception(self):
with mock.patch.multiple("littlechef_rackspace.runner", RackspaceApi=self.api_class,
ChefDeployer=self.deploy_class, RackspaceCreate=self.create_class):
r = Runner(options={})
with self.assertRaises(InvalidConfiguration) as cm:
r.main(self.create_args + [ '--networks', 'abcdefg'])
self.assertEquals('Must specify PublicNet in networks list (id=00000000-0000-0000-0000-000000000000)',
cm.exception.message)
示例13: test_create_with_networks_passes_networks
def test_create_with_networks_passes_networks(self):
with mock.patch.multiple("littlechef_rackspace.runner", RackspaceApi=self.api_class,
ChefDeployer=self.deploy_class, RackspaceCreate=self.create_class):
r = Runner(options={})
public_net_id = '00000000-0000-0000-0000-000000000000'
custom_net_id= '45e8b288-3a98-4092-a3e8-37e2a540d004'
r.main(self.create_args + [ '--networks', '{0},{1}'.format(public_net_id, custom_net_id)])
call_args = self.create_command.execute.call_args_list[0][1]
self.assertEquals([public_net_id, custom_net_id], call_args.get('networks'))
示例14: test_create_with_invalid_templates_raises_error
def test_create_with_invalid_templates_raises_error(self):
with mock.patch.multiple(
"littlechef_rackspace.runner",
RackspaceApi=self.api_class,
ChefDeployer=self.deploy_class,
RackspaceCreate=self.create_class):
r = Runner(options={})
with self.assertRaises(InvalidTemplate):
r.main('{0} --name test invalidtemplate'.format(
self.create_base).split(' '))
示例15: test_list_images_with_dfw_region_instantiates_api
def test_list_images_with_dfw_region_instantiates_api(self):
with mock.patch.multiple(
"littlechef_rackspace.runner",
RackspaceApi=self.api_class,
ChefDeployer=self.deploy_class,
RackspaceListImages=self.list_images_class):
r = Runner(options={})
r.main(self.dfw_list_images_args)
self.api_class.assert_any_call(username="username",
key="deadbeef",
region='dfw')