vagrant-arubacloud 0.0.7 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,167 +1,166 @@
1
- require 'vagrant'
2
- require 'fog'
3
-
4
- module VagrantPlugins
5
- module ArubaCloud
6
-
7
- DC_TABLES = {
8
- :dc1 => "https://api.dc1.computing.cloud.it/WsEndUser/v2.9/WsEndUser.svc/json",
9
- :dc2 => "https://api.dc2.computing.cloud.it/WsEndUser/v2.9/WsEndUser.svc/json",
10
- :dc3 => "https://api.dc3.computing.cloud.it/WsEndUser/v2.9/WsEndUser.svc/json",
11
- :dc4 => "https://api.dc4.computing.cloud.it/WsEndUser/v2.9/WsEndUser.svc/json",
12
- :dc5 => "https://api.dc5.computing.cloud.it/WsEndUser/v2.9/WsEndUser.svc/json",
13
- :dc6 => "https://api.dc6.computing.cloud.it/WsEndUser/v2.9/WsEndUser.svc/json",
14
- :dc8 => "https://api.dc8.computing.cloud.it/WsEndUser/v2.9/WsEndUser.svc/json"
15
- }
16
-
17
- DC_DEFAULT = "dc2"
18
-
19
- class Config < Vagrant.plugin('2', :config)
20
-
21
- # ArubaCloud Username
22
- # @return [String]
23
- attr_accessor :arubacloud_username
24
-
25
- # ArubaCloud Password
26
- # @return [String]
27
- attr_accessor :arubacloud_password
28
-
29
- # reserved for internal use
30
- attr_accessor :reserved_status
31
- attr_accessor :reserved_list_owned
32
-
33
- # Ws EndPoint Url
34
- # Expected to be the url of the web service to use
35
- # @return [String]
36
- attr_accessor :url
37
-
38
- # Ws EndPoint id : can be dc2,dc2,dc3,...dc8 (dc7 is not defined at this release)
39
- # @return [String]
40
- attr_accessor :endpoint
41
-
42
- # The name of the server. This defaults to the name of the machine
43
- # defined by Vagrant (via 'config.vm.define'), but can be override here.
44
- # @return [String]
45
- attr_accessor :server_name
46
-
47
- # The ID of the template to use, use vagrant arubacloud templates to obtain
48
- # the complete list.
49
- # @return [Integer]
50
- attr_accessor :template_id
51
-
52
- # The smart vm type expressed as String:
53
- # 'small'
54
- # 'medium'
55
- # 'large'
56
- # 'extra large'
57
- # @return [String]
58
- attr_accessor :package_id
59
-
60
- # Service Type expressed in ID [Integer]:
61
- # 1 = Pro Hyper-V
62
- # 2 = Pro VMWare
63
- # 3 = Pro Hyper-V Low Cost
64
- # 4 = Smart
65
- # @return [Integer]
66
- attr_accessor :service_type
67
-
68
- # Number of Virtual CPU to be assigned to the VM
69
- # Pro VMWare: 1 < n < 8
70
- # Pro Hyper-V: 1 < n < 4
71
- # @return [Integer]
72
- attr_accessor :cpu_number
73
-
74
- # Amount of GB of RAM to be assigned to the VM
75
- # n <= 16
76
- # @return [Integer]
77
- attr_accessor :ram_qty
78
-
79
- # Array containing hard disk Configuration
80
- # Example configuration (size is expressed in GB):
81
- # Hds = [{:type => 0, :size => 100}, {:type => 1, :size => 200}]
82
- # Hd type 0 is required because specify the first hard disk, max size per hd: 500 GB
83
- # Hd type > 0 < 4 are 3 additional hard disks (optional)
84
- # @return [Array]
85
- attr_accessor :hds
86
-
87
- def initialize
88
- @arubacloud_username = UNSET_VALUE
89
- @arubacloud_password = UNSET_VALUE
90
- @url = UNSET_VALUE
91
- @reserved_status = UNSET_VALUE
92
- @reserved_list_owned = UNSET_VALUE
93
- @endpoint = UNSET_VALUE
94
- @server_name = UNSET_VALUE
95
- @template_id = UNSET_VALUE
96
- @package_id = UNSET_VALUE
97
- @service_type = UNSET_VALUE
98
- @cpu_number = UNSET_VALUE
99
- @ram_qty = UNSET_VALUE
100
- @hds = UNSET_VALUE
101
- end
102
-
103
- def finalize!
104
- @arubacloud_username = nil if @arubacloud_username == UNSET_VALUE
105
- @arubacloud_password = nil if @arubacloud_password == UNSET_VALUE
106
- @url = nil if @url == UNSET_VALUE
107
- @reserved_status = nil if @reserved_status = UNSET_VALUE
108
- @reserved_list_owned = nil if @reserved_list_owned = UNSET_VALUE
109
- @endpoint = nil if @endpoint == UNSET_VALUE
110
- @server_name = nil if @server_name == UNSET_VALUE
111
- @template_id = nil if @template_id == UNSET_VALUE
112
- @package_id = nil if @package_id == UNSET_VALUE
113
- @service_type = nil if @service_type == UNSET_VALUE
114
- @cpu_number = nil if @cpu_number == UNSET_VALUE
115
- @ram_qty = nil if @ram_qty == UNSET_VALUE
116
- @hds = nil if @hds == UNSET_VALUE
117
- end
118
-
119
- def validate(machine)
120
- errors = _detected_errors
121
-
122
- # Global configurations needed by all service types
123
- errors << I18n.t('vagrant_arubacloud.config.arubacloud_username_required') unless @arubacloud_username
124
- errors << I18n.t('vagrant_arubacloud.config.arubacloud_password_required') unless @arubacloud_password
125
- errors << I18n.t('vagrant_arubacloud.config.template_id_required') unless @template_id
126
- errors << I18n.t('vagrant_arubacloud.config.service_type_required') unless @service_type
127
-
128
- errors << I18n.t('vagrant_arubacloud.config.ssh_password_required') unless machine.config.ssh.password
129
-
130
- #check if coded url or endpoint
131
- #if url not in table or dc wrong return error
132
- if (@url)
133
- if (DC_TABLES.key(@url))
134
- @endpoint = DC_TABLES.key(@url)
135
- else
136
- errors << I18n.t('vagrant_arubacloud.config.url_is_wrong')
137
- end
138
- else
139
- if (@endpoint)
140
- if DC_TABLES.key?(@endpoint.to_sym)
141
- @url = DC_TABLES[@endpoint.to_sym]
142
- else
143
- errors << I18n.t('vagrant_arubacloud.config.endpoint_is_wrong')
144
- end
145
- else
146
- @endpoint = DC_DEFAULT.to_sym
147
- @url = DC_TABLES[DC_DEFAULT.to_sym]
148
- end
149
- end
150
-
151
- if @service_type.eql? 4
152
- errors << I18n.t('vagrant_arubacloud.config.package_id_required') unless @package_id
153
- else
154
- errors << I18n.t('vagrant_arubacloud.config.cpu_number_required') unless @cpu_number
155
- errors << I18n.t('vagrant_arubacloud.config.ram_qty_required') unless @ram_qty
156
- if @hds
157
- errors << I18n.t('vagrant_arubacloud.config.hds_conf_must_be_array') unless @hds.kind_of?(Array)
158
- elsif
159
- errors << I18n.t('vagrant_arubacloud.config.hds_conf_required')
160
- end
161
- end
162
- {'ArubaCloud Provider' => errors}
163
- end
164
- end # Config
165
-
166
- end # ArubaCloud
167
- end # VagrantPlugins
1
+ require 'vagrant'
2
+
3
+ module VagrantPlugins
4
+ module ArubaCloud
5
+
6
+ DC_TABLES = {
7
+ :dc1 => "https://api.dc1.computing.cloud.it/WsEndUser/v2.9/WsEndUser.svc/json",
8
+ :dc2 => "https://api.dc2.computing.cloud.it/WsEndUser/v2.9/WsEndUser.svc/json",
9
+ :dc3 => "https://api.dc3.computing.cloud.it/WsEndUser/v2.9/WsEndUser.svc/json",
10
+ :dc4 => "https://api.dc4.computing.cloud.it/WsEndUser/v2.9/WsEndUser.svc/json",
11
+ :dc5 => "https://api.dc5.computing.cloud.it/WsEndUser/v2.9/WsEndUser.svc/json",
12
+ :dc6 => "https://api.dc6.computing.cloud.it/WsEndUser/v2.9/WsEndUser.svc/json",
13
+ :dc8 => "https://api.dc8.computing.cloud.it/WsEndUser/v2.9/WsEndUser.svc/json"
14
+ }
15
+
16
+ DC_DEFAULT = "dc2"
17
+
18
+ class Config < Vagrant.plugin('2', :config)
19
+
20
+ # ArubaCloud Username
21
+ # @return [String]
22
+ attr_accessor :arubacloud_username
23
+
24
+ # ArubaCloud Password
25
+ # @return [String]
26
+ attr_accessor :arubacloud_password
27
+
28
+ # reserved for internal use
29
+ attr_accessor :reserved_status
30
+ attr_accessor :reserved_list_owned
31
+
32
+ # Ws EndPoint Url
33
+ # Expected to be the url of the web service to use
34
+ # @return [String]
35
+ attr_accessor :url
36
+
37
+ # Ws EndPoint id : can be dc2,dc2,dc3,...dc8 (dc7 is not defined at this release)
38
+ # @return [String]
39
+ attr_accessor :endpoint
40
+
41
+ # The name of the server. This defaults to the name of the machine
42
+ # defined by Vagrant (via 'config.vm.define'), but can be override here.
43
+ # @return [String]
44
+ attr_accessor :server_name
45
+
46
+ # The ID of the template to use, use vagrant arubacloud templates to obtain
47
+ # the complete list.
48
+ # @return [Integer]
49
+ attr_accessor :template_id
50
+
51
+ # The smart vm type expressed as String:
52
+ # 'small'
53
+ # 'medium'
54
+ # 'large'
55
+ # 'extra large'
56
+ # @return [String]
57
+ attr_accessor :package_id
58
+
59
+ # Service Type expressed in ID [Integer]:
60
+ # 1 = Pro Hyper-V
61
+ # 2 = Pro VMWare
62
+ # 3 = Pro Hyper-V Low Cost
63
+ # 4 = Smart
64
+ # @return [Integer]
65
+ attr_accessor :service_type
66
+
67
+ # Number of Virtual CPU to be assigned to the VM
68
+ # Pro VMWare: 1 < n < 8
69
+ # Pro Hyper-V: 1 < n < 4
70
+ # @return [Integer]
71
+ attr_accessor :cpu_number
72
+
73
+ # Amount of GB of RAM to be assigned to the VM
74
+ # n <= 16
75
+ # @return [Integer]
76
+ attr_accessor :ram_qty
77
+
78
+ # Array containing hard disk Configuration
79
+ # Example configuration (size is expressed in GB):
80
+ # Hds = [{:type => 0, :size => 100}, {:type => 1, :size => 200}]
81
+ # Hd type 0 is required because specify the first hard disk, max size per hd: 500 GB
82
+ # Hd type > 0 < 4 are 3 additional hard disks (optional)
83
+ # @return [Array]
84
+ attr_accessor :hds
85
+
86
+ def initialize
87
+ @arubacloud_username = UNSET_VALUE
88
+ @arubacloud_password = UNSET_VALUE
89
+ @url = UNSET_VALUE
90
+ @reserved_status = UNSET_VALUE
91
+ @reserved_list_owned = UNSET_VALUE
92
+ @endpoint = UNSET_VALUE
93
+ @server_name = UNSET_VALUE
94
+ @template_id = UNSET_VALUE
95
+ @package_id = UNSET_VALUE
96
+ @service_type = UNSET_VALUE
97
+ @cpu_number = UNSET_VALUE
98
+ @ram_qty = UNSET_VALUE
99
+ @hds = UNSET_VALUE
100
+ end
101
+
102
+ def finalize!
103
+ @arubacloud_username = nil if @arubacloud_username == UNSET_VALUE
104
+ @arubacloud_password = nil if @arubacloud_password == UNSET_VALUE
105
+ @url = nil if @url == UNSET_VALUE
106
+ @reserved_status = nil if @reserved_status = UNSET_VALUE
107
+ @reserved_list_owned = nil if @reserved_list_owned = UNSET_VALUE
108
+ @endpoint = nil if @endpoint == UNSET_VALUE
109
+ @server_name = nil if @server_name == UNSET_VALUE
110
+ @template_id = nil if @template_id == UNSET_VALUE
111
+ @package_id = nil if @package_id == UNSET_VALUE
112
+ @service_type = nil if @service_type == UNSET_VALUE
113
+ @cpu_number = nil if @cpu_number == UNSET_VALUE
114
+ @ram_qty = nil if @ram_qty == UNSET_VALUE
115
+ @hds = nil if @hds == UNSET_VALUE
116
+ end
117
+
118
+ def validate(machine)
119
+ errors = _detected_errors
120
+
121
+ # Global configurations needed by all service types
122
+ errors << I18n.t('vagrant_arubacloud.config.arubacloud_username_required') unless @arubacloud_username
123
+ errors << I18n.t('vagrant_arubacloud.config.arubacloud_password_required') unless @arubacloud_password
124
+ errors << I18n.t('vagrant_arubacloud.config.template_id_required') unless @template_id
125
+ errors << I18n.t('vagrant_arubacloud.config.service_type_required') unless @service_type
126
+
127
+ errors << I18n.t('vagrant_arubacloud.config.ssh_password_required') unless machine.config.ssh.password
128
+
129
+ #check if coded url or endpoint
130
+ #if url not in table or dc wrong return error
131
+ if (@url)
132
+ if (DC_TABLES.key(@url))
133
+ @endpoint = DC_TABLES.key(@url)
134
+ else
135
+ errors << I18n.t('vagrant_arubacloud.config.url_is_wrong')
136
+ end
137
+ else
138
+ if (@endpoint)
139
+ if DC_TABLES.key?(@endpoint.to_sym)
140
+ @url = DC_TABLES[@endpoint.to_sym]
141
+ else
142
+ errors << I18n.t('vagrant_arubacloud.config.endpoint_is_wrong')
143
+ end
144
+ else
145
+ @endpoint = DC_DEFAULT.to_sym
146
+ @url = DC_TABLES[DC_DEFAULT.to_sym]
147
+ end
148
+ end
149
+
150
+ if @service_type.eql? 4
151
+ errors << I18n.t('vagrant_arubacloud.config.package_id_required') unless @package_id
152
+ else
153
+ errors << I18n.t('vagrant_arubacloud.config.cpu_number_required') unless @cpu_number
154
+ errors << I18n.t('vagrant_arubacloud.config.ram_qty_required') unless @ram_qty
155
+ if @hds
156
+ errors << I18n.t('vagrant_arubacloud.config.hds_conf_must_be_array') unless @hds.kind_of?(Array)
157
+ elsif
158
+ errors << I18n.t('vagrant_arubacloud.config.hds_conf_required')
159
+ end
160
+ end
161
+ {'ArubaCloud Provider' => errors}
162
+ end
163
+ end # Config
164
+
165
+ end # ArubaCloud
166
+ end # VagrantPlugins
@@ -1,56 +1,56 @@
1
- begin
2
- require 'vagrant'
3
- rescue LoadError
4
- raise 'The ArubaCloud IaaS provider must be run within Vagrant.'
5
- end
6
-
7
- if Vagrant::VERSION < '1.2.0'
8
- raise 'ArubaCloud IaaS provider is only compatible with Vagrant 1.2+'
9
- end
10
-
11
- module VagrantPlugins
12
- module ArubaCloud
13
- class Plugin < Vagrant.plugin('2')
14
- # noinspection RubyArgCount
15
- name 'ArubaCloud'
16
- description <<-DESC
17
- This plugin enable Vagrant to manage machines in ArubaCloud IaaS service.
18
- DESC
19
-
20
- config(:arubacloud, :provider) do
21
- require_relative 'config'
22
- Config
23
- end
24
-
25
- provider(:arubacloud, { :box_optional => true, :parallel => true }) do
26
- ArubaCloud.init_i18n
27
- ArubaCloud.init_logging
28
-
29
- require_relative 'provider'
30
- Provider
31
- end
32
-
33
- command('arubacloud') do
34
- ArubaCloud.init_i18n
35
- ArubaCloud.init_logging
36
-
37
- require_relative 'command/root'
38
- Command::Root
39
- end
40
-
41
- command('snapshot') do
42
- ArubaCloud.init_i18n
43
- ArubaCloud.init_logging
44
-
45
- require_relative 'command/snapshot'
46
- Command::Snapshot
47
- end
48
-
49
- # Disable require tty for centOS
50
- guest_capability 'redhat', 'disable_requiretty' do
51
- require_relative 'cap/disable_requiretty'
52
- Cap::DisableRequireTty
53
- end
54
- end # Plugin
55
- end # ArubaCloud
56
- end # VagrantPlugins
1
+ begin
2
+ require 'vagrant'
3
+ rescue LoadError
4
+ raise 'The ArubaCloud IaaS provider must be run within Vagrant.'
5
+ end
6
+
7
+ if Vagrant::VERSION < '1.2.0'
8
+ raise 'ArubaCloud IaaS provider is only compatible with Vagrant 1.2+'
9
+ end
10
+
11
+ module VagrantPlugins
12
+ module ArubaCloud
13
+ class Plugin < Vagrant.plugin('2')
14
+ # noinspection RubyArgCount
15
+ name 'ArubaCloud'
16
+ description <<-DESC
17
+ This plugin enable Vagrant to manage machines in ArubaCloud IaaS service.
18
+ DESC
19
+
20
+ config(:arubacloud, :provider) do
21
+ require_relative 'config'
22
+ Config
23
+ end
24
+
25
+ provider(:arubacloud, { :box_optional => true, :parallel => true }) do
26
+ ArubaCloud.init_i18n
27
+ ArubaCloud.init_logging
28
+
29
+ require_relative 'provider'
30
+ Provider
31
+ end
32
+
33
+ command('arubacloud') do
34
+ ArubaCloud.init_i18n
35
+ ArubaCloud.init_logging
36
+
37
+ require_relative 'command/root'
38
+ Command::Root
39
+ end
40
+
41
+ command('snapshot') do
42
+ ArubaCloud.init_i18n
43
+ ArubaCloud.init_logging
44
+
45
+ require_relative 'command/snapshot'
46
+ Command::Snapshot
47
+ end
48
+
49
+ # Disable require tty for centOS
50
+ guest_capability 'redhat', 'disable_requiretty' do
51
+ require_relative 'cap/disable_requiretty'
52
+ Cap::DisableRequireTty
53
+ end
54
+ end # Plugin
55
+ end # ArubaCloud
56
+ end # VagrantPlugins
@@ -1,51 +1,51 @@
1
- require 'vagrant'
2
-
3
- require 'vagrant-arubacloud/action'
4
-
5
-
6
- module VagrantPlugins
7
- module ArubaCloud
8
- class Provider < Vagrant.plugin('2', :provider)
9
- def initialize(machine)
10
- @machine = machine
11
- end
12
-
13
- def action(name)
14
- # Attempt to get the action method from the Action class if it
15
- # exists, otherwise return nil to show that we don't support the
16
- # given action.
17
- action_method = "action_#{name}"
18
- return Action.send(action_method) if Action.respond_to?(action_method)
19
- nil
20
- end
21
-
22
- def ssh_info
23
- # Run a custom action called "read_ssh_info" which does what it
24
- # says and puts the resulting SSH info into the `:machine_ssh_info`
25
- # key in the environment.
26
- env = @machine.action("read_ssh_info")
27
- env[:machine_ssh_info]
28
- end
29
-
30
- def state
31
- # Run a custom action we define called "read_state" which does
32
- # what it says. It puts the state in the `:machine_state_id`
33
- # key in the environment.
34
- env = @machine.action('read_state')
35
-
36
- state_id = env[:machine_state_id]
37
-
38
- # Get the short and long description
39
- short = I18n.t("vagrant_arubacloud.states.short_#{state_id}")
40
- long = I18n.t("vagrant_arubacloud.states.long_#{state_id}")
41
-
42
- # Return the MachineState object
43
- Vagrant::MachineState.new(state_id, short, long)
44
- end
45
-
46
- def to_s
47
- 'ArubaCloud IaaS'
48
- end
49
- end # Provider
50
- end # ArubaCloud
51
- end # VagrantPlugins
1
+ require 'vagrant'
2
+
3
+ require 'vagrant-arubacloud/action'
4
+
5
+
6
+ module VagrantPlugins
7
+ module ArubaCloud
8
+ class Provider < Vagrant.plugin('2', :provider)
9
+ def initialize(machine)
10
+ @machine = machine
11
+ end
12
+
13
+ def action(name)
14
+ # Attempt to get the action method from the Action class if it
15
+ # exists, otherwise return nil to show that we don't support the
16
+ # given action.
17
+ action_method = "action_#{name}"
18
+ return Action.send(action_method) if Action.respond_to?(action_method)
19
+ nil
20
+ end
21
+
22
+ def ssh_info
23
+ # Run a custom action called "read_ssh_info" which does what it
24
+ # says and puts the resulting SSH info into the `:machine_ssh_info`
25
+ # key in the environment.
26
+ env = @machine.action("read_ssh_info")
27
+ env[:machine_ssh_info]
28
+ end
29
+
30
+ def state
31
+ # Run a custom action we define called "read_state" which does
32
+ # what it says. It puts the state in the `:machine_state_id`
33
+ # key in the environment.
34
+ env = @machine.action('read_state')
35
+
36
+ state_id = env[:machine_state_id]
37
+
38
+ # Get the short and long description
39
+ short = I18n.t("vagrant_arubacloud.states.short_#{state_id}")
40
+ long = I18n.t("vagrant_arubacloud.states.long_#{state_id}")
41
+
42
+ # Return the MachineState object
43
+ Vagrant::MachineState.new(state_id, short, long)
44
+ end
45
+
46
+ def to_s
47
+ 'ArubaCloud IaaS'
48
+ end
49
+ end # Provider
50
+ end # ArubaCloud
51
+ end # VagrantPlugins