knife-profitbricks 1.2.1 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +303 -96
- data/knife-profitbricks.gemspec +1 -1
- data/lib/chef/knife/profitbricks_base.rb +24 -0
- data/lib/chef/knife/profitbricks_composite_server_create.rb +59 -45
- data/lib/chef/knife/profitbricks_contract_list.rb +37 -0
- data/lib/chef/knife/profitbricks_datacenter_create.rb +8 -7
- data/lib/chef/knife/profitbricks_firewall_create.rb +15 -15
- data/lib/chef/knife/profitbricks_firewall_delete.rb +6 -8
- data/lib/chef/knife/profitbricks_firewall_list.rb +6 -5
- data/lib/chef/knife/profitbricks_ipblock_create.rb +6 -7
- data/lib/chef/knife/profitbricks_ipfailover_add.rb +60 -0
- data/lib/chef/knife/profitbricks_ipfailover_remove.rb +60 -0
- data/lib/chef/knife/profitbricks_lan_create.rb +5 -3
- data/lib/chef/knife/profitbricks_lan_list.rb +1 -1
- data/lib/chef/knife/profitbricks_nic_create.rb +12 -14
- data/lib/chef/knife/profitbricks_nic_delete.rb +4 -3
- data/lib/chef/knife/profitbricks_nic_list.rb +4 -3
- data/lib/chef/knife/profitbricks_server_create.rb +14 -16
- data/lib/chef/knife/profitbricks_server_delete.rb +1 -1
- data/lib/chef/knife/profitbricks_server_list.rb +1 -1
- data/lib/chef/knife/profitbricks_server_reboot.rb +1 -1
- data/lib/chef/knife/profitbricks_server_start.rb +1 -1
- data/lib/chef/knife/profitbricks_server_stop.rb +1 -1
- data/lib/chef/knife/profitbricks_volume_attach.rb +5 -5
- data/lib/chef/knife/profitbricks_volume_create.rb +38 -18
- data/lib/chef/knife/profitbricks_volume_delete.rb +1 -1
- data/lib/chef/knife/profitbricks_volume_detach.rb +4 -4
- data/lib/chef/knife/profitbricks_volume_list.rb +5 -6
- data/lib/knife-profitbricks/version.rb +1 -1
- data/spec/chef/knife/profitbricks_composite_server_create_spec.rb +64 -0
- data/spec/chef/knife/profitbricks_contract_list_spec.rb +20 -0
- data/spec/chef/knife/profitbricks_datacenter_create_spec.rb +44 -0
- data/spec/chef/knife/profitbricks_datacenter_delete_spec.rb +39 -0
- data/spec/chef/knife/profitbricks_datacenter_list_spec.rb +7 -6
- data/spec/chef/knife/profitbricks_firewall_create_spec.rb +74 -0
- data/spec/chef/knife/profitbricks_firewall_delete_spec.rb +86 -0
- data/spec/chef/knife/profitbricks_firewall_list_spec.rb +61 -0
- data/spec/chef/knife/profitbricks_image_list_spec.rb +19 -0
- data/spec/chef/knife/profitbricks_ipblock_create_spec.rb +39 -0
- data/spec/chef/knife/profitbricks_ipblock_delete_spec.rb +37 -0
- data/spec/chef/knife/profitbricks_ipfailover_add_spec.rb +80 -0
- data/spec/chef/knife/profitbricks_ipfailover_remove_spec.rb +85 -0
- data/spec/chef/knife/profitbricks_lan_create_spec.rb +59 -0
- data/spec/chef/knife/profitbricks_lan_delete_spec.rb +58 -0
- data/spec/chef/knife/profitbricks_lan_list_spec.rb +37 -0
- data/spec/chef/knife/profitbricks_location_list_spec.rb +24 -0
- data/spec/chef/knife/profitbricks_nic_create_spec.rb +71 -0
- data/spec/chef/knife/profitbricks_nic_delete_spec.rb +69 -0
- data/spec/chef/knife/profitbricks_nic_list_spec.rb +69 -0
- data/spec/chef/knife/profitbricks_server_create_spec.rb +63 -0
- data/spec/chef/knife/profitbricks_server_delete_spec.rb +63 -0
- data/spec/chef/knife/profitbricks_server_list_spec.rb +65 -0
- data/spec/chef/knife/profitbricks_server_reboot_spec.rb +65 -0
- data/spec/chef/knife/profitbricks_server_start_spec.rb +68 -0
- data/spec/chef/knife/profitbricks_server_stop_spec.rb +65 -0
- data/spec/chef/knife/profitbricks_volume_attach_spec.rb +70 -0
- data/spec/chef/knife/profitbricks_volume_create_spec.rb +63 -0
- data/spec/chef/knife/profitbricks_volume_delete_spec.rb +70 -0
- data/spec/chef/knife/profitbricks_volume_detach_spec.rb +81 -0
- data/spec/chef/knife/profitbricks_volume_list_spec.rb +80 -0
- data/spec/spec_helper.rb +22 -3
- data/spec/test.sh +1 -1
- metadata +81 -18
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'profitbricks_nic_create'
|
3
|
+
|
4
|
+
Chef::Knife::ProfitbricksNicCreate.load_deps
|
5
|
+
|
6
|
+
describe Chef::Knife::ProfitbricksNicCreate do
|
7
|
+
subject { Chef::Knife::ProfitbricksNicCreate.new }
|
8
|
+
|
9
|
+
before :each do
|
10
|
+
{
|
11
|
+
name: 'Chef Test',
|
12
|
+
public: 'true'
|
13
|
+
}.each do |key, value|
|
14
|
+
Chef::Config[:knife][key] = value
|
15
|
+
end
|
16
|
+
|
17
|
+
ProfitBricks.configure do |config|
|
18
|
+
config.username = Chef::Config[:knife][:profitbricks_username]
|
19
|
+
config.password = Chef::Config[:knife][:profitbricks_password]
|
20
|
+
config.url = Chef::Config[:knife][:profitbricks_url]
|
21
|
+
config.debug = Chef::Config[:knife][:profitbricks_debug] || false
|
22
|
+
config.global_classes = false
|
23
|
+
end
|
24
|
+
|
25
|
+
@datacenter = ProfitBricks::Datacenter.create(name: 'Chef test',
|
26
|
+
description: 'Chef test datacenter',
|
27
|
+
location: 'us/las')
|
28
|
+
@datacenter.wait_for { ready? }
|
29
|
+
|
30
|
+
@lan = ProfitBricks::LAN.create(@datacenter.id, name: 'Chef Test',
|
31
|
+
public: 'true')
|
32
|
+
@lan.wait_for { ready? }
|
33
|
+
|
34
|
+
@server = ProfitBricks::Server.create(@datacenter.id, name: 'Chef Test',
|
35
|
+
ram: 1024,
|
36
|
+
cores: 1,
|
37
|
+
availabilityZone: 'ZONE_1',
|
38
|
+
cpuFamily: 'INTEL_XEON')
|
39
|
+
@server.wait_for { ready? }
|
40
|
+
|
41
|
+
Chef::Config[:knife][:datacenter_id] = @datacenter.id
|
42
|
+
Chef::Config[:knife][:server_id] = @server.id
|
43
|
+
Chef::Config[:knife][:lan] = @lan.id
|
44
|
+
Chef::Config[:knife][:name] = 'Chef Test'
|
45
|
+
|
46
|
+
allow(subject).to receive(:puts)
|
47
|
+
end
|
48
|
+
|
49
|
+
after :each do
|
50
|
+
ProfitBricks.configure do |config|
|
51
|
+
config.username = Chef::Config[:knife][:profitbricks_username]
|
52
|
+
config.password = Chef::Config[:knife][:profitbricks_password]
|
53
|
+
config.url = Chef::Config[:knife][:profitbricks_url]
|
54
|
+
config.debug = Chef::Config[:knife][:profitbricks_debug] || false
|
55
|
+
config.global_classes = false
|
56
|
+
end
|
57
|
+
|
58
|
+
@datacenter.delete
|
59
|
+
@datacenter.wait_for { ready? }
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '#run' do
|
63
|
+
it 'should create a nic' do
|
64
|
+
expect(subject).to receive(:puts).with('Name: Chef Test')
|
65
|
+
expect(subject).to receive(:puts).with('DHCP: true')
|
66
|
+
expect(subject).to receive(:puts).with('LAN: 1')
|
67
|
+
expect(subject).to receive(:puts).with('NAT: false')
|
68
|
+
subject.run
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'profitbricks_nic_delete'
|
3
|
+
|
4
|
+
Chef::Knife::ProfitbricksNicDelete.load_deps
|
5
|
+
|
6
|
+
describe Chef::Knife::ProfitbricksNicDelete do
|
7
|
+
subject { Chef::Knife::ProfitbricksNicDelete.new }
|
8
|
+
|
9
|
+
before :each do
|
10
|
+
subject.config[:yes] = true
|
11
|
+
allow(subject).to receive(:puts)
|
12
|
+
{
|
13
|
+
name: 'Chef Test',
|
14
|
+
public: 'true'
|
15
|
+
}.each do |key, value|
|
16
|
+
Chef::Config[:knife][key] = value
|
17
|
+
end
|
18
|
+
|
19
|
+
ProfitBricks.configure do |config|
|
20
|
+
config.username = Chef::Config[:knife][:profitbricks_username]
|
21
|
+
config.password = Chef::Config[:knife][:profitbricks_password]
|
22
|
+
config.url = Chef::Config[:knife][:profitbricks_url]
|
23
|
+
config.debug = Chef::Config[:knife][:profitbricks_debug] || false
|
24
|
+
config.global_classes = false
|
25
|
+
end
|
26
|
+
|
27
|
+
@datacenter = ProfitBricks::Datacenter.create(name: 'Chef test',
|
28
|
+
description: 'Chef test datacenter',
|
29
|
+
location: 'us/las')
|
30
|
+
@datacenter.wait_for { ready? }
|
31
|
+
|
32
|
+
@lan = ProfitBricks::LAN.create(@datacenter.id, name: 'Chef Test',
|
33
|
+
public: 'true')
|
34
|
+
@lan.wait_for { ready? }
|
35
|
+
|
36
|
+
@server = ProfitBricks::Server.create(@datacenter.id, name: 'Chef Test',
|
37
|
+
ram: 1024,
|
38
|
+
cores: 1,
|
39
|
+
availabilityZone: 'ZONE_1',
|
40
|
+
cpuFamily: 'INTEL_XEON')
|
41
|
+
@server.wait_for { ready? }
|
42
|
+
|
43
|
+
@nic = ProfitBricks::NIC.create(@datacenter.id, @server.id, lan: @lan.id)
|
44
|
+
@nic.wait_for { ready? }
|
45
|
+
|
46
|
+
Chef::Config[:knife][:datacenter_id] = @datacenter.id
|
47
|
+
Chef::Config[:knife][:server_id] = @server.id
|
48
|
+
subject.name_args = [@nic.id]
|
49
|
+
end
|
50
|
+
|
51
|
+
after :each do
|
52
|
+
ProfitBricks.configure do |config|
|
53
|
+
config.username = Chef::Config[:knife][:profitbricks_username]
|
54
|
+
config.password = Chef::Config[:knife][:profitbricks_password]
|
55
|
+
config.url = Chef::Config[:knife][:profitbricks_url]
|
56
|
+
config.debug = Chef::Config[:knife][:profitbricks_debug] || false
|
57
|
+
config.global_classes = false
|
58
|
+
end
|
59
|
+
|
60
|
+
@datacenter.delete
|
61
|
+
@datacenter.wait_for { ready? }
|
62
|
+
end
|
63
|
+
|
64
|
+
describe '#run' do
|
65
|
+
it 'should delete a nic' do
|
66
|
+
subject.run
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'profitbricks_nic_list'
|
3
|
+
|
4
|
+
Chef::Knife::ProfitbricksNicList.load_deps
|
5
|
+
|
6
|
+
describe Chef::Knife::ProfitbricksNicList do
|
7
|
+
subject { Chef::Knife::ProfitbricksNicList.new }
|
8
|
+
|
9
|
+
before :each do
|
10
|
+
{
|
11
|
+
name: 'Chef Test',
|
12
|
+
public: 'true'
|
13
|
+
}.each do |key, value|
|
14
|
+
Chef::Config[:knife][key] = value
|
15
|
+
end
|
16
|
+
|
17
|
+
ProfitBricks.configure do |config|
|
18
|
+
config.username = Chef::Config[:knife][:profitbricks_username]
|
19
|
+
config.password = Chef::Config[:knife][:profitbricks_password]
|
20
|
+
config.url = Chef::Config[:knife][:profitbricks_url]
|
21
|
+
config.debug = Chef::Config[:knife][:profitbricks_debug] || false
|
22
|
+
config.global_classes = false
|
23
|
+
end
|
24
|
+
|
25
|
+
@datacenter = ProfitBricks::Datacenter.create(name: 'Chef test',
|
26
|
+
description: 'Chef test datacenter',
|
27
|
+
location: 'us/las')
|
28
|
+
@datacenter.wait_for { ready? }
|
29
|
+
|
30
|
+
@lan = ProfitBricks::LAN.create(@datacenter.id, name: 'Chef Test',
|
31
|
+
public: 'true')
|
32
|
+
@lan.wait_for { ready? }
|
33
|
+
|
34
|
+
@server = ProfitBricks::Server.create(@datacenter.id, name: 'Chef Test',
|
35
|
+
ram: 1024,
|
36
|
+
cores: 1,
|
37
|
+
availabilityZone: 'ZONE_1',
|
38
|
+
cpuFamily: 'INTEL_XEON')
|
39
|
+
@server.wait_for { ready? }
|
40
|
+
|
41
|
+
@nic = ProfitBricks::NIC.create(@datacenter.id, @server.id, lan: @lan.id)
|
42
|
+
@nic.wait_for { ready? }
|
43
|
+
|
44
|
+
Chef::Config[:knife][:datacenter_id] = @datacenter.id
|
45
|
+
Chef::Config[:knife][:server_id] = @server.id
|
46
|
+
|
47
|
+
allow(subject).to receive(:puts)
|
48
|
+
end
|
49
|
+
|
50
|
+
after :each do
|
51
|
+
ProfitBricks.configure do |config|
|
52
|
+
config.username = Chef::Config[:knife][:profitbricks_username]
|
53
|
+
config.password = Chef::Config[:knife][:profitbricks_password]
|
54
|
+
config.url = Chef::Config[:knife][:profitbricks_url]
|
55
|
+
config.debug = Chef::Config[:knife][:profitbricks_debug] || false
|
56
|
+
config.global_classes = false
|
57
|
+
end
|
58
|
+
|
59
|
+
@datacenter.delete
|
60
|
+
@datacenter.wait_for { ready? }
|
61
|
+
end
|
62
|
+
|
63
|
+
describe '#run' do
|
64
|
+
it 'should output the column headers' do
|
65
|
+
expect(subject).to receive(:puts).with(/^ID\s+Name\s+IPs\s+DHCP\s+NAT\s+LAN\s*$/)
|
66
|
+
subject.run
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'profitbricks_server_create'
|
3
|
+
|
4
|
+
Chef::Knife::ProfitbricksServerCreate.load_deps
|
5
|
+
|
6
|
+
describe Chef::Knife::ProfitbricksServerCreate do
|
7
|
+
subject { Chef::Knife::ProfitbricksServerCreate.new }
|
8
|
+
|
9
|
+
before :each do
|
10
|
+
{
|
11
|
+
name: 'Chef Test',
|
12
|
+
public: 'true'
|
13
|
+
}.each do |key, value|
|
14
|
+
Chef::Config[:knife][key] = value
|
15
|
+
end
|
16
|
+
|
17
|
+
ProfitBricks.configure do |config|
|
18
|
+
config.username = Chef::Config[:knife][:profitbricks_username]
|
19
|
+
config.password = Chef::Config[:knife][:profitbricks_password]
|
20
|
+
config.url = Chef::Config[:knife][:profitbricks_url]
|
21
|
+
config.debug = Chef::Config[:knife][:profitbricks_debug] || false
|
22
|
+
config.global_classes = false
|
23
|
+
end
|
24
|
+
|
25
|
+
@datacenter = ProfitBricks::Datacenter.create(name: 'Chef test',
|
26
|
+
description: 'Chef test datacenter',
|
27
|
+
location: 'us/las')
|
28
|
+
@datacenter.wait_for { ready? }
|
29
|
+
|
30
|
+
@lan = ProfitBricks::LAN.create(@datacenter.id, name: 'Chef Test',
|
31
|
+
public: 'true')
|
32
|
+
@lan.wait_for { ready? }
|
33
|
+
|
34
|
+
Chef::Config[:knife][:datacenter_id] = @datacenter.id
|
35
|
+
Chef::Config[:knife][:cores] = 2
|
36
|
+
Chef::Config[:knife][:ram] = 2048
|
37
|
+
Chef::Config[:knife][:name] = 'Chef Test'
|
38
|
+
|
39
|
+
allow(subject).to receive(:puts)
|
40
|
+
end
|
41
|
+
|
42
|
+
after :each do
|
43
|
+
ProfitBricks.configure do |config|
|
44
|
+
config.username = Chef::Config[:knife][:profitbricks_username]
|
45
|
+
config.password = Chef::Config[:knife][:profitbricks_password]
|
46
|
+
config.url = Chef::Config[:knife][:profitbricks_url]
|
47
|
+
config.debug = Chef::Config[:knife][:profitbricks_debug] || false
|
48
|
+
config.global_classes = false
|
49
|
+
end
|
50
|
+
|
51
|
+
@datacenter.delete
|
52
|
+
@datacenter.wait_for { ready? }
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '#run' do
|
56
|
+
it 'should create a server' do
|
57
|
+
expect(subject).to receive(:puts).with('Name: Chef Test')
|
58
|
+
expect(subject).to receive(:puts).with('Cores: 2')
|
59
|
+
expect(subject).to receive(:puts).with('Ram: 2048')
|
60
|
+
subject.run
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'profitbricks_server_delete'
|
3
|
+
|
4
|
+
Chef::Knife::ProfitbricksServerDelete.load_deps
|
5
|
+
|
6
|
+
describe Chef::Knife::ProfitbricksServerDelete do
|
7
|
+
subject { Chef::Knife::ProfitbricksServerDelete.new }
|
8
|
+
|
9
|
+
before :each do
|
10
|
+
allow(subject).to receive(:puts)
|
11
|
+
subject.config[:yes] = true
|
12
|
+
|
13
|
+
{
|
14
|
+
name: 'Chef Test',
|
15
|
+
public: 'true'
|
16
|
+
}.each do |key, value|
|
17
|
+
Chef::Config[:knife][key] = value
|
18
|
+
end
|
19
|
+
|
20
|
+
ProfitBricks.configure do |config|
|
21
|
+
config.username = Chef::Config[:knife][:profitbricks_username]
|
22
|
+
config.password = Chef::Config[:knife][:profitbricks_password]
|
23
|
+
config.url = Chef::Config[:knife][:profitbricks_url]
|
24
|
+
config.debug = Chef::Config[:knife][:profitbricks_debug] || false
|
25
|
+
config.global_classes = false
|
26
|
+
end
|
27
|
+
|
28
|
+
@datacenter = ProfitBricks::Datacenter.create(name: 'Chef test',
|
29
|
+
description: 'Chef test datacenter',
|
30
|
+
location: 'us/las')
|
31
|
+
@datacenter.wait_for { ready? }
|
32
|
+
|
33
|
+
@server = ProfitBricks::Server.create(@datacenter.id, name: 'Chef Test',
|
34
|
+
ram: 1024,
|
35
|
+
cores: 1,
|
36
|
+
availabilityZone: 'ZONE_1',
|
37
|
+
cpuFamily: 'INTEL_XEON')
|
38
|
+
@server.wait_for { ready? }
|
39
|
+
|
40
|
+
Chef::Config[:knife][:datacenter_id] = @datacenter.id
|
41
|
+
|
42
|
+
subject.name_args = [@server.id]
|
43
|
+
end
|
44
|
+
|
45
|
+
after :each do
|
46
|
+
ProfitBricks.configure do |config|
|
47
|
+
config.username = Chef::Config[:knife][:profitbricks_username]
|
48
|
+
config.password = Chef::Config[:knife][:profitbricks_password]
|
49
|
+
config.url = Chef::Config[:knife][:profitbricks_url]
|
50
|
+
config.debug = Chef::Config[:knife][:profitbricks_debug] || false
|
51
|
+
config.global_classes = false
|
52
|
+
end
|
53
|
+
|
54
|
+
@datacenter.delete
|
55
|
+
@datacenter.wait_for { ready? }
|
56
|
+
end
|
57
|
+
|
58
|
+
describe '#run' do
|
59
|
+
it 'should delete a server' do
|
60
|
+
subject.run
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'profitbricks_server_list'
|
3
|
+
|
4
|
+
Chef::Knife::ProfitbricksServerList.load_deps
|
5
|
+
|
6
|
+
describe Chef::Knife::ProfitbricksServerList do
|
7
|
+
subject { Chef::Knife::ProfitbricksServerList.new }
|
8
|
+
|
9
|
+
before :each do
|
10
|
+
{
|
11
|
+
name: 'Chef Test',
|
12
|
+
public: 'true'
|
13
|
+
}.each do |key, value|
|
14
|
+
Chef::Config[:knife][key] = value
|
15
|
+
end
|
16
|
+
|
17
|
+
ProfitBricks.configure do |config|
|
18
|
+
config.username = Chef::Config[:knife][:profitbricks_username]
|
19
|
+
config.password = Chef::Config[:knife][:profitbricks_password]
|
20
|
+
config.url = Chef::Config[:knife][:profitbricks_url]
|
21
|
+
config.debug = Chef::Config[:knife][:profitbricks_debug] || false
|
22
|
+
config.global_classes = false
|
23
|
+
end
|
24
|
+
|
25
|
+
@datacenter = ProfitBricks::Datacenter.create(name: 'Chef test',
|
26
|
+
description: 'Chef test datacenter',
|
27
|
+
location: 'us/las')
|
28
|
+
@datacenter.wait_for { ready? }
|
29
|
+
|
30
|
+
@lan = ProfitBricks::LAN.create(@datacenter.id, name: 'Chef Test',
|
31
|
+
public: 'true')
|
32
|
+
@lan.wait_for { ready? }
|
33
|
+
|
34
|
+
@server = ProfitBricks::Server.create(@datacenter.id, name: 'Chef Test',
|
35
|
+
ram: 1024,
|
36
|
+
cores: 1,
|
37
|
+
availabilityZone: 'ZONE_1',
|
38
|
+
cpuFamily: 'INTEL_XEON')
|
39
|
+
@server.wait_for { ready? }
|
40
|
+
|
41
|
+
Chef::Config[:knife][:datacenter_id] = @datacenter.id
|
42
|
+
|
43
|
+
allow(subject).to receive(:puts)
|
44
|
+
end
|
45
|
+
|
46
|
+
after :each do
|
47
|
+
ProfitBricks.configure do |config|
|
48
|
+
config.username = Chef::Config[:knife][:profitbricks_username]
|
49
|
+
config.password = Chef::Config[:knife][:profitbricks_password]
|
50
|
+
config.url = Chef::Config[:knife][:profitbricks_url]
|
51
|
+
config.debug = Chef::Config[:knife][:profitbricks_debug] || false
|
52
|
+
config.global_classes = false
|
53
|
+
end
|
54
|
+
|
55
|
+
@datacenter.delete
|
56
|
+
@datacenter.wait_for { ready? }
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '#run' do
|
60
|
+
it 'should output the column headers' do
|
61
|
+
expect(subject).to receive(:puts).with(/^ID\s+Name\s+Cores\s+RAM\s+ Availability Zone\s+VM State\s+Boot Volume\s+Boot CDROM\s*$/)
|
62
|
+
subject.run
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'profitbricks_server_reboot'
|
3
|
+
|
4
|
+
Chef::Knife::ProfitbricksServerReboot.load_deps
|
5
|
+
|
6
|
+
describe Chef::Knife::ProfitbricksServerReboot do
|
7
|
+
subject { Chef::Knife::ProfitbricksServerReboot.new }
|
8
|
+
|
9
|
+
before :each do
|
10
|
+
{
|
11
|
+
name: 'Chef Test',
|
12
|
+
public: 'true'
|
13
|
+
}.each do |key, value|
|
14
|
+
Chef::Config[:knife][key] = value
|
15
|
+
end
|
16
|
+
|
17
|
+
ProfitBricks.configure do |config|
|
18
|
+
config.username = Chef::Config[:knife][:profitbricks_username]
|
19
|
+
config.password = Chef::Config[:knife][:profitbricks_password]
|
20
|
+
config.url = Chef::Config[:knife][:profitbricks_url]
|
21
|
+
config.debug = Chef::Config[:knife][:profitbricks_debug] || false
|
22
|
+
config.global_classes = false
|
23
|
+
end
|
24
|
+
|
25
|
+
@datacenter = ProfitBricks::Datacenter.create(name: 'Chef test',
|
26
|
+
description: 'Chef test datacenter',
|
27
|
+
location: 'us/las')
|
28
|
+
@datacenter.wait_for { ready? }
|
29
|
+
|
30
|
+
@lan = ProfitBricks::LAN.create(@datacenter.id, name: 'Chef Test',
|
31
|
+
public: 'true')
|
32
|
+
@lan.wait_for { ready? }
|
33
|
+
|
34
|
+
@server = ProfitBricks::Server.create(@datacenter.id, name: 'Chef Test',
|
35
|
+
ram: 1024,
|
36
|
+
cores: 1,
|
37
|
+
availabilityZone: 'ZONE_1',
|
38
|
+
cpuFamily: 'INTEL_XEON')
|
39
|
+
@server.wait_for { ready? }
|
40
|
+
|
41
|
+
Chef::Config[:knife][:datacenter_id] = @datacenter.id
|
42
|
+
subject.name_args = [@server.id]
|
43
|
+
|
44
|
+
allow(subject).to receive(:puts)
|
45
|
+
end
|
46
|
+
|
47
|
+
after :each do
|
48
|
+
ProfitBricks.configure do |config|
|
49
|
+
config.username = Chef::Config[:knife][:profitbricks_username]
|
50
|
+
config.password = Chef::Config[:knife][:profitbricks_password]
|
51
|
+
config.url = Chef::Config[:knife][:profitbricks_url]
|
52
|
+
config.debug = Chef::Config[:knife][:profitbricks_debug] || false
|
53
|
+
config.global_classes = false
|
54
|
+
end
|
55
|
+
|
56
|
+
@datacenter.delete
|
57
|
+
@datacenter.wait_for { ready? }
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '#run' do
|
61
|
+
it 'should output the column headers' do
|
62
|
+
subject.run
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|