knife-cloudstack-fog 0.2.3 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,115 @@
1
+ # Author:: Chirag Jog (<chirag@clogeny.com>)
2
+ # Copyright:: Copyright (c) 2011 Clogeny Technologies.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Author:: Jeff Moody (<jmoody@datapipe.com>)
6
+ # Copyright:: Copyright (c) 2012 Datapipe
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/cloudstack_base'
23
+
24
+ class Chef
25
+ class Knife
26
+ class CloudstackServerList < Knife
27
+
28
+ include Knife::CloudstackBase
29
+
30
+ banner "knife cloudstack server list (options)"
31
+ option :zoneid,
32
+ :short => "-z ZONEID",
33
+ :long => "--zoneid ZONEID",
34
+ :description => "Limit responses to servers only running in a specific zone (specified by ID #). Default provides servers from all zones.",
35
+ :default => "all"
36
+ option :state,
37
+ :short => "-s STATE",
38
+ :long => "--state STATE",
39
+ :description => "Limit responses to servers only of a given state. Possible values are 'running,' 'stopped,' 'starting,' 'pending,' 'shutting-down,' 'terminated,' and 'stopping.' Default provides servers in all states.",
40
+ :default => "all"
41
+
42
+ def print_servers(server_list,servers,options={})
43
+ server = servers
44
+ if zoneid = options[:zoneid]
45
+ server.reject!{|t| t['zoneid'] != zoneid.to_i}
46
+ end
47
+ if state = options[:state]
48
+ state.downcase!
49
+ server.reject!{|t| t['state'].downcase != state}
50
+ end
51
+
52
+ server.each do |instance|
53
+ server_list << instance['name'].to_s
54
+ server_list << instance['displayname'].to_s
55
+ ip_list = []
56
+ instance['nic'].each do |nic|
57
+ ip_list << nic['ipaddress'].to_s
58
+ end
59
+ server_list << ip_list.join(", ")
60
+ sg_list = []
61
+ instance['securitygroup'].each do |group|
62
+ sg_list << group['name'].to_s
63
+ end
64
+ server_list << sg_list.join(", ")
65
+
66
+ server_list << instance['zonename'].to_s
67
+ server_list << instance['serviceofferingname'].to_s
68
+ server_list << instance['templatedisplaytext'].to_s
69
+
70
+ server_list << begin
71
+ state = instance['state'].to_s.downcase
72
+ case state
73
+ when 'shutting-down','terminated','stopping','stopped'
74
+ ui.color(state, :red)
75
+ when 'pending', 'starting'
76
+ ui.color(state, :yellow)
77
+ else
78
+ ui.color(state, :green)
79
+ end
80
+ end
81
+ end
82
+
83
+ end
84
+
85
+ def run
86
+ $stdout.sync = true
87
+
88
+ validate!
89
+
90
+ server_list = [
91
+ ui.color('Server ID', :bold),
92
+ ui.color('Display Name', :bold),
93
+ ui.color('IP Address', :bold),
94
+ ui.color('Security Group', :bold),
95
+ ui.color('Server Zone', :bold),
96
+ ui.color('Service Offering', :bold),
97
+ ui.color('Template', :bold),
98
+ ui.color('State', :bold)
99
+ ]
100
+
101
+ zoneid = locate_config_value(:zoneid)
102
+ state = locate_config_value(:state)
103
+
104
+ response = connection.list_virtual_machines['listvirtualmachinesresponse']
105
+ if virtual_machines = response['virtualmachine']
106
+ filters = {}
107
+ filters[:zoneid] = zoneid unless zoneid == 'all'
108
+ filters[:state] = state unless state == 'all'
109
+ print_servers(server_list, virtual_machines, filters)
110
+ puts ui.list(server_list, :columns_across, 8)
111
+ end
112
+ end
113
+ end
114
+ end
115
+ end
@@ -28,31 +28,31 @@ class Chef
28
28
  include Knife::CloudstackBase
29
29
 
30
30
  banner "knife cloudstack template list (options)"
31
- option :filter,
32
- :short => "-L FILTER",
33
- :long => "--filter FILTER",
34
- :description => "The template search filter. Default is 'featured.' Other options are 'self,' 'self-executable,' 'executable,' and 'community.'",
35
- :default => "featured"
36
- option :zone,
37
- :short => "-Z ZONE",
38
- :long => "--zone ZONE",
39
- :description => "Limit responses to templates only located in a specific zone. Default provides templates from all zones.",
40
- :default => "all"
41
- option :hypervisor,
42
- :short => "-H HYPERVISOR",
43
- :long => "--hypervisor HYPERVISOR",
44
- :description => "Limit responses to templates only running on a specific hypervisor. Default provides templates from all hypervisors.",
45
- :default => "all"
46
- option :zoneid,
47
- :short => "-z ZONEID",
48
- :long => "--zoneid ZONEID",
49
- :description => "Limit responses to templates only running in a specific zone (specified by ID #). Default provides templates from all zones.",
50
- :default => "all"
51
- option :templateid,
52
- :short => "-T TEMPLATEID",
53
- :long => "--templateid TEMPLATEID",
54
- :description => "Limit responses to a single template ID. Default provides all templates.",
55
- :default => "all"
31
+ option :filter,
32
+ :short => "-L FILTER",
33
+ :long => "--filter FILTER",
34
+ :description => "The template search filter. Default is 'featured.' Other options are 'self,' 'self-executable,' 'executable,' and 'community.'",
35
+ :default => "featured"
36
+ option :zone,
37
+ :short => "-Z ZONE",
38
+ :long => "--zone ZONE",
39
+ :description => "Limit responses to templates only located in a specific zone. Default provides templates from all zones.",
40
+ :default => "all"
41
+ option :hypervisor,
42
+ :short => "-H HYPERVISOR",
43
+ :long => "--hypervisor HYPERVISOR",
44
+ :description => "Limit responses to templates only running on a specific hypervisor. Default provides templates from all hypervisors.",
45
+ :default => "all"
46
+ option :zoneid,
47
+ :short => "-z ZONEID",
48
+ :long => "--zoneid ZONEID",
49
+ :description => "Limit responses to templates only running in a specific zone (specified by ID #). Default provides templates from all zones.",
50
+ :default => "all"
51
+ option :templateid,
52
+ :short => "-T TEMPLATEID",
53
+ :long => "--templateid TEMPLATEID",
54
+ :description => "Limit responses to a single template ID. Default provides all templates.",
55
+ :default => "all"
56
56
 
57
57
 
58
58
  def print_templates(template_list,templates,options={})
@@ -1,6 +1,6 @@
1
1
  module Knife
2
2
  module Cloudstack
3
- VERSION = "0.2.3"
3
+ VERSION = "0.2.6"
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.3
4
+ version: 0.2.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-04-11 00:00:00.000000000 Z
13
+ date: 2012-04-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: fog
17
- requirement: &70181402276840 !ruby/object:Gem::Requirement
17
+ requirement: !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,7 +22,12 @@ dependencies:
22
22
  version: 1.3.1
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70181402276840
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ version: 1.3.1
26
31
  description: Support for the Chef Knife command, leveraging FOG, for the Citrix CloudStack
27
32
  API
28
33
  email:
@@ -34,27 +39,21 @@ extra_rdoc_files:
34
39
  - README.rdoc
35
40
  - LICENSE
36
41
  files:
37
- - .gitignore
38
- - CHANGES.rdoc
39
- - Gemfile
40
- - LICENSE
41
- - README.rdoc
42
- - Rakefile
43
- - erb/centos5-gems.erb
44
- - knife-cloudstack-fog.gemspec
45
42
  - lib/chef/knife/cloudstack_base.rb
46
43
  - lib/chef/knife/cloudstack_diskoffering_list.rb
47
- - lib/chef/knife/cloudstack_instance_create.rb
48
- - lib/chef/knife/cloudstack_instance_delete.rb
49
- - lib/chef/knife/cloudstack_instance_list.rb
50
44
  - lib/chef/knife/cloudstack_keypair_list.rb
51
45
  - lib/chef/knife/cloudstack_networks_list.rb
52
46
  - lib/chef/knife/cloudstack_securitygroup_list.rb
47
+ - lib/chef/knife/cloudstack_server_create.rb
48
+ - lib/chef/knife/cloudstack_server_delete.rb
49
+ - lib/chef/knife/cloudstack_server_list.rb
53
50
  - lib/chef/knife/cloudstack_serviceoffering_list.rb
54
51
  - lib/chef/knife/cloudstack_template_list.rb
55
52
  - lib/chef/knife/cloudstack_volumes_list.rb
56
53
  - lib/chef/knife/cloudstack_zone_list.rb
57
54
  - lib/knife-cloudstack/version.rb
55
+ - README.rdoc
56
+ - LICENSE
58
57
  homepage: https://github.com/fifthecho/knife-cloudstack-fog
59
58
  licenses: []
60
59
  post_install_message:
@@ -75,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
74
  version: '0'
76
75
  requirements: []
77
76
  rubyforge_project:
78
- rubygems_version: 1.8.10
77
+ rubygems_version: 1.8.23
79
78
  signing_key:
80
79
  specification_version: 3
81
80
  summary: Cloudstack Compute Support for Chef's Knife Command
data/.gitignore DELETED
@@ -1,19 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- coverage
6
- InstalledFiles
7
- lib/bundler/man
8
- pkg
9
- rdoc
10
- spec/reports
11
- test/tmp
12
- test/version_tmp
13
- tmp
14
- *.old
15
-
16
- # YARD artifacts
17
- .yardoc
18
- _yardoc
19
- doc/
data/CHANGES.rdoc DELETED
@@ -1,66 +0,0 @@
1
- = Changes
2
-
3
- == 2012-15-03 (0.2.0)
4
- * Brought in sync with Chirajog's knife-cloudstack plugin. Rewritten to leverage FOG CloudStack support (available in GIT
5
- gem), HTTP/HTTPS, and Security Groups.
6
-
7
- == 2011-11-03 (0.0.11)
8
- * Added LICENSE file and licensing headers to source. No feature changes.
9
-
10
- == 2011-10-13 (0.0.10)
11
- * Support for multi-homed VMs: The --networks option for the <tt>server create</tt> command takes a comma-separated list
12
- of network offering names. The created VM will have one nic per network, with nics assigned to networks in the order
13
- specified (e.g. the first network in the list will be assigned to eth0, the second to eth1 and so on). The --networks
14
- option replaces the --network option, which supported a single network name.
15
- * The <tt>server list</tt> command now shows the VM 'displayname' in parentheses when the displayname is defined and is
16
- different than the VM name.
17
- * Public IP logic has been updated to support multi-homed VMs. It now uses the first nic attached to a network with the
18
- 'default' value set to true as the primary interface.
19
-
20
- == 2011-08-30 (0.0.9)
21
- * Added subcommands: <tt>server start</tt>, <tt>server stop</tt> and <tt>server reboot</tt>.
22
- * Updated the <tt>hosts</tt> command to return short hostnames and FQDNs. Also added comments where needed so the output
23
- can be directly pasted into /etc/hosts.
24
-
25
- == 2011-08-06 (0.0.8)
26
- * Changed cloudstack async command timeout from 60 to 300 seconds.
27
-
28
- == 2011-07-21 (0.0.7)
29
- * Fixed http_request actions in <tt>stack create</tt>.
30
-
31
- == 2011-07-15 (0.0.6)
32
- * The <tt>server delete</tt> command now deletes the chef node and client if their names match the fqdn of the server.
33
- * Added the <tt>stack create</tt> and <tt>stack delete</tt> commands for bulk creation and deletion of servers using a
34
- JSON definition file. These commands are still experimental and subject to change. See README.rdoc for details.
35
- * Added a <tt>hosts</tt> command, which lists the public ip address and fqdn of all servers in /etc/hosts file format.
36
- * Fixed nil reference bug in <tt>server list</tt> command.
37
-
38
- == 2011-06-05 (0.0.5)
39
- * Added <tt>--port-rules</tt> option to the <tt>cs server create</tt> command. It accepts a list of port forwarding
40
- rules to be created for the server (only applies to servers on a virtual network). See 'Port forwarding rules for
41
- virtual networks' in README.rdoc for details.
42
-
43
- == 2011-06-01 (0.0.4)
44
- * Fixed ssh detection bug.
45
-
46
- == 2011-05-30 (0.0.3)
47
-
48
- * Added support for virtual networks. A public IP address is allocated for each new server in a virtual network
49
- and an ssh port forwarding rule is created. The IP is released when the server is destroyed as long as it doesn't
50
- have forwarding rules for any servers other than the one being deleted.
51
- * Default network is now detected automatically. If there is more than one network marked as 'default' for an
52
- account, the first Direct network is preferred.
53
-
54
- == 2011-05-22 (0.0.2)
55
-
56
- * Added subcommands: <tt>service list</tt>, <tt>template list</tt>, <tt>network list</tt> and <tt>zone list</tt>.
57
- * Removed -H (and --hostname) option from the <tt>cs server create</tt> command. The host name is now the first
58
- argument to the command: <tt>knife cs server create myhostname</tt>. If a host name is not specified, CloudStack
59
- will use an auto-generated name.
60
- * Added --no-bootstrap option to the server create command. This prevents Chef from being installed on the new server.
61
- * Fixed help banners (commands were shown as <tt>knife cloudstack ...</tt> instead of <tt>knife cs ...</tt>).
62
- * Added README.rdoc.
63
-
64
- == 2011-05-15 (0.0.1)
65
-
66
- * Initial release
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- # Specify your gem's dependencies in knife-cloudstack.gemspec
4
- gemspec
data/Rakefile DELETED
@@ -1,2 +0,0 @@
1
- require 'bundler'
2
- Bundler::GemHelper.install_tasks
data/erb/centos5-gems.erb DELETED
@@ -1,41 +0,0 @@
1
- bash -c '
2
- <%= "export http_proxy=\"#{knife_config[:bootstrap_proxy]}\"" if knife_config[:bootstrap_proxy] -%>
3
-
4
- if [ ! -f /usr/bin/chef-client ]; then
5
- wget <%= "--proxy=on " if knife_config[:bootstrap_proxy] %>http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
6
- rpm -Uvh epel-release-5-4.noarch.rpm
7
- wget <%= "--proxy=on " if knife_config[:bootstrap_proxy] %>-O /etc/yum.repos.d/aegis.repo http://rpm.aegisco.com/aegisco/el5/aegisco.repo
8
- yum install gcc gcc-c++ automake autoconf make ruby.x86_64 ruby-devel.x86_64 ruby-libs.x86_64 ruby-ri.x8_64 ruby-rdoc.x86_64 -y
9
- yum remove ruby-libs.i386 -y
10
- wget http://production.cf.rubygems.org/rubygems/rubygems-1.7.2.tgz
11
- tar zxf rubygems-1.7.2.tgz
12
- cd rubygems-1.7.2
13
- ruby setup.rb --no-format-executable
14
- gem install chef -V --no-rdoc --no-ri
15
-
16
- fi
17
-
18
-
19
- mkdir -p /etc/chef
20
-
21
- (
22
- cat <<'EOP'
23
- <%= validation_key %>
24
- EOP
25
- ) > /tmp/validation.pem
26
- awk NF /tmp/validation.pem > /etc/chef/validation.pem
27
- rm /tmp/validation.pem
28
-
29
- (
30
- cat <<'EOP'
31
- <%= config_content %>
32
- EOP
33
- ) > /etc/chef/client.rb
34
-
35
- (
36
- cat <<'EOP'
37
- <%= { "run_list" => @run_list }.to_json %>
38
- EOP
39
- ) > /etc/chef/first-boot.json
40
-
41
- <%= start_chef %>'
@@ -1,23 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "knife-cloudstack/version"
4
-
5
- Gem::Specification.new do |s|
6
- s.name = "knife-cloudstack-fog"
7
- s.version = Knife::Cloudstack::VERSION
8
- s.platform = Gem::Platform::RUBY
9
- s.has_rdoc = true
10
- s.extra_rdoc_files = ["README.rdoc", "LICENSE" ]
11
- s.authors = ["Chirag Jog", "Jeff Moody"]
12
- s.email = ["chirag@clogeny.com", "jmoody@datapipe.com"]
13
- s.homepage = "https://github.com/fifthecho/knife-cloudstack-fog"
14
- s.summary = %q{Cloudstack Compute Support for Chef's Knife Command}
15
- s.description = %q{Support for the Chef Knife command, leveraging FOG, for the Citrix CloudStack API}
16
-
17
- s.files = `git ls-files`.split("\n")
18
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
- s.require_paths = ["lib"]
21
-
22
- s.add_dependency "fog", "~> 1.3.1"
23
- end
@@ -1,91 +0,0 @@
1
- # Author:: Chirag Jog (<chirag@clogeny.com>)
2
- # Copyright:: Copyright (c) 2011 Clogeny Technologies.
3
- # License:: Apache License, Version 2.0
4
- #
5
- # Author:: Jeff Moody (<jmoody@datapipe.com>)
6
- # Copyright:: Copyright (c) 2012 Datapipe
7
- # License:: Apache License, Version 2.0
8
- #
9
- # Author:: Seth Chisamore (<schisamo@opscode.com>)
10
- # Copyright:: Copyright (c) 2011 Opscode, Inc.
11
- # License:: Apache License, Version 2.0
12
- #
13
- # Licensed under the Apache License, Version 2.0 (the "License");
14
- # you may not use this file except in compliance with the License.
15
- # You may obtain a copy of the License at
16
- #
17
- # http://www.apache.org/licenses/LICENSE-2.0
18
- #
19
- # Unless required by applicable law or agreed to in writing, software
20
- # distributed under the License is distributed on an "AS IS" BASIS,
21
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
- # See the License for the specific language governing permissions and
23
- # limitations under the License.
24
- #
25
-
26
- require 'chef/knife/cloudstack_base'
27
-
28
- class Chef
29
- class Knife
30
- class CloudstackServerList < Knife
31
-
32
- include Knife::CloudstackBase
33
-
34
- banner "knife cloudstack server list (options)"
35
-
36
- def run
37
- $stdout.sync = true
38
-
39
- validate!
40
-
41
- instance_list = [
42
- ui.color('Instance ID', :bold),
43
- ui.color('Display Name', :bold),
44
- ui.color('IP Address', :bold),
45
- ui.color('Security Group', :bold),
46
- ui.color('Instance Zone', :bold),
47
- ui.color('Service Offering', :bold),
48
- ui.color('Template', :bold),
49
- ui.color('State', :bold)
50
- ]
51
-
52
- response = connection.list_virtual_machines['listvirtualmachinesresponse']
53
- if virtual_machines = response['virtualmachine']
54
- virtual_machines.each do |instance|
55
- instance_list << instance['name'].to_s
56
- instance_list << instance['displayname'].to_s
57
- ip_list = []
58
- instance['nic'].each do |nic|
59
- ip_list << nic['ipaddress'].to_s
60
- end
61
- instance_list << ip_list.join(", ")
62
- sg_list = []
63
- instance['securitygroup'].each do |group|
64
- sg_list << group['name'].to_s
65
- end
66
- instance_list << sg_list.join(", ")
67
-
68
- instance_list << instance['zonename'].to_s
69
- instance_list << instance['serviceofferingname'].to_s
70
- instance_list << instance['templatedisplaytext'].to_s
71
-
72
- instance_list << begin
73
- state = instance['state'].to_s.downcase
74
- case state
75
- when 'shutting-down','terminated','stopping','stopped'
76
- ui.color(state, :red)
77
- when 'pending', 'starting'
78
- ui.color(state, :yellow)
79
- else
80
- ui.color(state, :green)
81
- end
82
- end
83
-
84
- end
85
-
86
- puts ui.list(instance_list, :columns_across, 8)
87
- end
88
- end
89
- end
90
- end
91
- end