knife-cloudstack-fog 0.5.0 → 0.5.1

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.
@@ -1,57 +1,57 @@
1
- # Author:: Jeff Moody (<jmoody@datapipe.com>)
2
- # Copyright:: Copyright (c) 2012 Datapipe
3
- # License:: Apache License, Version 2.0
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
- #
17
-
18
-
19
- require 'chef/knife/cloudstack_base'
20
-
21
- class Chef
22
- class Knife
23
- class CloudstackDiskofferingList < Knife
24
-
25
- include Knife::CloudstackBase
26
-
27
- banner "knife cloudstack diskoffering list"
28
-
29
- def run
30
- $stdout.sync = true
31
-
32
- validate!
33
-
34
- diskoffering_list = [
35
- ui.color('ID', :bold),
36
- ui.color('Name', :bold),
37
- ui.color('Description', :bold),
38
- ui.color('Disk Size (in GB)', :bold)
39
- ]
40
- response = connection.list_disk_offerings['listdiskofferingsresponse']
41
- if diskofferings = response['diskoffering']
42
- diskofferings.each do |diskoffering|
43
- diskoffering_list << diskoffering['id'].to_s
44
- diskoffering_list << diskoffering['name'].to_s
45
- diskoffering_list << diskoffering['displaytext'].to_s
46
- disk_size = diskoffering['disksize']
47
- diskoffering_list << disk_size.to_s
48
-
49
- end
50
- end
51
- puts ui.list(diskoffering_list, :columns_across, 4)
52
-
53
- end
54
-
55
- end
56
- end
57
- end
1
+ # Author:: Jeff Moody (<jmoody@datapipe.com>)
2
+ # Copyright:: Copyright (c) 2012 Datapipe
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+
19
+ require 'chef/knife/cloudstack_base'
20
+
21
+ class Chef
22
+ class Knife
23
+ class CloudstackDiskofferingList < Knife
24
+
25
+ include Knife::CloudstackBase
26
+
27
+ banner "knife cloudstack diskoffering list"
28
+
29
+ def run
30
+ $stdout.sync = true
31
+
32
+ validate!
33
+
34
+ diskoffering_list = [
35
+ ui.color('ID', :bold),
36
+ ui.color('Name', :bold),
37
+ ui.color('Description', :bold),
38
+ ui.color('Disk Size (in GB)', :bold)
39
+ ]
40
+ response = connection.list_disk_offerings['listdiskofferingsresponse']
41
+ if diskofferings = response['diskoffering']
42
+ diskofferings.each do |diskoffering|
43
+ diskoffering_list << diskoffering['id'].to_s
44
+ diskoffering_list << diskoffering['name'].to_s
45
+ diskoffering_list << diskoffering['displaytext'].to_s
46
+ disk_size = diskoffering['disksize']
47
+ diskoffering_list << disk_size.to_s
48
+
49
+ end
50
+ end
51
+ puts ui.list(diskoffering_list, :columns_across, 4)
52
+
53
+ end
54
+
55
+ end
56
+ end
57
+ end
@@ -1,102 +1,102 @@
1
- # Author:: Takashi Kanai (<anikundesu@gmail.com>)
2
- # Copyright:: Copyright (c) 2012 IDC Frontier Inc.
3
- # License:: Apache License, Version 2.0
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
- #
17
-
18
-
19
- require 'chef/knife/cloudstack_base'
20
-
21
- class Chef
22
- class Knife
23
- class CloudstackKeypairCreate < Knife
24
-
25
- include Knife::CloudstackBase
26
-
27
- banner "knife cloudstack keypair create -k NAME (options)"
28
-
29
- option :name,
30
- :short => "-k KEYPAIR",
31
- :long => "--keypair KEYPAIR",
32
- :description => "The name of the Key Pair to create."
33
-
34
- option :publickey,
35
- :short => "-p publickey",
36
- :long => "--public-key publickey",
37
- :description => "The public key to register."
38
-
39
- option :outfile,
40
- :short => "-o FILENAME",
41
- :long => "--out-file FILENAME",
42
- :description => "The output filename of created private key."
43
-
44
- def run
45
- $stdout.sync = true
46
-
47
- validate!
48
-
49
- options = {}
50
- if locate_config_value(:publickey) != nil
51
- options['publickey'] = locate_config_value(:publickey)
52
- mode = 'register'
53
- if locate_config_value(:name) != nil
54
- options['name'] = locate_config_value(:name)
55
- end
56
- else
57
- mode = 'create'
58
- if locate_config_value(:name) != nil
59
- keypair_name = locate_config_value(:name)
60
- end
61
- end
62
-
63
- case mode
64
- when 'register'
65
- response = connection.register_ssh_key_pair(options)
66
- sshkeypair = response['registersshkeypairresponse']['keypair']
67
-
68
- sshkeypair_list = [
69
- ui.color('Name', :bold),
70
- ui.color('Fingerprint', :bold),
71
- ui.color('Private Key', :bold)
72
- ]
73
-
74
- sshkeypair_list << sshkeypair['name'].to_s
75
- sshkeypair_list << sshkeypair['fingerprint'].to_s
76
- sshkeypair_list << sshkeypair['privatekey'].to_s
77
- puts ui.list(sshkeypair_list, :columns_across, 3)
78
- when 'create'
79
- response = connection.create_ssh_key_pair(keypair_name,options)
80
- sshkeypair = response['createsshkeypairresponse']['keypair']
81
-
82
- if locate_config_value(:outfile) != nil
83
- output = locate_config_value(:outfile)
84
- File.open(output,'w'){|f|
85
- f.print sshkeypair['privatekey'].to_s
86
- }
87
- else
88
- sshkeypair_list = [
89
- ui.color('Private Key', :bold)
90
- ]
91
- sshkeypair_list << sshkeypair['privatekey'].to_s
92
- puts ui.list(sshkeypair_list, :columns_across, 3)
93
- end
94
- else
95
- puts 'Error. Missing Keypair Name (-k) option.'
96
- end
97
-
98
- end
99
-
100
- end
101
- end
102
- end
1
+ # Author:: Takashi Kanai (<anikundesu@gmail.com>)
2
+ # Copyright:: Copyright (c) 2012 IDC Frontier Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+
19
+ require 'chef/knife/cloudstack_base'
20
+
21
+ class Chef
22
+ class Knife
23
+ class CloudstackKeypairCreate < Knife
24
+
25
+ include Knife::CloudstackBase
26
+
27
+ banner "knife cloudstack keypair create -k NAME (options)"
28
+
29
+ option :name,
30
+ :short => "-k KEYPAIR",
31
+ :long => "--keypair KEYPAIR",
32
+ :description => "The name of the Key Pair to create."
33
+
34
+ option :publickey,
35
+ :short => "-p publickey",
36
+ :long => "--public-key publickey",
37
+ :description => "The public key to register."
38
+
39
+ option :outfile,
40
+ :short => "-o FILENAME",
41
+ :long => "--out-file FILENAME",
42
+ :description => "The output filename of created private key."
43
+
44
+ def run
45
+ $stdout.sync = true
46
+
47
+ validate!
48
+
49
+ options = {}
50
+ if locate_config_value(:publickey) != nil
51
+ options['publickey'] = locate_config_value(:publickey)
52
+ mode = 'register'
53
+ if locate_config_value(:name) != nil
54
+ options['name'] = locate_config_value(:name)
55
+ end
56
+ else
57
+ mode = 'create'
58
+ if locate_config_value(:name) != nil
59
+ keypair_name = locate_config_value(:name)
60
+ end
61
+ end
62
+
63
+ case mode
64
+ when 'register'
65
+ response = connection.register_ssh_key_pair(options)
66
+ sshkeypair = response['registersshkeypairresponse']['keypair']
67
+
68
+ sshkeypair_list = [
69
+ ui.color('Name', :bold),
70
+ ui.color('Fingerprint', :bold),
71
+ ui.color('Private Key', :bold)
72
+ ]
73
+
74
+ sshkeypair_list << sshkeypair['name'].to_s
75
+ sshkeypair_list << sshkeypair['fingerprint'].to_s
76
+ sshkeypair_list << sshkeypair['privatekey'].to_s
77
+ puts ui.list(sshkeypair_list, :columns_across, 3)
78
+ when 'create'
79
+ response = connection.create_ssh_key_pair(keypair_name,options)
80
+ sshkeypair = response['createsshkeypairresponse']['keypair']
81
+
82
+ if locate_config_value(:outfile) != nil
83
+ output = locate_config_value(:outfile)
84
+ File.open(output,'w'){|f|
85
+ f.print sshkeypair['privatekey'].to_s
86
+ }
87
+ else
88
+ sshkeypair_list = [
89
+ ui.color('Private Key', :bold)
90
+ ]
91
+ sshkeypair_list << sshkeypair['privatekey'].to_s
92
+ puts ui.list(sshkeypair_list, :columns_across, 3)
93
+ end
94
+ else
95
+ puts 'Error. Missing Keypair Name (-k) option.'
96
+ end
97
+
98
+ end
99
+
100
+ end
101
+ end
102
+ end
@@ -1,49 +1,49 @@
1
- # Author:: Takashi Kanai (<anikundesu@gmail.com>)
2
- # Copyright:: Copyright (c) 2012 IDC Frontier Inc.
3
- # License:: Apache License, Version 2.0
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
- #
17
-
18
-
19
- require 'chef/knife/cloudstack_base'
20
-
21
- class Chef
22
- class Knife
23
- class CloudstackKeypairDelete < Knife
24
-
25
- include Knife::CloudstackBase
26
-
27
- banner "knife cloudstack keypair delete NAME"
28
-
29
-
30
- def run
31
- if @name_args.nil? || @name_args.empty?
32
- puts "#{ui.color("Please provide a keypair name.", :red)}"
33
- end
34
-
35
- @name_args.each do |keypair_name|
36
- response = connection.list_ssh_key_pairs('name' => keypair_name)
37
- fingerprint = response['listsshkeypairsresponse']['sshkeypair'].first['fingerprint']
38
- real_keypair_name = response['listsshkeypairsresponse']['sshkeypair'].first['name']
39
- puts "#{ui.color("Name", :red)}: #{real_keypair_name}"
40
- puts "#{ui.color("Fingerprint", :red)}: #{fingerprint}"
41
- puts "\n"
42
- confirm("#{ui.color("Do you really want to delete this keypair?", :red)}")
43
- connection.delete_ssh_key_pair(real_keypair_name)
44
- ui.warn("Deleted SSH keypair #{real_keypair_name}")
45
- end
46
- end
47
- end
48
- end
49
- end
1
+ # Author:: Takashi Kanai (<anikundesu@gmail.com>)
2
+ # Copyright:: Copyright (c) 2012 IDC Frontier Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+
19
+ require 'chef/knife/cloudstack_base'
20
+
21
+ class Chef
22
+ class Knife
23
+ class CloudstackKeypairDelete < Knife
24
+
25
+ include Knife::CloudstackBase
26
+
27
+ banner "knife cloudstack keypair delete NAME"
28
+
29
+
30
+ def run
31
+ if @name_args.nil? || @name_args.empty?
32
+ puts "#{ui.color("Please provide a keypair name.", :red)}"
33
+ end
34
+
35
+ @name_args.each do |keypair_name|
36
+ response = connection.list_ssh_key_pairs('name' => keypair_name)
37
+ fingerprint = response['listsshkeypairsresponse']['sshkeypair'].first['fingerprint']
38
+ real_keypair_name = response['listsshkeypairsresponse']['sshkeypair'].first['name']
39
+ puts "#{ui.color("Name", :red)}: #{real_keypair_name}"
40
+ puts "#{ui.color("Fingerprint", :red)}: #{fingerprint}"
41
+ puts "\n"
42
+ confirm("#{ui.color("Do you really want to delete this keypair?", :red)}")
43
+ connection.delete_ssh_key_pair(real_keypair_name)
44
+ ui.warn("Deleted SSH keypair #{real_keypair_name}")
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -1,53 +1,53 @@
1
- # Author:: Jeff Moody (<jmoody@datapipe.com>)
2
- # Copyright:: Copyright (c) 2012 Datapipe
3
- # License:: Apache License, Version 2.0
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
- #
17
-
18
-
19
- require 'chef/knife/cloudstack_base'
20
-
21
- class Chef
22
- class Knife
23
- class CloudstackKeypairList < Knife
24
-
25
- include Knife::CloudstackBase
26
-
27
- banner "knife cloudstack keypair list"
28
-
29
- def run
30
- $stdout.sync = true
31
-
32
- validate!
33
-
34
- sshkeypair_list = [
35
- ui.color('Name', :bold),
36
- ui.color('Fingerprint', :bold),
37
- ui.color('Private Key', :bold)
38
- ]
39
- response = connection.list_ssh_key_pairs['listsshkeypairsresponse']
40
- if sshkeypairs = response['sshkeypair']
41
- sshkeypairs.each do |sshkeypair|
42
- sshkeypair_list << sshkeypair['name'].to_s
43
- sshkeypair_list << sshkeypair['fingerprint'].to_s
44
- sshkeypair_list << sshkeypair['privatekey'].to_s
45
- end
46
- end
47
- puts ui.list(sshkeypair_list, :columns_across, 3)
48
-
49
- end
50
-
51
- end
52
- end
53
- end
1
+ # Author:: Jeff Moody (<jmoody@datapipe.com>)
2
+ # Copyright:: Copyright (c) 2012 Datapipe
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+
19
+ require 'chef/knife/cloudstack_base'
20
+
21
+ class Chef
22
+ class Knife
23
+ class CloudstackKeypairList < Knife
24
+
25
+ include Knife::CloudstackBase
26
+
27
+ banner "knife cloudstack keypair list"
28
+
29
+ def run
30
+ $stdout.sync = true
31
+
32
+ validate!
33
+
34
+ sshkeypair_list = [
35
+ ui.color('Name', :bold),
36
+ ui.color('Fingerprint', :bold),
37
+ ui.color('Private Key', :bold)
38
+ ]
39
+ response = connection.list_ssh_key_pairs['listsshkeypairsresponse']
40
+ if sshkeypairs = response['sshkeypair']
41
+ sshkeypairs.each do |sshkeypair|
42
+ sshkeypair_list << sshkeypair['name'].to_s
43
+ sshkeypair_list << sshkeypair['fingerprint'].to_s
44
+ sshkeypair_list << sshkeypair['privatekey'].to_s
45
+ end
46
+ end
47
+ puts ui.list(sshkeypair_list, :columns_across, 3)
48
+
49
+ end
50
+
51
+ end
52
+ end
53
+ end