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,16 +1,16 @@
1
- module VagrantPlugins
2
- module Cloudstack
3
- module Action
4
- class MessageAlreadyCreated
5
- def initialize(app, env)
6
- @app = app
7
- end
8
-
9
- def call(env)
10
- env[:ui].info(I18n.t("vagrant_cloudstack.already_status", :status => "created"))
11
- @app.call(env)
12
- end
13
- end
14
- end
15
- end
16
- end
1
+ module VagrantPlugins
2
+ module Cloudstack
3
+ module Action
4
+ class MessageAlreadyCreated
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ env[:ui].info(I18n.t("vagrant_cloudstack.already_status", :status => "created"))
11
+ @app.call(env)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,16 +1,16 @@
1
- module VagrantPlugins
2
- module Cloudstack
3
- module Action
4
- class MessageNotCreated
5
- def initialize(app, env)
6
- @app = app
7
- end
8
-
9
- def call(env)
10
- env[:ui].info(I18n.t("vagrant_cloudstack.not_created"))
11
- @app.call(env)
12
- end
13
- end
14
- end
15
- end
16
- end
1
+ module VagrantPlugins
2
+ module Cloudstack
3
+ module Action
4
+ class MessageNotCreated
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ env[:ui].info(I18n.t("vagrant_cloudstack.not_created"))
11
+ @app.call(env)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,16 +1,16 @@
1
- module VagrantPlugins
2
- module Cloudstack
3
- module Action
4
- class MessageWillNotDestroy
5
- def initialize(app, env)
6
- @app = app
7
- end
8
-
9
- def call(env)
10
- env[:ui].info(I18n.t("vagrant_cloudstack.will_not_destroy", name: env[:machine].name))
11
- @app.call(env)
12
- end
13
- end
14
- end
15
- end
16
- end
1
+ module VagrantPlugins
2
+ module Cloudstack
3
+ module Action
4
+ class MessageWillNotDestroy
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ env[:ui].info(I18n.t("vagrant_cloudstack.will_not_destroy", name: env[:machine].name))
11
+ @app.call(env)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,76 +1,76 @@
1
- require 'log4r'
2
-
3
- module VagrantPlugins
4
- module Cloudstack
5
- module Action
6
- # This action reads the WinRM info for the machine and puts it into the
7
- # `:machine_winrm_info` key in the environment.
8
- class ReadRdpInfo
9
- def initialize(app, env)
10
- @app = app
11
- @logger = Log4r::Logger.new("vagrant_cloudstack::action::read_rdp_info")
12
- end
13
-
14
- def call(env)
15
- env[:machine_rdp_info] = read_rdp_info(env[:cloudstack_compute], env[:machine])
16
-
17
- @app.call(env)
18
- end
19
-
20
- def read_rdp_info(cloudstack, machine)
21
- return nil if machine.id.nil?
22
-
23
- # Find the machine
24
- server = cloudstack.servers.get(machine.id)
25
- if server.nil?
26
- # The machine can't be found
27
- @logger.info("Machine couldn't be found, assuming it got destroyed.")
28
- machine.id = nil
29
- return nil
30
- end
31
-
32
- # Get the Port forwarding config
33
- domain = machine.provider_config.domain_id
34
- domain_config = machine.provider_config.get_domain_config(domain)
35
-
36
- pf_ip_address_id = domain_config.pf_ip_address_id
37
- pf_ip_address = domain_config.pf_ip_address
38
- pf_public_rdp_port = domain_config.pf_public_rdp_port
39
-
40
- if pf_public_rdp_port.nil?
41
- pf_public_rdp_port_file = machine.data_dir.join('pf_public_rdp_port')
42
- if pf_public_rdp_port_file.file?
43
- File.read(pf_public_rdp_port_file).each_line do |line|
44
- pf_public_rdp_port = line.strip
45
- end
46
- domain_config.pf_public_rdp_port = pf_public_rdp_port
47
- end
48
- end
49
-
50
- if not pf_ip_address and pf_ip_address_id and pf_public_rdp_port
51
- begin
52
- response = cloudstack.list_public_ip_addresses({:id => pf_ip_address_id})
53
- rescue Fog::Compute::Cloudstack::Error => e
54
- raise Errors::FogError, :message => e.message
55
- end
56
-
57
- if response["listpublicipaddressesresponse"]["count"] == 0
58
- @logger.info("IP address #{pf_ip_address_id} not exists.")
59
- env[:ui].info(I18n.t("IP address #{pf_ip_address_id} not exists."))
60
- pf_ip_address = nil
61
- else
62
- pf_ip_address = response["listpublicipaddressesresponse"]["publicipaddress"][0]["ipaddress"]
63
- end
64
- end
65
-
66
- rdp_info = {
67
- :host => pf_ip_address || server.nics[0]['ipaddress'],
68
- :port => pf_public_rdp_port
69
- }
70
-
71
- rdp_info
72
- end
73
- end
74
- end
75
- end
76
- end
1
+ require 'log4r'
2
+
3
+ module VagrantPlugins
4
+ module Cloudstack
5
+ module Action
6
+ # This action reads the WinRM info for the machine and puts it into the
7
+ # `:machine_winrm_info` key in the environment.
8
+ class ReadRdpInfo
9
+ def initialize(app, env)
10
+ @app = app
11
+ @logger = Log4r::Logger.new("vagrant_cloudstack::action::read_rdp_info")
12
+ end
13
+
14
+ def call(env)
15
+ env[:machine_rdp_info] = read_rdp_info(env[:cloudstack_compute], env[:machine])
16
+
17
+ @app.call(env)
18
+ end
19
+
20
+ def read_rdp_info(cloudstack, machine)
21
+ return nil if machine.id.nil?
22
+
23
+ # Find the machine
24
+ server = cloudstack.servers.get(machine.id)
25
+ if server.nil?
26
+ # The machine can't be found
27
+ @logger.info("Machine couldn't be found, assuming it got destroyed.")
28
+ machine.id = nil
29
+ return nil
30
+ end
31
+
32
+ # Get the Port forwarding config
33
+ domain = machine.provider_config.domain_id
34
+ domain_config = machine.provider_config.get_domain_config(domain)
35
+
36
+ pf_ip_address_id = domain_config.pf_ip_address_id
37
+ pf_ip_address = domain_config.pf_ip_address
38
+ pf_public_rdp_port = domain_config.pf_public_rdp_port
39
+
40
+ if pf_public_rdp_port.nil?
41
+ pf_public_rdp_port_file = machine.data_dir.join('pf_public_rdp_port')
42
+ if pf_public_rdp_port_file.file?
43
+ File.read(pf_public_rdp_port_file).each_line do |line|
44
+ pf_public_rdp_port = line.strip
45
+ end
46
+ domain_config.pf_public_rdp_port = pf_public_rdp_port
47
+ end
48
+ end
49
+
50
+ if not pf_ip_address and pf_ip_address_id and pf_public_rdp_port
51
+ begin
52
+ response = cloudstack.list_public_ip_addresses({:id => pf_ip_address_id})
53
+ rescue Fog::Compute::Cloudstack::Error => e
54
+ raise Errors::FogError, :message => e.message
55
+ end
56
+
57
+ if response["listpublicipaddressesresponse"]["count"] == 0
58
+ @logger.info("IP address #{pf_ip_address_id} not exists.")
59
+ env[:ui].info(I18n.t("IP address #{pf_ip_address_id} not exists."))
60
+ pf_ip_address = nil
61
+ else
62
+ pf_ip_address = response["listpublicipaddressesresponse"]["publicipaddress"][0]["ipaddress"]
63
+ end
64
+ end
65
+
66
+ rdp_info = {
67
+ :host => pf_ip_address || server.nics[0]['ipaddress'],
68
+ :port => pf_public_rdp_port
69
+ }
70
+
71
+ rdp_info
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
@@ -1,87 +1,104 @@
1
- require 'log4r'
2
-
3
- module VagrantPlugins
4
- module Cloudstack
5
- module Action
6
- # This action reads the SSH info for the machine and puts it into the
7
- # `:machine_ssh_info` key in the environment.
8
- class ReadSSHInfo
9
- def initialize(app, env)
10
- @app = app
11
- @logger = Log4r::Logger.new("vagrant_cloudstack::action::read_ssh_info")
12
- end
13
-
14
- def call(env)
15
- env[:machine_ssh_info] = read_ssh_info(env[:cloudstack_compute], env[:machine])
16
-
17
- @app.call(env)
18
- end
19
-
20
- def read_ssh_info(cloudstack, machine)
21
- return nil if machine.id.nil?
22
-
23
- # Find the machine
24
- server = cloudstack.servers.get(machine.id)
25
- if server.nil?
26
- # The machine can't be found
27
- @logger.info("Machine couldn't be found, assuming it got destroyed.")
28
- machine.id = nil
29
- return nil
30
- end
31
-
32
- # Get the Port forwarding config
33
- domain = machine.provider_config.domain_id
34
- domain_config = machine.provider_config.get_domain_config(domain)
35
-
36
- pf_ip_address_id = domain_config.pf_ip_address_id
37
- pf_ip_address = domain_config.pf_ip_address
38
- pf_public_port = domain_config.pf_public_port
39
-
40
- if pf_public_port.nil?
41
- pf_public_port_file = machine.data_dir.join('pf_public_port')
42
- if pf_public_port_file.file?
43
- File.read(pf_public_port_file).each_line do |line|
44
- pf_public_port = line.strip
45
- end
46
- domain_config.pf_public_port = pf_public_port
47
- end
48
- end
49
-
50
- if not pf_ip_address and pf_ip_address_id and pf_public_port
51
- begin
52
- response = cloudstack.list_public_ip_addresses({:id => pf_ip_address_id})
53
- rescue Fog::Compute::Cloudstack::Error => e
54
- raise Errors::FogError, :message => e.message
55
- end
56
-
57
- if response["listpublicipaddressesresponse"]["count"] == 0
58
- @logger.info("IP address #{pf_ip_address_id} not exists.")
59
- env[:ui].info(I18n.t("IP address #{pf_ip_address_id} not exists."))
60
- pf_ip_address = nil
61
- else
62
- pf_ip_address = response["listpublicipaddressesresponse"]["publicipaddress"][0]["ipaddress"]
63
- end
64
- end
65
-
66
- if domain_config.keypair.nil? && domain_config.ssh_key.nil?
67
- sshkeyfile_file = machine.data_dir.join('sshkeyfile')
68
- if sshkeyfile_file.file?
69
- domain_config.ssh_key = sshkeyfile_file.to_s
70
- end
71
- end
72
-
73
- ssh_info = {
74
- :host => pf_ip_address || server.nics[0]['ipaddress'],
75
- :port => pf_public_port
76
- }
77
- ssh_info = ssh_info.merge({
78
- :private_key_path => domain_config.ssh_key,
79
- :password => nil
80
- }) unless domain_config.ssh_key.nil?
81
- ssh_info = ssh_info.merge({ :username => domain_config.ssh_user }) unless domain_config.ssh_user.nil?
82
- ssh_info
83
- end
84
- end
85
- end
86
- end
87
- end
1
+ require 'log4r'
2
+
3
+ module VagrantPlugins
4
+ module Cloudstack
5
+ module Action
6
+ # This action reads the SSH info for the machine and puts it into the
7
+ # `:machine_ssh_info` key in the environment.
8
+ class ReadSSHInfo
9
+ def initialize(app, env)
10
+ @app = app
11
+ @logger = Log4r::Logger.new("vagrant_cloudstack::action::read_ssh_info")
12
+ end
13
+
14
+ def call(env)
15
+ env[:machine_ssh_info] = read_ssh_info(env[:cloudstack_compute], env[:machine])
16
+
17
+ @app.call(env)
18
+ end
19
+
20
+ def read_ssh_info(cloudstack, machine)
21
+ return nil if machine.id.nil?
22
+
23
+ # Find the machine
24
+ server = cloudstack.servers.get(machine.id)
25
+ if server.nil?
26
+ # The machine can't be found
27
+ @logger.info("Machine couldn't be found, assuming it got destroyed.")
28
+ machine.id = nil
29
+ return nil
30
+ end
31
+
32
+ # Get the Port forwarding config
33
+ domain = machine.provider_config.domain_id
34
+ domain_config = machine.provider_config.get_domain_config(domain)
35
+
36
+ pf_ip_address_id = domain_config.pf_ip_address_id
37
+ pf_ip_address = domain_config.pf_ip_address
38
+ pf_public_port = domain_config.pf_public_port
39
+
40
+ if pf_public_port.nil?
41
+ pf_public_port_file = machine.data_dir.join('pf_public_port')
42
+ if pf_public_port_file.file?
43
+ File.read(pf_public_port_file).each_line do |line|
44
+ pf_public_port = line.strip
45
+ end
46
+ domain_config.pf_public_port = pf_public_port
47
+ end
48
+ end
49
+
50
+ if not pf_ip_address and pf_ip_address_id and pf_public_port
51
+ begin
52
+ response = cloudstack.list_public_ip_addresses({:id => pf_ip_address_id})
53
+ rescue Fog::Compute::Cloudstack::Error => e
54
+ raise Errors::FogError, :message => e.message
55
+ end
56
+
57
+ if response["listpublicipaddressesresponse"]["count"] == 0
58
+ @logger.info("IP address #{pf_ip_address_id} not exists.")
59
+ env[:ui].info(I18n.t("IP address #{pf_ip_address_id} not exists."))
60
+ pf_ip_address = nil
61
+ else
62
+ pf_ip_address = response["listpublicipaddressesresponse"]["publicipaddress"][0]["ipaddress"]
63
+ end
64
+ end
65
+
66
+ if domain_config.keypair.nil? && domain_config.ssh_key.nil?
67
+ sshkeyfile_file = machine.data_dir.join('sshkeyfile')
68
+ if sshkeyfile_file.file?
69
+ domain_config.ssh_key = sshkeyfile_file.to_s
70
+ end
71
+ end
72
+
73
+ nic_ip_address = fetch_nic_ip_address(server.nics, domain_config)
74
+
75
+ ssh_info = {
76
+ :host => pf_ip_address || nic_ip_address,
77
+ :port => pf_public_port
78
+ }
79
+ ssh_info = ssh_info.merge({
80
+ :private_key_path => domain_config.ssh_key,
81
+ :password => nil
82
+ }) unless domain_config.ssh_key.nil?
83
+ ssh_info = ssh_info.merge({ :username => domain_config.ssh_user }) unless domain_config.ssh_user.nil?
84
+ ssh_info
85
+ end
86
+
87
+ def fetch_nic_ip_address(nics, domain_config)
88
+ ssh_nic =
89
+ if !domain_config.ssh_network_id.nil?
90
+ nics.find { |nic| nic["networkid"] == domain_config.ssh_network_id }
91
+ elsif !domain_config.ssh_network_name.nil?
92
+ nics.find { |nic| nic["networkname"] == domain_config.ssh_network_name }
93
+ else
94
+ # When without neither ssh_network_id and ssh_network_name, use 1st nic
95
+ nics[0]
96
+ end
97
+
98
+ ssh_nic ||= nics[0]
99
+ ssh_nic["ipaddress"]
100
+ end
101
+ end
102
+ end
103
+ end
104
+ end
@@ -1,38 +1,38 @@
1
- require "log4r"
2
-
3
- module VagrantPlugins
4
- module Cloudstack
5
- module Action
6
- # This action reads the state of the machine and puts it in the
7
- # `:machine_state_id` key in the environment.
8
- class ReadState
9
- def initialize(app, env)
10
- @app = app
11
- @logger = Log4r::Logger.new("vagrant_cloudstack::action::read_state")
12
- end
13
-
14
- def call(env)
15
- env[:machine_state_id] = read_state(env[:cloudstack_compute], env[:machine])
16
-
17
- @app.call(env)
18
- end
19
-
20
- def read_state(cloudstack, machine)
21
- return :not_created if machine.id.nil?
22
-
23
- # Find the machine
24
- server = cloudstack.servers.get(machine.id)
25
- if server.nil? || [:"shutting-down", :terminated].include?(server.state.downcase.to_sym)
26
- # The machine can't be found
27
- @logger.info("Machine not found or terminated, assuming it got destroyed.")
28
- machine.id = nil
29
- return :not_created
30
- end
31
-
32
- # Return the state
33
- server.state.downcase.to_sym
34
- end
35
- end
36
- end
37
- end
38
- end
1
+ require "log4r"
2
+
3
+ module VagrantPlugins
4
+ module Cloudstack
5
+ module Action
6
+ # This action reads the state of the machine and puts it in the
7
+ # `:machine_state_id` key in the environment.
8
+ class ReadState
9
+ def initialize(app, env)
10
+ @app = app
11
+ @logger = Log4r::Logger.new("vagrant_cloudstack::action::read_state")
12
+ end
13
+
14
+ def call(env)
15
+ env[:machine_state_id] = read_state(env[:cloudstack_compute], env[:machine])
16
+
17
+ @app.call(env)
18
+ end
19
+
20
+ def read_state(cloudstack, machine)
21
+ return :not_created if machine.id.nil?
22
+
23
+ # Find the machine
24
+ server = cloudstack.servers.get(machine.id)
25
+ if server.nil? || [:"shutting-down", :terminated].include?(server.state.downcase.to_sym)
26
+ # The machine can't be found
27
+ @logger.info("Machine not found or terminated, assuming it got destroyed.")
28
+ machine.id = nil
29
+ return :not_created
30
+ end
31
+
32
+ # Return the state
33
+ server.state.downcase.to_sym
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end