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
@@ -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 VcVappReset < Chef::Knife
22
+ include Knife::VcCommon
23
+ include Knife::VcVappCommon
24
+
25
+ banner "knife vc vapp reset [VAPP] (options)"
26
+
27
+ def run
28
+ $stdout.sync = true
29
+
30
+ vapp_arg = @name_args.shift
31
+
32
+ connection.login
33
+ vapp = get_vapp(vapp_arg)
34
+
35
+ task_id = connection.reset_vapp vapp[:id]
36
+
37
+ ui.msg "vApp reset..."
38
+ wait_task(connection, task_id)
39
+
40
+ connection.logout
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,90 @@
1
+ #
2
+ # Author:: Stefano Tortarolo (<stefano.tortarolo@gmail.com>)
3
+ # Copyright:: Copyright (c) 2012-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 VcVappShow < Chef::Knife
22
+ include Knife::VcCommon
23
+ include Knife::VcVappCommon
24
+
25
+ banner "knife vc vapp show VAPP (options)"
26
+
27
+ def run
28
+ $stdout.sync = true
29
+
30
+ vapp_arg = @name_args.shift
31
+
32
+ connection.login
33
+ vapp = get_vapp(vapp_arg)
34
+ connection.logout
35
+
36
+ out_msg("Name", vapp[:name])
37
+ out_msg("Description", vapp[:description])
38
+ out_msg("Status", vapp[:status])
39
+ out_msg("IP", vapp[:ip])
40
+
41
+ ui.msg("#{ui.color('Networks', :cyan)}")
42
+
43
+ vapp[:networks].each do |network|
44
+ ui.msg ui.color(network[:name], :bold)
45
+
46
+ list = [
47
+ ui.color(' ', :bold),
48
+ ui.color('Gateway', :bold),
49
+ ui.color('Netmask', :bold),
50
+ ui.color('Fence Mode', :bold),
51
+ ui.color('Parent Network', :bold),
52
+ ui.color('Retain Network', :bold)
53
+ ]
54
+
55
+ list << " "
56
+ list << (network[:scope][:gateway] || '')
57
+ list << (network[:scope][:netmask] || '')
58
+ list << (network[:scope][:fence_mode] || '')
59
+ list << (network[:scope][:parent_network] || '')
60
+ list << (network[:scope][:retain_network] || '')
61
+
62
+ ui.msg ui.list(list, :uneven_columns_across, 6)
63
+ end
64
+
65
+ if vapp[:vapp_snapshot]
66
+ out_msg("Snapshot", vapp[:vapp_snapshot][:creation_date])
67
+ end
68
+
69
+ ui.msg("#{ui.color('VMs', :cyan)}")
70
+
71
+ list = [
72
+ ui.color('Name', :bold),
73
+ ui.color('Status', :bold),
74
+ ui.color('IPs', :bold),
75
+ ui.color('ID', :bold),
76
+ ui.color('Scoped ID', :bold)
77
+ ]
78
+
79
+ vapp[:vms_hash].each do |k, v|
80
+ list << (k || '')
81
+ list << (v[:status] || '')
82
+ list << (v[:addresses].join(', ') || '<no ip>')
83
+ list << (v[:id] || '')
84
+ list << (v[:vapp_scoped_local_id] || '')
85
+ end
86
+ ui.msg ui.list(list, :uneven_columns_across, 5)
87
+ end
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,58 @@
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 VcVappSnapshot < Chef::Knife
22
+ include Knife::VcCommon
23
+ include Knife::VcVappCommon
24
+
25
+ banner "knife vc vapp snapshot [create|revert] [VAPP] (options)"
26
+
27
+ def run
28
+ $stdout.sync = true
29
+
30
+ command_arg = @name_args.shift
31
+ vapp_arg = @name_args.shift
32
+
33
+ unless command_arg =~ /create|revert/
34
+ raise ArgumentError, "Invalid command #{command_arg} supplied. Only create and revert are allowed."
35
+ end
36
+
37
+ command = command_arg.to_sym
38
+
39
+ connection.login
40
+
41
+ vapp = get_vapp(vapp_arg)
42
+
43
+ case command
44
+ when :create
45
+ task_id = connection.create_snapshot vapp[:id]
46
+ ui.msg "vApp snapshot creation..."
47
+ wait_task(connection, task_id)
48
+ when :revert
49
+ task_id = connection.revert_snapshot vapp[:id]
50
+ ui.msg "vApp snapshot revert..."
51
+ wait_task(connection, task_id)
52
+ end
53
+
54
+ connection.logout
55
+ end
56
+ end
57
+ end
58
+ end
@@ -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,25 +16,25 @@
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 VcVappStart < Chef::Knife
24
22
  include Knife::VcCommon
23
+ include Knife::VcVappCommon
25
24
 
26
- banner "knife vc vapp start [VAPP_ID] (options)"
25
+ banner "knife vc vapp start [VAPP] (options)"
27
26
 
28
27
  def run
29
28
  $stdout.sync = true
30
29
 
31
- vapp_id = @name_args.first
30
+ vapp_arg = @name_args.shift
32
31
 
33
32
  connection.login
33
+ vapp = get_vapp(vapp_arg)
34
34
 
35
- task_id = connection.poweron_vapp vapp_id
35
+ task_id = connection.poweron_vapp vapp[:id]
36
36
 
37
- print "vApp startup..."
37
+ ui.msg "vApp startup..."
38
38
  wait_task(connection, task_id)
39
39
 
40
40
  connection.logout
@@ -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,25 +16,25 @@
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 VcVappStop < Chef::Knife
24
22
  include Knife::VcCommon
23
+ include Knife::VcVappCommon
25
24
 
26
- banner "knife vc vapp stop [VAPP_ID] (options)"
25
+ banner "knife vc vapp stop [VAPP] (options)"
27
26
 
28
27
  def run
29
28
  $stdout.sync = true
30
29
 
31
- vapp_id = @name_args.first
30
+ vapp_arg = @name_args.shift
32
31
 
33
32
  connection.login
33
+ vapp = get_vapp(vapp_arg)
34
34
 
35
- task_id = connection.poweroff_vapp vapp_id
35
+ task_id = connection.poweroff_vapp vapp[:id]
36
36
 
37
- print "vApp shutdown..."
37
+ ui.msg "vApp shutdown..."
38
38
  wait_task(connection, task_id)
39
39
 
40
40
  connection.logout
@@ -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 VcVappSuspend < Chef::Knife
22
+ include Knife::VcCommon
23
+ include Knife::VcVappCommon
24
+
25
+ banner "knife vc vapp suspend [VAPP] (options)"
26
+
27
+ def run
28
+ $stdout.sync = true
29
+
30
+ vapp_arg = @name_args.shift
31
+
32
+ connection.login
33
+ vapp = get_vapp(vapp_arg)
34
+
35
+ task_id = connection.suspend_vapp vapp[:id]
36
+
37
+ ui.msg "vApp suspend..."
38
+ wait_task(connection, task_id)
39
+
40
+ connection.logout
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,70 @@
1
+ #
2
+ # Author:: Stefano Tortarolo (<stefano.tortarolo@gmail.com>)
3
+ # Copyright:: Copyright (c) 2012-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
+ require 'chef/knife/common/vc_common'
20
+
21
+ # ORG
22
+ require 'chef/knife/org/vc_org_list'
23
+ require 'chef/knife/org/vc_org_show'
24
+
25
+ # VDC
26
+ require 'chef/knife/common/vc_vdc_common'
27
+ require 'chef/knife/vdc/vc_vdc_show'
28
+
29
+ # Catalog
30
+ require 'chef/knife/common/vc_catalog_common'
31
+ require 'chef/knife/catalog/vc_catalog_show'
32
+ require 'chef/knife/catalog/vc_catalog_item_show'
33
+
34
+ # Network
35
+ require 'chef/knife/common/vc_network_common'
36
+ require 'chef/knife/network/vc_network_show'
37
+
38
+ # VAPP
39
+ require 'chef/knife/common/vc_bootstrap_common'
40
+ require 'chef/knife/common/vc_vapp_common'
41
+ require 'chef/knife/vapp/vc_vapp_network_external'
42
+ require 'chef/knife/vapp/vc_vapp_network_internal'
43
+ require 'chef/knife/vapp/vc_vapp_create'
44
+ require 'chef/knife/vapp/vc_vapp_delete'
45
+ require 'chef/knife/vapp/vc_vapp_reboot'
46
+ require 'chef/knife/vapp/vc_vapp_reset'
47
+ require 'chef/knife/vapp/vc_vapp_show'
48
+ require 'chef/knife/vapp/vc_vapp_start'
49
+ require 'chef/knife/vapp/vc_vapp_stop'
50
+ require 'chef/knife/vapp/vc_vapp_suspend'
51
+ require 'chef/knife/vapp/vc_vapp_clone'
52
+ require 'chef/knife/vapp/vc_vapp_bootstrap'
53
+ require 'chef/knife/vapp/vc_vapp_snapshot'
54
+
55
+ # VM
56
+ require 'chef/knife/common/vc_vm_common'
57
+ require 'chef/knife/vm/vc_vm_config_guest'
58
+ require 'chef/knife/vm/vc_vm_config_network'
59
+ require 'chef/knife/vm/vc_vm_show'
60
+ require 'chef/knife/vm/vc_vm_set_info'
61
+ require 'chef/knife/vm/vc_vm_set_disks'
62
+ require 'chef/knife/vm/vc_vm_reboot'
63
+ require 'chef/knife/vm/vc_vm_reset'
64
+ require 'chef/knife/vm/vc_vm_start'
65
+ require 'chef/knife/vm/vc_vm_stop'
66
+ require 'chef/knife/vm/vc_vm_suspend'
67
+ require 'chef/knife/vm/vc_vm_bootstrap'
68
+
69
+ # OVF
70
+ require 'chef/knife/ovf/vc_ovf_upload'
@@ -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,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require 'chef/knife/vc_common'
19
+ require 'chef/knife/common/vc_common'
20
20
 
21
21
  class Chef
22
22
  class Knife
@@ -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,22 +16,23 @@
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 VcVdcShow < Chef::Knife
24
22
  include Knife::VcCommon
23
+ include Knife::VcVDCCommon
25
24
 
26
- banner "knife vc vdc show [VDC_ID] (options)"
25
+ banner "knife vc vdc show VDC (options)"
27
26
 
28
27
  def run
29
28
  $stdout.sync = true
30
29
 
31
- vdc_id = @name_args.first
30
+ vdc_arg = @name_args.shift
32
31
 
33
32
  connection.login
34
33
 
34
+ vdc = get_vdc(vdc_arg)
35
+
35
36
  header = [
36
37
  ui.color('Name', :bold),
37
38
  ui.color('ID', :bold),
@@ -39,21 +40,19 @@ class Chef
39
40
  ui.color('IP', :bold),
40
41
  ]
41
42
 
42
- description, vapps, networks = connection.show_vdc vdc_id
43
-
44
- puts "#{ui.color('Description:', :cyan)} #{description}"
43
+ ui.msg "#{ui.color('Description:', :cyan)} #{vdc[:description]}"
45
44
  list = ["#{ui.color('vAPPS', :cyan)}", '', '', '']
46
45
  list << header
47
46
  list.flatten!
48
- vapps.each do |k, v|
49
- name, description, status, ip, vms_hash = connection.show_vapp v
50
- list << ("#{k} (#{vms_hash.count} VMs)" || '')
47
+ sort_by_key(vdc[:vapps]).each do |k, v|
48
+ vapp = connection.get_vapp v
49
+ list << ("#{k} (#{vapp[:vms_hash].count} VMs)" || '')
51
50
  list << (v || '')
52
- list << (status || '')
53
- list << (ip || '')
51
+ list << (vapp[:status] || '')
52
+ list << (vapp[:ip] || '')
54
53
  end
55
54
 
56
- puts ui.list(list, :columns_across, 4)
55
+ ui.msg ui.list(list, :columns_across, 4)
57
56
  connection.logout
58
57
  end
59
58
  end