knife-profitbricks 1.2.1 → 2.0.1
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.
- 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,68 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'profitbricks_server_start'
|
3
|
+
|
4
|
+
Chef::Knife::ProfitbricksServerStart.load_deps
|
5
|
+
|
6
|
+
describe Chef::Knife::ProfitbricksServerStart do
|
7
|
+
subject { Chef::Knife::ProfitbricksServerStart.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
|
+
@server.stop
|
42
|
+
@server.wait_for { ready? }
|
43
|
+
|
44
|
+
Chef::Config[:knife][:datacenter_id] = @datacenter.id
|
45
|
+
subject.name_args = [@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
|
+
subject.run
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'profitbricks_server_stop'
|
3
|
+
|
4
|
+
Chef::Knife::ProfitbricksServerStop.load_deps
|
5
|
+
|
6
|
+
describe Chef::Knife::ProfitbricksServerStop do
|
7
|
+
subject { Chef::Knife::ProfitbricksServerStop.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
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'profitbricks_volume_attach'
|
3
|
+
|
4
|
+
Chef::Knife::ProfitbricksVolumeAttach.load_deps
|
5
|
+
|
6
|
+
describe Chef::Knife::ProfitbricksVolumeAttach do
|
7
|
+
subject { Chef::Knife::ProfitbricksVolumeAttach.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
|
+
@server = ProfitBricks::Server.create(@datacenter.id, name: 'Chef Test',
|
31
|
+
ram: 1024,
|
32
|
+
cores: 1,
|
33
|
+
availabilityZone: 'ZONE_1',
|
34
|
+
cpuFamily: 'INTEL_XEON')
|
35
|
+
@server.wait_for { ready? }
|
36
|
+
|
37
|
+
@volume = ProfitBricks::Volume.create(@datacenter.id, size: 2,
|
38
|
+
type: 'HDD',
|
39
|
+
licenceType: 'UNKNOWN',
|
40
|
+
availabilityZone: 'ZONE_3',
|
41
|
+
bus: 'VIRTIO')
|
42
|
+
|
43
|
+
@volume.wait_for(300) { ready? }
|
44
|
+
|
45
|
+
Chef::Config[:knife][:datacenter_id] = @datacenter.id
|
46
|
+
Chef::Config[:knife][:server_id] = @server.id
|
47
|
+
subject.name_args = [@volume.id]
|
48
|
+
|
49
|
+
allow(subject).to receive(:puts)
|
50
|
+
end
|
51
|
+
|
52
|
+
after :each do
|
53
|
+
ProfitBricks.configure do |config|
|
54
|
+
config.username = Chef::Config[:knife][:profitbricks_username]
|
55
|
+
config.password = Chef::Config[:knife][:profitbricks_password]
|
56
|
+
config.url = Chef::Config[:knife][:profitbricks_url]
|
57
|
+
config.debug = Chef::Config[:knife][:profitbricks_debug] || false
|
58
|
+
config.global_classes = false
|
59
|
+
end
|
60
|
+
|
61
|
+
@datacenter.delete
|
62
|
+
@datacenter.wait_for { ready? }
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '#run' do
|
66
|
+
it 'should attach a volume' do
|
67
|
+
subject.run
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'profitbricks_volume_create'
|
3
|
+
|
4
|
+
Chef::Knife::ProfitbricksVolumeCreate.load_deps
|
5
|
+
|
6
|
+
describe Chef::Knife::ProfitbricksVolumeCreate do
|
7
|
+
subject { Chef::Knife::ProfitbricksVolumeCreate.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
|
+
Chef::Config[:knife][:datacenter_id] = @datacenter.id
|
31
|
+
Chef::Config[:knife][:imagealias] = 'ubuntu:latest'
|
32
|
+
Chef::Config[:knife][:size] = 4
|
33
|
+
Chef::Config[:knife][:name] = 'Chef Test'
|
34
|
+
Chef::Config[:knife][:type] = 'HDD'
|
35
|
+
Chef::Config[:knife][:imagepassword] = 'aheoizj4689'
|
36
|
+
|
37
|
+
allow(subject).to receive(:puts)
|
38
|
+
end
|
39
|
+
|
40
|
+
after :each do
|
41
|
+
ProfitBricks.configure do |config|
|
42
|
+
config.username = Chef::Config[:knife][:profitbricks_username]
|
43
|
+
config.password = Chef::Config[:knife][:profitbricks_password]
|
44
|
+
config.url = Chef::Config[:knife][:profitbricks_url]
|
45
|
+
config.debug = Chef::Config[:knife][:profitbricks_debug] || false
|
46
|
+
config.global_classes = false
|
47
|
+
end
|
48
|
+
|
49
|
+
@datacenter.delete
|
50
|
+
@datacenter.wait_for { ready? }
|
51
|
+
end
|
52
|
+
|
53
|
+
describe '#run' do
|
54
|
+
it 'should create a volume' do
|
55
|
+
expect(subject).to receive(:puts).with('Size: 4')
|
56
|
+
expect(subject).to receive(:puts).with('Bus: ')
|
57
|
+
expect(subject).to receive(:puts).with('Type: HDD')
|
58
|
+
expect(subject).to receive(:puts).with('Licence Type: LINUX')
|
59
|
+
expect(subject).to receive(:puts).with('Zone: AUTO')
|
60
|
+
subject.run
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'profitbricks_volume_delete'
|
3
|
+
|
4
|
+
Chef::Knife::ProfitbricksVolumeDelete.load_deps
|
5
|
+
|
6
|
+
describe Chef::Knife::ProfitbricksVolumeDelete do
|
7
|
+
subject { Chef::Knife::ProfitbricksVolumeDelete.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
|
+
location = 'us/las'
|
31
|
+
image_name = 'ubuntu'
|
32
|
+
image_type = 'HDD'
|
33
|
+
|
34
|
+
image = get_image(image_name, image_type, location)
|
35
|
+
|
36
|
+
@volume = ProfitBricks::Volume.create(@datacenter.id, size: 2,
|
37
|
+
type: 'HDD',
|
38
|
+
availabilityZone: 'ZONE_3',
|
39
|
+
image: image.id,
|
40
|
+
imagePassword: 'aoiaio00q235',
|
41
|
+
bus: 'VIRTIO')
|
42
|
+
|
43
|
+
@volume.wait_for(300) { ready? }
|
44
|
+
|
45
|
+
Chef::Config[:knife][:datacenter_id] = @datacenter.id
|
46
|
+
subject.name_args = [@volume.id]
|
47
|
+
|
48
|
+
allow(subject).to receive(:puts)
|
49
|
+
subject.config[:yes] = true
|
50
|
+
end
|
51
|
+
|
52
|
+
after :each do
|
53
|
+
ProfitBricks.configure do |config|
|
54
|
+
config.username = Chef::Config[:knife][:profitbricks_username]
|
55
|
+
config.password = Chef::Config[:knife][:profitbricks_password]
|
56
|
+
config.url = Chef::Config[:knife][:profitbricks_url]
|
57
|
+
config.debug = Chef::Config[:knife][:profitbricks_debug] || false
|
58
|
+
config.global_classes = false
|
59
|
+
end
|
60
|
+
|
61
|
+
@datacenter.delete
|
62
|
+
@datacenter.wait_for { ready? }
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '#run' do
|
66
|
+
it 'should delete a volume' do
|
67
|
+
subject.run
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'profitbricks_volume_detach'
|
3
|
+
|
4
|
+
Chef::Knife::ProfitbricksVolumeDetach.load_deps
|
5
|
+
|
6
|
+
describe Chef::Knife::ProfitbricksVolumeDetach do
|
7
|
+
subject { Chef::Knife::ProfitbricksVolumeDetach.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
|
+
@server = ProfitBricks::Server.create(@datacenter.id, name: 'Chef Test',
|
31
|
+
ram: 1024,
|
32
|
+
cores: 1,
|
33
|
+
availabilityZone: 'ZONE_1',
|
34
|
+
cpuFamily: 'INTEL_XEON')
|
35
|
+
@server.wait_for { ready? }
|
36
|
+
|
37
|
+
location = 'us/las'
|
38
|
+
image_name = 'ubuntu'
|
39
|
+
image_type = 'HDD'
|
40
|
+
|
41
|
+
image = get_image(image_name, image_type, location)
|
42
|
+
|
43
|
+
@volume = ProfitBricks::Volume.create(@datacenter.id, size: 2,
|
44
|
+
type: 'HDD',
|
45
|
+
availabilityZone: 'ZONE_3',
|
46
|
+
image: image.id,
|
47
|
+
imagePassword: 'aoiaio00q235',
|
48
|
+
bus: 'VIRTIO')
|
49
|
+
|
50
|
+
@volume.wait_for(300) { ready? }
|
51
|
+
|
52
|
+
@volume.attach(@server.id)
|
53
|
+
@volume.wait_for(300) { ready? }
|
54
|
+
|
55
|
+
Chef::Config[:knife][:datacenter_id] = @datacenter.id
|
56
|
+
Chef::Config[:knife][:server_id] = @server.id
|
57
|
+
subject.name_args = [@volume.id]
|
58
|
+
|
59
|
+
allow(subject).to receive(:puts)
|
60
|
+
subject.config[:yes] = true
|
61
|
+
end
|
62
|
+
|
63
|
+
after :each do
|
64
|
+
ProfitBricks.configure do |config|
|
65
|
+
config.username = Chef::Config[:knife][:profitbricks_username]
|
66
|
+
config.password = Chef::Config[:knife][:profitbricks_password]
|
67
|
+
config.url = Chef::Config[:knife][:profitbricks_url]
|
68
|
+
config.debug = Chef::Config[:knife][:profitbricks_debug] || false
|
69
|
+
config.global_classes = false
|
70
|
+
end
|
71
|
+
|
72
|
+
@datacenter.delete
|
73
|
+
@datacenter.wait_for { ready? }
|
74
|
+
end
|
75
|
+
|
76
|
+
describe '#run' do
|
77
|
+
it 'should detach a volume' do
|
78
|
+
subject.run
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'profitbricks_volume_list'
|
3
|
+
|
4
|
+
Chef::Knife::ProfitbricksVolumeList.load_deps
|
5
|
+
|
6
|
+
describe Chef::Knife::ProfitbricksVolumeList do
|
7
|
+
subject { Chef::Knife::ProfitbricksVolumeList.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
|
+
location = 'us/las'
|
31
|
+
image_name = 'ubuntu'
|
32
|
+
image_type = 'HDD'
|
33
|
+
|
34
|
+
image = get_image(image_name, image_type, location)
|
35
|
+
|
36
|
+
@volume = ProfitBricks::Volume.create(@datacenter.id, size: 2,
|
37
|
+
type: 'HDD',
|
38
|
+
availabilityZone: 'ZONE_3',
|
39
|
+
image: image.id,
|
40
|
+
imagePassword: 'aoiaio00q235',
|
41
|
+
bus: 'VIRTIO')
|
42
|
+
|
43
|
+
@volume.wait_for(300) { ready? }
|
44
|
+
|
45
|
+
@server = ProfitBricks::Server.create(@datacenter.id, name: 'Chef Test',
|
46
|
+
ram: 1024,
|
47
|
+
cores: 1,
|
48
|
+
availabilityZone: 'ZONE_1',
|
49
|
+
cpuFamily: 'INTEL_XEON')
|
50
|
+
@server.wait_for { ready? }
|
51
|
+
|
52
|
+
@volume.attach(@server.id)
|
53
|
+
@volume.wait_for(300) { ready? }
|
54
|
+
|
55
|
+
Chef::Config[:knife][:datacenter_id] = @datacenter.id
|
56
|
+
Chef::Config[:knife][:server_id] = @server.id
|
57
|
+
|
58
|
+
allow(subject).to receive(:puts)
|
59
|
+
end
|
60
|
+
|
61
|
+
after :each do
|
62
|
+
ProfitBricks.configure do |config|
|
63
|
+
config.username = Chef::Config[:knife][:profitbricks_username]
|
64
|
+
config.password = Chef::Config[:knife][:profitbricks_password]
|
65
|
+
config.url = Chef::Config[:knife][:profitbricks_url]
|
66
|
+
config.debug = Chef::Config[:knife][:profitbricks_debug] || false
|
67
|
+
config.global_classes = false
|
68
|
+
end
|
69
|
+
|
70
|
+
@datacenter.delete
|
71
|
+
@datacenter.wait_for { ready? }
|
72
|
+
end
|
73
|
+
|
74
|
+
describe '#run' do
|
75
|
+
it 'should list volumes' do
|
76
|
+
expect(subject).to receive(:puts).with(/^ID\s+Name\s+Size\s+Bus\s+Image\s+Type\s+Zone\s+Device Number\s*$/)
|
77
|
+
subject.run
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|