avst-cloud 0.1.37 → 0.1.38
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -0
- data/avst-cloud.gemspec +1 -1
- data/bin/avst-cloud-azure-rm +1 -1
- data/lib/avst-cloud/aws_connection.rb +44 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce616eddab00f500b04085c616b6cc4415b319dac8cf1a29973460fae64fe905
|
4
|
+
data.tar.gz: 685fa1a66ec43f53726f9208ceb480633f94980d6b3039514407f232715628a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53d7bd60378e3e1114ff1ed000efa78b53acd75e73390496b05d41d8ae7f7a24a4158640c39c60bbb573a25e911725d40764c213d9c35b7749db46a3c2bef1da
|
7
|
+
data.tar.gz: 0a274f0af0b36dd8f2a9a4e65913849366d3a6f33b671baae484cb0de99f4c2c9ac9cd44382673f40f6403e26ac7a28d02cfc03cf4e1f981c4a642896a9c999d
|
data/.travis.yml
CHANGED
@@ -1,4 +1,8 @@
|
|
1
1
|
language: ruby
|
2
|
+
before_install:
|
3
|
+
# https://github.com/travis-ci/travis-rubies/issues/57#issuecomment-458981237
|
4
|
+
- "find /home/travis/.rvm/rubies -wholename '*default/bundler-*.gemspec' -delete"
|
5
|
+
- gem install bundler --version 1.17.3
|
2
6
|
notifications:
|
3
7
|
email: false
|
4
8
|
hipchat:
|
data/avst-cloud.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "avst-cloud"
|
7
|
-
spec.version = '0.1.
|
7
|
+
spec.version = '0.1.38'
|
8
8
|
spec.authors = ["Martin Brehovsky", "Jon Bevan", "Matthew Hope"]
|
9
9
|
spec.email = ["mbrehovsky@adaptavist.com", "jbevan@adaptavist.com", "mhope@adaptavist.com"]
|
10
10
|
spec.summary = %q{Automated creation, bootstrapping and provisioning of servers }
|
data/bin/avst-cloud-azure-rm
CHANGED
@@ -39,7 +39,7 @@ platform = nil # defaults to Linux
|
|
39
39
|
server_name = "hostname1"
|
40
40
|
user = "ubuntu"
|
41
41
|
# Must comply to Azure pass guidelines
|
42
|
-
password = "
|
42
|
+
password = ""
|
43
43
|
location = nil # Will default to West Europe
|
44
44
|
resource_group = "new_resource_group" # if RG does not exists it will create it
|
45
45
|
vm_size = nil # Defaults to Basic_A0
|
@@ -33,7 +33,7 @@ module AvstCloud
|
|
33
33
|
AvstCloud::AwsServer.new(server, server_name, server.public_ip_address, root_user, root_password)
|
34
34
|
end
|
35
35
|
|
36
|
-
def create_server(server_name, flavour, os, key_name, ssh_key, subnet_id, security_group_ids, ebs_size, hdd_device_path, ami_image_id, availability_zone, additional_hdds={}, vpc=nil, created_by=nil, custom_tags={}, root_username=nil)
|
36
|
+
def create_server(server_name, flavour, os, key_name, ssh_key, subnet_id, security_group_ids, ebs_size, hdd_device_path, ami_image_id, availability_zone, additional_hdds={}, vpc=nil, created_by=nil, custom_tags={}, root_username=nil, create_elastic_ip=false)
|
37
37
|
# Permit named instances from DEFAULT_FLAVOURS
|
38
38
|
flavour = flavour || "t2.micro"
|
39
39
|
os = os || "ubuntu-14"
|
@@ -122,6 +122,7 @@ module AvstCloud
|
|
122
122
|
tags['created_by'] = created_by
|
123
123
|
end
|
124
124
|
tags.merge!(custom_tags)
|
125
|
+
|
125
126
|
# create server
|
126
127
|
server = connect.servers.create :tags => tags,
|
127
128
|
:flavor_id => flavour,
|
@@ -133,7 +134,6 @@ module AvstCloud
|
|
133
134
|
:availability_zone => availability_zone,
|
134
135
|
:block_device_mapping => create_ebs_volume,
|
135
136
|
:vpc => vpc
|
136
|
-
|
137
137
|
|
138
138
|
result_server = AvstCloud::AwsServer.new(server, server_name, nil, root_user, ssh_key)
|
139
139
|
# result_server.logger = logger
|
@@ -143,6 +143,27 @@ module AvstCloud
|
|
143
143
|
|
144
144
|
logger.debug "[DONE]\n\n"
|
145
145
|
|
146
|
+
# create Elastic IP Address if required
|
147
|
+
if create_elastic_ip
|
148
|
+
logger.debug("Attempting to create elastic IP address")
|
149
|
+
elastic_ip = connect.allocate_address("vpc").body
|
150
|
+
elastic_ip_address = elastic_ip['publicIp']
|
151
|
+
# if we have a server id and an Elastic public IP attempt to join the two togehter
|
152
|
+
if server.id and elastic_ip_address
|
153
|
+
logger.debug ("Elastic IP #{elastic_ip_address} created, attempting to allocate to server")
|
154
|
+
connect.associate_address(server.id, elastic_ip_address)
|
155
|
+
# reacquire server object as IP has, probably, changed
|
156
|
+
server = find_fog_server(server_name)
|
157
|
+
|
158
|
+
# create tag on the Elastic IP
|
159
|
+
# TODO: add ability for other tags to be defined by the user
|
160
|
+
logger.debug("Creating tags on Elastic IP Address #{elastic_ip}\n\n")
|
161
|
+
connect.tags.create(:resource_id => elastic_ip['allocationId'], :key => "Name", :value => server_name)
|
162
|
+
else
|
163
|
+
logger.warn("Elastic IP creation failed, proceeding with non Elastic IP\n\n")
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
146
167
|
logger.debug "The server has been successfully created, to login onto the server:\n"
|
147
168
|
logger.debug "\t ssh -i #{ssh_key} #{root_user}@#{server.public_ip_address}\n"
|
148
169
|
if create_ebs_volume
|
@@ -201,6 +222,18 @@ module AvstCloud
|
|
201
222
|
servers.first
|
202
223
|
end
|
203
224
|
|
225
|
+
def delete_elastic_ip(ip_address)
|
226
|
+
address = is_elastic_ip(ip_address)
|
227
|
+
if address
|
228
|
+
logger.debug "Found Elastic IP #{address.public_ip}, attempting to delete"
|
229
|
+
logger.debug "Elastic IP #{ip_address} deleted" if address.destroy
|
230
|
+
return true
|
231
|
+
else
|
232
|
+
logger.debug "IP #{ip_address} does NOT appear to be an Elastic IP"
|
233
|
+
end
|
234
|
+
return false
|
235
|
+
end
|
236
|
+
|
204
237
|
private
|
205
238
|
def user_from_os(os)
|
206
239
|
case os.to_s
|
@@ -233,5 +266,14 @@ module AvstCloud
|
|
233
266
|
def all_named_servers(server_name)
|
234
267
|
connect.servers.all({'tag:Name' => server_name})
|
235
268
|
end
|
269
|
+
|
270
|
+
def is_elastic_ip(ip_address)
|
271
|
+
connect.addresses.each do |address|
|
272
|
+
if address.public_ip == ip_address
|
273
|
+
return address
|
274
|
+
end
|
275
|
+
end
|
276
|
+
return false
|
277
|
+
end
|
236
278
|
end
|
237
279
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: avst-cloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.38
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Brehovsky
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2020-03-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|