knife-profitbricks 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +24 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +201 -0
- data/README.md +209 -0
- data/Rakefile +7 -0
- data/knife-profitbricks.gemspec +27 -0
- data/lib/chef/knife/profitbricks_base.rb +56 -0
- data/lib/chef/knife/profitbricks_datacenter_create.rb +51 -0
- data/lib/chef/knife/profitbricks_datacenter_delete.rb +44 -0
- data/lib/chef/knife/profitbricks_datacenter_list.rb +32 -0
- data/lib/chef/knife/profitbricks_firewall_create.rb +121 -0
- data/lib/chef/knife/profitbricks_firewall_delete.rb +58 -0
- data/lib/chef/knife/profitbricks_firewall_list.rb +59 -0
- data/lib/chef/knife/profitbricks_image_list.rb +35 -0
- data/lib/chef/knife/profitbricks_ipblock_create.rb +43 -0
- data/lib/chef/knife/profitbricks_ipblock_delete.rb +32 -0
- data/lib/chef/knife/profitbricks_ipblock_list.rb +29 -0
- data/lib/chef/knife/profitbricks_lan_create.rb +54 -0
- data/lib/chef/knife/profitbricks_lan_delete.rb +38 -0
- data/lib/chef/knife/profitbricks_lan_list.rb +35 -0
- data/lib/chef/knife/profitbricks_location_list.rb +26 -0
- data/lib/chef/knife/profitbricks_nic_create.rb +78 -0
- data/lib/chef/knife/profitbricks_nic_delete.rb +45 -0
- data/lib/chef/knife/profitbricks_nic_list.rb +44 -0
- data/lib/chef/knife/profitbricks_server_create.rb +81 -0
- data/lib/chef/knife/profitbricks_server_delete.rb +40 -0
- data/lib/chef/knife/profitbricks_server_list.rb +45 -0
- data/lib/chef/knife/profitbricks_server_reboot.rb +32 -0
- data/lib/chef/knife/profitbricks_server_start.rb +32 -0
- data/lib/chef/knife/profitbricks_server_stop.rb +32 -0
- data/lib/chef/knife/profitbricks_volume_attach.rb +38 -0
- data/lib/chef/knife/profitbricks_volume_create.rb +82 -0
- data/lib/chef/knife/profitbricks_volume_delete.rb +40 -0
- data/lib/chef/knife/profitbricks_volume_detach.rb +45 -0
- data/lib/chef/knife/profitbricks_volume_list.rb +61 -0
- data/lib/knife-profitbricks/version.rb +6 -0
- data/spec/chef/knife/profitbricks_datacenter_list_spec.rb +23 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/test.sh +3 -0
- metadata +157 -0
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'chef/knife/profitbricks_base'
|
2
|
+
|
3
|
+
class Chef
|
4
|
+
class Knife
|
5
|
+
class ProfitbricksVolumeList < Knife
|
6
|
+
include Knife::ProfitbricksBase
|
7
|
+
|
8
|
+
banner 'knife profitbricks volume list (options)'
|
9
|
+
|
10
|
+
option :datacenter_id,
|
11
|
+
short: '-D DATACENTER_UUID',
|
12
|
+
long: '--datacenter-id DATACENTER_UUID',
|
13
|
+
description: 'The UUID of the virtul data center containing the volume',
|
14
|
+
proc: proc { |datacenter_id| Chef::Config[:knife][:datacenter_id] = datacenter_id }
|
15
|
+
|
16
|
+
option :server_id,
|
17
|
+
short: '-S SERVER_UUID',
|
18
|
+
long: '--server-id SERVER_UUID',
|
19
|
+
description: 'The UUID of the server'
|
20
|
+
|
21
|
+
def run
|
22
|
+
$stdout.sync = true
|
23
|
+
volume_list = [
|
24
|
+
ui.color('ID', :bold),
|
25
|
+
ui.color('Name', :bold),
|
26
|
+
ui.color('Size', :bold),
|
27
|
+
ui.color('Bus', :bold),
|
28
|
+
ui.color('Image', :bold),
|
29
|
+
ui.color('Type', :bold),
|
30
|
+
ui.color('Device Number', :bold)
|
31
|
+
]
|
32
|
+
|
33
|
+
connection
|
34
|
+
if defined?(config[:server_id]) && config[:server_id]
|
35
|
+
server = ProfitBricks::Server.get(config[:datacenter_id], config[:server_id])
|
36
|
+
server.list_volumes.each do |volume|
|
37
|
+
volume_list << volume.id
|
38
|
+
volume_list << volume.properties['name']
|
39
|
+
volume_list << volume.properties['size'].to_s
|
40
|
+
volume_list << volume.properties['bus']
|
41
|
+
volume_list << volume.properties['image']
|
42
|
+
volume_list << volume.properties['type']
|
43
|
+
volume_list << volume.properties['deviceNumber'].to_s
|
44
|
+
end
|
45
|
+
else
|
46
|
+
ProfitBricks::Volume.list(config[:datacenter_id]).each do |volume|
|
47
|
+
volume_list << volume.id
|
48
|
+
volume_list << volume.properties['name']
|
49
|
+
volume_list << volume.properties['size'].to_s
|
50
|
+
volume_list << volume.properties['bus']
|
51
|
+
volume_list << volume.properties['image']
|
52
|
+
volume_list << volume.properties['type']
|
53
|
+
volume_list << volume.properties['deviceNumber'].to_s
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
puts ui.list(volume_list, :uneven_columns_across, 7)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'profitbricks_datacenter_list'
|
3
|
+
|
4
|
+
Chef::Knife::ProfitbricksDatacenterList.load_deps
|
5
|
+
|
6
|
+
describe Chef::Knife::ProfitbricksDatacenterList do
|
7
|
+
before :each do
|
8
|
+
subject { Chef::Knife::ProfitbricksDatacenterList.new }
|
9
|
+
allow(subject).to receive(:puts)
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#run' do
|
13
|
+
it 'should output the column headers' do
|
14
|
+
expect(subject).to receive(:puts).with(/^ID\s+Name\s+Description\s+Location\s+Version\s*$/)
|
15
|
+
subject.run
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should output the data center locations' do
|
19
|
+
expect(subject).to receive(:puts).with(/(?:us\/las)/)
|
20
|
+
subject.run
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
$:.unshift File.expand_path('../../lib/chef/knife', __FILE__)
|
2
|
+
require 'rspec'
|
3
|
+
require 'chef'
|
4
|
+
|
5
|
+
RSpec.configure do |config|
|
6
|
+
config.before(:each) do
|
7
|
+
Chef::Config.reset
|
8
|
+
{ :profitbricks_username => 'farid.shah@profitbricks.com',
|
9
|
+
:profitbricks_password => 'spc2015',
|
10
|
+
:profitbricks_url => 'https://spc.profitbricks.com'
|
11
|
+
}.each do |key, value|
|
12
|
+
Chef::Config[:knife][key] = value
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/spec/test.sh
ADDED
metadata
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: knife-profitbricks
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ethan Devenport
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: profitbricks-sdk-ruby
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: chef
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '12'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '12'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.6'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.4'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.4'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.2'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.2'
|
83
|
+
description: Official Chef Knife plugin for ProfitBricks platform using REST API
|
84
|
+
email:
|
85
|
+
- ethand@stackpointcloud.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- .gitignore
|
91
|
+
- Gemfile
|
92
|
+
- LICENSE.txt
|
93
|
+
- README.md
|
94
|
+
- Rakefile
|
95
|
+
- knife-profitbricks.gemspec
|
96
|
+
- lib/chef/knife/profitbricks_base.rb
|
97
|
+
- lib/chef/knife/profitbricks_datacenter_create.rb
|
98
|
+
- lib/chef/knife/profitbricks_datacenter_delete.rb
|
99
|
+
- lib/chef/knife/profitbricks_datacenter_list.rb
|
100
|
+
- lib/chef/knife/profitbricks_firewall_create.rb
|
101
|
+
- lib/chef/knife/profitbricks_firewall_delete.rb
|
102
|
+
- lib/chef/knife/profitbricks_firewall_list.rb
|
103
|
+
- lib/chef/knife/profitbricks_image_list.rb
|
104
|
+
- lib/chef/knife/profitbricks_ipblock_create.rb
|
105
|
+
- lib/chef/knife/profitbricks_ipblock_delete.rb
|
106
|
+
- lib/chef/knife/profitbricks_ipblock_list.rb
|
107
|
+
- lib/chef/knife/profitbricks_lan_create.rb
|
108
|
+
- lib/chef/knife/profitbricks_lan_delete.rb
|
109
|
+
- lib/chef/knife/profitbricks_lan_list.rb
|
110
|
+
- lib/chef/knife/profitbricks_location_list.rb
|
111
|
+
- lib/chef/knife/profitbricks_nic_create.rb
|
112
|
+
- lib/chef/knife/profitbricks_nic_delete.rb
|
113
|
+
- lib/chef/knife/profitbricks_nic_list.rb
|
114
|
+
- lib/chef/knife/profitbricks_server_create.rb
|
115
|
+
- lib/chef/knife/profitbricks_server_delete.rb
|
116
|
+
- lib/chef/knife/profitbricks_server_list.rb
|
117
|
+
- lib/chef/knife/profitbricks_server_reboot.rb
|
118
|
+
- lib/chef/knife/profitbricks_server_start.rb
|
119
|
+
- lib/chef/knife/profitbricks_server_stop.rb
|
120
|
+
- lib/chef/knife/profitbricks_volume_attach.rb
|
121
|
+
- lib/chef/knife/profitbricks_volume_create.rb
|
122
|
+
- lib/chef/knife/profitbricks_volume_delete.rb
|
123
|
+
- lib/chef/knife/profitbricks_volume_detach.rb
|
124
|
+
- lib/chef/knife/profitbricks_volume_list.rb
|
125
|
+
- lib/knife-profitbricks/version.rb
|
126
|
+
- spec/chef/knife/profitbricks_datacenter_list_spec.rb
|
127
|
+
- spec/spec_helper.rb
|
128
|
+
- spec/test.sh
|
129
|
+
homepage: https://github.com/profitbricks/knife-profitbricks
|
130
|
+
licenses:
|
131
|
+
- Apache
|
132
|
+
metadata: {}
|
133
|
+
post_install_message:
|
134
|
+
rdoc_options: []
|
135
|
+
require_paths:
|
136
|
+
- lib
|
137
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - '>='
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
requirements: []
|
148
|
+
rubyforge_project:
|
149
|
+
rubygems_version: 2.4.2
|
150
|
+
signing_key:
|
151
|
+
specification_version: 4
|
152
|
+
summary: Chef Knife plugin for ProfitBricks platform
|
153
|
+
test_files:
|
154
|
+
- spec/chef/knife/profitbricks_datacenter_list_spec.rb
|
155
|
+
- spec/spec_helper.rb
|
156
|
+
- spec/test.sh
|
157
|
+
has_rdoc:
|