secured-cloud-vagrant 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/Gemfile +12 -0
  4. data/LICENSE.txt +9 -0
  5. data/README.md +340 -0
  6. data/README.txt +358 -0
  7. data/Rakefile +22 -0
  8. data/Vagrantfile_multipleVMs +124 -0
  9. data/Vagrantfile_singleVM +43 -0
  10. data/dummy.box +0 -0
  11. data/example_box/README.md +13 -0
  12. data/example_box/metadata.json +3 -0
  13. data/lib/secured-cloud-vagrant.rb +22 -0
  14. data/lib/secured-cloud-vagrant/action.rb +259 -0
  15. data/lib/secured-cloud-vagrant/actions/assign_public_ips.rb +142 -0
  16. data/lib/secured-cloud-vagrant/actions/check_state.rb +64 -0
  17. data/lib/secured-cloud-vagrant/actions/create.rb +112 -0
  18. data/lib/secured-cloud-vagrant/actions/delete.rb +105 -0
  19. data/lib/secured-cloud-vagrant/actions/has_public_ips.rb +53 -0
  20. data/lib/secured-cloud-vagrant/actions/power_off.rb +22 -0
  21. data/lib/secured-cloud-vagrant/actions/power_on.rb +22 -0
  22. data/lib/secured-cloud-vagrant/actions/power_vm.rb +100 -0
  23. data/lib/secured-cloud-vagrant/actions/read_ssh_info.rb +148 -0
  24. data/lib/secured-cloud-vagrant/actions/reboot.rb +98 -0
  25. data/lib/secured-cloud-vagrant/actions/release_ips_confirm.rb +25 -0
  26. data/lib/secured-cloud-vagrant/actions/wait_for_state.rb +54 -0
  27. data/lib/secured-cloud-vagrant/actions/warn_networks.rb +32 -0
  28. data/lib/secured-cloud-vagrant/actions/warn_provision.rb +32 -0
  29. data/lib/secured-cloud-vagrant/commands/list.rb +149 -0
  30. data/lib/secured-cloud-vagrant/commands/ssh_config.rb +43 -0
  31. data/lib/secured-cloud-vagrant/configs/authentication_info.rb +49 -0
  32. data/lib/secured-cloud-vagrant/configs/config.rb +87 -0
  33. data/lib/secured-cloud-vagrant/configs/ip_mapping.rb +71 -0
  34. data/lib/secured-cloud-vagrant/configs/virtual_machine.rb +136 -0
  35. data/lib/secured-cloud-vagrant/plugin.rb +77 -0
  36. data/lib/secured-cloud-vagrant/provider.rb +73 -0
  37. data/lib/secured-cloud-vagrant/version.rb +5 -0
  38. data/locales/en.yml +91 -0
  39. data/secured-cloud-vagrant.gemspec +59 -0
  40. data/templates/os_templates.erb +12 -0
  41. metadata +160 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6e6d414cfb54b490ebdaab4df677a1447e16398b
4
+ data.tar.gz: a37d591a6bed1f76ef7d06b9e941db187fcc2380
5
+ SHA512:
6
+ metadata.gz: b13be8a2e210119bb8e564340fb825c4f9155cf0e5f2023f7621b123d372af038b6b69d578db37225695feb788217e9e177fc975822281bcc992da99e9a50b16
7
+ data.tar.gz: 0a2d7937d205865ed9bb7c1bbcc86a268ba05829bbea37b9ab3372e07e41fdaee5bfa210665c993a01f4922f50b0a762b0ace8be69b3b76f88d0caefe57a96c7
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ Vagrantfile
19
+ .MySCMServerInfo
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in secured-cloud-vagrant.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ # We depend on Vagrant for development, but we don't add it as a
8
+ # gem dependency because we expect to be installed within the
9
+ # Vagrant environment itself using `vagrant plugin`.
10
+ gem "vagrant", :path => "../vagrant-1.4.0"
11
+ #gem "secured_cloud_api_client", :path => "../secured_cloud_api_client"
12
+ end
@@ -0,0 +1,9 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 PhoenixNAP
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,340 @@
1
+ # SecuredCloud Vagrant Provider
2
+
3
+ <span class="badges">
4
+ [![Gem Version](https://badge.fury.io/rb/secured-cloud-vagrant.png)][gem]
5
+ </span>
6
+
7
+ [gem]: https://rubygems.org/gems/secured-cloud-vagrant
8
+
9
+ This is a [Vagrant](http://www.vagrantup.com) 1.2+ plugin that adds a [SecuredCloud](http://phoenixnap.com/secured-cloud/) provider to Vagrant, allowing Vagrant to control and provision machines through the
10
+ SecuredCloud API.
11
+
12
+ **NOTE:** This plugin requires Vagrant 1.2+,
13
+
14
+
15
+ ## Features
16
+
17
+ - Create and destroy VMs
18
+ - Power on and off VMs
19
+ - Reboot VMs
20
+ - SSH into VMs using password authentication
21
+ - Get the current state of the created VMs
22
+ - Get the list of available SecuredCloud OS templates from which VMs can be created
23
+
24
+
25
+ ## Usage
26
+
27
+ Install using standard Vagrant 1.1+ plugin installation methods. After installing, use the `vagrant up` command and specify the
28
+ `secured_cloud` provider. An example is shown below:
29
+
30
+ ```
31
+ $ vagrant plugin install secured-cloud-vagrant
32
+ ...
33
+ $ vagrant up --provider=secured_cloud
34
+ ...
35
+ ```
36
+
37
+ Before running the second command, you'll obviously need to add a SecuredCloud-compatible box file to your Vagrant environment.
38
+
39
+
40
+
41
+ ## Server Certificate Validation
42
+
43
+ The supplied certificate file "sc.pem" must be placed in the cert directory of your vagrant workspace. The SecuredCloud Vagrant plugin will use this certificate to perform SSL validation against the SecuredCloud API server.
44
+
45
+
46
+ ## Quick Start
47
+
48
+ After installing the plugin (as indicated in the above section), the quickest way to get started is to use a dummy SecuredCloud box and
49
+ specify all the required details in the `config.vm.provider` block in the Vagrantfile. So first add the dummy box as follows:
50
+
51
+ ```
52
+ $ vagrant box add sc_dummy https://raw.github.com/cwiechris/secured-cloud-vagrant/master/dummy.box
53
+ ...
54
+ ```
55
+
56
+ And then make a Vagrantfile that looks like the following, filling in your information where necessary.
57
+
58
+
59
+ ```ruby
60
+ Vagrant.configure('2') do |config|
61
+ config.vm.box = "sc_dummy"
62
+
63
+ config.vm.provider :secured_cloud do |sc|
64
+
65
+ # Authentication info to connect to the SecuredCloud API
66
+ sc.auth.url = "URL TO CONNECT TO THE SECURED CLOUD API"
67
+ sc.auth.applicationKey = "YOUR APPLICATION KEY"
68
+ sc.auth.sharedSecret = "YOUR SHARED SECRET"
69
+
70
+ # VM details
71
+ sc.vm.name = "vmName"
72
+ sc.vm.storageGB = 16
73
+ sc.vm.memoryMB = 1024
74
+ sc.vm.vcpus = 1
75
+ sc.vm.osTemplateUrl = "OS TEMPLATE RESOURCE URL"
76
+ sc.vm.newOsPassword = "abcdefgh"
77
+ sc.vm.nodeResourceUrl = "NODE RESOURCE URL"
78
+ sc.vm.orgResourceUrl = "YOUR ORGANIZATION RESOURCE URL"
79
+
80
+ end
81
+ end
82
+ ```
83
+
84
+ And then run `vagrant up --provider=secured_cloud`
85
+
86
+ This will start a VM within your organization account on the specified node. Also, assuming that the created VM supports SSH connections,
87
+ you can also SSH into the VM using password authentication. Unfortunately, provisioning is not supported in the current release.
88
+
89
+ Please note that since provisioning is not supported, any additional custom scripts defined within the box to be executed during provisioning,
90
+ will be ignored.
91
+
92
+
93
+ ## Box Format
94
+
95
+ Every provider in Vagrant must introduce a custom box format. This provider introduces `secured_cloud` boxes. You can view an example
96
+ box in the [example_box/](https://github.com/leanneb/secured-cloud-vagrant/tree/master/example_box) directory. That directory also contains instructions on how to build a box.
97
+
98
+ The box format is basically just the required `metadata.json` file along with a `Vagrantfile` that does default settings for the provider-
99
+ specific configuration for this provider which can be overriden by higher-level Vagrantfiles.
100
+
101
+
102
+ ## Configuration
103
+
104
+ The `secured_cloud` provider exposes a number of provider-specific configuration options as indicated in the following list:
105
+
106
+ * `vm.name` - The name that the Vagrant-managed VM is to be given on SecuredCloud
107
+ * `vm.description` - The description that the Vagrant-managed VM is to be given on SecuredCloud
108
+ * `vm.storageGB` - The amount of storage to be allocated to the the VM in GB
109
+ * `vm.memoryMB` - The amount of memory to be allocated to the VM in MB
110
+ * `vm.vcpus` - The number of VCPUs to be allocated to the VM
111
+ * `vm.osTemplateUrl` - The resource URL of the SecuredCloud OS template from which the VM is to be created.
112
+ * `vm.imageResourceUrl` - The resource URL of the customer image from which the VM is to be created.
113
+ * `vm.newOsPassword` - The password to be given to the default user of the VM when creating a VM from a SecuredCloud OS template.
114
+ * `vm.nodeResourceUrl` - The resource URL of the node on which the VM is to be created on SecuredCloud.
115
+ * `vm.orgResourceUrl` - The resource URL of the organization under which the VM is to be created on SecuredCloud.
116
+ * `vm.ipMappings` - This is a list of IP mappings representing the IPs to be assigned to the VM where each IP mapping defines a `privateIp`, `newPublicIpCount` or `publicIpsFromReserved`. Please refer to the Examples section for further information on how these should be specified.
117
+
118
+ * `auth.url` - The SecuredCloud API URL.
119
+ * `auth.applicationKey` - The organization's SecuredCloud API application key
120
+ * `auth.sharedSecret` - The organization's SecuredCloud API shared secret
121
+
122
+ **NOTE:** Only one of `vm.osTemplateUrl` or `vm.imageResourceUrl` must be specified for each VM in the Vagrantfile.
123
+
124
+
125
+ ## Commands
126
+
127
+ The `secured_cloud` provider supports the following Vagrant commands:
128
+
129
+ * `vagrant up [vm_name]` - Creates a powered on VM on SecuredCloud as specified in the Vagrantfile, or powers it on if already created. Should [vm_name] be omitted, all the VMs specified in the Vagrantfile will be created/powered on.
130
+ * `vagrant destroy [vm_name]` - Powers OFF and destroys the VM from SecuredCloud. Should [vm_name] be omitted, all the VMs specified in the Vagrantfile will be destroyed.
131
+ * `vagrant halt [vm_name]` - Powers OFF the VM. Should [vm_name] be omitted, all the VMs specified in the Vagrantfile will be halted.
132
+ * `vagrant reload [vm_name]` - Reboots the VM if ON, or powers it ON when stopped. Should [vm_name] be omitted, all the VMs specified in the Vagrantfile will be reloaded.
133
+ * `vagrant status` - Outputs the status (running, stopped or not created) of the VM. Should [vm_name] be omitted, the status of all the VMs specified in the Vagrantfile will be displayed.
134
+ * `vagrant ssh-config [vm_name]` - Outputs the SSH connection details for the VM. The [vm_name] option can only be omitted when the Vagrantfile describes only one VM.
135
+ * `vagrant ssh` - Opens an SSH connection to the VM using the VM details on SecuredCloud which can in turn be overridden in the Vagrantfile. This command requires the SSH command to be installed if running on a Windows machine. The [vm_name] option can only be omitted when the Vagrantfile describes only one VM.
136
+ * `vagrant list -t -O [org_resource_url] -N [node_resource_url]` - Outputs the list of available SecuredCloud OS templates from which VMs can be created on the specified node
137
+ under the specified organization
138
+
139
+ Please note that private key authentication is not supported by the `secured_cloud` provider.
140
+
141
+
142
+ ## Known Issues
143
+
144
+ The current release of the `secured-cloud-vagrant` plugin does not support a number of Vagrant features, the details of which can be
145
+ found in the following subsections.
146
+
147
+
148
+ ### Networks
149
+
150
+ Networking features in the form of `config.vm.network` are not supported with `secured-cloud-vagrant`, currently. If any of these are
151
+ specified, Vagrant will emit a warning, but will otherwise boot the VM.
152
+
153
+
154
+ ### Provisioning
155
+
156
+ Provisioning features in the form of `config.vm.provision` are not currently supported by `secured-cloud-vagrant`. If any of these are
157
+ specified, a warning is emitted by Vagrant, but will otherwise create and boot the VM.
158
+
159
+
160
+ ### Synced Folder
161
+
162
+ Folder syncing features in the form of `config.vm.synced_folder` are not supported by the `secured-cloud-vagrant` plugin. If any of
163
+ these are specified they will be ignored by the `secured_cloud` provider.
164
+
165
+
166
+ ### VM Suspension
167
+
168
+ Suspension of VMs is not supported in SecuredCloud. For this reason, the `vagrant suspend` command is not supported by the
169
+ `secured-cloud-vagrant` plugin.
170
+
171
+
172
+ ### VM Resume
173
+
174
+ Similarly to VM suspension, the `secured_cloud` provider does not allow VMs to be resumed. As a result, the `vagrant resume`
175
+ command is not supported by the `secured-cloud-vagrant` plugin.
176
+
177
+
178
+ ## Examples
179
+
180
+ The `secured_cloud` provider allows you to specify different configuration options in the Vagrantfile depending on your needs. In this
181
+ section we provide two example Vagrantfiles: one that manages one VM and another that manages two.
182
+
183
+
184
+ ### Single Machine
185
+
186
+
187
+ ```ruby
188
+ Vagrant.configure('2') do |config|
189
+
190
+ config.vm.box = "dummy_sc_box"
191
+
192
+ # SSH settings for the VM can be overriden as follows
193
+ #config.ssh.username = "root"
194
+ #config.ssh.port = 22
195
+ #config.ssh.host = "my-hostname"
196
+
197
+ config.vm.provider :secured_cloud do |sc|
198
+
199
+ # Authentication info to connect to the SecuredCloud API
200
+ sc.auth.url = "https://mysecuredcloudapi.com"
201
+ sc.auth.applicationKey = "my_application_key"
202
+ sc.auth.sharedSecret = "my_shared_secret"
203
+
204
+ # VM details
205
+ sc.vm.name = "vmName"
206
+ sc.vm.storageGB = 16
207
+ sc.vm.memoryMB = 2048
208
+ sc.vm.vcpus = 2
209
+ sc.vm.newOsPassword = "mypassw0rd"
210
+ sc.vm.nodeResourceUrl = "/node/1"
211
+ sc.vm.orgResourceUrl = "/organization/415824"
212
+
213
+ # This property should be specified if the VM is to be created from a SecuredCloud OS template
214
+ sc.vm.osTemplateUrl = "/ostemplate/178"
215
+
216
+ # This property should be specified if the VM is to be created from a customer image
217
+ # sc.vm.imageResourceUrl = "/image/1466"
218
+
219
+ #This will assign a new public IP to the VM.
220
+ sc.vm.ipMappings = [
221
+ {
222
+ :newPublicIpCount => 1
223
+ }
224
+ ]
225
+
226
+ end
227
+ end
228
+ ```
229
+
230
+
231
+ ## Multiple Machines
232
+
233
+
234
+ The following is an example of a Vagrantfile containing the configuration for two machines.
235
+
236
+
237
+ ```ruby
238
+ Vagrant.configure('2') do |config|
239
+
240
+ # Configuration settings that are common for all machines
241
+ config.vm.provider :secured_cloud do |sc|
242
+
243
+ # Authentication info to connect to the SecuredCloud API
244
+ sc.auth.url = "https://mysecuredcloudapi.com"
245
+ sc.auth.applicationKey = "my_application_key"
246
+ sc.auth.sharedSecret = "my_shared_secret"
247
+
248
+ end
249
+
250
+
251
+ # Configuration for VM 1
252
+ config.vm.define "machine_1" do |machine_1|
253
+
254
+ machine_1.vm.box = "dummy_sc_box"
255
+
256
+ # Properties defined for secured_cloud
257
+ machine_1.vm.provider :secured_cloud do |sc|
258
+
259
+ sc.vm.name = "vagrantVm1"
260
+ sc.vm.description = "Description for vagrantVm1"
261
+ sc.vm.storageGB = 25
262
+ sc.vm.memoryMB = 2048
263
+ sc.vm.vcpus = 2
264
+ sc.vm.newOsPassword = "mypassw0rd01"
265
+ sc.vm.nodeResourceUrl = "/node/1"
266
+ sc.vm.orgResourceUrl = "/organization/415824"
267
+
268
+ # VM created from OS template
269
+ sc.vm.osTemplateUrl = "/ostemplate/178"
270
+
271
+ # This will assign private IP 10.2.0.19 to the VM (this is only allowed when running
272
+ # your org in custom network mode).
273
+ # This will also assign two public IPs to your VM from your org's public IP reserve pool.
274
+ sc.vm.ipMappings = [
275
+ {
276
+ :privateIp => "10.2.0.19",
277
+ :publicIpsFromReserved => ["172.27.21.40", "172.27.21.34"]
278
+ }
279
+ ]
280
+
281
+ end
282
+
283
+ end
284
+
285
+
286
+ # Configuration for VM 2
287
+ config.vm.define "machine_2" do |machine_2|
288
+
289
+ machine_2.vm.box = "dummy_sc_box"
290
+
291
+ # Properties defined for secured_cloud
292
+ machine_2.vm.provider :secured_cloud do |sc|
293
+
294
+ sc.vm.name = "vagrantVm2"
295
+ sc.vm.description = "Description for vagrantVm2"
296
+ sc.vm.storageGB = 50
297
+ sc.vm.memoryMB = 4096
298
+ sc.vm.vcpus = 2
299
+ sc.vm.newOsPassword = "mypassw0rd02"
300
+ sc.vm.nodeResourceUrl = "/node/1"
301
+ sc.vm.orgResourceUrl = "/organization/415824"
302
+
303
+ # VM created from customer image
304
+ sc.vm.imageResourceUrl = "/image/2796"
305
+
306
+ # This will assign a new public IP from the global pool and another one from
307
+ # your org's public IP reserve pool
308
+ sc.vm.ipMappings = [
309
+ {
310
+ :newPublicIpCount => 1,
311
+ :publicIpsFromReserved => "172.27.21.48"
312
+ }
313
+ ]
314
+
315
+ end
316
+
317
+ end
318
+
319
+ end
320
+ ```
321
+
322
+
323
+ ## Development
324
+
325
+ To work on the `secured-cloud-vagrant` plugin, clone this repository out, and use [Bundler](http://gembundler.com) to get the dependencies:
326
+
327
+ ```
328
+ $ bundle
329
+ ```
330
+
331
+ Once you have the dependencies, you're ready to start developing the plugin. You can test the plugin without installing it into your Vagrant
332
+ environment by just creating a `Vagrantfile` in the top level of this directory (it is gitignored) and add the following line to your `Vagrantfile`
333
+
334
+ ```ruby
335
+ Vagrant.require_plugin "secured-cloud-vagrant"
336
+ ```
337
+ Use bundler to execute Vagrant:
338
+ ```
339
+ $ bundle exec vagrant up --provider=secured_cloud
340
+ ```
@@ -0,0 +1,358 @@
1
+
2
+ ####################################
3
+ ## SECUREDCLOUD VAGRANT PROVIDERs ##
4
+ ####################################
5
+
6
+ This is a Vagrant (http://www.vagrantup.com) 1.2+ plugin that adds a SecuredCloud (http://phoenixnap.com/secured-cloud/) provider to Vagrant, allowing Vagrant to control and provision machines through the SecuredCloud API.
7
+
8
+ **NOTE:** This plugin requires Vagrant 1.2+,
9
+
10
+
11
+
12
+ #########################
13
+ ## Features
14
+ ##
15
+
16
+ - Create and destroy VMs
17
+ - Power on and off VMs
18
+ - Reboot VMs
19
+ - SSH into VMs using password authentication
20
+ - Get the current state of the created VMs
21
+ - Get the list of available SecuredCloud OS templates from which VMs can be created
22
+
23
+
24
+
25
+ #########################
26
+ ## Usage
27
+ ##
28
+
29
+ Install using standard Vagrant 1.1+ plugin installation methods. After installing, use the "vagrant up" command and specify the secured_cloud provider. An example is shown below:
30
+
31
+
32
+ $ vagrant plugin install secured-cloud-vagrant
33
+
34
+ ...
35
+
36
+ $ vagrant up --provider=secured_cloud
37
+
38
+ ...
39
+
40
+ Before running the second command, you'll obviously need to add a SecuredCloud-compatible box file to your Vagrant environment.
41
+
42
+
43
+
44
+ #########################
45
+ ## Server Certificate Validation
46
+ ##
47
+
48
+ The supplied certificate file "sc.pem" must be placed in the cert directory of your vagrant workspace. The SecuredCloud Vagrant plugin will use this certificate to perform SSL validation against the SecuredCloud API server.
49
+
50
+
51
+
52
+ #########################
53
+ ## Quick Start
54
+ ##
55
+
56
+ After installing the plugin (as indicated in the above section), the quickest way to get started is to use a dummy SecuredCloud box and specify all the required details in the config.vm.provider block in the Vagrantfile. So first add the dummy box as follows:
57
+
58
+ $ vagrant box add sc_dummy https://github.com/leanneb/secured-cloud-vagrant/raw/master/dummy.box
59
+
60
+ ...
61
+
62
+
63
+ And then make a Vagrantfile that looks like the following, filling in your information where necessary.
64
+
65
+
66
+
67
+ Vagrant.configure('2') do |config|
68
+ config.vm.box = "sc_dummy"
69
+
70
+ config.vm.provider :secured_cloud do |sc|
71
+
72
+ # Authentication info to connect to the SecuredCloud API
73
+ sc.auth.url = "URL TO CONNECT TO THE SECURED CLOUD API"
74
+ sc.auth.applicationKey = "YOUR APPLICATION KEY"
75
+ sc.auth.sharedSecret = "YOUR SHARED SECRET"
76
+
77
+ # VM details
78
+ sc.vm.name = "vmName"
79
+ sc.vm.storageGB = 16
80
+ sc.vm.memoryMB = 1024
81
+ sc.vm.vcpus = 1
82
+ sc.vm.osTemplateUrl = "OS TEMPLATE RESOURCE URL"
83
+ sc.vm.newOsPassword = "abcdefgh"
84
+ sc.vm.nodeResourceUrl = "NODE RESOURCE URL"
85
+ sc.vm.orgResourceUrl = "YOUR ORGANIZATION RESOURCE URL"
86
+
87
+ end
88
+ end
89
+
90
+
91
+ And then run vagrant up --provider=secured_cloud
92
+
93
+ This will start a VM within your organization account on the specified node. Also, assuming that the created VM supports SSH connections, you can also SSH into the VM using password authentication. Unfortunately, provisioning is not supported in the current release.
94
+
95
+ Please note that since provisioning is not supported, any additional custom scripts defined within the box to be executed during provisioning, will be ignored.
96
+
97
+
98
+
99
+ #########################
100
+ ## Box Format
101
+ ##
102
+
103
+ Every provider in Vagrant must introduce a custom box format. This provider introduces secured_cloud boxes. You can view an example box in the example_box/ directory. That directory also contains instructions on how to build a box.
104
+
105
+ The box format is basically just the required metadata.json file along with a Vagrantfile that does default settings for the provider-specific configuration for this provider which can be overriden by higher-level Vagrantfiles.
106
+
107
+
108
+
109
+ #########################
110
+ ## Configuration
111
+ ##
112
+
113
+ The secured_cloud provider exposes a number of provider-specific configuration options as indicated in the following list:
114
+
115
+ * vm.name - The name that the Vagrant-managed VM is to be given on SecuredCloud
116
+ * vm.description - The description that the Vagrant-managed VM is to be given on SecuredCloud
117
+ * vm.storageGB - The amount of storage to be allocated to the the VM in GB
118
+ * vm.memoryMB - The amount of memory to be allocated to the VM in MB
119
+ * vm.vcpus - The number of VCPUs to be allocated to the VM
120
+ * vm.osTemplateUrl - The resource URL of the SecuredCloud OS template from which the VM is to be created.
121
+ * vm.imageResourceUrl - The resource URL of the customer image from which the VM is to be created.
122
+ * vm.newOsPassword - The password to be given to the default user of the VM when creating a VM from a SecuredCloud OS template.
123
+ * vm.nodeResourceUrl - The resource URL of the node on which the VM is to be created on SecuredCloud.
124
+ * vm.orgResourceUrl - The resource URL of the organization under which the VM is to be created on SecuredCloud.
125
+ * vm.ipMappings - This is a list of IP mappings representing the IPs to be assigned to the VM where each IP mapping defines a privateIp, newPublicIpCount or publicIpsFromReserved. Please refer to the Examples section for further information on how these should be specified.
126
+
127
+ * auth.url - The SecuredCloud API URL.
128
+ * auth.applicationKey - The organization's SecuredCloud API application key
129
+ * auth.sharedSecret - The organization's SecuredCloud API shared secret
130
+
131
+ **NOTE:** Only one of vm.osTemplateUrl or vm.imageResourceUrl must be specified for each VM in the Vagrantfile.
132
+
133
+
134
+
135
+ #########################
136
+ ## Commands
137
+ ##
138
+
139
+ The secured_cloud provider supports the following Vagrant commands:
140
+
141
+ * vagrant up [vm_name] - Creates a powered on VM on SecuredCloud as specified in the Vagrantfile, or powers it on if already created. Should [vm_name] be omitted, all the VMs specified in the Vagrantfile will be created/powered on.
142
+ * vagrant destroy [vm_name] - Powers OFF and destroys the VM from SecuredCloud. Should [vm_name] be omitted, all the VMs specified in the Vagrantfile will be destroyed.
143
+ * vagrant halt [vm_name] - Powers OFF the VM. Should [vm_name] be omitted, all the VMs specified in the Vagrantfile will be halted.
144
+ * vagrant reload [vm_name] - Reboots the VM if ON, or powers it ON when stopped. Should [vm_name] be omitted, all the VMs specified in the Vagrantfile will be reloaded.
145
+ * vagrant status - Outputs the status (running, stopped or not created) of the VM. Should [vm_name] be omitted, the status of all the VMs specified in the Vagrantfile will be displayed.
146
+ * vagrant ssh-config [vm_name] - Outputs the SSH connection details for the VM. The [vm_name] option can only be omitted when the Vagrantfile describes only one VM.
147
+ * vagrant ssh - Opens an SSH connection to the VM using the VM details on SecuredCloud which can in turn be overridden in the Vagrantfile. This command requires the SSH command to be installed if running on a Windows machine. The [vm_name] option can only be omitted when the Vagrantfile describes only one VM.
148
+ * vagrant list -t -O [org_resource_url] -N [node_resource_url] - Outputs the list of available SecuredCloud OS templates from which VMs can be created on the specified node under the specified organization
149
+
150
+ Please note that private key authentication is not supported by the secured_cloud provider.
151
+
152
+
153
+
154
+ #########################
155
+ ## Known Issues
156
+ ##
157
+
158
+ The current release of the secured-cloud-vagrant plugin does not support a number of Vagrant features, the details of which can be found in the following subsections.
159
+
160
+
161
+
162
+ #########################
163
+ ## Networks
164
+ ##
165
+
166
+ Networking features in the form of config.vm.network are not supported with secured-cloud-vagrant, currently. If any of these are specified, Vagrant will emit a warning, but will otherwise boot the VM.
167
+
168
+
169
+
170
+ #########################
171
+ ## Provisioning
172
+ ##
173
+
174
+ Provisioning features in the form of config.vm.provision are not currently supported by secured-cloud-vagrant. If any of these are specified, a warning is emitted by Vagrant, but will otherwise create and boot the VM.
175
+
176
+
177
+
178
+ #########################
179
+ ## Synced Folder
180
+ ##
181
+
182
+ Folder syncing features in the form of config.vm.synced_folder are not supported by the secured-cloud-vagrant plugin. If any of these are specified they will be ignored by the secured_cloud provider.
183
+
184
+
185
+
186
+ #########################
187
+ ## VM Suspension
188
+ ##
189
+
190
+ Suspension of VMs is not supported in SecuredCloud. For this reason, the vagrant suspend command is not supported by the secured-cloud-vagrant plugin.
191
+
192
+
193
+
194
+ #########################
195
+ ## VM Resume
196
+ ##
197
+
198
+ Similarly to VM suspension, the secured_cloud provider does not allow VMs to be resumed. As a result, the vagrant resume command is not supported by the secured-cloud-vagrant plugin.
199
+
200
+
201
+
202
+ #########################
203
+ ## Examples
204
+ ##
205
+
206
+ The secured_cloud provider allows you to specify different configuration options in the Vagrantfile depending on your needs. In this section we provide two example Vagrantfiles: one that manages one VM and another that manages two.
207
+
208
+
209
+
210
+ ### Single Machine Example
211
+
212
+ Vagrant.configure('2') do |config|
213
+
214
+ config.vm.box = "dummy_sc_box"
215
+
216
+ # SSH settings for the VM can be overriden as follows
217
+ #config.ssh.username = "root"
218
+ #config.ssh.port = 22
219
+ #config.ssh.host = "my-hostname"
220
+
221
+ config.vm.provider :secured_cloud do |sc|
222
+
223
+ # Authentication info to connect to the SecuredCloud API
224
+ sc.auth.url = "https://mysecuredcloudapi.com"
225
+ sc.auth.applicationKey = "my_application_key"
226
+ sc.auth.sharedSecret = "my_shared_secret"
227
+
228
+ # VM details
229
+ sc.vm.name = "vmName"
230
+ sc.vm.storageGB = 16
231
+ sc.vm.memoryMB = 2048
232
+ sc.vm.vcpus = 2
233
+ sc.vm.newOsPassword = "mypassw0rd"
234
+ sc.vm.nodeResourceUrl = "/node/1"
235
+ sc.vm.orgResourceUrl = "/organization/415824"
236
+
237
+ # This property should be specified if the VM is to be created from a SecuredCloud OS template
238
+ sc.vm.osTemplateUrl = "/ostemplate/178"
239
+
240
+ # This property should be specified if the VM is to be created from a customer image
241
+ # sc.vm.imageResourceUrl = "/image/1466"
242
+
243
+ #This will assign a new public IP to the VM.
244
+ sc.vm.ipMappings = [
245
+ {
246
+ :newPublicIpCount => 1
247
+ }
248
+ ]
249
+
250
+ end
251
+ end
252
+
253
+
254
+
255
+
256
+ ## Multiple Machines Example
257
+
258
+ Vagrant.configure('2') do |config|
259
+
260
+ # Configuration settings that are common for all machines
261
+ config.vm.provider :secured_cloud do |sc|
262
+
263
+ # Authentication info to connect to the SecuredCloud API
264
+ sc.auth.url = "https://mysecuredcloudapi.com"
265
+ sc.auth.applicationKey = "my_application_key"
266
+ sc.auth.sharedSecret = "my_shared_secret"
267
+
268
+ end
269
+
270
+
271
+ # Configuration for VM 1
272
+ config.vm.define "machine_1" do |machine_1|
273
+
274
+ machine_1.vm.box = "dummy_sc_box"
275
+
276
+ # Properties defined for secured_cloud
277
+ machine_1.vm.provider :secured_cloud do |sc|
278
+
279
+ sc.vm.name = "vagrantVm1"
280
+ sc.vm.description = "Description for vagrantVm1"
281
+ sc.vm.storageGB = 25
282
+ sc.vm.memoryMB = 2048
283
+ sc.vm.vcpus = 2
284
+ sc.vm.newOsPassword = "mypassw0rd01"
285
+ sc.vm.nodeResourceUrl = "/node/1"
286
+ sc.vm.orgResourceUrl = "/organization/415824"
287
+
288
+ # VM created from OS template
289
+ sc.vm.osTemplateUrl = "/ostemplate/178"
290
+
291
+ # This will assign private IP 10.2.0.19 to the VM (this is only allowed when running
292
+ # your org in custom network mode).
293
+ # This will also assign two public IPs to your VM from your org's public IP reserve pool.
294
+ sc.vm.ipMappings = [
295
+ {
296
+ :privateIp => "10.2.0.19",
297
+ :publicIpsFromReserved => ["172.27.21.40", "172.27.21.34"]
298
+ }
299
+ ]
300
+
301
+ end
302
+
303
+ end
304
+
305
+
306
+ # Configuration for VM 2
307
+ config.vm.define "machine_2" do |machine_2|
308
+
309
+ machine_2.vm.box = "dummy_sc_box"
310
+
311
+ # Properties defined for secured_cloud
312
+ machine_2.vm.provider :secured_cloud do |sc|
313
+
314
+ sc.vm.name = "vagrantVm2"
315
+ sc.vm.description = "Description for vagrantVm2"
316
+ sc.vm.storageGB = 50
317
+ sc.vm.memoryMB = 4096
318
+ sc.vm.vcpus = 2
319
+ sc.vm.newOsPassword = "mypassw0rd02"
320
+ sc.vm.nodeResourceUrl = "/node/1"
321
+ sc.vm.orgResourceUrl = "/organization/415824"
322
+
323
+ # VM created from customer image
324
+ sc.vm.imageResourceUrl = "/image/2796"
325
+
326
+ # This will assign a new public IP from the global pool and another one from
327
+ # your org's public IP reserve pool
328
+ sc.vm.ipMappings = [
329
+ {
330
+ :newPublicIpCount => 1,
331
+ :publicIpsFromReserved => "172.27.21.48"
332
+ }
333
+ ]
334
+
335
+ end
336
+
337
+ end
338
+
339
+ end
340
+
341
+
342
+
343
+ #########################
344
+ ## Development
345
+ ##
346
+
347
+ To work on the secured-cloud-vagrant plugin, clone this repository out, and use Bundler (http://gembundler.com) to get the dependencies:
348
+
349
+ $ bundle
350
+
351
+ Once you have the dependencies, you're ready to start developing the plugin. You can test the plugin without installing it into your Vagrant environment by just creating a Vagrantfile in the top level of this directory (it is gitignored) and add the following line to your Vagrantfile.
352
+
353
+ Vagrant.require_plugin "secured-cloud-vagrant"
354
+
355
+
356
+ Use bundler to execute Vagrant:
357
+
358
+ $ bundle exec vagrant up --provider=secured_cloud