knife-cloudstack-fog 0.2.15 → 0.2.16

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.
data/README.rdoc CHANGED
@@ -71,6 +71,14 @@ Outputs a list of all available service offerings (available hardware configurat
71
71
 
72
72
  Outputs a list of all available templates available to the currently configured Cloudstack Compute cloud account. A template is a collection of files used to create or rebuild a server. This data can be useful when choosing an template ID to pass to the <tt>knife cloudstack server create</tt> subcommand.
73
73
 
74
+ == knife cloudstack keypair create
75
+
76
+ Create a new SSH keypair or register a public key to the currently configured Cloudstack Compute cloud account. This command is valuable to provide password recovery options as well as associating a Cloudstack keypair with an instance for any advanced authentication methods when instantiating a server with the <tt>knife cloudstack server create</tt> subcommand.
77
+
78
+ == knife cloudstack keypair delete
79
+
80
+ Delete a keypair which is abailable to the currently configured Cloudstack Compute cloud account.
81
+
74
82
  == knife cloudstack keypair list
75
83
 
76
84
  Outputs a list of all available keypairs available to the currently configured Cloudstack Compute cloud account. This information is valuable to provide password recovery options as well as associating a Cloudstack keypair with an instance for any advanced authentication methods when instantiating a server with the <tt>knife cloudstack server create</tt> subcommand.
@@ -79,6 +87,18 @@ Outputs a list of all available keypairs available to the currently configured C
79
87
 
80
88
  Outputs a list of all available network offerings available to the currently configured Cloudstack Compute cloud account. This information is necessary to locate a network ID when instantiating a server with the <tt>knife cloudstack server create</tt> subcommand if your Cloudstack Compute cloud requires a server be associated with a particular network offering.
81
89
 
90
+ == knife cloudstack portforwardingrule list
91
+
92
+ Outputs a list of all port forwarding rules.
93
+
94
+ == knife cloudstack publicip create
95
+
96
+ Assign a new public ip address to the zone specified by -z option. This sub command is available only on advanced network (VLAN enabled) zone.
97
+
98
+ == knife cloudstack publicip list
99
+
100
+ Outputs a list of all public ip addresses assigned to the account. This sub command is available only on advanced network (VLAN enabled) zone.
101
+
82
102
  == knife cloudstack securitygroup list
83
103
 
84
104
  Outputs a list of all available security groups defined for the currently configured Cloudstack Compute cloud account. This information is necessary to locate a security group ID when instantiating a server with the <tt>knife cloudstack server create</tt> subcommand if your Cloudstack Compute cloud requires a server be associated with a security group.
@@ -95,7 +115,7 @@ Outputs a list of all available disk offerings available to the currently config
95
115
  = LICENSE:
96
116
 
97
117
  Author:: Chirag Jog (<chirag@clogeny.com>), Jeff Moody (<jmoody@datapipe.com>), dfuentes77, Takashi Kanai (<anikundesu@gmail.com>)
98
- Copyright:: Copyright (c) 2011 Clogeny, 2012 Datapipe
118
+ Copyright:: Copyright (c) 2011 Clogeny, 2012 Datapipe, 2012 IDC Frontier Inc.
99
119
  License:: Apache License, Version 2.0
100
120
 
101
121
  Licensed under the Apache License, Version 2.0 (the "License");
@@ -0,0 +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 (options)"
28
+
29
+ option :name,
30
+ :short => "-k KEYPAIR",
31
+ :long => "--keypair KEYPAIR",
32
+ :description => "The Name of 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 -k option.'
96
+ end
97
+
98
+ end
99
+
100
+ end
101
+ end
102
+ end
@@ -0,0 +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 [NAME] (options)"
28
+
29
+
30
+ def run
31
+ if @name_args.nil?
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
@@ -0,0 +1,63 @@
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 CloudstackPortforwardingruleList < Knife
24
+
25
+ include Knife::CloudstackBase
26
+
27
+ banner "knife cloudstack portforwardingrule list (options)"
28
+
29
+ def run
30
+ $stdout.sync = true
31
+
32
+ validate!
33
+
34
+ rule_list = [
35
+ ui.color('ID', :bold),
36
+ ui.color('PublicIPID', :bold),
37
+ ui.color('PublicIP', :bold),
38
+ ui.color('PublicPort', :bold),
39
+ ui.color('PrivatePort', :bold),
40
+ ui.color('Protocol', :bold),
41
+ ui.color('VirtualMachineID', :bold),
42
+ ui.color('VirtualMachineName', :bold)
43
+ ]
44
+ response = connection.list_port_forwarding_rules['listportforwardingrulesresponse']
45
+ if rules = response['portforwardingrule']
46
+ rules.each do |rule|
47
+ rule_list << rule['id'].to_s
48
+ rule_list << rule['ipaddressid'].to_s
49
+ rule_list << rule['ipaddress'].to_s
50
+ rule_list << rule['publicport'].to_s
51
+ rule_list << rule['privateport'].to_s
52
+ rule_list << rule['protocol'].to_s
53
+ rule_list << rule['virtualmachineid'].to_s
54
+ rule_list << rule['virtualmachinename'].to_s
55
+ end
56
+ end
57
+ puts ui.list(rule_list, :columns_across, 8)
58
+
59
+ end
60
+
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,90 @@
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 CloudstackPublicipCreate < Knife
24
+
25
+ include Knife::CloudstackBase
26
+
27
+ banner "knife cloudstack publicip create (options)"
28
+
29
+ option :zoneid,
30
+ :short => "-z ZONEID",
31
+ :long => "--zoneid ZONEID",
32
+ :description => "[REQUIRED]The CloudStack zone ID to create new public IP."
33
+
34
+ option :networkid,
35
+ :long => "--network-id NETWORKID",
36
+ :description => "[OPTIONAL]The CloudStack network ID to crate new public IP."
37
+
38
+ def run
39
+ $stdout.sync = true
40
+
41
+ validate!
42
+
43
+ options = {}
44
+
45
+ if locate_config_value(:networkid) != nil
46
+ options['networkid']=locate_config_value(:networkid)
47
+ end
48
+
49
+ if locate_config_value(:zoneid) != nil
50
+ options['zoneid']=locate_config_value(:zoneid)
51
+
52
+ publicip_list = [
53
+ ui.color('ID', :bold),
54
+ ui.color('ipaddress', :bold),
55
+ ui.color('isSourceNAT', :bold),
56
+ ui.color('isStaticNAT', :bold)
57
+ ]
58
+
59
+ response = connection.acquire_ip_address(options)
60
+ publicipid = response['associateipaddressresponse']['id']
61
+ jobid = response['associateipaddressresponse'].fetch('jobid')
62
+
63
+ publicip_assign = connection.query_async_job_result('jobid'=>jobid)
64
+ print "#{ui.color("Waiting for assigning Public IP", :magenta)}"
65
+ while publicip_assign['queryasyncjobresultresponse'].fetch('jobstatus') != 1
66
+ print "#{ui.color(".", :magenta)}"
67
+ sleep(5)
68
+ publicip_assign = connection.query_async_job_result('jobid'=>jobid)
69
+ end
70
+ puts "\n\n"
71
+
72
+ publicip_assign = connection.query_async_job_result('jobid'=>jobid)
73
+ publicip = publicip_assign['queryasyncjobresultresponse']['jobresult']['ipaddress']
74
+
75
+ publicip_list << publicip['id'].to_s
76
+ publicip_list << publicip['ipaddress'].to_s
77
+ publicip_list << publicip['issourcenat'].to_s
78
+ publicip_list << publicip['isstaticnat'].to_s
79
+
80
+ puts ui.list(publicip_list, :columns_across, 4)
81
+
82
+ else
83
+ puts 'Error. Missing -z option.'
84
+ end
85
+
86
+ end
87
+
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,57 @@
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 CloudstackPublicipList < Knife
24
+
25
+ include Knife::CloudstackBase
26
+
27
+ banner "knife cloudstack publicip list (options)"
28
+
29
+ def run
30
+ $stdout.sync = true
31
+
32
+ validate!
33
+
34
+ publicip_list = [
35
+ ui.color('ID', :bold),
36
+ ui.color('ipaddress', :bold),
37
+ ui.color('isSourceNAT', :bold),
38
+ ui.color('isStaticNAT', :bold),
39
+ ui.color('VirtualMachineDisplayName', :bold)
40
+ ]
41
+ response = connection.list_public_ip_addresses['listpublicipaddressesresponse']
42
+ if publicips = response['publicipaddress']
43
+ publicips.each do |publicip|
44
+ publicip_list << publicip['id'].to_s
45
+ publicip_list << publicip['ipaddress'].to_s
46
+ publicip_list << publicip['issourcenat'].to_s
47
+ publicip_list << publicip['isstaticnat'].to_s
48
+ publicip_list << publicip['virtualmachinedisplayname'].to_s
49
+ end
50
+ end
51
+ puts ui.list(publicip_list, :columns_across, 5)
52
+
53
+ end
54
+
55
+ end
56
+ end
57
+ end
@@ -131,7 +131,7 @@ class Chef
131
131
  bootstrap.config[:run_list] = config[:run_list]
132
132
  bootstrap.config[:ssh_user] = user
133
133
  bootstrap.config[:ssh_password] = password
134
- bootstrap.config[:identity_file] = config[:identity_file]
134
+ bootstrap.config[:identity_file] = locate_config_value(:identity_file)
135
135
  bootstrap.config[:chef_node_name] = config[:server_name] if config[:server_name]
136
136
  bootstrap.config[:prerelease] = config[:prerelease]
137
137
  bootstrap.config[:bootstrap_version] = locate_config_value(:bootstrap_version)
@@ -1,6 +1,6 @@
1
1
  module Knife
2
2
  module Cloudstack
3
- VERSION = "0.2.15"
3
+ VERSION = "0.2.16"
4
4
  MAJOR, MINOR, TINY = VERSION.split('.')
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-cloudstack-fog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.15
4
+ version: 0.2.16
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2012-08-22 00:00:00.000000000 Z
15
+ date: 2012-10-22 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: fog
@@ -21,7 +21,7 @@ dependencies:
21
21
  requirements:
22
22
  - - ~>
23
23
  - !ruby/object:Gem::Version
24
- version: 1.5.0
24
+ version: 1.6.0
25
25
  type: :runtime
26
26
  prerelease: false
27
27
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,23 @@ dependencies:
29
29
  requirements:
30
30
  - - ~>
31
31
  - !ruby/object:Gem::Version
32
- version: 1.5.0
32
+ version: 1.6.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: chef
35
+ requirement: !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 10.12.0
41
+ type: :runtime
42
+ prerelease: false
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: 10.12.0
33
49
  description: Support for the Chef Knife command, leveraging FOG, for the Citrix CloudStack
34
50
  API
35
51
  email:
@@ -45,8 +61,13 @@ extra_rdoc_files:
45
61
  files:
46
62
  - lib/chef/knife/cloudstack_base.rb
47
63
  - lib/chef/knife/cloudstack_diskoffering_list.rb
64
+ - lib/chef/knife/cloudstack_keypair_create.rb
65
+ - lib/chef/knife/cloudstack_keypair_delete.rb
48
66
  - lib/chef/knife/cloudstack_keypair_list.rb
49
67
  - lib/chef/knife/cloudstack_networks_list.rb
68
+ - lib/chef/knife/cloudstack_portforwardingrule_list.rb
69
+ - lib/chef/knife/cloudstack_publicip_create.rb
70
+ - lib/chef/knife/cloudstack_publicip_list.rb
50
71
  - lib/chef/knife/cloudstack_securitygroup_list.rb
51
72
  - lib/chef/knife/cloudstack_server_create.rb
52
73
  - lib/chef/knife/cloudstack_server_delete.rb
@@ -56,7 +77,7 @@ files:
56
77
  - lib/chef/knife/cloudstack_template_list.rb
57
78
  - lib/chef/knife/cloudstack_volumes_list.rb
58
79
  - lib/chef/knife/cloudstack_zone_list.rb
59
- - lib/knife-cloudstack/version.rb
80
+ - lib/knife-cloudstack-fog/version.rb
60
81
  - README.rdoc
61
82
  - LICENSE
62
83
  homepage: https://github.com/fifthecho/knife-cloudstack-fog