knife-vcloud 0.2.3 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +44 -1
  3. data/README.md +356 -91
  4. data/lib/chef/knife/{vc_catalog_item_show.rb → catalog/vc_catalog_item_show.rb} +13 -13
  5. data/lib/chef/knife/{vc_catalog_show.rb → catalog/vc_catalog_show.rb} +9 -12
  6. data/lib/chef/knife/common/vc_bootstrap_common.rb +208 -0
  7. data/lib/chef/knife/common/vc_catalog_common.rb +58 -0
  8. data/lib/chef/knife/common/vc_common.rb +165 -0
  9. data/lib/chef/knife/common/vc_network_common.rb +34 -0
  10. data/lib/chef/knife/common/vc_vapp_common.rb +49 -0
  11. data/lib/chef/knife/common/vc_vdc_common.rb +43 -0
  12. data/lib/chef/knife/common/vc_vm_common.rb +80 -0
  13. data/lib/chef/knife/network/vc_network_show.rb +45 -0
  14. data/lib/chef/knife/{vc_org_list.rb → org/vc_org_list.rb} +3 -5
  15. data/lib/chef/knife/{vc_org_show.rb → org/vc_org_show.rb} +10 -11
  16. data/lib/chef/knife/ovf/vc_ovf_upload.rb +71 -0
  17. data/lib/chef/knife/vapp/vc_vapp_bootstrap.rb +51 -0
  18. data/lib/chef/knife/vapp/vc_vapp_clone.rb +80 -0
  19. data/lib/chef/knife/{vc_vapp_create.rb → vapp/vc_vapp_create.rb} +10 -9
  20. data/lib/chef/knife/{vc_vapp_delete.rb → vapp/vc_vapp_delete.rb} +12 -10
  21. data/lib/chef/knife/vapp/vc_vapp_network_external.rb +101 -0
  22. data/lib/chef/knife/vapp/vc_vapp_network_internal.rb +151 -0
  23. data/lib/chef/knife/vapp/vc_vapp_reboot.rb +45 -0
  24. data/lib/chef/knife/vapp/vc_vapp_reset.rb +44 -0
  25. data/lib/chef/knife/vapp/vc_vapp_show.rb +90 -0
  26. data/lib/chef/knife/vapp/vc_vapp_snapshot.rb +58 -0
  27. data/lib/chef/knife/{vc_vapp_start.rb → vapp/vc_vapp_start.rb} +7 -7
  28. data/lib/chef/knife/{vc_vapp_stop.rb → vapp/vc_vapp_stop.rb} +7 -7
  29. data/lib/chef/knife/vapp/vc_vapp_suspend.rb +44 -0
  30. data/lib/chef/knife/vc_commands.rb +70 -0
  31. data/lib/chef/knife/vc_login.rb +2 -2
  32. data/lib/chef/knife/{vc_vdc_show.rb → vdc/vc_vdc_show.rb} +13 -14
  33. data/lib/chef/knife/vm/vc_vm_bootstrap.rb +48 -0
  34. data/lib/chef/knife/vm/vc_vm_config_guest.rb +110 -0
  35. data/lib/chef/knife/{vc_vm_config_network.rb → vm/vc_vm_config_network.rb} +17 -11
  36. data/lib/chef/knife/vm/vc_vm_reboot.rb +44 -0
  37. data/lib/chef/knife/vm/vc_vm_reset.rb +44 -0
  38. data/lib/chef/knife/vm/vc_vm_set_disks.rb +78 -0
  39. data/lib/chef/knife/vm/vc_vm_set_info.rb +79 -0
  40. data/lib/chef/knife/{vc_vm_show.rb → vm/vc_vm_show.rb} +35 -18
  41. data/lib/chef/knife/vm/vc_vm_start.rb +44 -0
  42. data/lib/chef/knife/vm/vc_vm_stop.rb +44 -0
  43. data/lib/chef/knife/vm/vc_vm_suspend.rb +44 -0
  44. data/lib/knife-vcloud/version.rb +3 -0
  45. metadata +69 -38
  46. data/lib/chef/knife/vc_common.rb +0 -103
  47. data/lib/chef/knife/vc_vapp_config_network.rb +0 -63
  48. data/lib/chef/knife/vc_vapp_show.rb +0 -59
  49. data/lib/chef/knife/vc_vm_config_guest.rb +0 -67
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Stefano Tortarolo (<stefano.tortarolo@gmail.com>)
3
- # Copyright:: Copyright (c) 2012
3
+ # Copyright:: Copyright (c) 2012-2013
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,35 +16,52 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require 'chef/knife/vc_common'
20
-
21
19
  class Chef
22
20
  class Knife
23
21
  class VcVmShow < Chef::Knife
24
22
  include Knife::VcCommon
23
+ include Knife::VcVmCommon
25
24
 
26
- banner "knife vc vm show [VM_ID] (options)"
27
-
28
- def pretty_symbol(key)
29
- key.to_s.gsub('_', ' ').capitalize
30
- end
25
+ banner "knife vc vm show VM (options)"
31
26
 
32
27
  def run
33
28
  $stdout.sync = true
34
29
 
35
- vm_id = @name_args.first
36
-
37
- list = []
30
+ vm_arg = @name_args.first
38
31
 
39
32
  connection.login
40
- os_desc, networks, guest_customizations = connection.show_vm vm_id
33
+
34
+ vm = get_vm(vm_arg)
35
+
36
+ vm_info = connection.get_vm_info vm[:id]
37
+ vm_disks = connection.get_vm_disk_info vm[:id]
41
38
  connection.logout
42
39
 
43
- out_msg("OS Name", os_desc)
40
+ out_msg("VM Name", vm[:vm_name])
41
+ out_msg("OS Name", vm[:os_desc])
42
+ out_msg("Status", vm[:status])
43
+
44
+ list = []
45
+ list << ['', '']
46
+ vm_info.each do |section, values|
47
+ list << ui.color(section.capitalize, :bold)
48
+ list << ''
49
+
50
+ list << (values[:description] || '')
51
+ list << (values[:name] || '')
52
+
53
+ list << ['', '']
54
+ end
55
+
56
+ list << [ui.color('Disks', :bold), '']
57
+ vm_disks.each do |values|
58
+ list << (values[:name] || '')
59
+ list << (values[:capacity] || '')
60
+ end
44
61
 
45
- networks.each do |network, values|
46
- list << ui.color('Network', :bold)
47
- list << (network || '')
62
+ list << ['', '', ui.color('Networks', :bold), '']
63
+ vm[:networks].each do |network, values|
64
+ list << [(network || ''), '']
48
65
  values.each do |k, v|
49
66
  list << (pretty_symbol(k) || '')
50
67
  list << (v || '')
@@ -53,11 +70,11 @@ class Chef
53
70
 
54
71
  list << ['', '', ui.color('Guest Customizations', :bold), '']
55
72
  list.flatten!
56
- guest_customizations.each do |k, v|
73
+ vm[:guest_customizations].each do |k, v|
57
74
  list << (pretty_symbol(k) || '')
58
75
  list << (v || '')
59
76
  end
60
- puts ui.list(list, :columns_across, 2)
77
+ ui.msg ui.list(list, :columns_across, 2)
61
78
  end
62
79
  end
63
80
  end
@@ -0,0 +1,44 @@
1
+ #
2
+ # Author:: Stefano Tortarolo (<stefano.tortarolo@gmail.com>)
3
+ # Copyright:: Copyright (c) 2013
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ class Chef
20
+ class Knife
21
+ class VcVmStart < Chef::Knife
22
+ include Knife::VcCommon
23
+ include Knife::VcVmCommon
24
+
25
+ banner "knife vc vm start [VM] (options)"
26
+
27
+ def run
28
+ $stdout.sync = true
29
+
30
+ vm_arg = @name_args.shift
31
+
32
+ connection.login
33
+ vm = get_vm(vm_arg)
34
+
35
+ task_id = connection.poweron_vm vm[:id]
36
+
37
+ ui.msg "VM start..."
38
+ wait_task(connection, task_id)
39
+
40
+ connection.logout
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,44 @@
1
+ #
2
+ # Author:: Stefano Tortarolo (<stefano.tortarolo@gmail.com>)
3
+ # Copyright:: Copyright (c) 2013
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ class Chef
20
+ class Knife
21
+ class VcVmStop < Chef::Knife
22
+ include Knife::VcCommon
23
+ include Knife::VcVmCommon
24
+
25
+ banner "knife vc vm stop [VM] (options)"
26
+
27
+ def run
28
+ $stdout.sync = true
29
+
30
+ vm_arg = @name_args.shift
31
+
32
+ connection.login
33
+ vm = get_vm(vm_arg)
34
+
35
+ task_id = connection.poweroff_vm vm[:id]
36
+
37
+ ui.msg "VM stop..."
38
+ wait_task(connection, task_id)
39
+
40
+ connection.logout
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,44 @@
1
+ #
2
+ # Author:: Stefano Tortarolo (<stefano.tortarolo@gmail.com>)
3
+ # Copyright:: Copyright (c) 2013
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ class Chef
20
+ class Knife
21
+ class VcVmSuspend < Chef::Knife
22
+ include Knife::VcCommon
23
+ include Knife::VcVmCommon
24
+
25
+ banner "knife vc vm suspend [VM] (options)"
26
+
27
+ def run
28
+ $stdout.sync = true
29
+
30
+ vm_arg = @name_args.shift
31
+
32
+ connection.login
33
+ vm = get_vm(vm_arg)
34
+
35
+ task_id = connection.suspend_vm vm[:id]
36
+
37
+ ui.msg "VM suspend..."
38
+ wait_task(connection, task_id)
39
+
40
+ connection.logout
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,3 @@
1
+ module KnifeVCloud
2
+ VERSION = "1.0.0"
3
+ end
metadata CHANGED
@@ -1,64 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-vcloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
5
- prerelease:
4
+ version: 1.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Stefano Tortarolo
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-12-28 00:00:00.000000000 Z
11
+ date: 2013-11-29 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: chef
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: 0.10.0
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: 0.10.0
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: knife-windows
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: vcloud-rest
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
53
- version: 0.2.1
47
+ version: 1.0.0
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
61
- version: 0.2.1
54
+ version: 1.0.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: winrm
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.1.3
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 1.1.3
62
69
  description: A Knife plugin to create, list and manage vCloud servers
63
70
  email:
64
71
  - stefano.tortarolo@gmail.com
@@ -69,45 +76,69 @@ files:
69
76
  - CHANGELOG.md
70
77
  - README.md
71
78
  - LICENSE
72
- - lib/chef/knife/vc_catalog_item_show.rb
73
- - lib/chef/knife/vc_catalog_show.rb
74
- - lib/chef/knife/vc_common.rb
79
+ - lib/chef/knife/catalog/vc_catalog_item_show.rb
80
+ - lib/chef/knife/catalog/vc_catalog_show.rb
81
+ - lib/chef/knife/common/vc_bootstrap_common.rb
82
+ - lib/chef/knife/common/vc_catalog_common.rb
83
+ - lib/chef/knife/common/vc_common.rb
84
+ - lib/chef/knife/common/vc_network_common.rb
85
+ - lib/chef/knife/common/vc_vapp_common.rb
86
+ - lib/chef/knife/common/vc_vdc_common.rb
87
+ - lib/chef/knife/common/vc_vm_common.rb
88
+ - lib/chef/knife/network/vc_network_show.rb
89
+ - lib/chef/knife/org/vc_org_list.rb
90
+ - lib/chef/knife/org/vc_org_show.rb
91
+ - lib/chef/knife/ovf/vc_ovf_upload.rb
92
+ - lib/chef/knife/vapp/vc_vapp_bootstrap.rb
93
+ - lib/chef/knife/vapp/vc_vapp_clone.rb
94
+ - lib/chef/knife/vapp/vc_vapp_create.rb
95
+ - lib/chef/knife/vapp/vc_vapp_delete.rb
96
+ - lib/chef/knife/vapp/vc_vapp_network_external.rb
97
+ - lib/chef/knife/vapp/vc_vapp_network_internal.rb
98
+ - lib/chef/knife/vapp/vc_vapp_reboot.rb
99
+ - lib/chef/knife/vapp/vc_vapp_reset.rb
100
+ - lib/chef/knife/vapp/vc_vapp_show.rb
101
+ - lib/chef/knife/vapp/vc_vapp_snapshot.rb
102
+ - lib/chef/knife/vapp/vc_vapp_start.rb
103
+ - lib/chef/knife/vapp/vc_vapp_stop.rb
104
+ - lib/chef/knife/vapp/vc_vapp_suspend.rb
105
+ - lib/chef/knife/vc_commands.rb
75
106
  - lib/chef/knife/vc_login.rb
76
- - lib/chef/knife/vc_org_list.rb
77
- - lib/chef/knife/vc_org_show.rb
78
- - lib/chef/knife/vc_vapp_config_network.rb
79
- - lib/chef/knife/vc_vapp_create.rb
80
- - lib/chef/knife/vc_vapp_delete.rb
81
- - lib/chef/knife/vc_vapp_show.rb
82
- - lib/chef/knife/vc_vapp_start.rb
83
- - lib/chef/knife/vc_vapp_stop.rb
84
- - lib/chef/knife/vc_vdc_show.rb
85
- - lib/chef/knife/vc_vm_config_guest.rb
86
- - lib/chef/knife/vc_vm_config_network.rb
87
- - lib/chef/knife/vc_vm_show.rb
107
+ - lib/chef/knife/vdc/vc_vdc_show.rb
108
+ - lib/chef/knife/vm/vc_vm_bootstrap.rb
109
+ - lib/chef/knife/vm/vc_vm_config_guest.rb
110
+ - lib/chef/knife/vm/vc_vm_config_network.rb
111
+ - lib/chef/knife/vm/vc_vm_reboot.rb
112
+ - lib/chef/knife/vm/vc_vm_reset.rb
113
+ - lib/chef/knife/vm/vc_vm_set_disks.rb
114
+ - lib/chef/knife/vm/vc_vm_set_info.rb
115
+ - lib/chef/knife/vm/vc_vm_show.rb
116
+ - lib/chef/knife/vm/vc_vm_start.rb
117
+ - lib/chef/knife/vm/vc_vm_stop.rb
118
+ - lib/chef/knife/vm/vc_vm_suspend.rb
119
+ - lib/knife-vcloud/version.rb
88
120
  homepage: https://github.com/astratto/knife-vcloud
89
- licenses: []
121
+ licenses:
122
+ - Apache 2.0
123
+ metadata: {}
90
124
  post_install_message:
91
125
  rdoc_options: []
92
126
  require_paths:
93
127
  - lib
94
128
  required_ruby_version: !ruby/object:Gem::Requirement
95
- none: false
96
129
  requirements:
97
- - - ! '>='
130
+ - - '>='
98
131
  - !ruby/object:Gem::Version
99
132
  version: '0'
100
133
  required_rubygems_version: !ruby/object:Gem::Requirement
101
- none: false
102
134
  requirements:
103
- - - ! '>='
135
+ - - '>='
104
136
  - !ruby/object:Gem::Version
105
137
  version: '0'
106
138
  requirements: []
107
139
  rubyforge_project:
108
- rubygems_version: 1.8.24
140
+ rubygems_version: 2.1.11
109
141
  signing_key:
110
- specification_version: 3
142
+ specification_version: 4
111
143
  summary: A knife plugin for the VMWare vCloud API
112
144
  test_files: []
113
- has_rdoc:
@@ -1,103 +0,0 @@
1
- #
2
- # Author:: Stefano Tortarolo (<stefano.tortarolo@gmail.com>)
3
- # Copyright:: Copyright (c) 2012
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- require 'chef/knife'
20
-
21
- class Chef
22
- class Knife
23
- # Module for operations common among commands
24
- module VcCommon
25
- # :nodoc:
26
- # Would prefer to do this in a rational way, but can't be done b/c of
27
- # Mixlib::CLI's design :(
28
- def self.included(includer)
29
- includer.class_eval do
30
-
31
- deps do
32
- require 'vcloud-rest/connection'
33
- require 'chef/api_client'
34
- end
35
-
36
- option :vcloud_url,
37
- :short => "-H URL",
38
- :long => "--vcloud-url URL",
39
- :description => "The vCloud endpoint URL",
40
- :proc => Proc.new { |url| Chef::Config[:knife][:vcloud_url] = url }
41
-
42
- option :vcloud_user,
43
- :short => "-U USER",
44
- :long => "--vcloud-user USER",
45
- :description => "Your vCloud User",
46
- :proc => Proc.new { |key| Chef::Config[:knife][:vcloud_user] = key }
47
-
48
- option :vcloud_password,
49
- :short => "-P SECRET",
50
- :long => "--vcloud-password SECRET",
51
- :description => "Your vCloud secret key",
52
- :proc => Proc.new { |key| Chef::Config[:knife][:vcloud_password] = key }
53
-
54
- option :vcloud_org,
55
- :short => "-O ORGANIZATION",
56
- :long => "--vcloud-organization ORGANIZATION",
57
- :description => "Your vCloud Organization",
58
- :proc => Proc.new { |key| Chef::Config[:knife][:vcloud_org] = key }
59
-
60
- option :vcloud_api_version,
61
- :short => "-A API_VERSION",
62
- :long => "--vcloud-api-version API_VERSION",
63
- :description => "vCloud API version (1.5 and 5.1 supported)",
64
- :proc => Proc.new { |key| Chef::Config[:knife][:vcloud_api_version] = key }
65
- end
66
- end
67
-
68
- def connection
69
- unless @connection
70
- @connection = VCloudClient::Connection.new(
71
- locate_config_value(:vcloud_url),
72
- locate_config_value(:vcloud_user),
73
- locate_config_value(:vcloud_password),
74
- locate_config_value(:vcloud_org),
75
- locate_config_value(:vcloud_api_version)
76
- )
77
- end
78
- @connection
79
- end
80
-
81
- def out_msg(label, value)
82
- if value && !value.empty?
83
- puts "#{ui.color(label, :cyan)}: #{value}"
84
- end
85
- end
86
-
87
- def locate_config_value(key)
88
- key = key.to_sym
89
- Chef::Config[:knife][key] || config[key]
90
- end
91
-
92
- def wait_task(connection, task_id)
93
- status, errormsg, start_time, end_time = connection.wait_task_completion task_id
94
- puts "Done!"
95
- out_msg("Summary", "Status: #{ui.color(status, :cyan)} - started at #{start_time} and ended at #{end_time}")
96
-
97
- if errormsg
98
- puts ui.color("ATTENTION: #{errormsg}", :red)
99
- end
100
- end
101
- end
102
- end
103
- end