vagrant-softlayer 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -15
- data/CHANGELOG.md +18 -9
- data/Gemfile +12 -7
- data/README.md +247 -243
- data/contrib/README.md +11 -0
- data/contrib/vagrant-softlayer-boxes +408 -0
- data/lib/vagrant-softlayer/action/create_instance.rb +58 -54
- data/lib/vagrant-softlayer/action/join_load_balancer.rb +95 -95
- data/lib/vagrant-softlayer/action/resume_instance.rb +21 -0
- data/lib/vagrant-softlayer/action/setup_softlayer.rb +38 -37
- data/lib/vagrant-softlayer/action/suspend_instance.rb +21 -0
- data/lib/vagrant-softlayer/action/sync_folders.rb +1 -1
- data/lib/vagrant-softlayer/action/update_dns.rb +94 -94
- data/lib/vagrant-softlayer/action/wait_for_provision.rb +40 -40
- data/lib/vagrant-softlayer/action.rb +242 -208
- data/lib/vagrant-softlayer/config.rb +246 -229
- data/lib/vagrant-softlayer/version.rb +5 -5
- data/locales/en.yml +206 -170
- data/spec/vagrant-softlayer/config_spec.rb +261 -227
- data/vagrant-softlayer.gemspec +3 -1
- metadata +20 -31
@@ -1,229 +1,246 @@
|
|
1
|
-
require "ostruct"
|
2
|
-
|
3
|
-
module VagrantPlugins
|
4
|
-
module SoftLayer
|
5
|
-
class Config < Vagrant.plugin("2", :config)
|
6
|
-
# The API key to access SoftLayer.
|
7
|
-
attr_accessor :api_key
|
8
|
-
|
9
|
-
# The endpoint SoftLayer API url.
|
10
|
-
attr_accessor :endpoint_url
|
11
|
-
|
12
|
-
# The username to access SoftLayer.
|
13
|
-
attr_accessor :username
|
14
|
-
|
15
|
-
# The datacenter shortname.
|
16
|
-
attr_accessor :datacenter
|
17
|
-
|
18
|
-
# Whether to allocate a dedicated instance.
|
19
|
-
attr_accessor :dedicated
|
20
|
-
|
21
|
-
# The
|
22
|
-
attr_accessor :
|
23
|
-
|
24
|
-
# The
|
25
|
-
attr_accessor :
|
26
|
-
|
27
|
-
# The
|
28
|
-
attr_accessor :
|
29
|
-
|
30
|
-
# The
|
31
|
-
attr_accessor :
|
32
|
-
|
33
|
-
# The
|
34
|
-
attr_accessor :
|
35
|
-
|
36
|
-
#
|
37
|
-
attr_accessor :
|
38
|
-
|
39
|
-
# The
|
40
|
-
attr_accessor :
|
41
|
-
|
42
|
-
#
|
43
|
-
attr_accessor :
|
44
|
-
|
45
|
-
#
|
46
|
-
attr_accessor :
|
47
|
-
|
48
|
-
#
|
49
|
-
attr_accessor :
|
50
|
-
|
51
|
-
#
|
52
|
-
attr_accessor :
|
53
|
-
|
54
|
-
#
|
55
|
-
attr_accessor :
|
56
|
-
|
57
|
-
# The
|
58
|
-
attr_accessor :
|
59
|
-
|
60
|
-
#
|
61
|
-
attr_accessor :
|
62
|
-
|
63
|
-
# The
|
64
|
-
|
65
|
-
|
66
|
-
#
|
67
|
-
attr_accessor :
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
@
|
77
|
-
@
|
78
|
-
@
|
79
|
-
|
80
|
-
@
|
81
|
-
@
|
82
|
-
@
|
83
|
-
@
|
84
|
-
@
|
85
|
-
@
|
86
|
-
@
|
87
|
-
@
|
88
|
-
@
|
89
|
-
@
|
90
|
-
|
91
|
-
@
|
92
|
-
@
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
#
|
104
|
-
#
|
105
|
-
#
|
106
|
-
#
|
107
|
-
# :
|
108
|
-
# :
|
109
|
-
# :
|
110
|
-
#
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
#
|
121
|
-
opts[:method]
|
122
|
-
opts[:type]
|
123
|
-
opts[:service].health_check
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
#
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
@
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
1
|
+
require "ostruct"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module SoftLayer
|
5
|
+
class Config < Vagrant.plugin("2", :config)
|
6
|
+
# The API key to access SoftLayer.
|
7
|
+
attr_accessor :api_key
|
8
|
+
|
9
|
+
# The endpoint SoftLayer API url.
|
10
|
+
attr_accessor :endpoint_url
|
11
|
+
|
12
|
+
# The username to access SoftLayer.
|
13
|
+
attr_accessor :username
|
14
|
+
|
15
|
+
# The datacenter shortname.
|
16
|
+
attr_accessor :datacenter
|
17
|
+
|
18
|
+
# Whether to allocate a dedicated instance.
|
19
|
+
attr_accessor :dedicated
|
20
|
+
|
21
|
+
# The disk image capacity
|
22
|
+
attr_accessor :disk_capacity
|
23
|
+
|
24
|
+
# The domain of the instance.
|
25
|
+
attr_accessor :domain
|
26
|
+
|
27
|
+
# The hostname of the instance.
|
28
|
+
attr_accessor :hostname
|
29
|
+
|
30
|
+
# The billing type of the instance (true for hourly, false for monthly).
|
31
|
+
attr_accessor :hourly_billing
|
32
|
+
|
33
|
+
# The global identifier of the compute or flex image to use.
|
34
|
+
attr_accessor :image_guid
|
35
|
+
|
36
|
+
# The disk type of the instance (true for local, false for SAN).
|
37
|
+
attr_accessor :local_disk
|
38
|
+
|
39
|
+
# The amount of RAM of the instance.
|
40
|
+
attr_accessor :max_memory
|
41
|
+
|
42
|
+
# Network port speed in Mbps.
|
43
|
+
attr_accessor :network_speed
|
44
|
+
|
45
|
+
# The instance operating system identifier.
|
46
|
+
attr_accessor :operating_system
|
47
|
+
|
48
|
+
# URI of post-install script to download.
|
49
|
+
attr_accessor :post_install
|
50
|
+
|
51
|
+
# Whether or not the instance only has access to the private network.
|
52
|
+
attr_accessor :private_only
|
53
|
+
|
54
|
+
# The id or name of the ssh key to be provisioned.
|
55
|
+
attr_accessor :ssh_key
|
56
|
+
|
57
|
+
# The number of processors of the instance.
|
58
|
+
attr_accessor :start_cpus
|
59
|
+
|
60
|
+
# User defined metadata string.
|
61
|
+
attr_accessor :user_data
|
62
|
+
|
63
|
+
# The ID of the private VLAN.
|
64
|
+
attr_accessor :vlan_private
|
65
|
+
|
66
|
+
# The ID of the public VLAN.
|
67
|
+
attr_accessor :vlan_public
|
68
|
+
|
69
|
+
# The load balancers service groups to join.
|
70
|
+
attr_reader :load_balancers
|
71
|
+
|
72
|
+
# Automatically update DNS on create and destroy.
|
73
|
+
attr_accessor :manage_dns
|
74
|
+
|
75
|
+
def initialize
|
76
|
+
@api_key = UNSET_VALUE
|
77
|
+
@endpoint_url = UNSET_VALUE
|
78
|
+
@username = UNSET_VALUE
|
79
|
+
|
80
|
+
@datacenter = UNSET_VALUE
|
81
|
+
@dedicated = UNSET_VALUE
|
82
|
+
@disk_capacity = UNSET_VALUE
|
83
|
+
@domain = UNSET_VALUE
|
84
|
+
@hostname = UNSET_VALUE
|
85
|
+
@image_guid = UNSET_VALUE
|
86
|
+
@hourly_billing = UNSET_VALUE
|
87
|
+
@local_disk = UNSET_VALUE
|
88
|
+
@max_memory = UNSET_VALUE
|
89
|
+
@network_speed = UNSET_VALUE
|
90
|
+
@operating_system = UNSET_VALUE
|
91
|
+
@post_install = UNSET_VALUE
|
92
|
+
@private_only = UNSET_VALUE
|
93
|
+
@ssh_key = UNSET_VALUE
|
94
|
+
@start_cpus = UNSET_VALUE
|
95
|
+
@user_data = UNSET_VALUE
|
96
|
+
@vlan_private = UNSET_VALUE
|
97
|
+
@vlan_public = UNSET_VALUE
|
98
|
+
|
99
|
+
@load_balancers = []
|
100
|
+
@manage_dns = UNSET_VALUE
|
101
|
+
end
|
102
|
+
|
103
|
+
# Set the load balancer service group to join.
|
104
|
+
#
|
105
|
+
# Available options:
|
106
|
+
#
|
107
|
+
# :method => Routing method. Default to round robin.
|
108
|
+
# :port => Load balancer virtual port.
|
109
|
+
# :type => Routing type. Default to TCP.
|
110
|
+
# :vip => Load balancer virtual IP address.
|
111
|
+
#
|
112
|
+
# An optional block will accept parameters for the
|
113
|
+
# balanced service. Available parameters:
|
114
|
+
#
|
115
|
+
# :destination_port => TCP port on the node.
|
116
|
+
# :health_check => Service health check. Default to ping.
|
117
|
+
# :weight => Service weight. Default to 1.
|
118
|
+
#
|
119
|
+
def join_load_balancer(opts = {}, &block)
|
120
|
+
# Defaults
|
121
|
+
opts[:method] ||= "ROUND ROBIN"
|
122
|
+
opts[:type] ||= "TCP"
|
123
|
+
opts[:service] = OpenStruct.new(:destination_port => nil, :health_check => "PING", :weight => 1)
|
124
|
+
|
125
|
+
yield opts[:service] if block_given?
|
126
|
+
|
127
|
+
# Convert all options that belongs to
|
128
|
+
# an enumeration in uppercase.
|
129
|
+
opts[:method].upcase!
|
130
|
+
opts[:type].upcase!
|
131
|
+
opts[:service].health_check.upcase!
|
132
|
+
|
133
|
+
@load_balancers << opts
|
134
|
+
end
|
135
|
+
|
136
|
+
def finalize!
|
137
|
+
# Try to get username and api key from environment variables.
|
138
|
+
# They will default to nil if the environment variables are not present.
|
139
|
+
@api_key = ENV["SL_API_KEY"] if @api_key == UNSET_VALUE
|
140
|
+
@username = ENV["SL_USERNAME"] if @username == UNSET_VALUE
|
141
|
+
|
142
|
+
# Endpoint url defaults to public SoftLayer API url.
|
143
|
+
@endpoint_url = API_PUBLIC_ENDPOINT if @endpoint_url == UNSET_VALUE
|
144
|
+
|
145
|
+
# No default datacenter.
|
146
|
+
@datacenter = nil if @datacenter == UNSET_VALUE
|
147
|
+
|
148
|
+
# Shared instance by default.
|
149
|
+
@dedicated = false if @dedicated == UNSET_VALUE
|
150
|
+
|
151
|
+
# 25GB disk capacity image by default.
|
152
|
+
@disk_capacity = nil if @disk_capacity == UNSET_VALUE
|
153
|
+
|
154
|
+
# Domain should be specified in Vagrantfile, so we set default to nil.
|
155
|
+
@domain = nil if @domain == UNSET_VALUE
|
156
|
+
|
157
|
+
# Hostname should be specified in Vagrantfile, either using `config.vm.hostname`
|
158
|
+
# or the provider specific configuration entry.
|
159
|
+
@hostname = nil if @hostname == UNSET_VALUE
|
160
|
+
|
161
|
+
# Bill hourly by default.
|
162
|
+
@hourly_billing = true if @hourly_billing == UNSET_VALUE
|
163
|
+
|
164
|
+
# Disable the use of a specific block device image so we can leave the OS template as default
|
165
|
+
@image_guid = nil if @image_guid == UNSET_VALUE
|
166
|
+
|
167
|
+
# Use local disk by default.
|
168
|
+
@local_disk = true if @local_disk == UNSET_VALUE
|
169
|
+
|
170
|
+
# 1Gb of RAM by default.
|
171
|
+
@max_memory = 1024 if @max_memory == UNSET_VALUE
|
172
|
+
|
173
|
+
# 10Mbps by default.
|
174
|
+
@network_speed = 10 if @network_speed == UNSET_VALUE
|
175
|
+
|
176
|
+
# Provision with the latest Ubuntu by default.
|
177
|
+
@operating_system = "UBUNTU_LATEST" if @operating_system == UNSET_VALUE
|
178
|
+
|
179
|
+
# No post install script by default.
|
180
|
+
@post_install = nil if @post_install == UNSET_VALUE
|
181
|
+
|
182
|
+
# Private-network only is false by default.
|
183
|
+
@private_only = false if @private_only == UNSET_VALUE
|
184
|
+
|
185
|
+
# SSH key should be specified in Vagrantfile, so we set default to nil.
|
186
|
+
@ssh_key = nil if @ssh_key == UNSET_VALUE
|
187
|
+
|
188
|
+
# One processor by default.
|
189
|
+
@start_cpus = 1 if @start_cpus == UNSET_VALUE
|
190
|
+
|
191
|
+
# No user metadata by default.
|
192
|
+
@user_data = nil if @user_data == UNSET_VALUE
|
193
|
+
|
194
|
+
# No specific private VLAN by default.
|
195
|
+
@vlan_private = nil if @vlan_private == UNSET_VALUE
|
196
|
+
|
197
|
+
# No specific public VLAN by default.
|
198
|
+
@vlan_public = nil if @vlan_public == UNSET_VALUE
|
199
|
+
|
200
|
+
# DNS management off by default
|
201
|
+
@manage_dns = false if @manage_dns == UNSET_VALUE
|
202
|
+
end
|
203
|
+
|
204
|
+
# Aliases for ssh_key for beautiful semantic.
|
205
|
+
def ssh_keys=(value)
|
206
|
+
@ssh_key = value
|
207
|
+
end
|
208
|
+
alias_method :ssh_key_id=, :ssh_keys=
|
209
|
+
alias_method :ssh_key_ids=, :ssh_keys=
|
210
|
+
alias_method :ssh_key_name=, :ssh_keys=
|
211
|
+
alias_method :ssh_key_names=, :ssh_keys=
|
212
|
+
|
213
|
+
def validate(machine)
|
214
|
+
errors = []
|
215
|
+
|
216
|
+
errors << I18n.t("vagrant_softlayer.config.api_key_required") if !@api_key
|
217
|
+
errors << I18n.t("vagrant_softlayer.config.username_required") if !@username
|
218
|
+
|
219
|
+
errors << I18n.t("vagrant_softlayer.config.domain_required") if !@domain
|
220
|
+
errors << I18n.t("vagrant_softlayer.config.ssh_key_required") if !@ssh_key
|
221
|
+
|
222
|
+
errors << I18n.t("vagrant_softlayer.config.img_guid_os_code_mutually_exclusive") if @image_guid && @operating_system
|
223
|
+
errors << I18n.t("vagrant_softlayer.config.img_guid_capacity_mutually_exclusive") if @image_guid && @disk_capacity
|
224
|
+
|
225
|
+
# Fail if both `vm.hostname` and `provider.hostname` are nil.
|
226
|
+
if !@hostname && !machine.config.vm.hostname
|
227
|
+
errors << I18n.t("vagrant_softlayer.config.hostname_required")
|
228
|
+
end
|
229
|
+
|
230
|
+
# Fail if a load balancer has been specified without vip, port or destination port.
|
231
|
+
unless @load_balancers.empty?
|
232
|
+
@load_balancers.each do |lb|
|
233
|
+
errors << I18n.t("vagrant_softlayer.config.lb_port_vip_required") unless (lb[:vip] && lb[:port] && lb[:service].destination_port)
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
# Fail if two or more load balancers has been specified with same vip and port.
|
238
|
+
if @load_balancers.map { |lb| { :port => lb[:port], :vip => lb[:vip] } }.uniq!
|
239
|
+
errors << I18n.t("vagrant_softlayer.config.lb_duplicate")
|
240
|
+
end
|
241
|
+
|
242
|
+
{ "SoftLayer" => errors }
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
module VagrantPlugins
|
2
|
-
module SoftLayer
|
3
|
-
VERSION = "0.
|
4
|
-
end
|
5
|
-
end
|
1
|
+
module VagrantPlugins
|
2
|
+
module SoftLayer
|
3
|
+
VERSION = "0.3.0"
|
4
|
+
end
|
5
|
+
end
|