bosh_aws_cpi 0.7.0 → 1.5.0.pre.1113
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +22 -19
- data/bin/bosh_aws_console +1 -13
- data/lib/bosh_aws_cpi.rb +1 -1
- data/lib/cloud/aws/aki_picker.rb +7 -7
- data/lib/cloud/aws/availability_zone_selector.rb +40 -0
- data/lib/cloud/aws/cloud.rb +359 -476
- data/lib/cloud/aws/dynamic_network.rb +0 -6
- data/lib/cloud/aws/helpers.rb +10 -68
- data/lib/cloud/aws/instance_manager.rb +171 -0
- data/lib/cloud/aws/manual_network.rb +26 -0
- data/lib/cloud/aws/network_configurator.rb +33 -62
- data/lib/cloud/aws/resource_wait.rb +189 -0
- data/lib/cloud/aws/stemcell.rb +68 -0
- data/lib/cloud/aws/stemcell_creator.rb +114 -0
- data/lib/cloud/aws/tag_manager.rb +30 -0
- data/lib/cloud/aws/version.rb +1 -1
- data/lib/cloud/aws/vip_network.rb +9 -7
- data/lib/cloud/aws.rb +11 -2
- data/scripts/stemcell-copy.sh +37 -0
- metadata +45 -81
- data/Rakefile +0 -50
- data/lib/cloud/aws/registry_client.rb +0 -109
- data/spec/assets/stemcell-copy +0 -31
- data/spec/integration/cpi_test.rb +0 -78
- data/spec/spec_helper.rb +0 -121
- data/spec/unit/aki_picker_spec.rb +0 -29
- data/spec/unit/attach_disk_spec.rb +0 -143
- data/spec/unit/cloud_spec.rb +0 -32
- data/spec/unit/configure_networks_spec.rb +0 -113
- data/spec/unit/create_disk_spec.rb +0 -73
- data/spec/unit/create_stemcell_spec.rb +0 -113
- data/spec/unit/create_vm_spec.rb +0 -249
- data/spec/unit/delete_disk_spec.rb +0 -34
- data/spec/unit/delete_stemcell_spec.rb +0 -29
- data/spec/unit/delete_vm_spec.rb +0 -25
- data/spec/unit/detach_disk_spec.rb +0 -63
- data/spec/unit/helpers_spec.rb +0 -64
- data/spec/unit/network_configurator_spec.rb +0 -57
- data/spec/unit/reboot_vm_spec.rb +0 -38
- data/spec/unit/set_vm_metadata_spec.rb +0 -30
- data/spec/unit/validate_deployment_spec.rb +0 -16
@@ -0,0 +1,114 @@
|
|
1
|
+
module Bosh::AwsCloud
|
2
|
+
class StemcellCreator
|
3
|
+
include Bosh::Exec
|
4
|
+
include Helpers
|
5
|
+
|
6
|
+
attr_reader :region, :stemcell_properties
|
7
|
+
attr_reader :volume, :ebs_volume, :image_path
|
8
|
+
|
9
|
+
def initialize(region, stemcell_properties)
|
10
|
+
@region = region
|
11
|
+
@stemcell_properties = stemcell_properties
|
12
|
+
end
|
13
|
+
|
14
|
+
def create(volume, ebs_volume, image_path)
|
15
|
+
@volume = volume
|
16
|
+
@ebs_volume = ebs_volume
|
17
|
+
@image_path = image_path
|
18
|
+
|
19
|
+
copy_root_image
|
20
|
+
|
21
|
+
snapshot = volume.create_snapshot
|
22
|
+
ResourceWait.for_snapshot(snapshot: snapshot, state: :completed)
|
23
|
+
|
24
|
+
params = image_params(snapshot.id)
|
25
|
+
image = region.images.create(params)
|
26
|
+
ResourceWait.for_image(image: image, state: :available)
|
27
|
+
|
28
|
+
TagManager.tag(image, 'Name', params[:description]) if params[:description]
|
29
|
+
|
30
|
+
Stemcell.new(region, image)
|
31
|
+
end
|
32
|
+
|
33
|
+
def fake?
|
34
|
+
stemcell_properties.has_key?('ami')
|
35
|
+
end
|
36
|
+
|
37
|
+
def fake
|
38
|
+
id = stemcell_properties['ami'][region.name]
|
39
|
+
|
40
|
+
raise Bosh::Clouds::CloudError, "Stemcell does not contain an AMI for this region (#{region.name})" unless id
|
41
|
+
|
42
|
+
Stemcell.find(region, id)
|
43
|
+
end
|
44
|
+
|
45
|
+
# This method tries to execute the helper script stemcell-copy
|
46
|
+
# as root using sudo, since it needs to write to the ebs_volume.
|
47
|
+
# If stemcell-copy isn't available, it falls back to writing directly
|
48
|
+
# to the device, which is used in the micro bosh deployer.
|
49
|
+
# The stemcell-copy script must be in the PATH of the user running
|
50
|
+
# the director, and needs sudo privileges to execute without
|
51
|
+
# password.
|
52
|
+
#
|
53
|
+
def copy_root_image
|
54
|
+
stemcell_copy = find_in_path("stemcell-copy")
|
55
|
+
|
56
|
+
if stemcell_copy
|
57
|
+
logger.debug("copying stemcell using stemcell-copy script")
|
58
|
+
# note that is is a potentially dangerous operation, but as the
|
59
|
+
# stemcell-copy script sets PATH to a sane value this is safe
|
60
|
+
command = "sudo -n #{stemcell_copy} #{image_path} #{ebs_volume} 2>&1"
|
61
|
+
else
|
62
|
+
logger.info("falling back to using included copy stemcell")
|
63
|
+
included_stemcell_copy = File.expand_path("../../../../scripts/stemcell-copy.sh", __FILE__)
|
64
|
+
command = "sudo -n #{included_stemcell_copy} #{image_path} #{ebs_volume} 2>&1"
|
65
|
+
end
|
66
|
+
|
67
|
+
result = sh(command)
|
68
|
+
|
69
|
+
logger.debug("stemcell copy output:\n#{result.output}")
|
70
|
+
rescue Bosh::Exec::Error => e
|
71
|
+
raise Bosh::Clouds::CloudError, "Unable to copy stemcell root image: #{e.message}"
|
72
|
+
end
|
73
|
+
|
74
|
+
# checks if the stemcell-copy script can be found in
|
75
|
+
# the current PATH
|
76
|
+
def find_in_path(command, path=ENV["PATH"])
|
77
|
+
path.split(":").each do |dir|
|
78
|
+
stemcell_copy = File.join(dir, command)
|
79
|
+
return stemcell_copy if File.exist?(stemcell_copy)
|
80
|
+
end
|
81
|
+
nil
|
82
|
+
end
|
83
|
+
|
84
|
+
def image_params(snapshot_id)
|
85
|
+
root_device_name = stemcell_properties["root_device_name"]
|
86
|
+
architecture = stemcell_properties["architecture"]
|
87
|
+
|
88
|
+
aki = AKIPicker.new(region).pick(architecture, root_device_name)
|
89
|
+
|
90
|
+
params = {
|
91
|
+
:name => "BOSH-#{SecureRandom.uuid}",
|
92
|
+
:architecture => architecture,
|
93
|
+
:kernel_id => aki,
|
94
|
+
:root_device_name => root_device_name,
|
95
|
+
:block_device_mappings => {
|
96
|
+
"/dev/sda" => {:snapshot_id => snapshot_id},
|
97
|
+
"/dev/sdb" => "ephemeral0"
|
98
|
+
}
|
99
|
+
}
|
100
|
+
|
101
|
+
# old stemcells doesn't have name & version
|
102
|
+
if stemcell_properties["name"] && stemcell_properties["version"]
|
103
|
+
name = "#{stemcell_properties['name']} #{stemcell_properties['version']}"
|
104
|
+
params[:description] = name
|
105
|
+
end
|
106
|
+
|
107
|
+
params
|
108
|
+
end
|
109
|
+
|
110
|
+
def logger
|
111
|
+
Bosh::Clouds::Config.logger
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Bosh::AwsCloud
|
2
|
+
class TagManager
|
3
|
+
|
4
|
+
MAX_TAG_KEY_LENGTH = 127
|
5
|
+
MAX_TAG_VALUE_LENGTH = 255
|
6
|
+
|
7
|
+
# Add a tag to something, make sure that the tag conforms to the
|
8
|
+
# AWS limitation of 127 character key and 255 character value
|
9
|
+
def self.tag(taggable, key, value)
|
10
|
+
return if key.nil? || value.nil?
|
11
|
+
trimmed_key = key.to_s.slice(0, MAX_TAG_KEY_LENGTH)
|
12
|
+
trimmed_value = value.to_s.slice(0, MAX_TAG_VALUE_LENGTH)
|
13
|
+
taggable.add_tag(trimmed_key, :value => trimmed_value)
|
14
|
+
rescue AWS::EC2::Errors::InvalidParameterValue => e
|
15
|
+
logger.error("could not tag #{taggable.id}: #{e.message}")
|
16
|
+
rescue AWS::EC2::Errors::InvalidAMIID::NotFound,
|
17
|
+
AWS::EC2::Errors::InvalidInstanceID::NotFound=> e
|
18
|
+
# Due to the AWS eventual consistency, the taggable might not
|
19
|
+
# be there, even though we previous have waited until it is,
|
20
|
+
# so we wait again...
|
21
|
+
logger.warn("tagged object doesn't exist: #{taggable.id}")
|
22
|
+
sleep(1)
|
23
|
+
retry
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.logger
|
27
|
+
Bosh::Clouds::Config.logger
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/cloud/aws/version.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
# Copyright (c) 2009-2012 VMware, Inc.
|
2
2
|
|
3
3
|
module Bosh::AwsCloud
|
4
|
-
|
5
|
-
#
|
4
|
+
|
6
5
|
class VipNetwork < Network
|
7
6
|
|
8
7
|
##
|
@@ -24,18 +23,21 @@ module Bosh::AwsCloud
|
|
24
23
|
cloud_error("No IP provided for vip network `#{@name}'")
|
25
24
|
end
|
26
25
|
|
26
|
+
elastic_ip = ec2.elastic_ips[@ip]
|
27
27
|
@logger.info("Associating instance `#{instance.id}' " \
|
28
|
-
"with elastic IP `#{
|
28
|
+
"with elastic IP `#{elastic_ip}'")
|
29
29
|
|
30
30
|
# New elastic IP reservation supposed to clear the old one,
|
31
31
|
# so no need to disassociate manually. Also, we don't check
|
32
32
|
# if this IP is actually an allocated EC2 elastic IP, as
|
33
33
|
# API call will fail in that case.
|
34
|
-
# TODO: wrap error for non-existing elastic IP?
|
35
|
-
# TODO: poll instance until this IP is returned as its public IP?
|
36
|
-
instance.associate_elastic_ip(@ip)
|
37
|
-
end
|
38
34
|
|
35
|
+
errors = [AWS::EC2::Errors::IncorrectInstanceState]
|
36
|
+
Bosh::Common.retryable(tries: 10, sleep: 1, on: errors) do
|
37
|
+
instance.associate_elastic_ip(elastic_ip)
|
38
|
+
true # need to return true to end the retries
|
39
|
+
end
|
40
|
+
end
|
39
41
|
end
|
40
42
|
end
|
41
43
|
|
data/lib/cloud/aws.rb
CHANGED
@@ -9,23 +9,32 @@ require "httpclient"
|
|
9
9
|
require "pp"
|
10
10
|
require "set"
|
11
11
|
require "tmpdir"
|
12
|
-
require "
|
12
|
+
require "securerandom"
|
13
13
|
require "yajl"
|
14
14
|
|
15
|
+
require "common/exec"
|
15
16
|
require "common/thread_pool"
|
16
17
|
require "common/thread_formatter"
|
17
18
|
|
19
|
+
require "bosh/registry/client"
|
20
|
+
|
18
21
|
require "cloud"
|
19
22
|
require "cloud/aws/helpers"
|
20
23
|
require "cloud/aws/cloud"
|
21
|
-
require "cloud/aws/registry_client"
|
22
24
|
require "cloud/aws/version"
|
23
25
|
|
24
26
|
require "cloud/aws/aki_picker"
|
25
27
|
require "cloud/aws/network_configurator"
|
26
28
|
require "cloud/aws/network"
|
29
|
+
require "cloud/aws/stemcell"
|
30
|
+
require "cloud/aws/stemcell_creator"
|
27
31
|
require "cloud/aws/dynamic_network"
|
32
|
+
require "cloud/aws/manual_network"
|
28
33
|
require "cloud/aws/vip_network"
|
34
|
+
require "cloud/aws/instance_manager"
|
35
|
+
require "cloud/aws/tag_manager"
|
36
|
+
require "cloud/aws/availability_zone_selector"
|
37
|
+
require "cloud/aws/resource_wait"
|
29
38
|
|
30
39
|
module Bosh
|
31
40
|
module Clouds
|
@@ -0,0 +1,37 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
#
|
3
|
+
# This script runs as root through sudo without the need for a password,
|
4
|
+
# so it needs to make sure it can't be abused.
|
5
|
+
#
|
6
|
+
|
7
|
+
# make sure we have a secure PATH
|
8
|
+
PATH=/bin:/usr/bin
|
9
|
+
export PATH
|
10
|
+
if [ $# -ne 2 ]; then
|
11
|
+
echo "usage: $0 <image-file> <block device>"
|
12
|
+
exit 1
|
13
|
+
fi
|
14
|
+
|
15
|
+
IMAGE="$1"
|
16
|
+
OUTPUT="$2"
|
17
|
+
|
18
|
+
# workaround for issue on 12.04 LTS, use LANG=C
|
19
|
+
echo ${IMAGE} | LANG=C egrep '^/[A-za-z0-9_/-]+/image$' > /dev/null 2>&1
|
20
|
+
if [ $? -ne 0 ]; then
|
21
|
+
echo "ERROR: illegal image file: ${IMAGE}"
|
22
|
+
exit 1
|
23
|
+
fi
|
24
|
+
|
25
|
+
echo ${OUTPUT} | egrep '^/dev/[svx]+d[a-z0-9]+$' > /dev/null 2>&1
|
26
|
+
if [ $? -ne 0 ]; then
|
27
|
+
echo "ERROR: illegal device: ${OUTPUT}"
|
28
|
+
exit 1
|
29
|
+
fi
|
30
|
+
|
31
|
+
if [ ! -b ${OUTPUT} ]; then
|
32
|
+
echo "ERROR: not a device: ${OUTPUT}"
|
33
|
+
exit 1
|
34
|
+
fi
|
35
|
+
|
36
|
+
# copy image to block device with 1 MB block size
|
37
|
+
tar -xzf ${IMAGE} -O root.img | dd bs=1M of=${OUTPUT}
|
metadata
CHANGED
@@ -1,96 +1,96 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bosh_aws_cpi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.5.0.pre.1113
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- VMware
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-10-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.
|
21
|
+
version: 1.8.5
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - '='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 1.
|
29
|
+
version: 1.8.5
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: bosh_common
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
none: false
|
34
34
|
requirements:
|
35
|
-
- -
|
35
|
+
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version:
|
37
|
+
version: 1.5.0.pre.1113
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
|
-
- -
|
43
|
+
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version:
|
45
|
+
version: 1.5.0.pre.1113
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: bosh_cpi
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
49
49
|
none: false
|
50
50
|
requirements:
|
51
|
-
- -
|
51
|
+
- - ~>
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
53
|
+
version: 1.5.0.pre.1113
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
none: false
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 1.5.0.pre.1113
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
|
-
name:
|
63
|
+
name: bosh-registry
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
65
65
|
none: false
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ~>
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
69
|
+
version: 1.5.0.pre.1113
|
70
70
|
type: :runtime
|
71
71
|
prerelease: false
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
|
-
- -
|
75
|
+
- - ~>
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version:
|
77
|
+
version: 1.5.0.pre.1113
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
|
-
name:
|
79
|
+
name: httpclient
|
80
80
|
requirement: !ruby/object:Gem::Requirement
|
81
81
|
none: false
|
82
82
|
requirements:
|
83
|
-
- -
|
83
|
+
- - '='
|
84
84
|
- !ruby/object:Gem::Version
|
85
|
-
version: 2.
|
85
|
+
version: 2.2.4
|
86
86
|
type: :runtime
|
87
87
|
prerelease: false
|
88
88
|
version_requirements: !ruby/object:Gem::Requirement
|
89
89
|
none: false
|
90
90
|
requirements:
|
91
|
-
- -
|
91
|
+
- - '='
|
92
92
|
- !ruby/object:Gem::Version
|
93
|
-
version: 2.
|
93
|
+
version: 2.2.4
|
94
94
|
- !ruby/object:Gem::Dependency
|
95
95
|
name: yajl-ruby
|
96
96
|
requirement: !ruby/object:Gem::Requirement
|
@@ -107,8 +107,10 @@ dependencies:
|
|
107
107
|
- - ! '>='
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: 0.8.2
|
110
|
-
description: BOSH AWS CPI
|
111
|
-
|
110
|
+
description: ! 'BOSH AWS CPI
|
111
|
+
|
112
|
+
cfd471'
|
113
|
+
email: support@cloudfoundry.com
|
112
114
|
executables:
|
113
115
|
- bosh_aws_console
|
114
116
|
extensions: []
|
@@ -118,37 +120,25 @@ files:
|
|
118
120
|
- lib/bosh_aws_cpi.rb
|
119
121
|
- lib/cloud/aws.rb
|
120
122
|
- lib/cloud/aws/aki_picker.rb
|
123
|
+
- lib/cloud/aws/availability_zone_selector.rb
|
121
124
|
- lib/cloud/aws/cloud.rb
|
122
125
|
- lib/cloud/aws/dynamic_network.rb
|
123
126
|
- lib/cloud/aws/helpers.rb
|
127
|
+
- lib/cloud/aws/instance_manager.rb
|
128
|
+
- lib/cloud/aws/manual_network.rb
|
124
129
|
- lib/cloud/aws/network.rb
|
125
130
|
- lib/cloud/aws/network_configurator.rb
|
126
|
-
- lib/cloud/aws/
|
131
|
+
- lib/cloud/aws/resource_wait.rb
|
132
|
+
- lib/cloud/aws/stemcell.rb
|
133
|
+
- lib/cloud/aws/stemcell_creator.rb
|
134
|
+
- lib/cloud/aws/tag_manager.rb
|
127
135
|
- lib/cloud/aws/version.rb
|
128
136
|
- lib/cloud/aws/vip_network.rb
|
137
|
+
- scripts/stemcell-copy.sh
|
129
138
|
- README.md
|
130
|
-
|
131
|
-
|
132
|
-
-
|
133
|
-
- spec/spec_helper.rb
|
134
|
-
- spec/unit/aki_picker_spec.rb
|
135
|
-
- spec/unit/attach_disk_spec.rb
|
136
|
-
- spec/unit/cloud_spec.rb
|
137
|
-
- spec/unit/configure_networks_spec.rb
|
138
|
-
- spec/unit/create_disk_spec.rb
|
139
|
-
- spec/unit/create_stemcell_spec.rb
|
140
|
-
- spec/unit/create_vm_spec.rb
|
141
|
-
- spec/unit/delete_disk_spec.rb
|
142
|
-
- spec/unit/delete_stemcell_spec.rb
|
143
|
-
- spec/unit/delete_vm_spec.rb
|
144
|
-
- spec/unit/detach_disk_spec.rb
|
145
|
-
- spec/unit/helpers_spec.rb
|
146
|
-
- spec/unit/network_configurator_spec.rb
|
147
|
-
- spec/unit/reboot_vm_spec.rb
|
148
|
-
- spec/unit/set_vm_metadata_spec.rb
|
149
|
-
- spec/unit/validate_deployment_spec.rb
|
150
|
-
homepage: http://www.vmware.com
|
151
|
-
licenses: []
|
139
|
+
homepage: https://github.com/cloudfoundry/bosh
|
140
|
+
licenses:
|
141
|
+
- Apache 2.0
|
152
142
|
post_install_message:
|
153
143
|
rdoc_options: []
|
154
144
|
require_paths:
|
@@ -158,43 +148,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
158
148
|
requirements:
|
159
149
|
- - ! '>='
|
160
150
|
- !ruby/object:Gem::Version
|
161
|
-
version:
|
162
|
-
segments:
|
163
|
-
- 0
|
164
|
-
hash: -1915781663242535072
|
151
|
+
version: 1.9.3
|
165
152
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
166
153
|
none: false
|
167
154
|
requirements:
|
168
|
-
- - ! '
|
155
|
+
- - ! '>'
|
169
156
|
- !ruby/object:Gem::Version
|
170
|
-
version:
|
171
|
-
segments:
|
172
|
-
- 0
|
173
|
-
hash: -1915781663242535072
|
157
|
+
version: 1.3.1
|
174
158
|
requirements: []
|
175
159
|
rubyforge_project:
|
176
|
-
rubygems_version: 1.8.
|
160
|
+
rubygems_version: 1.8.23
|
177
161
|
signing_key:
|
178
162
|
specification_version: 3
|
179
163
|
summary: BOSH AWS CPI
|
180
|
-
test_files:
|
181
|
-
- spec/assets/stemcell-copy
|
182
|
-
- spec/integration/cpi_test.rb
|
183
|
-
- spec/spec_helper.rb
|
184
|
-
- spec/unit/aki_picker_spec.rb
|
185
|
-
- spec/unit/attach_disk_spec.rb
|
186
|
-
- spec/unit/cloud_spec.rb
|
187
|
-
- spec/unit/configure_networks_spec.rb
|
188
|
-
- spec/unit/create_disk_spec.rb
|
189
|
-
- spec/unit/create_stemcell_spec.rb
|
190
|
-
- spec/unit/create_vm_spec.rb
|
191
|
-
- spec/unit/delete_disk_spec.rb
|
192
|
-
- spec/unit/delete_stemcell_spec.rb
|
193
|
-
- spec/unit/delete_vm_spec.rb
|
194
|
-
- spec/unit/detach_disk_spec.rb
|
195
|
-
- spec/unit/helpers_spec.rb
|
196
|
-
- spec/unit/network_configurator_spec.rb
|
197
|
-
- spec/unit/reboot_vm_spec.rb
|
198
|
-
- spec/unit/set_vm_metadata_spec.rb
|
199
|
-
- spec/unit/validate_deployment_spec.rb
|
200
|
-
has_rdoc:
|
164
|
+
test_files: []
|
data/Rakefile
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
# Copyright (c) 2009-2012 VMware, Inc.
|
2
|
-
|
3
|
-
$:.unshift(File.expand_path("../../rake", __FILE__))
|
4
|
-
|
5
|
-
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __FILE__)
|
6
|
-
|
7
|
-
require "rubygems"
|
8
|
-
require "bundler"
|
9
|
-
Bundler.setup(:default, :test)
|
10
|
-
|
11
|
-
require "rake"
|
12
|
-
begin
|
13
|
-
require "rspec/core/rake_task"
|
14
|
-
rescue LoadError
|
15
|
-
end
|
16
|
-
|
17
|
-
require "bundler_task"
|
18
|
-
require "ci_task"
|
19
|
-
|
20
|
-
gem_helper = Bundler::GemHelper.new(Dir.pwd)
|
21
|
-
|
22
|
-
desc "Build CPI gem into the pkg directory"
|
23
|
-
task "build" do
|
24
|
-
gem_helper.build_gem
|
25
|
-
end
|
26
|
-
|
27
|
-
desc "Build and install CPI into system gems"
|
28
|
-
task "install" do
|
29
|
-
Rake::Task["bundler:install"].invoke
|
30
|
-
gem_helper.install_gem
|
31
|
-
end
|
32
|
-
|
33
|
-
BundlerTask.new
|
34
|
-
|
35
|
-
if defined?(RSpec)
|
36
|
-
namespace :spec do
|
37
|
-
desc "Run Unit Tests"
|
38
|
-
rspec_task = RSpec::Core::RakeTask.new(:unit) do |t|
|
39
|
-
t.pattern = "spec/unit/**/*_spec.rb"
|
40
|
-
t.rspec_opts = %w(--format progress --colour)
|
41
|
-
end
|
42
|
-
|
43
|
-
CiTask.new do |task|
|
44
|
-
task.rspec_task = rspec_task
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
desc "Run tests"
|
49
|
-
task :spec => %w(spec:unit)
|
50
|
-
end
|
@@ -1,109 +0,0 @@
|
|
1
|
-
# Copyright (c) 2009-2012 VMware, Inc.
|
2
|
-
|
3
|
-
module Bosh::AwsCloud
|
4
|
-
class RegistryClient
|
5
|
-
include Helpers
|
6
|
-
|
7
|
-
attr_reader :endpoint
|
8
|
-
attr_reader :user
|
9
|
-
attr_reader :password
|
10
|
-
|
11
|
-
def initialize(endpoint, user, password)
|
12
|
-
@endpoint = endpoint
|
13
|
-
|
14
|
-
unless @endpoint =~ /^http:\/\//
|
15
|
-
@endpoint = "http://#{@endpoint}"
|
16
|
-
end
|
17
|
-
|
18
|
-
@user = user
|
19
|
-
@password = password
|
20
|
-
|
21
|
-
auth = Base64.encode64("#{@user}:#{@password}").gsub("\n", "")
|
22
|
-
|
23
|
-
@headers = {
|
24
|
-
"Accept" => "application/json",
|
25
|
-
"Authorization" => "Basic #{auth}"
|
26
|
-
}
|
27
|
-
|
28
|
-
@client = HTTPClient.new
|
29
|
-
end
|
30
|
-
|
31
|
-
##
|
32
|
-
# Update instance settings in the registry
|
33
|
-
# @param [String] instance_id EC2 instance id
|
34
|
-
# @param [Hash] settings New agent settings
|
35
|
-
# @return [Boolean]
|
36
|
-
def update_settings(instance_id, settings)
|
37
|
-
unless settings.is_a?(Hash)
|
38
|
-
raise ArgumentError, "Invalid settings format, " \
|
39
|
-
"Hash expected, #{settings.class} given"
|
40
|
-
end
|
41
|
-
|
42
|
-
payload = Yajl::Encoder.encode(settings)
|
43
|
-
url = "#{@endpoint}/instances/#{instance_id}/settings"
|
44
|
-
|
45
|
-
response = @client.put(url, {:body => payload, :header => @headers})
|
46
|
-
|
47
|
-
if response.status != 200
|
48
|
-
cloud_error("Cannot update settings for `#{instance_id}', " \
|
49
|
-
"got HTTP #{response.status}")
|
50
|
-
end
|
51
|
-
|
52
|
-
true
|
53
|
-
end
|
54
|
-
|
55
|
-
##
|
56
|
-
# Read instance settings from the registry
|
57
|
-
# @param [String] instance_id EC2 instance id
|
58
|
-
# @return [Hash] Agent settings
|
59
|
-
def read_settings(instance_id)
|
60
|
-
url = "#{@endpoint}/instances/#{instance_id}/settings"
|
61
|
-
|
62
|
-
response = @client.get(url, {:header => @headers})
|
63
|
-
|
64
|
-
if response.status != 200
|
65
|
-
cloud_error("Cannot read settings for `#{instance_id}', " \
|
66
|
-
"got HTTP #{response.status}")
|
67
|
-
end
|
68
|
-
|
69
|
-
body = Yajl::Parser.parse(response.body)
|
70
|
-
|
71
|
-
unless body.is_a?(Hash)
|
72
|
-
cloud_error("Invalid registry response, Hash expected, " \
|
73
|
-
"got #{body.class}: #{body}")
|
74
|
-
end
|
75
|
-
|
76
|
-
settings = Yajl::Parser.parse(body["settings"])
|
77
|
-
|
78
|
-
unless settings.is_a?(Hash)
|
79
|
-
cloud_error("Invalid settings format, " \
|
80
|
-
"Hash expected, got #{settings.class}: " \
|
81
|
-
"#{settings}")
|
82
|
-
end
|
83
|
-
|
84
|
-
settings
|
85
|
-
|
86
|
-
rescue Yajl::ParseError
|
87
|
-
cloud_error("Cannot parse settings for `#{instance_id}'")
|
88
|
-
end
|
89
|
-
|
90
|
-
##
|
91
|
-
# Delete instance settings from the registry
|
92
|
-
# @param [String] instance_id EC2 instance id
|
93
|
-
# @return [Boolean]
|
94
|
-
def delete_settings(instance_id)
|
95
|
-
url = "#{@endpoint}/instances/#{instance_id}/settings"
|
96
|
-
|
97
|
-
response = @client.delete(url, {:header => @headers})
|
98
|
-
|
99
|
-
if response.status != 200
|
100
|
-
cloud_error("Cannot delete settings for `#{instance_id}', " \
|
101
|
-
"got HTTP #{response.status}")
|
102
|
-
end
|
103
|
-
|
104
|
-
true
|
105
|
-
end
|
106
|
-
|
107
|
-
end
|
108
|
-
|
109
|
-
end
|
data/spec/assets/stemcell-copy
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
#!/bin/sh
|
2
|
-
#
|
3
|
-
# This script runs as root through sudo without the need for a password,
|
4
|
-
# so it needs to make sure it can't be abused.
|
5
|
-
#
|
6
|
-
|
7
|
-
# make sure we have a secure PATH
|
8
|
-
PATH=/bin:/usr/bin
|
9
|
-
export PATH
|
10
|
-
|
11
|
-
if [ $# -ne 1 ]; then
|
12
|
-
echo "usage: $0 <block device>"
|
13
|
-
exit 1
|
14
|
-
fi
|
15
|
-
|
16
|
-
OUTPUT="$1"
|
17
|
-
|
18
|
-
# TODO perhaps this should be more restrictive?
|
19
|
-
echo ${OUTPUT} | egrep '^/dev/[a-z0-9]+$' > /dev/null 2>&1
|
20
|
-
if [ $? -ne 0 ]; then
|
21
|
-
echo "ERROR: illegal device: ${OUTPUT}"
|
22
|
-
exit 1
|
23
|
-
fi
|
24
|
-
|
25
|
-
if [ ! -b ${OUTPUT} ]; then
|
26
|
-
echo "ERROR: missing device: ${OUTPUT}"
|
27
|
-
exit 1
|
28
|
-
fi
|
29
|
-
|
30
|
-
# copy image to block device with 1 MB block size
|
31
|
-
dd if=root.img if=${OUTPUT} bs=1M
|