knife-cosmic 0.2.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 (55) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGES.rdoc +186 -0
  3. data/LICENSE +202 -0
  4. data/README.rdoc +427 -0
  5. data/lib/chef/knife/cosmic_aag_list.rb +58 -0
  6. data/lib/chef/knife/cosmic_account_list.rb +87 -0
  7. data/lib/chef/knife/cosmic_base.rb +108 -0
  8. data/lib/chef/knife/cosmic_baselist.rb +111 -0
  9. data/lib/chef/knife/cosmic_cluster_list.rb +60 -0
  10. data/lib/chef/knife/cosmic_config_list.rb +56 -0
  11. data/lib/chef/knife/cosmic_disk_list.rb +58 -0
  12. data/lib/chef/knife/cosmic_domain_list.rb +53 -0
  13. data/lib/chef/knife/cosmic_firewallrule_create.rb +138 -0
  14. data/lib/chef/knife/cosmic_firewallrule_list.rb +62 -0
  15. data/lib/chef/knife/cosmic_forwardrule_create.rb +145 -0
  16. data/lib/chef/knife/cosmic_host_list.rb +61 -0
  17. data/lib/chef/knife/cosmic_hosts.rb +58 -0
  18. data/lib/chef/knife/cosmic_iso_list.rb +89 -0
  19. data/lib/chef/knife/cosmic_keypair_create.rb +72 -0
  20. data/lib/chef/knife/cosmic_keypair_delete.rb +60 -0
  21. data/lib/chef/knife/cosmic_keypair_list.rb +44 -0
  22. data/lib/chef/knife/cosmic_network_list.rb +63 -0
  23. data/lib/chef/knife/cosmic_oscategory_list.rb +50 -0
  24. data/lib/chef/knife/cosmic_ostype_list.rb +52 -0
  25. data/lib/chef/knife/cosmic_pod_list.rb +60 -0
  26. data/lib/chef/knife/cosmic_project_list.rb +63 -0
  27. data/lib/chef/knife/cosmic_publicip_list.rb +55 -0
  28. data/lib/chef/knife/cosmic_router_list.rb +64 -0
  29. data/lib/chef/knife/cosmic_securitygroup_list.rb +59 -0
  30. data/lib/chef/knife/cosmic_server_add_nic.rb +109 -0
  31. data/lib/chef/knife/cosmic_server_create.rb +674 -0
  32. data/lib/chef/knife/cosmic_server_delete.rb +153 -0
  33. data/lib/chef/knife/cosmic_server_list.rb +167 -0
  34. data/lib/chef/knife/cosmic_server_passwordreset.rb +91 -0
  35. data/lib/chef/knife/cosmic_server_reboot.rb +99 -0
  36. data/lib/chef/knife/cosmic_server_remove_nic.rb +101 -0
  37. data/lib/chef/knife/cosmic_server_start.rb +104 -0
  38. data/lib/chef/knife/cosmic_server_stop.rb +118 -0
  39. data/lib/chef/knife/cosmic_server_update.rb +47 -0
  40. data/lib/chef/knife/cosmic_service_list.rb +74 -0
  41. data/lib/chef/knife/cosmic_stack_create.rb +298 -0
  42. data/lib/chef/knife/cosmic_stack_delete.rb +79 -0
  43. data/lib/chef/knife/cosmic_template_create.rb +129 -0
  44. data/lib/chef/knife/cosmic_template_extract.rb +104 -0
  45. data/lib/chef/knife/cosmic_template_list.rb +88 -0
  46. data/lib/chef/knife/cosmic_template_register.rb +187 -0
  47. data/lib/chef/knife/cosmic_user_list.rb +62 -0
  48. data/lib/chef/knife/cosmic_volume_attach.rb +70 -0
  49. data/lib/chef/knife/cosmic_volume_create.rb +108 -0
  50. data/lib/chef/knife/cosmic_volume_delete.rb +97 -0
  51. data/lib/chef/knife/cosmic_volume_detach.rb +61 -0
  52. data/lib/chef/knife/cosmic_volume_list.rb +77 -0
  53. data/lib/chef/knife/cosmic_zone_list.rb +53 -0
  54. data/lib/knife-cosmic/connection.rb +1046 -0
  55. metadata +127 -0
@@ -0,0 +1,50 @@
1
+ #
2
+ # Original knife-cloudstack author:: Sander Botman (<sbotman@schubergphilis.com>)
3
+ # Copyright:: Copyright (c) 2013 Sander Botman.
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
+ require 'chef/knife/cosmic_baselist'
21
+
22
+ module Knifecosmic
23
+ class CosmicOscategoryList < Chef::Knife
24
+
25
+ include Chef::Knife::KnifecosmicBaseList
26
+
27
+ banner "knife cosmic oscategory list (options)"
28
+
29
+ option :keyword,
30
+ :long => "--keyword KEY",
31
+ :description => "List by keyword"
32
+
33
+ def run
34
+ validate_base_options
35
+
36
+ columns = [
37
+ 'Name :name',
38
+ 'ID :id'
39
+ ]
40
+
41
+ params = { 'command' => "listOsCategories" }
42
+ params['filter'] = locate_config_value(:filter) if locate_config_value(:filter)
43
+ params['keyword'] = locate_config_value(:keyword) if locate_config_value(:keyword)
44
+
45
+ result = connection.list_object(params, "oscategory")
46
+ list_object(columns, result)
47
+ end
48
+
49
+ end
50
+ end
@@ -0,0 +1,52 @@
1
+ #
2
+ # Original knife-cloudstack author:: Sander Botman (<sbotman@schubergphilis.com>)
3
+ # Copyright:: Copyright (c) 2013 Sander Botman.
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
+ require 'chef/knife/cosmic_baselist'
21
+
22
+ module Knifecosmic
23
+ class CosmicOstypeList < Chef::Knife
24
+
25
+ include Chef::Knife::KnifecosmicBaseList
26
+
27
+ banner "knife cosmic ostype list (options)"
28
+
29
+ option :keyword,
30
+ :long => "--keyword KEY",
31
+ :description => "List by keyword"
32
+
33
+ def run
34
+ validate_base_options
35
+
36
+ columns = [
37
+ 'Description :description',
38
+ 'ID :id',
39
+ 'OS Categorie ID :oscategoryid'
40
+ ]
41
+
42
+ params = { 'command' => "listOsTypes" }
43
+ params['filter'] = locate_config_value(:filter) if locate_config_value(:filter)
44
+ params['listall'] = locate_config_value(:listall) if locate_config_value(:listall)
45
+ params['keyword'] = locate_config_value(:keyword) if locate_config_value(:keyword)
46
+
47
+ result = connection.list_object(params, "ostype")
48
+ list_object(columns, result)
49
+ end
50
+
51
+ end
52
+ end
@@ -0,0 +1,60 @@
1
+ #
2
+ # Original knife-cloudstack author:: Sander Botman (<sbotman@schubergphilis.com>)
3
+ # Copyright:: Copyright (c) 2013 Sander Botman.
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
+ require 'chef/knife/cosmic_baselist'
21
+
22
+ module Knifecosmic
23
+ class CosmicPodList < Chef::Knife
24
+
25
+ include Chef::Knife::KnifecosmicBaseList
26
+
27
+ banner "knife cosmic pod list (options)"
28
+
29
+ option :name,
30
+ :long => "--name NAME",
31
+ :description => "Specify router pod to list"
32
+
33
+ option :keyword,
34
+ :long => "--keyword KEY",
35
+ :description => "List by keyword"
36
+
37
+ def run
38
+ validate_base_options
39
+
40
+ columns = [
41
+ 'Name :name',
42
+ 'Zone :zonename',
43
+ 'Gateway :gateway',
44
+ 'Netmask :netmask',
45
+ 'Start IP :startip',
46
+ 'End IP :endip',
47
+ 'AllocationState :allocationstate'
48
+ ]
49
+
50
+ params = { 'command' => "listPods" }
51
+ params['filter'] = locate_config_value(:filter) if locate_config_value(:filter)
52
+ params['keyword'] = locate_config_value(:keyword) if locate_config_value(:keyword)
53
+ params['name'] = locate_config_value(:name) if locate_config_value(:name)
54
+
55
+ result = connection.list_object(params, "pod")
56
+ list_object(columns, result)
57
+ end
58
+
59
+ end
60
+ end
@@ -0,0 +1,63 @@
1
+ #
2
+ # Original knife-cloudstack author:: Sander Botman (<sbotman@schubergphilis.com>)
3
+ # Copyright:: Copyright (c) 2013 Sander Botman.
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
+ require 'chef/knife/cosmic_baselist'
21
+
22
+ module Knifecosmic
23
+ class CosmicProjectList < Chef::Knife
24
+
25
+ include Chef::Knife::KnifecosmicBaseList
26
+
27
+ banner "knife cosmic project list (options)"
28
+
29
+ option :listall,
30
+ :long => "--listall",
31
+ :description => "List all projects",
32
+ :boolean => true
33
+
34
+ option :name,
35
+ :long => "--name NAME",
36
+ :description => "Specify project name to list"
37
+
38
+ option :keyword,
39
+ :long => "--keyword KEY",
40
+ :description => "List by keyword"
41
+
42
+ def run
43
+ validate_base_options
44
+
45
+ columns = [
46
+ 'Name :name',
47
+ 'Account :account',
48
+ 'Domain :domain',
49
+ 'State :state'
50
+ ]
51
+
52
+ params = { 'command' => "listProjects" }
53
+ params['filter'] = locate_config_value(:filter) if locate_config_value(:filter)
54
+ params['listall'] = locate_config_value(:listall) if locate_config_value(:listall)
55
+ params['keyword'] = locate_config_value(:keyword) if locate_config_value(:keyword)
56
+ params['name'] = locate_config_value(:name) if locate_config_value(:name)
57
+
58
+ result = connection.list_object(params, "project")
59
+ list_object(columns, result)
60
+ end
61
+
62
+ end
63
+ end
@@ -0,0 +1,55 @@
1
+ #
2
+ # Original knife-cloudstack author:: Sander Botman (<sbotman@schubergphilis.com>)
3
+ # Copyright:: Copyright (c) 2013 Sander Botman.
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
+ require 'chef/knife/cosmic_baselist'
21
+
22
+ module Knifecosmic
23
+ class CosmicPublicipList < Chef::Knife
24
+
25
+ include Chef::Knife::KnifecosmicBaseList
26
+
27
+ banner "knife cosmic publicip list (options)"
28
+
29
+ option :listall,
30
+ :long => "--listall",
31
+ :description => "List all public ip addresses",
32
+ :boolean => true
33
+
34
+ def run
35
+ validate_base_options
36
+
37
+ columns = [
38
+ 'IP :ipaddress',
39
+ 'Account :account',
40
+ 'Domain :domain',
41
+ 'Zone :zonename',
42
+ 'State :state',
43
+ 'Allocated :allocated'
44
+ ]
45
+
46
+ params = { 'command' => "listPublicIpAddresses" }
47
+ params['filter'] = locate_config_value(:filter) if locate_config_value(:filter)
48
+ params['listall'] = locate_config_value(:listall) if locate_config_value(:listall)
49
+
50
+ result = connection.list_object(params, "publicipaddress")
51
+ list_object(columns, result)
52
+ end
53
+
54
+ end
55
+ end
@@ -0,0 +1,64 @@
1
+ #
2
+ # Original knife-cloudstack author:: Sander Botman (<sbotman@schubergphilis.com>)
3
+ # Copyright:: Copyright (c) 2013 Sander Botman.
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
+ require 'chef/knife/cosmic_baselist'
21
+
22
+ module Knifecosmic
23
+ class CosmicRouterList < Chef::Knife
24
+
25
+ include Chef::Knife::KnifecosmicBaseList
26
+
27
+ banner "knife cosmic router list (options)"
28
+
29
+ option :listall,
30
+ :long => "--listall",
31
+ :description => "List all routers",
32
+ :boolean => true
33
+
34
+ option :name,
35
+ :long => "--name NAME",
36
+ :description => "Specify router name to list"
37
+
38
+ option :keyword,
39
+ :long => "--keyword KEY",
40
+ :description => "List by keyword"
41
+
42
+ def run
43
+ validate_base_options
44
+
45
+ columns = [
46
+ 'Name :name',
47
+ 'Account :account',
48
+ 'Domain :domain',
49
+ 'State :state',
50
+ 'Address :publicip'
51
+ ]
52
+
53
+ params = { 'command' => "listRouters" }
54
+ params['filter'] = locate_config_value(:filter) if locate_config_value(:filter)
55
+ params['listall'] = locate_config_value(:listall) if locate_config_value(:listall)
56
+ params['keyword'] = locate_config_value(:keyword) if locate_config_value(:keyword)
57
+ params['name'] = locate_config_value(:name) if locate_config_value(:name)
58
+
59
+ result = connection.list_object(params, "router")
60
+ list_object(columns, result)
61
+ end
62
+
63
+ end
64
+ end
@@ -0,0 +1,59 @@
1
+ #
2
+ # Original knife-cloudstack author:: Ryan Holmes (<rholmes@edmunds.com>)
3
+ # Original knife-cloudstack author:: Sander Botman (<sbotman@schubergphilis.com>)
4
+ # Original knife-cloudstack author:: Sebastien Goasguen (<runseb@gmail.com>)
5
+ # Copyright:: Copyright (c) 2011 Edmunds, Inc.
6
+ # Copyright:: Copyright (c) 2013 Sander Botman.
7
+ # License:: Apache License, Version 2.0
8
+ #
9
+ # Licensed under the Apache License, Version 2.0 (the "License");
10
+ # you may not use this file except in compliance with the License.
11
+ # You may obtain a copy of the License at
12
+ #
13
+ # http://www.apache.org/licenses/LICENSE-2.0
14
+ #
15
+ # Unless required by applicable law or agreed to in writing, software
16
+ # distributed under the License is distributed on an "AS IS" BASIS,
17
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ # See the License for the specific language governing permissions and
19
+ # limitations under the License.
20
+ #
21
+
22
+ require 'chef/knife'
23
+ require 'chef/knife/cosmic_baselist'
24
+
25
+ module Knifecosmic
26
+ class CosmicSecuritygroupList < Chef::Knife
27
+
28
+ include Chef::Knife::KnifecosmicBaseList
29
+
30
+ banner "knife cosmic securitygroup list (options)"
31
+
32
+ option :name,
33
+ :long => "--name NAME",
34
+ :description => "Specify security group to list"
35
+
36
+ option :keyword,
37
+ :long => "--keyword NAME",
38
+ :description => "Specify part of servicename to list"
39
+
40
+ def run
41
+ validate_base_options
42
+
43
+ columns = [
44
+ 'Name :name',
45
+ 'Description :description',
46
+ 'Account :account'
47
+ ]
48
+
49
+ params = { 'command' => "listSecurityGroups" }
50
+ params['filter'] = locate_config_value(:filter) if locate_config_value(:filter)
51
+ params['keyword'] = locate_config_value(:keyword) if locate_config_value(:keyword)
52
+ params['name'] = locate_config_value(:name) if locate_config_value(:name)
53
+
54
+ result = connection.list_object(params, "securitygroup")
55
+ list_object(columns, result)
56
+ end
57
+
58
+ end
59
+ end
@@ -0,0 +1,109 @@
1
+ #
2
+ # Original knife-cloudstack author:: John E. Vincent (<lusis.org+github.com@gmail.com>)
3
+ # Copyright:: Copyright (c) 2013 John E. Vincent
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/cosmic_base'
20
+ require 'chef/knife/cosmic_baselist'
21
+
22
+ module Knifecosmic
23
+ class CosmicServerAddNic < Chef::Knife
24
+
25
+ include Chef::Knife::KnifecosmicBase
26
+ include Chef::Knife::KnifecosmicBaseList
27
+
28
+ deps do
29
+ require 'knife-cosmic/connection'
30
+ require 'chef/knife'
31
+ Chef::Knife.load_deps
32
+ end
33
+
34
+ banner "knife cosmic server add nic SERVERID NETWORKID (--ipaddress X.X.X.X)"
35
+
36
+ option :ipaddress,
37
+ :long => "--ipaddress IPADDRESS",
38
+ :description => "Attach with the specified IP",
39
+ :default => nil
40
+
41
+
42
+ def run
43
+ validate_base_options
44
+
45
+ @server_id, @network_id = name_args
46
+
47
+ if @network_id.nil? || @server_id.nil?
48
+ show_usage
49
+ ui.fatal("You must provide both a network id and a server id")
50
+ exit(1)
51
+ end
52
+
53
+ @ipaddr = locate_config_value(:ipaddress)
54
+
55
+ object_list = []
56
+ if locate_config_value(:fields)
57
+ locate_config_value(:fields).split(',').each { |n| object_list << ui.color(("#{n}").strip, :bold) }
58
+ else
59
+ object_list << ui.color('Server', :bold)
60
+ object_list << ui.color('Network', :bold)
61
+ object_list << ui.color('Type', :bold)
62
+ object_list << ui.color('Default', :bold)
63
+ object_list << ui.color('Address', :bold)
64
+ object_list << ui.color('Gateway', :bold)
65
+ object_list << ui.color('Netmask', :bold)
66
+ object_list << ui.color('ID', :bold)
67
+ end
68
+
69
+ columns = object_list.count
70
+
71
+ connection_result = connection.add_nic_to_vm(
72
+ @network_id,
73
+ @server_id,
74
+ @ipaddr
75
+ )
76
+
77
+ output_format(connection_result)
78
+
79
+ object_list << connection_result['name']
80
+ object_list << ''
81
+ object_list << ''
82
+ object_list << ''
83
+ object_list << ''
84
+ object_list << ''
85
+ object_list << ''
86
+ object_list << ''
87
+ if connection_result['nic']
88
+ connection_result['nic'].each do |r|
89
+ if locate_config_value(:fields)
90
+ locate_config_value(:fields).downcase.split(',').each { |n| object_list << ((r[("#{n}").strip]).to_s || 'N/A') }
91
+ else
92
+ object_list << ''
93
+ object_list << r['networkname'].to_s
94
+ object_list << r['type'].to_s
95
+ object_list << (r['isdefault'] ? r['isdefault'].to_s : 'false')
96
+ object_list << (r['ipaddress'] || '')
97
+ object_list << (r['gateway'] || '')
98
+ object_list << (r['netmask'] || '')
99
+ object_list << (r['networkid'] || '')
100
+ end
101
+ end
102
+ puts ui.list(object_list, :uneven_columns_across, columns)
103
+ list_object_fields(connection_result) if locate_config_value(:fieldlist)
104
+ else
105
+ ui.error("No nicosmic returned in response")
106
+ end
107
+ end
108
+ end
109
+ end