vcloud-launcher 0.0.5 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -9,3 +9,4 @@
9
9
  /pkg/
10
10
  fog_integration_test.config
11
11
  .idea
12
+ /spec/integration/vcloud_tools_testing_config.yaml
data/.travis.yml CHANGED
@@ -2,8 +2,5 @@
2
2
  language: ruby
3
3
  rvm:
4
4
  - 1.9.3
5
- branches:
6
- except:
7
- - master
8
5
  notifications:
9
6
  email: false
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## 0.1.0 (2014-06-02)
2
+
3
+ Features:
4
+
5
+ - Support 'pool' mode for VM IP address allocation. Thanks @geriBatai.
6
+
7
+ Maint:
8
+
9
+ - Deprecate 'catalog_item' for 'vapp_template_name' in config.
10
+ - Deprecate 'catalog' for 'catalog_name' in config.
11
+
1
12
  ## 0.0.5 (2014-05-14)
2
13
 
3
14
  Features:
data/README.md CHANGED
@@ -43,6 +43,12 @@ Or install it yourself as:
43
43
 
44
44
  `vcloud-launch node.yaml`
45
45
 
46
+ ## Configuration schemas
47
+
48
+ Configuration schemas can be found in [`lib/vcloud/launcher/schema/`][schema].
49
+
50
+ [schema]: /lib/vcloud/launcher/schema
51
+
46
52
  ## Credentials
47
53
 
48
54
  vCloud Launcher is based around [fog](http://fog.io/). To use it you'll need to give it
@@ -125,45 +131,5 @@ Run the integration tests minus some that are very slow:
125
131
  bundle exec rake integration:quick
126
132
 
127
133
  You need access to a suitable vCloud Director organization to run the
128
- integration tests. It is not necessarily safe to run them against an existing
129
- environment, unless care is taken with the entities being tested.
130
-
131
- The easiest thing to do is create a local shell script called
132
- `vcloud_env.sh` and set the contents:
133
-
134
- export FOG_CREDENTIAL=test
135
- export VCLOUD_VDC_NAME="Name of the VDC"
136
- export VCLOUD_CATALOG_NAME="catalog-name"
137
- export VCLOUD_TEMPLATE_NAME="name-of-template"
138
- export VCLOUD_NETWORK1_NAME="name-of-primary-network"
139
- export VCLOUD_NETWORK2_NAME="name-of-secondary-network"
140
- export VCLOUD_NETWORK1_IP="ip-on-primary-network"
141
- export VCLOUD_NETWORK2_IP="ip-on-secondary-network"
142
- export VCLOUD_STORAGE_PROFILE_NAME="storage-profile-name"
143
- export VCLOUD_EDGE_GATEWAY="name-of-edge-gateway-in-vdc"
144
-
145
- Then run this before you run the integration tests.
146
-
147
- ### Specific integration tests
148
-
149
- #### Storage profile tests
150
-
151
- There is an integration test to check storage profile behaviour, but it requires
152
- a lot of set-up so it is not called by the rake task. If you wish to run it you
153
- need access to an environment that has two VDCs, each one containing a storage
154
- profile with the same name. This named storage profile needs to be different
155
- from the default storage profile.
156
-
157
- You will need to set the following environment variables:
158
-
159
- export VDC_NAME_1="Name of the first vDC"
160
- export VDC_NAME_2="Name of the second vDC"
161
- export VCLOUD_CATALOG_NAME="Catalog name" # Can be the same as above settings if appropriate
162
- export VCLOUD_TEMPLATE_NAME="Template name" # Can be the same as above setting if appropriate
163
- export VCLOUD_STORAGE_PROFILE_NAME="Storage profile name" # This needs to exist in both vDCs
164
- export VDC_1_STORAGE_PROFILE_HREF="Href of the named storage profile in vDC 1"
165
- export VDC_2_STORAGE_PROFILE_HREF="Href of the named storage profile in vDC 2"
166
- export DEFAULT_STORAGE_PROFILE_NAME="Default storage profile name"
167
- export DEFAULT_STORAGE_PROFILE_HREF="Href of default storage profile"
168
-
169
- To run this test: `rspec spec/integration/launcher/storage_profile_integration_test.rb`
134
+ integration tests. See the [integration tests README](/spec/integration/README.md) for
135
+ further details.
@@ -29,8 +29,8 @@
29
29
  vapps:
30
30
  - name: 'vapp-example-complete'
31
31
  vdc_name: 'Our vDC 1'
32
- catalog: 'our-catalog'
33
- catalog_item: 'our-template-vapp'
32
+ catalog_name: 'our-catalog'
33
+ vapp_template_name: 'our-template-vapp'
34
34
  vm:
35
35
  hardware_config:
36
36
  memory: 4096
@@ -39,6 +39,7 @@ vapps:
39
39
  - name: 'FrontendNetwork'
40
40
  ip_address: '192.0.2.10'
41
41
  - name: 'BackendNetwork'
42
+ allocation_mode: 'pool'
42
43
  extra_disks:
43
44
  - name: logs-disk
44
45
  size: 10240
@@ -7,5 +7,5 @@
7
7
  vapps:
8
8
  - name: 'vapp-example-1'
9
9
  vdc_name: 'vDC Example [1]'
10
- catalog: 'example-catalog'
11
- catalog_item: 'our-vapp-template'
10
+ catalog_name: 'example-catalog'
11
+ vapp_template_name: 'our-vapp-template'
@@ -10,8 +10,8 @@ vapps:
10
10
 
11
11
  - name: vapp-example-1
12
12
  vdc_name: "Our VDC1"
13
- catalog: our-catalog
14
- catalog_item: our-vapp-template
13
+ catalog_name: our-catalog
14
+ vapp_template_name: our-vapp-template
15
15
  vm:
16
16
  hardware_config:
17
17
  memory: '4096'
@@ -22,8 +22,8 @@ vapps:
22
22
 
23
23
  - name: vapp-example-2
24
24
  vdc_name: "Our VDC1"
25
- catalog: our-catalog
26
- catalog_item: our-vapp-template
25
+ catalog_name: our-catalog
26
+ vapp_template_name: our-vapp-template
27
27
  vm:
28
28
  hardware_config:
29
29
  memory: '4096'
@@ -34,8 +34,8 @@ vapps:
34
34
 
35
35
  - name: vapp-example-3
36
36
  vdc_name: "Our VDC1"
37
- catalog: our-catalog
38
- catalog_item: our-vapp-template
37
+ catalog_name: our-catalog
38
+ vapp_template_name: our-vapp-template
39
39
  vm:
40
40
  hardware_config:
41
41
  memory: '4096'
@@ -10,7 +10,7 @@
10
10
  ---
11
11
  anchors:
12
12
 
13
- - &VAPP_TEMPLATE our-vapp-template
13
+ - &VAPP_TEMPLATE_NAME our-vapp-template
14
14
 
15
15
  - &ENVIRONMENT example
16
16
  - &VDC_NAME example-vdc
@@ -20,18 +20,18 @@ anchors:
20
20
 
21
21
  - &BASE_VAPP
22
22
  vdc_name: *VDC_NAME
23
- catalog: our-catalog
24
- catalog_item: *VAPP_TEMPLATE
23
+ catalog_name: our-catalog
24
+ vapp_template_name: *VAPP_TEMPLATE_NAME
25
25
 
26
26
  - &BASE_VM
27
27
  metadata:
28
28
  environment: *ENVIRONMENT
29
- vapp_template: *VAPP_TEMPLATE
29
+ vapp_template: *VAPP_TEMPLATE_NAME
30
30
  bootstrap: &BASE_VM_BOOTSTRAP
31
31
  script_path: basic_preamble.erb
32
32
  vars: &BASE_VM_VARS
33
33
  environment: *ENVIRONMENT
34
- vapp_template: *VAPP_TEMPLATE
34
+ vapp_template: *VAPP_TEMPLATE_NAME
35
35
  vdc: *VDC_NAME
36
36
 
37
37
  - &SMALL_VM
data/jenkins.sh CHANGED
@@ -1,8 +1,16 @@
1
1
  #!/bin/bash -x
2
2
  set -e
3
+
4
+ git clean -ffdx
5
+
3
6
  bundle install --path "${HOME}/bundles/${JOB_NAME}"
4
7
  bundle exec rake
5
8
 
9
+ # Obtain the integration test parameters
10
+ git clone git@github.gds:gds/vcloud-tools-testing-config.git
11
+ mv vcloud-tools-testing-config/vcloud_tools_testing_config.yaml spec/integration/
12
+ rm -rf vcloud-tools-testing-config
13
+
6
14
  RUBYOPT="-r ./tools/fog_credentials" bundle exec rake integration:all
7
15
 
8
16
  bundle exec rake publish_gem
@@ -1,4 +1,13 @@
1
1
  #!/bin/bash -x
2
2
  set -e
3
+
4
+ git clean -ffdx
5
+
3
6
  bundle install --path "${HOME}/bundles/${JOB_NAME}"
7
+
8
+ # Obtain the integration test parameters
9
+ git clone git@github.gds:gds/vcloud-tools-testing-config.git
10
+ mv vcloud-tools-testing-config/vcloud_tools_testing_config.yaml spec/integration/
11
+ rm -rf vcloud-tools-testing-config
12
+
4
13
  RUBYOPT="-r ./tools/fog_credentials" bundle exec rake integration:all
@@ -1,6 +1,10 @@
1
1
  require 'vcloud/fog'
2
2
  require 'vcloud/core'
3
3
 
4
+ require 'vcloud/launcher/schema/vm'
5
+ require 'vcloud/launcher/schema/vapp'
6
+ require 'vcloud/launcher/schema/launcher_vapps'
7
+
4
8
  require 'vcloud/launcher/launch'
5
9
  require 'vcloud/launcher/vm_orchestrator'
6
10
  require 'vcloud/launcher/vapp_orchestrator'
@@ -8,7 +8,7 @@ module Vcloud
8
8
 
9
9
  def run(config_file = nil, cli_options = {})
10
10
  set_logging_level(cli_options)
11
- config = @config_loader.load_config(config_file, config_schema)
11
+ config = @config_loader.load_config(config_file, Vcloud::Launcher::Schema::LAUNCHER_VAPPS)
12
12
  config[:vapps].each do |vapp_config|
13
13
  Vcloud::Core.logger.info("Provisioning vApp #{vapp_config[:name]}.")
14
14
  begin
@@ -24,22 +24,6 @@ module Vcloud
24
24
  end
25
25
  end
26
26
 
27
- def config_schema
28
- {
29
- type: 'hash',
30
- allowed_empty: false,
31
- permit_unknown_parameters: true,
32
- internals: {
33
- vapps: {
34
- type: 'array',
35
- required: false,
36
- allowed_empty: true,
37
- each_element_is: ::Vcloud::Launcher::VappOrchestrator.provision_schema
38
- },
39
- }
40
- }
41
- end
42
-
43
27
  def set_logging_level(cli_options)
44
28
  if cli_options[:verbose]
45
29
  Vcloud::Core.logger.level = Logger::DEBUG
@@ -0,0 +1,21 @@
1
+ module Vcloud
2
+ module Launcher
3
+ module Schema
4
+
5
+ LAUNCHER_VAPPS = {
6
+ type: 'hash',
7
+ allowed_empty: false,
8
+ permit_unknown_parameters: true,
9
+ internals: {
10
+ vapps: {
11
+ type: 'array',
12
+ required: false,
13
+ allowed_empty: true,
14
+ each_element_is: Vcloud::Launcher::Schema::VAPP,
15
+ },
16
+ },
17
+ }
18
+
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,22 @@
1
+ module Vcloud
2
+ module Launcher
3
+ module Schema
4
+
5
+ VAPP = {
6
+ type: 'hash',
7
+ required: true,
8
+ allowed_empty: false,
9
+ internals: {
10
+ name: { type: 'string', required: true, allowed_empty: false },
11
+ vdc_name: { type: 'string', required: true, allowed_empty: false },
12
+ catalog: { type: 'string', deprecated_by: 'catalog_name', allowed_empty: false },
13
+ catalog_name: { type: 'string', required: true, allowed_empty: false },
14
+ catalog_item: { type: 'string', deprecated_by: 'vapp_template_name', allowed_empty: false },
15
+ vapp_template_name: { type: 'string', required: true, allowed_empty: false },
16
+ vm: Vcloud::Launcher::Schema::VM,
17
+ },
18
+ }
19
+
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,63 @@
1
+ module Vcloud
2
+ module Launcher
3
+ module Schema
4
+
5
+ VM = {
6
+ type: 'hash',
7
+ required: false,
8
+ allowed_empty: false,
9
+ internals: {
10
+ network_connections: {
11
+ type: 'array',
12
+ required: false,
13
+ each_element_is: {
14
+ type: 'hash',
15
+ internals: {
16
+ name: { type: 'string', required: true },
17
+ ip_address: { type: 'ip_address', required: false },
18
+ allocation_mode: { type: 'string', required: false },
19
+ },
20
+ },
21
+ },
22
+ storage_profile: { type: 'string', required: false },
23
+ hardware_config: {
24
+ type: 'hash',
25
+ required: false,
26
+ internals: {
27
+ cpu: { type: 'string_or_number', required: false },
28
+ memory: { type: 'string_or_number', required: false },
29
+ },
30
+ },
31
+ extra_disks: {
32
+ type: 'array',
33
+ required: false,
34
+ allowed_empty: false,
35
+ each_element_is: {
36
+ type: 'hash',
37
+ internals: {
38
+ name: { type: 'string', required: false },
39
+ size: { type: 'string_or_number', required: false },
40
+ },
41
+ },
42
+ },
43
+ bootstrap: {
44
+ type: 'hash',
45
+ required: false,
46
+ allowed_empty: false,
47
+ internals: {
48
+ script_path: { type: 'string', required: false },
49
+ script_post_processor: { type: 'string', required: false },
50
+ vars: { type: 'hash', required: false, allowed_empty: true },
51
+ },
52
+ },
53
+ metadata: {
54
+ type: 'hash',
55
+ required: false,
56
+ allowed_empty: true,
57
+ },
58
+ },
59
+ }
60
+
61
+ end
62
+ end
63
+ end
@@ -11,7 +11,9 @@ module Vcloud
11
11
  return vapp_existing
12
12
  end
13
13
 
14
- template = Vcloud::Core::VappTemplate.get(vapp_config[:catalog], vapp_config[:catalog_item])
14
+ template_name = vapp_config[:vapp_template_name] || vapp_config[:catalog_item]
15
+ catalog_name = vapp_config[:catalog_name] || vapp_config[:catalog]
16
+ template = Vcloud::Core::VappTemplate.get(template_name, catalog_name)
15
17
  template_id = template.id
16
18
 
17
19
  network_names = extract_vm_networks(vapp_config)
@@ -21,21 +23,6 @@ module Vcloud
21
23
  vapp
22
24
  end
23
25
 
24
- def self.provision_schema
25
- {
26
- type: 'hash',
27
- required: true,
28
- allowed_empty: false,
29
- internals: {
30
- name: { type: 'string', required: true, allowed_empty: false },
31
- vdc_name: { type: 'string', required: true, allowed_empty: false },
32
- catalog: { type: 'string', required: true, allowed_empty: false },
33
- catalog_item: { type: 'string', required: true, allowed_empty: false },
34
- vm: Vcloud::Launcher::VmOrchestrator.customize_schema,
35
- }
36
- }
37
- end
38
-
39
26
  def self.extract_vm_networks(config)
40
27
  if (config[:vm] && config[:vm][:network_connections])
41
28
  config[:vm][:network_connections].collect { |h| h[:name] }
@@ -1,5 +1,5 @@
1
1
  module Vcloud
2
2
  module Launcher
3
- VERSION = '0.0.5'
3
+ VERSION = '0.1.0'
4
4
  end
5
5
  end
@@ -1,6 +1,7 @@
1
1
  module Vcloud
2
2
  module Launcher
3
3
  class VmOrchestrator
4
+
4
5
  def initialize fog_vm, vapp
5
6
  vm_id = fog_vm[:href].split('/').last
6
7
  @vm = Core::Vm.new(vm_id, vapp)
@@ -23,63 +24,6 @@ module Vcloud
23
24
  )
24
25
  end
25
26
 
26
- def self.customize_schema
27
- {
28
- type: 'hash',
29
- required: false,
30
- allowed_empty: false,
31
- internals: {
32
- network_connections: {
33
- type: 'array',
34
- required: false,
35
- each_element_is: {
36
- type: 'hash',
37
- internals: {
38
- name: { type: 'string', required: true },
39
- ip_address: { type: 'ip_address', required: false },
40
- },
41
- },
42
- },
43
- storage_profile: { type: 'string', required: false },
44
- hardware_config: {
45
- type: 'hash',
46
- required: false,
47
- internals: {
48
- cpu: { type: 'string_or_number', required: false },
49
- memory: { type: 'string_or_number', required: false },
50
- },
51
- },
52
- extra_disks: {
53
- type: 'array',
54
- required: false,
55
- allowed_empty: false,
56
- each_element_is: {
57
- type: 'hash',
58
- internals: {
59
- name: { type: 'string', required: false },
60
- size: { type: 'string_or_number', required: false },
61
- },
62
- },
63
- },
64
- bootstrap: {
65
- type: 'hash',
66
- required: false,
67
- allowed_empty: false,
68
- internals: {
69
- script_path: { type: 'string', required: false },
70
- script_post_processor: { type: 'string', required: false },
71
- vars: { type: 'hash', required: false, allowed_empty: true },
72
- },
73
- },
74
- metadata: {
75
- type: 'hash',
76
- required: false,
77
- allowed_empty: true,
78
- },
79
- },
80
- }
81
- end
82
-
83
27
  end
84
28
  end
85
29
  end