vagrant-cloudstack 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +18 -19
  3. data/.ruby-version +1 -1
  4. data/.travis.yml +19 -19
  5. data/CHANGELOG.md +179 -171
  6. data/Docker/.dockerignore +2 -0
  7. data/Docker/Dockerfile +51 -0
  8. data/Docker/Dockerfile.chefdk_0_17 +49 -0
  9. data/Docker/Dockerfile.latest_dependencies +49 -0
  10. data/Docker/README.md +67 -0
  11. data/Docker/vac.ps1 +29 -0
  12. data/Docker/vac.sh +30 -0
  13. data/Gemfile +20 -20
  14. data/LICENSE +8 -8
  15. data/README.md +416 -416
  16. data/Rakefile +106 -99
  17. data/bootstrap.key +27 -0
  18. data/build_rpm.sh +7 -7
  19. data/functional-tests/basic/Vagrantfile.basic_networking +45 -45
  20. data/functional-tests/basic/basic_spec.rb +21 -21
  21. data/functional-tests/networking/Vagrantfile.advanced_networking +119 -102
  22. data/functional-tests/networking/networking_spec.rb +14 -0
  23. data/functional-tests/rsync/Vagrantfile.advanced_networking +39 -56
  24. data/functional-tests/rsync/rsync_spec.rb +9 -9
  25. data/functional-tests/vmlifecycle/Vagrantfile.advanced_networking +66 -82
  26. data/functional-tests/vmlifecycle/vmlifecycle_spec.rb +13 -13
  27. data/lib/vagrant-cloudstack/action/connect_cloudstack.rb +47 -47
  28. data/lib/vagrant-cloudstack/action/is_created.rb +18 -18
  29. data/lib/vagrant-cloudstack/action/is_stopped.rb +18 -18
  30. data/lib/vagrant-cloudstack/action/message_already_created.rb +16 -16
  31. data/lib/vagrant-cloudstack/action/message_not_created.rb +16 -16
  32. data/lib/vagrant-cloudstack/action/message_will_not_destroy.rb +16 -16
  33. data/lib/vagrant-cloudstack/action/read_rdp_info.rb +76 -76
  34. data/lib/vagrant-cloudstack/action/read_ssh_info.rb +104 -87
  35. data/lib/vagrant-cloudstack/action/read_state.rb +38 -38
  36. data/lib/vagrant-cloudstack/action/read_winrm_info.rb +103 -103
  37. data/lib/vagrant-cloudstack/action/run_instance.rb +798 -703
  38. data/lib/vagrant-cloudstack/action/start_instance.rb +81 -81
  39. data/lib/vagrant-cloudstack/action/stop_instance.rb +28 -28
  40. data/lib/vagrant-cloudstack/action/terminate_instance.rb +269 -224
  41. data/lib/vagrant-cloudstack/action/timed_provision.rb +21 -21
  42. data/lib/vagrant-cloudstack/action/wait_for_state.rb +41 -41
  43. data/lib/vagrant-cloudstack/action/warn_networks.rb +19 -19
  44. data/lib/vagrant-cloudstack/action.rb +210 -210
  45. data/lib/vagrant-cloudstack/capabilities/rdp.rb +12 -12
  46. data/lib/vagrant-cloudstack/capabilities/winrm.rb +12 -12
  47. data/lib/vagrant-cloudstack/config.rb +566 -548
  48. data/lib/vagrant-cloudstack/errors.rb +27 -27
  49. data/lib/vagrant-cloudstack/exceptions/exceptions.rb +10 -10
  50. data/lib/vagrant-cloudstack/model/cloudstack_resource.rb +51 -33
  51. data/lib/vagrant-cloudstack/plugin.rb +82 -82
  52. data/lib/vagrant-cloudstack/provider.rb +58 -58
  53. data/lib/vagrant-cloudstack/service/cloudstack_resource_service.rb +64 -58
  54. data/lib/vagrant-cloudstack/util/timer.rb +17 -17
  55. data/lib/vagrant-cloudstack/version.rb +5 -5
  56. data/lib/vagrant-cloudstack.rb +17 -17
  57. data/locales/en.yml +131 -123
  58. data/spec/spec_helper.rb +8 -6
  59. data/spec/vagrant-cloudstack/action/read_ssh_info_spec.rb +80 -0
  60. data/spec/vagrant-cloudstack/config_spec.rb +355 -355
  61. data/spec/vagrant-cloudstack/model/cloudstack_resource_spec.rb +95 -73
  62. data/spec/vagrant-cloudstack/service/cloudstack_resource_service_spec.rb +43 -43
  63. data/spec/vagrant-cloudstack/support/be_a_resource.rb +6 -0
  64. data/vagrant-cloudstack.gemspec +59 -59
  65. data/vagrant-cloudstack.spec +42 -42
  66. metadata +14 -7
  67. data/dummy.box +0 -0
  68. data/example_box/README.md +0 -13
  69. data/example_box/metadata.json +0 -3
  70. data/functional-tests/networking/rsync_spec.rb +0 -12
@@ -1,17 +1,17 @@
1
- module VagrantPlugins
2
- module Cloudstack
3
- module Util
4
- class Timer
5
- # A basic utility method that times the execution of the given
6
- # block and returns it.
7
- def self.time
8
- start_time = Time.now.to_f
9
- yield
10
- end_time = Time.now.to_f
11
-
12
- end_time - start_time
13
- end
14
- end
15
- end
16
- end
17
- end
1
+ module VagrantPlugins
2
+ module Cloudstack
3
+ module Util
4
+ class Timer
5
+ # A basic utility method that times the execution of the given
6
+ # block and returns it.
7
+ def self.time
8
+ start_time = Time.now.to_f
9
+ yield
10
+ end_time = Time.now.to_f
11
+
12
+ end_time - start_time
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,5 +1,5 @@
1
- module VagrantPlugins
2
- module Cloudstack
3
- VERSION = '1.3.0'
4
- end
5
- end
1
+ module VagrantPlugins
2
+ module Cloudstack
3
+ VERSION = '1.4.0'
4
+ end
5
+ end
@@ -1,17 +1,17 @@
1
- require "pathname"
2
- require "vagrant-cloudstack/plugin"
3
-
4
- module VagrantPlugins
5
- module Cloudstack
6
- lib_path = Pathname.new(File.expand_path("../vagrant-cloudstack", __FILE__))
7
- autoload :Action, lib_path.join("action")
8
- autoload :Errors, lib_path.join("errors")
9
-
10
- # This returns the path to the source of this plugin.
11
- #
12
- # @return [Pathname]
13
- def self.source_root
14
- @source_root ||= Pathname.new(File.expand_path("../../", __FILE__))
15
- end
16
- end
17
- end
1
+ require "pathname"
2
+ require "vagrant-cloudstack/plugin"
3
+
4
+ module VagrantPlugins
5
+ module Cloudstack
6
+ lib_path = Pathname.new(File.expand_path("../vagrant-cloudstack", __FILE__))
7
+ autoload :Action, lib_path.join("action")
8
+ autoload :Errors, lib_path.join("errors")
9
+
10
+ # This returns the path to the source of this plugin.
11
+ #
12
+ # @return [Pathname]
13
+ def self.source_root
14
+ @source_root ||= Pathname.new(File.expand_path("../../", __FILE__))
15
+ end
16
+ end
17
+ end
data/locales/en.yml CHANGED
@@ -1,123 +1,131 @@
1
- en:
2
- vagrant_cloudstack:
3
- already_status: |-
4
- The machine is already %{status}.
5
- basic_network: |-
6
- Network name or id defined but zone %{zone_name} is of network type 'Basic'
7
- Network name or id will be ignored
8
- launching_instance: |-
9
- Launching an instance with the following settings...
10
- launch_no_keypair_no_sshkey: |-
11
- No keypair or ssh_key specified to launch your instance with.
12
- Generating a temporary keypair for this instance...
13
- launch_vpc_warning: |-
14
- Warning! You're launching this instance into a VPC without an
15
- elastic IP. Please verify you're properly connected to a VPN so
16
- you can access this machine, otherwise Vagrant will not be able
17
- to SSH into it.
18
- not_created: |-
19
- Instance is not created. Please run `vagrant up` first.
20
- ready: |-
21
- Machine is booted and ready for use!
22
- rsync_not_found_warning: |-
23
- Warning! Folder sync disabled because the rsync binary is missing.
24
- Make sure rsync is installed and the binary can be found in the PATH.
25
- rsync_folder: |-
26
- Rsyncing folder: %{hostpath} => %{guestpath}
27
- security_groups_disabled: |-
28
- Security groups defined but not supported in the zone %{zone_name}
29
- Defined security groups will be ignored
30
- ssh_key_pair_creating: |-
31
- Creating an SSH keypair in CloudStack...
32
- ssh_key_pair_removing: |-
33
- Deleting the SSH keypair in CloudStack...
34
- ssh_key_pair_no_success_removing: |-
35
- Removing SSH keypair returned unsuccesful (keypair name: %{name})
36
- starting: |-
37
- Starting the instance...
38
- stopping: |-
39
- Stopping the instance...
40
- terminating: |-
41
- Terminating the instance...
42
- waiting_for_ready: |-
43
- Waiting for instance to become "ready"...
44
- waiting_for_communicator: |-
45
- Waiting for %{communicator} to become available...
46
- enabling_static_nat: |-
47
- Enabling Static NAT for this instance ...
48
- disabling_static_nat: |-
49
- Disabling Static NAT ...
50
- creating_port_forwarding_rule: |-
51
- Creating a port forwarding rule for this instance ...
52
- deleting_port_forwarding_rule: |-
53
- Deleting the port forwarding rule ...
54
- creating_firewall_rule: |-
55
- Creating a firewall rule ...
56
- deleting_firewall_rule: |-
57
- Deleting the firewall rule ...
58
- warn_networks: |-
59
- Warning! The Cloudstack provider doesn't support any of the Vagrant
60
- high-level network configurations (`config.vm.network`). They
61
- will be silently ignored.
62
- will_not_destroy: |-
63
- The instance '%{name}' will not be destroyed, since the confirmation
64
- was declined.
65
- no_instance_found : |-
66
- No instance found, already destroyed?
67
-
68
- config:
69
- api_key_required: |-
70
- An access key ID must be specified via "api_key"
71
- template_id_required: |-
72
- A template_id must be configured via "template_id"
73
- secret_key_missing: |-
74
- The specified secret key for Cloudstack could not be found
75
-
76
- errors:
77
- fog_error: |-
78
- There was an error talking to Cloudstack. The error message is shown
79
- below:
80
-
81
- %{message}
82
- instance_ready_timeout: |-
83
- The instance never became "ready" in Cloudstack. The timeout currently
84
- set waiting for the instance to become ready is %{timeout} seconds.
85
- Please verify that the machine properly boots. If you need more time
86
- set the `instance_ready_timeout` configuration on the Cloudstack provider.
87
- rsync_error: |-
88
- There was an error when attemping to rsync a share folder.
89
- Please inspect the error message below for more info.
90
-
91
- Host path: %{hostpath}
92
- Guest path: %{guestpath}
93
- Error: %{stderr}
94
- user_data_error: |-
95
- The base64 encoded user data length (%{userdataLength}) is greater than 2048.
96
-
97
- states:
98
- short_not_created: |-
99
- not created
100
- long_not_created: |-
101
- The instance is not created. Run `vagrant up` to create it.
102
-
103
- short_starting: |-
104
- starting
105
- long_starting: |-
106
- The instance is starting.
107
-
108
- short_stopped: |-
109
- stopped
110
- long_stopped: |-
111
- The instance is stopped. Run `vagrant up` to start it.
112
-
113
- short_stopping: |-
114
- stopping
115
- long_stopping: |-
116
- The instance is stopping. Wait until is completely stopped to
117
- run `vagrant up` and start it.
118
-
119
- short_running: |-
120
- running
121
- long_running: |-
122
- The instance is running. To stop this machine, you can run
123
- `vagrant halt`. To destroy the machine, you can run `vagrant destroy`.
1
+ en:
2
+ vagrant_cloudstack:
3
+ already_status: |-
4
+ The machine is already %{status}.
5
+ basic_network: |-
6
+ Network name or id defined but zone %{zone_name} is of network type 'Basic'
7
+ Network name or id will be ignored
8
+ launching_instance: |-
9
+ Launching an instance with the following settings...
10
+ launch_no_keypair_no_sshkey: |-
11
+ No keypair or ssh_key specified to launch your instance with.
12
+ Generating a temporary keypair for this instance...
13
+ launch_vpc_warning: |-
14
+ Warning! You're launching this instance into a VPC without an
15
+ elastic IP. Please verify you're properly connected to a VPN so
16
+ you can access this machine, otherwise Vagrant will not be able
17
+ to SSH into it.
18
+ not_created: |-
19
+ Instance is not created. Please run `vagrant up` first.
20
+ ready: |-
21
+ Machine is booted and ready for use!
22
+ rsync_not_found_warning: |-
23
+ Warning! Folder sync disabled because the rsync binary is missing.
24
+ Make sure rsync is installed and the binary can be found in the PATH.
25
+ rsync_folder: |-
26
+ Rsyncing folder: %{hostpath} => %{guestpath}
27
+ security_groups_disabled: |-
28
+ Security groups defined but not supported in the zone %{zone_name}
29
+ Defined security groups will be ignored
30
+ ssh_key_pair_creating: |-
31
+ Creating an SSH keypair in CloudStack...
32
+ ssh_key_pair_removing: |-
33
+ Deleting the SSH keypair in CloudStack...
34
+ ssh_key_pair_no_success_removing: |-
35
+ Removing SSH keypair returned unsuccesful (keypair name: %{name})
36
+ starting: |-
37
+ Starting the instance...
38
+ stopping: |-
39
+ Stopping the instance...
40
+ terminating: |-
41
+ Terminating the instance...
42
+ terminateinstance_done: |-
43
+ Done removing resources
44
+ waiting_for_ready: |-
45
+ Waiting for instance to become "ready"...
46
+ waiting_for_communicator: |-
47
+ Waiting for %{communicator} to become available...
48
+ enabling_static_nat: |-
49
+ Enabling Static NAT for this instance ...
50
+ disabling_static_nat: |-
51
+ Disabling Static NAT ...
52
+ creating_port_forwarding_rule: |-
53
+ Creating a port forwarding rule for this instance ...
54
+ deleting_port_forwarding_rule: |-
55
+ Deleting the port forwarding rule ...
56
+ deleting_volumes: |-
57
+ Deleting additional volumes ...
58
+ delete_volume_failed: |-
59
+ -- Failed to delete volume: %{volume_id}
60
+ detach_volume_failed: |-
61
+ -- Failed to detach volume: %{message}
62
+ creating_firewall_rule: |-
63
+ Creating a firewall rule ...
64
+ deleting_firewall_rule: |-
65
+ Deleting the firewall rule ...
66
+ warn_networks: |-
67
+ Warning! The Cloudstack provider doesn't support any of the Vagrant
68
+ high-level network configurations (`config.vm.network`). They
69
+ will be silently ignored.
70
+ will_not_destroy: |-
71
+ The instance '%{name}' will not be destroyed, since the confirmation
72
+ was declined.
73
+ no_instance_found : |-
74
+ No instance found, already destroyed?
75
+
76
+ config:
77
+ api_key_required: |-
78
+ An access key ID must be specified via "api_key"
79
+ template_id_required: |-
80
+ A template_id must be configured via "template_id"
81
+ secret_key_missing: |-
82
+ The specified secret key for Cloudstack could not be found
83
+
84
+ errors:
85
+ fog_error: |-
86
+ There was an error talking to Cloudstack. The error message is shown
87
+ below:
88
+
89
+ %{message}
90
+ instance_ready_timeout: |-
91
+ The instance never became "ready" in Cloudstack. The timeout currently
92
+ set waiting for the instance to become ready is %{timeout} seconds.
93
+ Please verify that the machine properly boots. If you need more time
94
+ set the `instance_ready_timeout` configuration on the Cloudstack provider.
95
+ rsync_error: |-
96
+ There was an error when attemping to rsync a share folder.
97
+ Please inspect the error message below for more info.
98
+
99
+ Host path: %{hostpath}
100
+ Guest path: %{guestpath}
101
+ Error: %{stderr}
102
+ user_data_error: |-
103
+ The base64 encoded user data length (%{userdataLength}) is greater than 2048.
104
+
105
+ states:
106
+ short_not_created: |-
107
+ not created
108
+ long_not_created: |-
109
+ The instance is not created. Run `vagrant up` to create it.
110
+
111
+ short_starting: |-
112
+ starting
113
+ long_starting: |-
114
+ The instance is starting.
115
+
116
+ short_stopped: |-
117
+ stopped
118
+ long_stopped: |-
119
+ The instance is stopped. Run `vagrant up` to start it.
120
+
121
+ short_stopping: |-
122
+ stopping
123
+ long_stopping: |-
124
+ The instance is stopping. Wait until is completely stopped to
125
+ run `vagrant up` and start it.
126
+
127
+ short_running: |-
128
+ running
129
+ long_running: |-
130
+ The instance is running. To stop this machine, you can run
131
+ `vagrant halt`. To destroy the machine, you can run `vagrant destroy`.
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,8 @@
1
- require 'simplecov'
2
- require 'coveralls'
3
- require 'rspec/its'
4
-
5
- SimpleCov.start
6
- Coveralls.wear!
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+ require 'rspec/its'
4
+
5
+ Dir["#{__dir__}/vagrant-cloudstack/support/**/*.rb"].each { |f| require f }
6
+
7
+ SimpleCov.start
8
+ Coveralls.wear!
@@ -0,0 +1,80 @@
1
+ require 'spec_helper'
2
+ require 'vagrant-cloudstack/action/read_ssh_info'
3
+ require 'vagrant-cloudstack/config'
4
+
5
+ describe VagrantPlugins::Cloudstack::Action::ReadSSHInfo do
6
+ let(:action) { VagrantPlugins::Cloudstack::Action::ReadSSHInfo.new(nil, nil) }
7
+
8
+ describe "#fetch_nic_ip_address" do
9
+ subject { action.fetch_nic_ip_address(nics, domain_config) }
10
+
11
+ let(:nics) do
12
+ [
13
+ { "networkid" => "networkid1", "networkname" => "networkname1", "ipaddress" => "127.0.0.1" },
14
+ { "networkid" => "networkid2", "networkname" => "networkname2", "ipaddress" => "127.0.0.2" },
15
+ { "networkid" => "networkid3", "networkname" => "networkname3", "ipaddress" => "127.0.0.3" },
16
+ ]
17
+ end
18
+
19
+ let(:ssh_network_id) { Vagrant::Plugin::V2::Config::UNSET_VALUE }
20
+ let(:ssh_network_name) { Vagrant::Plugin::V2::Config::UNSET_VALUE }
21
+
22
+ let(:domain_config) do
23
+ config = VagrantPlugins::Cloudstack::Config.new
24
+ config.domain_config :cloudstack do |cloudstack|
25
+ cloudstack.ssh_network_id = ssh_network_id
26
+ cloudstack.ssh_network_name = ssh_network_name
27
+ end
28
+ config.finalize!
29
+ config.get_domain_config(:cloudstack)
30
+ end
31
+
32
+ context "without neither ssh_network_id and ssh_network_name" do
33
+ it { should eq "127.0.0.1" }
34
+ end
35
+
36
+ context "with ssh_network_id" do
37
+ context "when exists in nics" do
38
+ let(:ssh_network_id) { "networkid2" }
39
+
40
+ it { should eq "127.0.0.2" }
41
+ end
42
+
43
+ context "when not exists in nics" do
44
+ let(:ssh_network_id) { "unknown" }
45
+
46
+ it { should eq "127.0.0.1" }
47
+ end
48
+ end
49
+
50
+ context "with ssh_network_id" do
51
+ context "when exists in nics" do
52
+ let(:ssh_network_name) { "networkname3" }
53
+
54
+ it { should eq "127.0.0.3" }
55
+ end
56
+
57
+ context "when not exists in nics" do
58
+ let(:ssh_network_name) { "unknown" }
59
+
60
+ it { should eq "127.0.0.1" }
61
+ end
62
+ end
63
+
64
+ context "with both ssh_network_id and ssh_network_name" do
65
+ context "when exists in nics" do
66
+ let(:ssh_network_id) { "networkid2" }
67
+ let(:ssh_network_name) { "networkname3" }
68
+
69
+ it { should eq "127.0.0.2" }
70
+ end
71
+
72
+ context "when not exists in nics" do
73
+ let(:ssh_network_id) { "unknown" }
74
+ let(:ssh_network_name) { "unknown" }
75
+
76
+ it { should eq "127.0.0.1" }
77
+ end
78
+ end
79
+ end
80
+ end
@@ -1,355 +1,355 @@
1
- require "spec_helper"
2
- require "vagrant-cloudstack/config"
3
-
4
- describe VagrantPlugins::Cloudstack::Config do
5
- let(:instance) { described_class.new }
6
-
7
- # Ensure tests are not affected by Cloudstack credential environment variables
8
- before :each do
9
- ENV.stub(:[] => nil)
10
- end
11
-
12
- describe "defaults" do
13
- subject do
14
- instance.tap do |o|
15
- o.finalize!
16
- end
17
- end
18
-
19
- its("host") { should be_nil }
20
- its("path") { should be_nil }
21
- its("port") { should be_nil }
22
- its("scheme") { should be_nil }
23
- its("api_key") { should be_nil }
24
- its("secret_key") { should be_nil }
25
- its("instance_ready_timeout") { should == 120 }
26
- its("domain_id") { should be_nil }
27
- its("network_id") { should be_nil }
28
- its("project_id") { should be_nil }
29
- its("service_offering_id") { should be_nil }
30
- its("disk_offering_id") { should be_nil }
31
- its("template_id") { should be_nil }
32
- its("zone_id") { should be_nil }
33
- its("keypair") { should be_nil }
34
- its("static_nat") { should == [] }
35
- its("pf_ip_address_id") { should be_nil }
36
- its("pf_ip_address") { should be_nil }
37
- its("pf_public_port") { should be_nil }
38
- its("pf_public_rdp_port") { should be_nil }
39
- its("pf_private_rdp_port") { should == 3389 }
40
- its("pf_public_port_randomrange") { should == {:start=>49160, :end=>49200} }
41
- its("pf_private_port") { should be_nil }
42
- its("pf_open_firewall") { should == true }
43
- its("pf_trusted_networks") { should be_nil }
44
- its("port_forwarding_rules") { should == [] }
45
- its("firewall_rules") { should == [] }
46
- its("security_group_ids") { should == [] }
47
- its("display_name") { should be_nil }
48
- its("group") { should be_nil }
49
- its("security_group_names") { should == [] }
50
- its("security_groups") { should == [] }
51
- its("user_data") { should be_nil }
52
- its("ssh_key") { should be_nil }
53
- its("ssh_user") { should be_nil }
54
- its("vm_user") { should be_nil }
55
- its("vm_password") { should be_nil }
56
- its("private_ip_address") { should be_nil }
57
- its("expunge_on_destroy") { should == false }
58
- end
59
-
60
- describe "getting credentials from environment" do
61
- context "without CloudStack credential environment variables" do
62
- subject do
63
- instance.tap do |o|
64
- o.finalize!
65
- end
66
- end
67
-
68
- its("api_key") { should be_nil }
69
- its("secret_key") { should be_nil }
70
- end
71
-
72
- context "with CloudStack credential variables" do
73
- before :each do
74
- ENV.stub(:[]).with("CLOUDSTACK_API_KEY").and_return("api_key")
75
- ENV.stub(:[]).with("CLOUDSTACK_SECRET_KEY").and_return("secret_key")
76
- end
77
-
78
- subject do
79
- instance.tap do |o|
80
- o.finalize!
81
- end
82
- end
83
-
84
- its("api_key") { should == "api_key" }
85
- its("secret_key") { should == "secret_key" }
86
- end
87
- end
88
-
89
- describe "overriding defaults" do
90
- # I typically don't meta-program in tests, but this is a very
91
- # simple boilerplate test, so I cut corners here. It just sets
92
- # each of these attributes to "foo" in isolation, and reads the value
93
- # and asserts the proper result comes back out.
94
- [:api_key, :template_id, :zone_id, :instance_ready_timeout,
95
- :service_offering_id, :disk_offering_id, :api_key,
96
- :secret_key, :network_id, :user_data].each do |attribute|
97
-
98
- it "should not default #{attribute} if overridden" do
99
- instance.send("#{attribute}=".to_sym, "foo")
100
- instance.finalize!
101
- instance.send(attribute).should == "foo"
102
- end
103
-
104
- end
105
-
106
- it 'should not default pf_open_firewall if overridden' do
107
- instance.pf_open_firewall = false
108
- instance.finalize!
109
-
110
- instance.pf_open_firewall.should == false
111
- end
112
- end
113
-
114
- describe "getting credentials from environment" do
115
- context "without Cloudstack credential environment variables" do
116
- subject do
117
- instance.tap do |o|
118
- o.finalize!
119
- end
120
- end
121
-
122
- its("api_key") { should be_nil }
123
- its("secret_key") { should be_nil }
124
- end
125
-
126
- end
127
-
128
- describe "domain config" do
129
- let(:config_host) { "foo" }
130
- let(:config_path) { "foo" }
131
- let(:config_port) { "foo" }
132
- let(:config_scheme) { "foo" }
133
- let(:config_api_key) { "foo" }
134
- let(:config_secret_key) { "foo" }
135
- let(:config_instance_ready_timeout) { 11111 }
136
- let(:config_domain_id) { "foo" }
137
- let(:config_network_id) { "foo" }
138
- let(:config_project_id) { "foo" }
139
- let(:config_service_offering_id) { "foo" }
140
- let(:config_disk_offering_id) { "foo" }
141
- let(:config_template_id) { "foo" }
142
- let(:config_zone_id) { "foo" }
143
- let(:config_keypair) { "foo" }
144
- let(:config_static_nat) { [{:foo => "bar"}, {:bar => "foo"}] }
145
- let(:config_pf_ip_address_id) { "foo" }
146
- let(:config_pf_ip_address) { "foo" }
147
- let(:config_pf_public_port_randomrange) { {:start=>1, :end=>9} }
148
- let(:config_pf_public_port) { "foo" }
149
- let(:config_pf_public_rdp_port) { "foo" }
150
- let(:config_pf_private_rdp_port) { "foo" }
151
- let(:config_pf_private_port) { "foo" }
152
- let(:config_pf_open_firewall) { false }
153
- let(:config_pf_trusted_networks) { ["foo", "bar"] }
154
- let(:config_port_forwarding_rules) { [{:foo => "bar"}, {:bar => "foo"}] }
155
- let(:config_firewall_rules) { [{:foo => "bar"}, {:bar => "foo"}] }
156
- let(:config_security_group_ids) { ["foo", "bar"] }
157
- let(:config_display_name) { "foo" }
158
- let(:config_group) { "foo" }
159
- let(:config_security_group_names) { ["foo", "bar"] }
160
- let(:config_security_groups) { [{:foo => "bar"}, {:bar => "foo"}] }
161
- let(:config_ssh_key) { "./foo.pem" }
162
- let(:config_ssh_user) { "foo" }
163
- let(:config_vm_user) { "foo" }
164
- let(:config_vm_password) { "foo" }
165
- let(:config_private_ip_address) { "foo" }
166
- let(:config_expunge_on_destroy) { "foo" }
167
-
168
- def set_test_values(instance)
169
- instance.host = config_host
170
- instance.path = config_path
171
- instance.port = config_port
172
- instance.scheme = config_scheme
173
- instance.api_key = config_api_key
174
- instance.secret_key = config_secret_key
175
- instance.instance_ready_timeout = config_instance_ready_timeout
176
- instance.domain_id = config_domain_id
177
- instance.network_id = config_network_id
178
- instance.project_id = config_project_id
179
- instance.service_offering_id = config_service_offering_id
180
- instance.disk_offering_id = config_disk_offering_id
181
- instance.template_id = config_template_id
182
- instance.zone_id = config_zone_id
183
- instance.keypair = config_keypair
184
- instance.static_nat = config_static_nat
185
- instance.pf_ip_address_id = config_pf_ip_address_id
186
- instance.pf_public_port_randomrange = config_pf_public_port_randomrange
187
- instance.pf_ip_address = config_pf_ip_address
188
- instance.pf_public_port = config_pf_public_port
189
- instance.pf_public_rdp_port = config_pf_public_rdp_port
190
- instance.pf_private_rdp_port = config_pf_private_rdp_port
191
- instance.pf_private_port = config_pf_private_port
192
- instance.pf_open_firewall = config_pf_open_firewall
193
- instance.pf_trusted_networks = config_pf_trusted_networks
194
- instance.port_forwarding_rules = config_port_forwarding_rules
195
- instance.firewall_rules = config_firewall_rules
196
- instance.security_group_ids = config_security_group_ids
197
- instance.display_name = config_display_name
198
- instance.group = config_group
199
- instance.security_group_names = config_security_group_names
200
- instance.security_groups = config_security_groups
201
- instance.ssh_key = config_ssh_key
202
- instance.ssh_user = config_ssh_user
203
- instance.vm_user = config_vm_user
204
- instance.vm_password = config_vm_password
205
- instance.private_ip_address = config_private_ip_address
206
- instance.expunge_on_destroy = config_expunge_on_destroy
207
- end
208
-
209
- it "should raise an exception if not finalized" do
210
- expect { instance.get_domain_config("default") }.
211
- to raise_error
212
- end
213
-
214
- context "with no specific config set" do
215
- subject do
216
- # Set the values on the top-level object
217
- set_test_values(instance)
218
-
219
- # Finalize so we can get the domain config
220
- instance.finalize!
221
-
222
- # Get a lower level domain
223
- instance.get_domain_config("default")
224
- end
225
-
226
- its("host") { should == config_host }
227
- its("path") { should == config_path }
228
- its("port") { should == config_port }
229
- its("scheme") { should == config_scheme }
230
- its("api_key") { should == config_api_key }
231
- its("secret_key") { should == config_secret_key }
232
- its("instance_ready_timeout") { should == config_instance_ready_timeout }
233
- its("domain_id") { should == config_domain_id }
234
- its("network_id") { should == config_network_id }
235
- its("project_id") { should == config_project_id }
236
- its("service_offering_id") { should == config_service_offering_id }
237
- its("disk_offering_id") { should == config_disk_offering_id }
238
- its("template_id") { should == config_template_id }
239
- its("zone_id") { should == config_zone_id }
240
- its("keypair") { should == config_keypair }
241
- its("static_nat") { should == config_static_nat }
242
- its("pf_ip_address_id") { should == config_pf_ip_address_id }
243
- its("pf_ip_address") { should == config_pf_ip_address }
244
- its("pf_public_port") { should == config_pf_public_port }
245
- its("pf_public_rdp_port") { should == config_pf_public_rdp_port }
246
- its("pf_private_rdp_port") { should == config_pf_private_rdp_port }
247
- its("pf_public_port_randomrange") { should == config_pf_public_port_randomrange}
248
- its("pf_private_port") { should == config_pf_private_port }
249
- its("pf_trusted_networks") { should == config_pf_trusted_networks}
250
- its("pf_open_firewall") { should == config_pf_open_firewall }
251
- its("port_forwarding_rules") { should == config_port_forwarding_rules }
252
- its("firewall_rules") { should == config_firewall_rules }
253
- its("security_group_ids") { should == config_security_group_ids }
254
- its("display_name") { should == config_display_name }
255
- its("group") { should == config_group }
256
- its("security_group_names") { should == config_security_group_names }
257
- its("security_groups") { should == config_security_groups }
258
- its("ssh_key") { should == config_ssh_key }
259
- its("ssh_user") { should == config_ssh_user }
260
- its("vm_user") { should == config_vm_user }
261
- its("vm_password") { should == config_vm_password }
262
- its("private_ip_address") { should == config_private_ip_address }
263
- its("expunge_on_destroy") { should == config_expunge_on_destroy }
264
- end
265
-
266
- context "with a specific config set" do
267
- let(:domain_name) { "hashi-domain" }
268
-
269
- subject do
270
- # Set the values on a specific domain
271
- instance.domain_config domain_name do |config|
272
- set_test_values(config)
273
- end
274
-
275
- # Finalize so we can get the domain config
276
- instance.finalize!
277
-
278
- # Get the domain
279
- instance.get_domain_config(domain_name)
280
- end
281
-
282
- its("host") { should == config_host }
283
- its("path") { should == config_path }
284
- its("port") { should == config_port }
285
- its("scheme") { should == config_scheme }
286
- its("api_key") { should == config_api_key }
287
- its("secret_key") { should == config_secret_key }
288
- its("instance_ready_timeout") { should == config_instance_ready_timeout }
289
- its("domain_id") { should == config_domain_id }
290
- its("network_id") { should == config_network_id }
291
- its("project_id") { should == config_project_id }
292
- its("service_offering_id") { should == config_service_offering_id }
293
- its("disk_offering_id") { should == config_disk_offering_id }
294
- its("template_id") { should == config_template_id }
295
- its("zone_id") { should == config_zone_id }
296
- its("keypair") { should == config_keypair }
297
- its("static_nat") { should == config_static_nat }
298
- its("pf_ip_address_id") { should == config_pf_ip_address_id }
299
- its("pf_ip_address") { should == config_pf_ip_address }
300
- its("pf_public_port") { should == config_pf_public_port }
301
- its("pf_public_rdp_port") { should == config_pf_public_rdp_port }
302
- its("pf_private_rdp_port") { should == config_pf_private_rdp_port }
303
- its("pf_public_port_randomrange") { should == config_pf_public_port_randomrange}
304
- its("pf_private_port") { should == config_pf_private_port }
305
- its("pf_open_firewall") { should == config_pf_open_firewall }
306
- its("pf_trusted_networks") { should == config_pf_trusted_networks}
307
- its("port_forwarding_rules") { should == config_port_forwarding_rules }
308
- its("firewall_rules") { should == config_firewall_rules }
309
- its("security_group_ids") { should == config_security_group_ids }
310
- its("display_name") { should == config_display_name }
311
- its("group") { should == config_group }
312
- its("security_group_names") { should == config_security_group_names }
313
- its("security_groups") { should == config_security_groups }
314
- its("ssh_key") { should == config_ssh_key }
315
- its("ssh_user") { should == config_ssh_user }
316
- its("vm_user") { should == config_vm_user }
317
- its("vm_password") { should == config_vm_password }
318
- its("private_ip_address") { should == config_private_ip_address }
319
- its("expunge_on_destroy") { should == config_expunge_on_destroy }
320
- end
321
-
322
- describe "inheritance of parent config" do
323
- let(:domain_name) { "hashi-domain" }
324
-
325
- subject do
326
- # Set the values on a specific domain
327
- instance.domain_config domain_name do |config|
328
- config.template_id = "child"
329
- end
330
-
331
- # Set some top-level values
332
- instance.api_key = "parent"
333
- instance.template_id = "parent"
334
-
335
- # Finalize and get the domain
336
- instance.finalize!
337
- instance.get_domain_config(domain_name)
338
- end
339
-
340
- its("api_key") { should == "parent" }
341
- its("template_id") { should == "child" }
342
- end
343
-
344
- describe "shortcut configuration" do
345
- subject do
346
- # Use the shortcut configuration to set some values
347
- instance.domain_config "Domain1", :template_id => "child"
348
- instance.finalize!
349
- instance.get_domain_config("Domain1")
350
- end
351
-
352
- its("template_id") { should == "child" }
353
- end
354
- end
355
- end
1
+ require "spec_helper"
2
+ require "vagrant-cloudstack/config"
3
+
4
+ describe VagrantPlugins::Cloudstack::Config do
5
+ let(:instance) { described_class.new }
6
+
7
+ # Ensure tests are not affected by Cloudstack credential environment variables
8
+ before :each do
9
+ ENV.stub(:[] => nil)
10
+ end
11
+
12
+ describe "defaults" do
13
+ subject do
14
+ instance.tap do |o|
15
+ o.finalize!
16
+ end
17
+ end
18
+
19
+ its("host") { should be_nil }
20
+ its("path") { should be_nil }
21
+ its("port") { should be_nil }
22
+ its("scheme") { should be_nil }
23
+ its("api_key") { should be_nil }
24
+ its("secret_key") { should be_nil }
25
+ its("instance_ready_timeout") { should == 120 }
26
+ its("domain_id") { should be_nil }
27
+ its("network_id") { should be_nil }
28
+ its("project_id") { should be_nil }
29
+ its("service_offering_id") { should be_nil }
30
+ its("disk_offering_id") { should be_nil }
31
+ its("template_id") { should be_nil }
32
+ its("zone_id") { should be_nil }
33
+ its("keypair") { should be_nil }
34
+ its("static_nat") { should == [] }
35
+ its("pf_ip_address_id") { should be_nil }
36
+ its("pf_ip_address") { should be_nil }
37
+ its("pf_public_port") { should be_nil }
38
+ its("pf_public_rdp_port") { should be_nil }
39
+ its("pf_private_rdp_port") { should == 3389 }
40
+ its("pf_public_port_randomrange") { should == {:start=>49160, :end=>49200} }
41
+ its("pf_private_port") { should be_nil }
42
+ its("pf_open_firewall") { should == true }
43
+ its("pf_trusted_networks") { should be_nil }
44
+ its("port_forwarding_rules") { should == [] }
45
+ its("firewall_rules") { should == [] }
46
+ its("security_group_ids") { should == [] }
47
+ its("display_name") { should be_nil }
48
+ its("group") { should be_nil }
49
+ its("security_group_names") { should == [] }
50
+ its("security_groups") { should == [] }
51
+ its("user_data") { should be_nil }
52
+ its("ssh_key") { should be_nil }
53
+ its("ssh_user") { should be_nil }
54
+ its("vm_user") { should be_nil }
55
+ its("vm_password") { should be_nil }
56
+ its("private_ip_address") { should be_nil }
57
+ its("expunge_on_destroy") { should == false }
58
+ end
59
+
60
+ describe "getting credentials from environment" do
61
+ context "without CloudStack credential environment variables" do
62
+ subject do
63
+ instance.tap do |o|
64
+ o.finalize!
65
+ end
66
+ end
67
+
68
+ its("api_key") { should be_nil }
69
+ its("secret_key") { should be_nil }
70
+ end
71
+
72
+ context "with CloudStack credential variables" do
73
+ before :each do
74
+ ENV.stub(:[]).with("CLOUDSTACK_API_KEY").and_return("api_key")
75
+ ENV.stub(:[]).with("CLOUDSTACK_SECRET_KEY").and_return("secret_key")
76
+ end
77
+
78
+ subject do
79
+ instance.tap do |o|
80
+ o.finalize!
81
+ end
82
+ end
83
+
84
+ its("api_key") { should == "api_key" }
85
+ its("secret_key") { should == "secret_key" }
86
+ end
87
+ end
88
+
89
+ describe "overriding defaults" do
90
+ # I typically don't meta-program in tests, but this is a very
91
+ # simple boilerplate test, so I cut corners here. It just sets
92
+ # each of these attributes to "foo" in isolation, and reads the value
93
+ # and asserts the proper result comes back out.
94
+ [:api_key, :template_id, :zone_id, :instance_ready_timeout,
95
+ :service_offering_id, :disk_offering_id, :api_key,
96
+ :secret_key, :network_id, :user_data].each do |attribute|
97
+
98
+ it "should not default #{attribute} if overridden" do
99
+ instance.send("#{attribute}=".to_sym, "foo")
100
+ instance.finalize!
101
+ instance.send(attribute).should == "foo"
102
+ end
103
+
104
+ end
105
+
106
+ it 'should not default pf_open_firewall if overridden' do
107
+ instance.pf_open_firewall = false
108
+ instance.finalize!
109
+
110
+ instance.pf_open_firewall.should == false
111
+ end
112
+ end
113
+
114
+ describe "getting credentials from environment" do
115
+ context "without Cloudstack credential environment variables" do
116
+ subject do
117
+ instance.tap do |o|
118
+ o.finalize!
119
+ end
120
+ end
121
+
122
+ its("api_key") { should be_nil }
123
+ its("secret_key") { should be_nil }
124
+ end
125
+
126
+ end
127
+
128
+ describe "domain config" do
129
+ let(:config_host) { "foo" }
130
+ let(:config_path) { "foo" }
131
+ let(:config_port) { "foo" }
132
+ let(:config_scheme) { "foo" }
133
+ let(:config_api_key) { "foo" }
134
+ let(:config_secret_key) { "foo" }
135
+ let(:config_instance_ready_timeout) { 11111 }
136
+ let(:config_domain_id) { "foo" }
137
+ let(:config_network_id) { "foo" }
138
+ let(:config_project_id) { "foo" }
139
+ let(:config_service_offering_id) { "foo" }
140
+ let(:config_disk_offering_id) { "foo" }
141
+ let(:config_template_id) { "foo" }
142
+ let(:config_zone_id) { "foo" }
143
+ let(:config_keypair) { "foo" }
144
+ let(:config_static_nat) { [{:foo => "bar"}, {:bar => "foo"}] }
145
+ let(:config_pf_ip_address_id) { "foo" }
146
+ let(:config_pf_ip_address) { "foo" }
147
+ let(:config_pf_public_port_randomrange) { {:start=>1, :end=>9} }
148
+ let(:config_pf_public_port) { "foo" }
149
+ let(:config_pf_public_rdp_port) { "foo" }
150
+ let(:config_pf_private_rdp_port) { "foo" }
151
+ let(:config_pf_private_port) { "foo" }
152
+ let(:config_pf_open_firewall) { false }
153
+ let(:config_pf_trusted_networks) { ["foo", "bar"] }
154
+ let(:config_port_forwarding_rules) { [{:foo => "bar"}, {:bar => "foo"}] }
155
+ let(:config_firewall_rules) { [{:foo => "bar"}, {:bar => "foo"}] }
156
+ let(:config_security_group_ids) { ["foo", "bar"] }
157
+ let(:config_display_name) { "foo" }
158
+ let(:config_group) { "foo" }
159
+ let(:config_security_group_names) { ["foo", "bar"] }
160
+ let(:config_security_groups) { [{:foo => "bar"}, {:bar => "foo"}] }
161
+ let(:config_ssh_key) { "./foo.pem" }
162
+ let(:config_ssh_user) { "foo" }
163
+ let(:config_vm_user) { "foo" }
164
+ let(:config_vm_password) { "foo" }
165
+ let(:config_private_ip_address) { "foo" }
166
+ let(:config_expunge_on_destroy) { "foo" }
167
+
168
+ def set_test_values(instance)
169
+ instance.host = config_host
170
+ instance.path = config_path
171
+ instance.port = config_port
172
+ instance.scheme = config_scheme
173
+ instance.api_key = config_api_key
174
+ instance.secret_key = config_secret_key
175
+ instance.instance_ready_timeout = config_instance_ready_timeout
176
+ instance.domain_id = config_domain_id
177
+ instance.network_id = config_network_id
178
+ instance.project_id = config_project_id
179
+ instance.service_offering_id = config_service_offering_id
180
+ instance.disk_offering_id = config_disk_offering_id
181
+ instance.template_id = config_template_id
182
+ instance.zone_id = config_zone_id
183
+ instance.keypair = config_keypair
184
+ instance.static_nat = config_static_nat
185
+ instance.pf_ip_address_id = config_pf_ip_address_id
186
+ instance.pf_public_port_randomrange = config_pf_public_port_randomrange
187
+ instance.pf_ip_address = config_pf_ip_address
188
+ instance.pf_public_port = config_pf_public_port
189
+ instance.pf_public_rdp_port = config_pf_public_rdp_port
190
+ instance.pf_private_rdp_port = config_pf_private_rdp_port
191
+ instance.pf_private_port = config_pf_private_port
192
+ instance.pf_open_firewall = config_pf_open_firewall
193
+ instance.pf_trusted_networks = config_pf_trusted_networks
194
+ instance.port_forwarding_rules = config_port_forwarding_rules
195
+ instance.firewall_rules = config_firewall_rules
196
+ instance.security_group_ids = config_security_group_ids
197
+ instance.display_name = config_display_name
198
+ instance.group = config_group
199
+ instance.security_group_names = config_security_group_names
200
+ instance.security_groups = config_security_groups
201
+ instance.ssh_key = config_ssh_key
202
+ instance.ssh_user = config_ssh_user
203
+ instance.vm_user = config_vm_user
204
+ instance.vm_password = config_vm_password
205
+ instance.private_ip_address = config_private_ip_address
206
+ instance.expunge_on_destroy = config_expunge_on_destroy
207
+ end
208
+
209
+ it "should raise an exception if not finalized" do
210
+ expect { instance.get_domain_config("default") }.
211
+ to raise_error
212
+ end
213
+
214
+ context "with no specific config set" do
215
+ subject do
216
+ # Set the values on the top-level object
217
+ set_test_values(instance)
218
+
219
+ # Finalize so we can get the domain config
220
+ instance.finalize!
221
+
222
+ # Get a lower level domain
223
+ instance.get_domain_config("default")
224
+ end
225
+
226
+ its("host") { should == config_host }
227
+ its("path") { should == config_path }
228
+ its("port") { should == config_port }
229
+ its("scheme") { should == config_scheme }
230
+ its("api_key") { should == config_api_key }
231
+ its("secret_key") { should == config_secret_key }
232
+ its("instance_ready_timeout") { should == config_instance_ready_timeout }
233
+ its("domain_id") { should == config_domain_id }
234
+ its("network_id") { should == config_network_id }
235
+ its("project_id") { should == config_project_id }
236
+ its("service_offering_id") { should == config_service_offering_id }
237
+ its("disk_offering_id") { should == config_disk_offering_id }
238
+ its("template_id") { should == config_template_id }
239
+ its("zone_id") { should == config_zone_id }
240
+ its("keypair") { should == config_keypair }
241
+ its("static_nat") { should == config_static_nat }
242
+ its("pf_ip_address_id") { should == config_pf_ip_address_id }
243
+ its("pf_ip_address") { should == config_pf_ip_address }
244
+ its("pf_public_port") { should == config_pf_public_port }
245
+ its("pf_public_rdp_port") { should == config_pf_public_rdp_port }
246
+ its("pf_private_rdp_port") { should == config_pf_private_rdp_port }
247
+ its("pf_public_port_randomrange") { should == config_pf_public_port_randomrange}
248
+ its("pf_private_port") { should == config_pf_private_port }
249
+ its("pf_trusted_networks") { should == config_pf_trusted_networks}
250
+ its("pf_open_firewall") { should == config_pf_open_firewall }
251
+ its("port_forwarding_rules") { should == config_port_forwarding_rules }
252
+ its("firewall_rules") { should == config_firewall_rules }
253
+ its("security_group_ids") { should == config_security_group_ids }
254
+ its("display_name") { should == config_display_name }
255
+ its("group") { should == config_group }
256
+ its("security_group_names") { should == config_security_group_names }
257
+ its("security_groups") { should == config_security_groups }
258
+ its("ssh_key") { should == config_ssh_key }
259
+ its("ssh_user") { should == config_ssh_user }
260
+ its("vm_user") { should == config_vm_user }
261
+ its("vm_password") { should == config_vm_password }
262
+ its("private_ip_address") { should == config_private_ip_address }
263
+ its("expunge_on_destroy") { should == config_expunge_on_destroy }
264
+ end
265
+
266
+ context "with a specific config set" do
267
+ let(:domain_name) { "hashi-domain" }
268
+
269
+ subject do
270
+ # Set the values on a specific domain
271
+ instance.domain_config domain_name do |config|
272
+ set_test_values(config)
273
+ end
274
+
275
+ # Finalize so we can get the domain config
276
+ instance.finalize!
277
+
278
+ # Get the domain
279
+ instance.get_domain_config(domain_name)
280
+ end
281
+
282
+ its("host") { should == config_host }
283
+ its("path") { should == config_path }
284
+ its("port") { should == config_port }
285
+ its("scheme") { should == config_scheme }
286
+ its("api_key") { should == config_api_key }
287
+ its("secret_key") { should == config_secret_key }
288
+ its("instance_ready_timeout") { should == config_instance_ready_timeout }
289
+ its("domain_id") { should == config_domain_id }
290
+ its("network_id") { should == config_network_id }
291
+ its("project_id") { should == config_project_id }
292
+ its("service_offering_id") { should == config_service_offering_id }
293
+ its("disk_offering_id") { should == config_disk_offering_id }
294
+ its("template_id") { should == config_template_id }
295
+ its("zone_id") { should == config_zone_id }
296
+ its("keypair") { should == config_keypair }
297
+ its("static_nat") { should == config_static_nat }
298
+ its("pf_ip_address_id") { should == config_pf_ip_address_id }
299
+ its("pf_ip_address") { should == config_pf_ip_address }
300
+ its("pf_public_port") { should == config_pf_public_port }
301
+ its("pf_public_rdp_port") { should == config_pf_public_rdp_port }
302
+ its("pf_private_rdp_port") { should == config_pf_private_rdp_port }
303
+ its("pf_public_port_randomrange") { should == config_pf_public_port_randomrange}
304
+ its("pf_private_port") { should == config_pf_private_port }
305
+ its("pf_open_firewall") { should == config_pf_open_firewall }
306
+ its("pf_trusted_networks") { should == config_pf_trusted_networks}
307
+ its("port_forwarding_rules") { should == config_port_forwarding_rules }
308
+ its("firewall_rules") { should == config_firewall_rules }
309
+ its("security_group_ids") { should == config_security_group_ids }
310
+ its("display_name") { should == config_display_name }
311
+ its("group") { should == config_group }
312
+ its("security_group_names") { should == config_security_group_names }
313
+ its("security_groups") { should == config_security_groups }
314
+ its("ssh_key") { should == config_ssh_key }
315
+ its("ssh_user") { should == config_ssh_user }
316
+ its("vm_user") { should == config_vm_user }
317
+ its("vm_password") { should == config_vm_password }
318
+ its("private_ip_address") { should == config_private_ip_address }
319
+ its("expunge_on_destroy") { should == config_expunge_on_destroy }
320
+ end
321
+
322
+ describe "inheritance of parent config" do
323
+ let(:domain_name) { "hashi-domain" }
324
+
325
+ subject do
326
+ # Set the values on a specific domain
327
+ instance.domain_config domain_name do |config|
328
+ config.template_id = "child"
329
+ end
330
+
331
+ # Set some top-level values
332
+ instance.api_key = "parent"
333
+ instance.template_id = "parent"
334
+
335
+ # Finalize and get the domain
336
+ instance.finalize!
337
+ instance.get_domain_config(domain_name)
338
+ end
339
+
340
+ its("api_key") { should == "parent" }
341
+ its("template_id") { should == "child" }
342
+ end
343
+
344
+ describe "shortcut configuration" do
345
+ subject do
346
+ # Use the shortcut configuration to set some values
347
+ instance.domain_config "Domain1", :template_id => "child"
348
+ instance.finalize!
349
+ instance.get_domain_config("Domain1")
350
+ end
351
+
352
+ its("template_id") { should == "child" }
353
+ end
354
+ end
355
+ end