knife-cloudstack-fog 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +19 -0
- data/CHANGES.rdoc +66 -0
- data/Gemfile +4 -0
- data/LICENSE +202 -0
- data/README.rdoc +111 -0
- data/Rakefile +2 -0
- data/erb/centos5-gems.erb +41 -0
- data/knife-cloudstack-fog.gemspec +23 -0
- data/lib/chef/knife/cloudstack_base.rb +105 -0
- data/lib/chef/knife/cloudstack_diskoffering_list.rb +57 -0
- data/lib/chef/knife/cloudstack_instance_create.rb +275 -0
- data/lib/chef/knife/cloudstack_instance_delete.rb +53 -0
- data/lib/chef/knife/cloudstack_instance_list.rb +91 -0
- data/lib/chef/knife/cloudstack_keypair_list.rb +53 -0
- data/lib/chef/knife/cloudstack_networks_list.rb +67 -0
- data/lib/chef/knife/cloudstack_securitygroup_list.rb +124 -0
- data/lib/chef/knife/cloudstack_serviceoffering_list.rb +61 -0
- data/lib/chef/knife/cloudstack_template_list.rb +121 -0
- data/lib/chef/knife/cloudstack_volumes_list.rb +78 -0
- data/lib/chef/knife/cloudstack_zone_list.rb +63 -0
- data/lib/knife-cloudstack/version.rb +6 -0
- metadata +82 -0
@@ -0,0 +1,61 @@
|
|
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 CloudstackServiceofferingList < Knife
|
24
|
+
|
25
|
+
include Knife::CloudstackBase
|
26
|
+
|
27
|
+
banner "knife cloudstack serviceoffering list (options)"
|
28
|
+
|
29
|
+
def run
|
30
|
+
$stdout.sync = true
|
31
|
+
|
32
|
+
validate!
|
33
|
+
|
34
|
+
serviceoffering_list = [
|
35
|
+
ui.color('ID', :bold),
|
36
|
+
ui.color('Name', :bold),
|
37
|
+
ui.color('Description', :bold),
|
38
|
+
ui.color('Number of CPUs', :bold),
|
39
|
+
ui.color('CPU Speed', :bold),
|
40
|
+
ui.color('Memory (in MB)', :bold),
|
41
|
+
ui.color('Network Speed', :bold)
|
42
|
+
]
|
43
|
+
response = connection.list_service_offerings['listserviceofferingsresponse']
|
44
|
+
if serviceofferings = response['serviceoffering']
|
45
|
+
serviceofferings.each do |serviceoffering|
|
46
|
+
serviceoffering_list << serviceoffering['id'].to_s
|
47
|
+
serviceoffering_list << serviceoffering['name'].to_s
|
48
|
+
serviceoffering_list << serviceoffering['displaytext'].to_s
|
49
|
+
serviceoffering_list << serviceoffering['cpunumber'].to_s
|
50
|
+
serviceoffering_list << serviceoffering['cpuspeed'].to_s
|
51
|
+
serviceoffering_list << serviceoffering['memory'].to_s
|
52
|
+
serviceoffering_list << serviceoffering['networkrate'].to_s
|
53
|
+
end
|
54
|
+
end
|
55
|
+
puts ui.list(serviceoffering_list, :columns_across, 7)
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,121 @@
|
|
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 CloudstackTemplateList < Knife
|
27
|
+
|
28
|
+
include Knife::CloudstackBase
|
29
|
+
|
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"
|
56
|
+
|
57
|
+
|
58
|
+
def print_templates(template_list,templates,options={})
|
59
|
+
temp = templates
|
60
|
+
|
61
|
+
if templateid = options[:templateid]
|
62
|
+
temp.reject!{|t| t['id'] != templateid.to_i}
|
63
|
+
end
|
64
|
+
if zoneid = options[:zoneid]
|
65
|
+
temp.reject!{|t| t['zoneid'] != zoneid.to_i}
|
66
|
+
end
|
67
|
+
if zone = options[:zone]
|
68
|
+
temp.reject!{|t| t['zonename'] != zone}
|
69
|
+
end
|
70
|
+
if hypervisor = options[:hypervisor]
|
71
|
+
temp.reject!{|t| t['hypervisor'] != hypervisor}
|
72
|
+
end
|
73
|
+
|
74
|
+
temp.each do |template|
|
75
|
+
template_list << template['id'].to_s
|
76
|
+
template_list << template['hypervisor']
|
77
|
+
|
78
|
+
template_size = template['size']
|
79
|
+
template_size = (template_size/1024/1024/1024)
|
80
|
+
template_list << template_size.to_s
|
81
|
+
|
82
|
+
template_list << template['zonename']
|
83
|
+
template_list << template['name']
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def run
|
88
|
+
validate!
|
89
|
+
|
90
|
+
template_list = [
|
91
|
+
ui.color('ID', :bold),
|
92
|
+
ui.color('Hypervisor', :bold),
|
93
|
+
ui.color('Size (in GB)', :bold),
|
94
|
+
ui.color('Zone Location', :bold),
|
95
|
+
ui.color('Name', :bold)
|
96
|
+
]
|
97
|
+
|
98
|
+
filter = locate_config_value(:filter)
|
99
|
+
zone = locate_config_value(:zone)
|
100
|
+
zoneid = locate_config_value(:zoneid)
|
101
|
+
hypervisor = locate_config_value(:hypervisor)
|
102
|
+
templateid = locate_config_value(:templateid)
|
103
|
+
|
104
|
+
settings = connection.list_templates('templatefilter' => filter)
|
105
|
+
if response = settings['listtemplatesresponse']
|
106
|
+
if templates = response['template']
|
107
|
+
filters = {}
|
108
|
+
filters[:hypervisor] = hypervisor unless hypervisor == 'all'
|
109
|
+
filters[:zone] = zone unless zone == 'all'
|
110
|
+
filters[:zoneid] = zoneid unless zoneid == 'all'
|
111
|
+
filters[:templateid] = templateid unless templateid == 'all'
|
112
|
+
|
113
|
+
print_templates(template_list,templates,filters)
|
114
|
+
end
|
115
|
+
puts ui.list(template_list, :columns_across, 5)
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,78 @@
|
|
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 CloudstackVolumeList < Knife
|
24
|
+
|
25
|
+
include Knife::CloudstackBase
|
26
|
+
|
27
|
+
banner "knife cloudstack volume list (options)"
|
28
|
+
|
29
|
+
def run
|
30
|
+
$stdout.sync = true
|
31
|
+
|
32
|
+
validate!
|
33
|
+
|
34
|
+
volume_list = [
|
35
|
+
ui.color('ID', :bold),
|
36
|
+
ui.color('Name', :bold),
|
37
|
+
ui.color('Size (in GB)', :bold),
|
38
|
+
ui.color('Type', :bold),
|
39
|
+
ui.color('Virtual Machine', :bold),
|
40
|
+
ui.color('State', :bold)
|
41
|
+
]
|
42
|
+
|
43
|
+
response = connection.list_volumes['listvolumesresponse']
|
44
|
+
|
45
|
+
if volumes = response['volume']
|
46
|
+
volumes.each do |volume|
|
47
|
+
volume_list << volume['id'].to_s
|
48
|
+
volume_list << volume['name'].to_s
|
49
|
+
volume_size = volume['size']
|
50
|
+
volume_size = (volume_size/1024/1024/1024)
|
51
|
+
volume_list << volume_size.to_s
|
52
|
+
volume_list << volume['type']
|
53
|
+
if (volume['vmdisplayname'].nil?)
|
54
|
+
volume_list << ' '
|
55
|
+
else
|
56
|
+
volume_list << volume['vmdisplayname']
|
57
|
+
end
|
58
|
+
|
59
|
+
volume_list << begin
|
60
|
+
state = volume['state'].to_s.downcase
|
61
|
+
case state
|
62
|
+
when 'allocated'
|
63
|
+
ui.color(state, :red)
|
64
|
+
when 'pending'
|
65
|
+
ui.color(state, :yellow)
|
66
|
+
else
|
67
|
+
ui.color(state, :green)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
puts ui.list(volume_list, :columns_across, 6)
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,63 @@
|
|
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 CloudstackZoneList < Knife
|
24
|
+
|
25
|
+
include Knife::CloudstackBase
|
26
|
+
|
27
|
+
banner "knife cloudstack zone list (options)"
|
28
|
+
|
29
|
+
def run
|
30
|
+
$stdout.sync = true
|
31
|
+
|
32
|
+
validate!
|
33
|
+
|
34
|
+
zone_list = [
|
35
|
+
ui.color('ID', :bold),
|
36
|
+
ui.color('Name', :bold),
|
37
|
+
ui.color('Network Type', :bold),
|
38
|
+
ui.color('Security Groups?', :bold)
|
39
|
+
]
|
40
|
+
response = connection.list_zones['listzonesresponse']
|
41
|
+
if zones = response['zone']
|
42
|
+
zones.each do |zone|
|
43
|
+
zone_list << zone['id'].to_s
|
44
|
+
zone_list << zone['name'].to_s
|
45
|
+
zone_list << zone['networktype'].to_s
|
46
|
+
zone_list << begin
|
47
|
+
state = zone['securitygroupsenabled'].to_s.downcase
|
48
|
+
case state
|
49
|
+
when 'false'
|
50
|
+
ui.color('No', :red)
|
51
|
+
else
|
52
|
+
ui.color('Yes', :green)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
puts ui.list(zone_list, :columns_across, 4)
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: knife-cloudstack-fog
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Chirag Jog
|
9
|
+
- Jeff Moody
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2012-04-11 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: fog
|
17
|
+
requirement: &70148116239160 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ~>
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.1.2
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *70148116239160
|
26
|
+
description: Support for the Chef Knife command, leveraging FOG, for the Citrix CloudStack
|
27
|
+
API
|
28
|
+
email:
|
29
|
+
- chirag@clogeny.com
|
30
|
+
- jmoody@datapipe.com
|
31
|
+
executables: []
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files:
|
34
|
+
- README.rdoc
|
35
|
+
- LICENSE
|
36
|
+
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
|
+
- lib/chef/knife/cloudstack_base.rb
|
46
|
+
- 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
|
+
- lib/chef/knife/cloudstack_keypair_list.rb
|
51
|
+
- lib/chef/knife/cloudstack_networks_list.rb
|
52
|
+
- lib/chef/knife/cloudstack_securitygroup_list.rb
|
53
|
+
- lib/chef/knife/cloudstack_serviceoffering_list.rb
|
54
|
+
- lib/chef/knife/cloudstack_template_list.rb
|
55
|
+
- lib/chef/knife/cloudstack_volumes_list.rb
|
56
|
+
- lib/chef/knife/cloudstack_zone_list.rb
|
57
|
+
- lib/knife-cloudstack/version.rb
|
58
|
+
homepage: https://github.com/fifthecho/knife-cloudstack-fog
|
59
|
+
licenses: []
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 1.8.10
|
79
|
+
signing_key:
|
80
|
+
specification_version: 3
|
81
|
+
summary: Cloudstack Compute Support for Chef's Knife Command
|
82
|
+
test_files: []
|