chef-provisioning-opennebula 0.3.4

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.
Files changed (41) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +201 -0
  3. data/README.md +532 -0
  4. data/Rakefile +6 -0
  5. data/lib/chef/provider/one_image.rb +244 -0
  6. data/lib/chef/provider/one_template.rb +95 -0
  7. data/lib/chef/provider/one_user.rb +105 -0
  8. data/lib/chef/provider/one_vnet.rb +122 -0
  9. data/lib/chef/provider/one_vnet_lease.rb +133 -0
  10. data/lib/chef/provisioning/driver_init/opennebula.rb +17 -0
  11. data/lib/chef/provisioning/opennebula_driver.rb +18 -0
  12. data/lib/chef/provisioning/opennebula_driver/credentials.rb +105 -0
  13. data/lib/chef/provisioning/opennebula_driver/driver.rb +572 -0
  14. data/lib/chef/provisioning/opennebula_driver/one_lib.rb +352 -0
  15. data/lib/chef/provisioning/opennebula_driver/resources.rb +20 -0
  16. data/lib/chef/provisioning/opennebula_driver/version.rb +30 -0
  17. data/lib/chef/resource/one_image.rb +65 -0
  18. data/lib/chef/resource/one_template.rb +46 -0
  19. data/lib/chef/resource/one_user.rb +50 -0
  20. data/lib/chef/resource/one_vnet.rb +51 -0
  21. data/lib/chef/resource/one_vnet_lease.rb +46 -0
  22. data/spec/integration/test_all_integration_spec.rb +102 -0
  23. data/spec/recipes/attach_back_one_vm_spec.rb +20 -0
  24. data/spec/recipes/attach_back_two_vm_spec.rb +20 -0
  25. data/spec/recipes/attach_one_image_spec.rb +20 -0
  26. data/spec/recipes/converge_back_one_vm_spec.rb +19 -0
  27. data/spec/recipes/converge_back_two_vm_spec.rb +19 -0
  28. data/spec/recipes/converge_bootstrap_vm_spec.rb +34 -0
  29. data/spec/recipes/create_back_one_vm_spec.rb +20 -0
  30. data/spec/recipes/create_back_two_vm_spec.rb +20 -0
  31. data/spec/recipes/create_bootstrap_vm_spec.rb +34 -0
  32. data/spec/recipes/create_one_image_spec.rb +21 -0
  33. data/spec/recipes/create_one_template_spec.rb +52 -0
  34. data/spec/recipes/delete_all_spec.rb +47 -0
  35. data/spec/recipes/driver_options_spec.rb +70 -0
  36. data/spec/recipes/instantiate_one_template_spec.rb +35 -0
  37. data/spec/recipes/snapshot_one_image_spec.rb +21 -0
  38. data/spec/recipes/snapshot_two_image_spec.rb +21 -0
  39. data/spec/spec_helper.rb +35 -0
  40. data/spec/support/opennebula_support.rb +64 -0
  41. metadata +168 -0
@@ -0,0 +1,46 @@
1
+ # Copyright 2015, BlackBerry, Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'chef/provider/one_template'
16
+
17
+ #
18
+ # Implementation of Resource class.
19
+ #
20
+ class Chef
21
+ #
22
+ # Implementation of Resource class.
23
+ #
24
+ class Resource
25
+ #
26
+ # Implementation of Resource class.
27
+ #
28
+ class OneTemplate < Chef::Resource::LWRPBase
29
+ resource_name :one_template
30
+
31
+ attribute :template, :kind_of => Hash
32
+ attribute :template_file, :kind_of => String
33
+ attribute :driver
34
+
35
+ actions :create, :delete
36
+ default_action :create
37
+
38
+ def initialize(*args)
39
+ super
40
+ @chef_environment = run_context.cheffish.current_environment
41
+ @chef_server = run_context.cheffish.current_chef_server
42
+ @driver = run_context.chef_provisioning.current_driver
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,50 @@
1
+ # Copyright 2015, BlackBerry, Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'chef/provider/one_user'
16
+
17
+ #
18
+ # Implementation of Resource class.
19
+ #
20
+ class Chef
21
+ #
22
+ # Implementation of Resource class.
23
+ #
24
+ class Resource
25
+ #
26
+ # Implementation of Resource class.
27
+ #
28
+ class OneUser < Chef::Resource::LWRPBase
29
+ resource_name :one_user
30
+
31
+ attribute :name, :kind_of => String, :name_attribute => true
32
+ attribute :user_id, :kind_of => Integer
33
+ attribute :password, :kind_of => String
34
+ attribute :groups, :kind_of => Array
35
+ attribute :quotas, :kind_of => Array
36
+ attribute :template_file, :kind_of => String
37
+ attribute :template, :kind_of => Hash
38
+ attribute :append, :kind_of => [TrueClass, FalseClass], :default => true
39
+ attribute :driver
40
+
41
+ actions :update, :create, :delete
42
+ default_action :update
43
+
44
+ def initialize(*args)
45
+ super
46
+ @driver = run_context.chef_provisioning.current_driver
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,51 @@
1
+ # Copyright 2015, BlackBerry, Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'chef/provider/one_vnet'
16
+
17
+ #
18
+ # Implementation of Resource class.
19
+ #
20
+ class Chef
21
+ #
22
+ # Implementation of Resource class.
23
+ #
24
+ class Resource
25
+ #
26
+ # Implementation of Resource class.
27
+ #
28
+ class OneVnet < Chef::Resource::LWRPBase
29
+ resource_name :one_vnet
30
+
31
+ attribute :name, :kind_of => String, :name_attribute => true
32
+ attribute :vnet_id, :kind_of => Integer
33
+ attribute :network, :kind_of => Integer
34
+ attribute :size, :kind_of => Integer, :default => 1
35
+ attribute :mac_ip, :kind_of => String
36
+ attribute :ar_id, :kind_of => Integer
37
+ attribute :template_file, :kind_of => String
38
+ attribute :cluster_id, :kind_of => Integer
39
+
40
+ attribute :driver
41
+
42
+ actions :reserve, :create, :delete
43
+ default_action :reserve
44
+
45
+ def initialize(*args)
46
+ super
47
+ @driver = run_context.chef_provisioning.current_driver
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,46 @@
1
+ # Copyright 2015, BlackBerry, Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'chef/provider/one_vnet_lease'
16
+
17
+ #
18
+ # Implementation of Resource class.
19
+ #
20
+ class Chef
21
+ #
22
+ # Implementation of Resource class.
23
+ #
24
+ class Resource
25
+ #
26
+ # Implementation of Resource class.
27
+ #
28
+ class OneVnetLease < Chef::Resource::LWRPBase
29
+ resource_name :one_vnet_lease
30
+
31
+ attribute :mac_ip, :kind_of => String, :name_attribute => true
32
+ attribute :vnet, :kind_of => [String, Integer], :required => true
33
+ attribute :ar_id, :kind_of => Integer, :default => -1
34
+
35
+ attribute :driver
36
+
37
+ actions :hold, :release
38
+ default_action :hold
39
+
40
+ def initialize(*args)
41
+ super
42
+ @driver = run_context.chef_provisioning.current_driver
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,102 @@
1
+ # Copyright 2015, BlackBerry, Inc.
2
+ #
3
+ #Licensed under the Apache License, Version 2.0 (the "License");
4
+ #you may not use this file except in compliance with the License.
5
+ #You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ #Unless required by applicable law or agreed to in writing, software
10
+ #distributed under the License is distributed on an "AS IS" BASIS,
11
+ #WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ #See the License for the specific language governing permissions and
13
+ #limitations under the License.
14
+
15
+ require 'spec_helper'
16
+ require 'chef/provisioning/opennebula_driver'
17
+
18
+ describe "create_one_template_spec.rb", :type => :recipe do
19
+ it { is_expected.to converge_test_recipe("create_one_template_spec.rb",
20
+ "Creating template OpenNebula-test-tpl",
21
+ "Template OpenNebula-test-tpl already exists") }
22
+ end
23
+
24
+ describe "instantiate_one_template_spec.rb", :type => :recipe do
25
+ it { is_expected.to converge_test_recipe("instantiate_one_template_spec.rb",
26
+ "Creating instances from template",
27
+ "Instance with name 'OpenNebula-test-1-vm' already exists") }
28
+ end
29
+
30
+ describe "create_bootstrap_vm_spec.rb", :type => :recipe do
31
+ it { is_expected.to converge_test_recipe("create_bootstrap_vm_spec.rb",
32
+ "Creating VM OpenNebula-bootstrap-vm",
33
+ "VM OpenNebula-bootstrap-vm exists. Rebooting...") }
34
+ end
35
+
36
+ describe "create_one_image_spec.rb", :type => :recipe do
37
+ it { is_expected.to converge_test_recipe("create_one_image_spec.rb",
38
+ "Waiting for image 'OpenNebula-bootstrap-img' to be READY",
39
+ "Image 'OpenNebula-bootstrap-img' is already in READY state") }
40
+ end
41
+
42
+ describe "attach_one_image_spec.rb", :type => :recipe do
43
+ it { is_expected.to converge_test_recipe("attach_one_image_spec.rb",
44
+ "Disk not attached. Attaching...",
45
+ "Disk is already attached") }
46
+ end
47
+
48
+ describe "snapshot_one_image_spec.rb", :type => :recipe do
49
+ it { is_expected.to converge_test_recipe("snapshot_one_image_spec.rb",
50
+ "Creating snapshot from 'OpenNebula-bootstrap-vm'",
51
+ "Snapshot image 'OpenNebula-snap-1-img' already exists") }
52
+ end
53
+
54
+ describe "converge_bootstrap_vm_spec.rb", :type => :recipe do
55
+ it { is_expected.to converge_test_recipe("converge_bootstrap_vm_spec.rb") }
56
+ end
57
+
58
+ # deploys two test backend VM's
59
+ describe "snapshot_two_image_spec.rb", :type => :recipe do
60
+ it { is_expected.to converge_test_recipe("snapshot_two_image_spec.rb",
61
+ "Creating snapshot from 'OpenNebula-bootstrap-vm'",
62
+ "Snapshot image 'OpenNebula-snap-1-img' already exists") }
63
+ end
64
+
65
+ describe "create_back_one_vm_spec.rb", :type => :recipe do
66
+ it { is_expected.to converge_test_recipe("create_back_one_vm_spec.rb",
67
+ "Creating VM OpenNebula-back-1-vm",
68
+ "VM OpenNebula-back-1-vm exists. Rebooting...") }
69
+ end
70
+
71
+ describe "attach_back_one_vm_spec.rb", :type => :recipe do
72
+ it { is_expected.to converge_test_recipe("attach_back_one_vm_spec.rb",
73
+ "Disk not attached. Attaching...",
74
+ "Disk is already attached") }
75
+ end
76
+
77
+ describe "converge_back_one_vm_spec.rb", :type => :recipe do
78
+ it { is_expected.to converge_test_recipe("converge_back_one_vm_spec.rb") }
79
+ end
80
+
81
+ describe "create_back_two_vm_spec.rb", :type => :recipe do
82
+ it { is_expected.to converge_test_recipe("create_back_two_vm_spec.rb",
83
+ "Creating VM OpenNebula-back-2-vm",
84
+ "VM OpenNebula-back-2-vm exists. Rebooting...") }
85
+ end
86
+
87
+ describe "attach_back_two_vm_spec.rb", :type => :recipe do
88
+ it { is_expected.to converge_test_recipe("attach_back_two_vm_spec.rb",
89
+ "Disk not attached. Attaching...",
90
+ "Disk is already attached") }
91
+ end
92
+
93
+ describe "converge_back_two_vm_spec.rb", :type => :recipe do
94
+ it { is_expected.to converge_test_recipe("converge_back_two_vm_spec.rb") }
95
+ end
96
+
97
+ # cleans up all test VMs/templates/images after testing
98
+ # assuming all other tests work as intended, this test will pass
99
+ # in the event a previous test failed, this test will also fail
100
+ describe "delete_all_spec.rb", :type => :recipe do
101
+ it { is_expected.to converge_test_recipe("delete_all_spec.rb", nil, "does not exist") }
102
+ end
@@ -0,0 +1,20 @@
1
+ # Copyright 2015, BlackBerry, Inc.
2
+ #
3
+ #Licensed under the Apache License, Version 2.0 (the "License");
4
+ #you may not use this file except in compliance with the License.
5
+ #You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ #Unless required by applicable law or agreed to in writing, software
10
+ #distributed under the License is distributed on an "AS IS" BASIS,
11
+ #WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ #See the License for the specific language governing permissions and
13
+ #limitations under the License.
14
+
15
+ require 'chef/provisioning/opennebula_driver'
16
+
17
+ one_image "OpenNebula-snap-1-img" do
18
+ machine_id 'OpenNebula-back-1-vm'
19
+ action :attach
20
+ end
@@ -0,0 +1,20 @@
1
+ # Copyright 2015, BlackBerry, Inc.
2
+ #
3
+ #Licensed under the Apache License, Version 2.0 (the "License");
4
+ #you may not use this file except in compliance with the License.
5
+ #You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ #Unless required by applicable law or agreed to in writing, software
10
+ #distributed under the License is distributed on an "AS IS" BASIS,
11
+ #WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ #See the License for the specific language governing permissions and
13
+ #limitations under the License.
14
+
15
+ require 'chef/provisioning/opennebula_driver'
16
+
17
+ one_image "OpenNebula-snap-2-img" do
18
+ machine_id 'OpenNebula-back-2-vm'
19
+ action :attach
20
+ end
@@ -0,0 +1,20 @@
1
+ # Copyright 2015, BlackBerry, Inc.
2
+ #
3
+ #Licensed under the Apache License, Version 2.0 (the "License");
4
+ #you may not use this file except in compliance with the License.
5
+ #You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ #Unless required by applicable law or agreed to in writing, software
10
+ #distributed under the License is distributed on an "AS IS" BASIS,
11
+ #WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ #See the License for the specific language governing permissions and
13
+ #limitations under the License.
14
+
15
+ require 'chef/provisioning/opennebula_driver'
16
+
17
+ one_image "OpenNebula-bootstrap-img" do
18
+ machine_id 'OpenNebula-bootstrap-vm'
19
+ action :attach
20
+ end
@@ -0,0 +1,19 @@
1
+ # Copyright 2015, BlackBerry, Inc.
2
+ #
3
+ #Licensed under the Apache License, Version 2.0 (the "License");
4
+ #you may not use this file except in compliance with the License.
5
+ #You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ #Unless required by applicable law or agreed to in writing, software
10
+ #distributed under the License is distributed on an "AS IS" BASIS,
11
+ #WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ #See the License for the specific language governing permissions and
13
+ #limitations under the License.
14
+
15
+ require 'chef/provisioning/opennebula_driver'
16
+
17
+ machine "OpenNebula-back-1-vm" do
18
+ run_list []
19
+ end
@@ -0,0 +1,19 @@
1
+ # Copyright 2015, BlackBerry, Inc.
2
+ #
3
+ #Licensed under the Apache License, Version 2.0 (the "License");
4
+ #you may not use this file except in compliance with the License.
5
+ #You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ #Unless required by applicable law or agreed to in writing, software
10
+ #distributed under the License is distributed on an "AS IS" BASIS,
11
+ #WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ #See the License for the specific language governing permissions and
13
+ #limitations under the License.
14
+
15
+ require 'chef/provisioning/opennebula_driver'
16
+
17
+ machine "OpenNebula-back-2-vm" do
18
+ run_list []
19
+ end
@@ -0,0 +1,34 @@
1
+ # Copyright 2015, BlackBerry, Inc.
2
+ #
3
+ #Licensed under the Apache License, Version 2.0 (the "License");
4
+ #you may not use this file except in compliance with the License.
5
+ #You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ #Unless required by applicable law or agreed to in writing, software
10
+ #distributed under the License is distributed on an "AS IS" BASIS,
11
+ #WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ #See the License for the specific language governing permissions and
13
+ #limitations under the License.
14
+
15
+ require 'chef/provisioning/opennebula_driver'
16
+
17
+ machine "OpenNebula-bootstrap-vm" do
18
+ machine_options :bootstrap_options => ({
19
+ :user_variables => {'MEMORY' => '2048', 'CONTEXT/TEST' => 'test'},
20
+ :template_name => 'OpenNebula-test-tpl'
21
+ }),
22
+ :ssh_user => 'local',
23
+ :ssh_options => {
24
+ :keys_only => false,
25
+ :forward_agent => true,
26
+ :use_agent => true,
27
+ :user_known_hosts_file => '/dev/null'
28
+ },
29
+ :ssh_execute_options => {
30
+ :prefix => 'sudo '
31
+ },
32
+ :cached_installer => true
33
+ run_list []
34
+ end
@@ -0,0 +1,20 @@
1
+ # Copyright 2015, BlackBerry, Inc.
2
+ #
3
+ #Licensed under the Apache License, Version 2.0 (the "License");
4
+ #you may not use this file except in compliance with the License.
5
+ #You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ #Unless required by applicable law or agreed to in writing, software
10
+ #distributed under the License is distributed on an "AS IS" BASIS,
11
+ #WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ #See the License for the specific language governing permissions and
13
+ #limitations under the License.
14
+
15
+ require 'chef/provisioning/opennebula_driver'
16
+
17
+ machine "OpenNebula-back-1-vm" do
18
+ from_image "OpenNebula-snap-1-img"
19
+ action :ready
20
+ end