avst-cloud 0.1.40 → 0.1.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 46cf2e686b412006cb9a4cbd2ae7fb624f5dbadf800bc05db414e7b2718e98e0
4
- data.tar.gz: b56b12c41540f2d787fb80db59cc9cc6d1017721b327fa9bfd48adb0bab75afa
3
+ metadata.gz: 733f10630f58e2081f47fd017b462c8a150b37e1009cd2c0557bbcce5dc061a9
4
+ data.tar.gz: 6fd8942f5dbd0e83482966ed4f96ed76dbe959ac5391c656e577f1cf1f3503b6
5
5
  SHA512:
6
- metadata.gz: 25461b2620b01cfd5e82909a00ad833787df06ef96729ce76e476cfddc9eb83189add2a324c2c7b51fb5c5e3d8428fd19e0d9520315ea76f868b23966c40b6cf
7
- data.tar.gz: 388417ecbce19754583fb90c0b3e884e4d1d8ef1b585d8feef8b1e908dee98e8615914571584a7ce8c61ebfc4e5f58180ea1bd266649802d91d8132e5406072d
6
+ metadata.gz: 4fe6c7b1260da9a622621e871936d79bc468e256e61ec29d760028eb47624ccf2d5a859c93a3998c2bae6957af9e13e8547c57e8dac5915b1a91ccec4ad40fca
7
+ data.tar.gz: def1c8d32b83f8f693fa5b82583eb165190801c6f48b1867dd3212e6ae4ed05feb043d267675d882e227e66421c04a7223040f3c5af0efc462a8f417d9b35e9c
data/.travis.yml CHANGED
@@ -2,7 +2,7 @@ language: ruby
2
2
  before_install:
3
3
  # https://github.com/travis-ci/travis-rubies/issues/57#issuecomment-458981237
4
4
  - "find /home/travis/.rvm/rubies -wholename '*default/bundler-*.gemspec' -delete"
5
- - gem install bundler --version 1.17.3
5
+ - gem install bundler --version 2.2.10
6
6
  notifications:
7
7
  email: false
8
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.40'
7
+ spec.version = '0.1.41'
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 }
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
15
15
  spec.executables = ["avst-cloud", "avst-cloud-puppet", "avst-cloud-rackspace", "avst-cloud-azure", "avst-cloud-azure-rm"]
16
16
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
17
  spec.require_paths = ["lib"]
18
- spec.add_development_dependency "bundler", "~> 1.17.3"
18
+ spec.add_development_dependency "bundler", "2.2.10"
19
19
  spec.add_development_dependency "rake"
20
20
  spec.add_dependency "fog"
21
21
  spec.add_dependency "fog-core", "1.43.0"
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
31
31
  spec.add_dependency "derelict"
32
32
  spec.add_dependency "docopt", ">= 0.5.0"
33
33
  spec.add_dependency "rainbow", '3.0.0'
34
- spec.add_dependency "nokogiri", "~> 1.8.5"
34
+ spec.add_dependency "nokogiri", "~> 1.10.8"
35
35
  spec.add_dependency "signet", "0.14.1"
36
36
  end
37
37
 
@@ -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, create_elastic_ip=false, encrypt_root=false ,root_encryption_key=nil, delete_root_disk=true, root_disk_type='gp2', root_disk_iops=0, private_ip=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, encrypt_root=false ,root_encryption_key=nil, delete_root_disk=true, root_disk_type='gp2', root_disk_iops=0, private_ip=nil, public_ip=nil)
37
37
  # Permit named instances from DEFAULT_FLAVOURS
38
38
  flavour = flavour || "t2.micro"
39
39
  os = os || "ubuntu-14"
@@ -90,6 +90,31 @@ module AvstCloud
90
90
  logger.debug "create_elastic_ip - #{create_elastic_ip}"
91
91
  logger.debug "custom_private_ip - #{private_ip}"
92
92
 
93
+ elastic_ip_address = nil
94
+
95
+ # if a public IP has been specified, try to lookup the elastic IP and use it
96
+ if public_ip
97
+ require "resolv"
98
+ # we can find IP based on either its address or its Name tag, if the provided value is not an IP try by tag
99
+ if public_ip =~ Resolv::IPv4::Regex
100
+ found_eip = connect.describe_addresses('public-ip' => [public_ip])
101
+ else
102
+ found_eip = connect.describe_addresses('tag:Name' => [public_ip])
103
+ end
104
+ if ! found_eip.data[:body]['addressesSet'][0].nil?
105
+ # if we have found the IP and its not already associated use it
106
+ if found_eip.data[:body]['addressesSet'][0]['publicIp'] and ! found_eip.data[:body]['addressesSet'][0]['associationId']
107
+ elastic_ip =found_eip.data[:body]['addressesSet'][0]
108
+ elastic_ip_address = elastic_ip['publicIp']
109
+ logger.debug "Requested Elastic IP found and is unallocated, an attempt to attach this to the VM will be made"
110
+ else
111
+ logger.warn "Requested Elastic IP exist but is already allocated, the system will be created but will NOT use this IP"
112
+ end
113
+ else
114
+ logger.warn "Requested Elastic IP does not exist, the system will be created but will NOT use this IP"
115
+ end
116
+ end
117
+
93
118
  create_ebs_volume = nil
94
119
  if ebs_size
95
120
  # in case of centos ami we need to use /dev/xvda this is ami dependent
@@ -181,26 +206,33 @@ module AvstCloud
181
206
  logger.debug "[DONE]\n\n"
182
207
 
183
208
  # create Elastic IP Address if required
184
- if create_elastic_ip
185
- logger.debug("Attempting to create elastic IP address")
186
- elastic_ip = connect.allocate_address("vpc").body
187
- elastic_ip_address = elastic_ip['publicIp']
188
- # if we have a server id and an Elastic public IP attempt to join the two togehter
189
- if server.id and elastic_ip_address
190
- logger.debug ("Elastic IP #{elastic_ip_address} created, attempting to allocate to server")
191
- connect.associate_address(server.id, elastic_ip_address)
192
- # reacquire server object as IP has, probably, changed
193
- server = find_fog_server(server_name)
194
-
195
- # create tag on the Elastic IP
196
- # TODO: add ability for other tags to be defined by the user
197
- logger.debug("Creating tags on Elastic IP Address #{elastic_ip}\n\n")
198
- connect.tags.create(:resource_id => elastic_ip['allocationId'], :key => "Name", :value => server_name)
209
+ if create_elastic_ip
210
+ if elastic_ip_address.nil?
211
+ logger.debug("Attempting to create elastic IP address")
212
+ elastic_ip = connect.allocate_address("vpc").body
213
+ elastic_ip_address = elastic_ip['publicIp']
214
+ logger.warn "Elastic IP creation failed, proceeding with non Elastic IP\n\n" if ! elastic_ip_address
199
215
  else
200
- logger.warn("Elastic IP creation failed, proceeding with non Elastic IP\n\n")
216
+ logger.warn "You have asked to create an Elastic IP and ALSO use an existing one"
217
+ logger.warn "The existing IP is avaliable and as such will be used INSTEAD of creating a new one!"
201
218
  end
202
219
  end
203
220
 
221
+ # if we have a server id and an Elastic public IP attempt to join the two togehter
222
+ if server.id and elastic_ip_address
223
+ logger.debug ("Attempting to allocate Elastic IP #{elastic_ip_address} to server")
224
+ connect.associate_address(server.id, elastic_ip_address)
225
+ # reacquire server object as IP has, probably, changed
226
+ server = find_fog_server(server_name)
227
+
228
+ # create tag on the Elastic IP
229
+ # TODO: add ability for other tags to be defined by the user
230
+ logger.debug("Creating tags on Elastic IP Address #{elastic_ip}\n\n")
231
+ connect.tags.create(:resource_id => elastic_ip['allocationId'], :key => "Name", :value => server_name)
232
+ else
233
+ logger.warn("EAllocation of Elastic IP failed, proceeding with non Elastic IP\n\n")
234
+ end
235
+
204
236
  logger.debug "The server has been successfully created, to login onto the server:\n"
205
237
  logger.debug "\t ssh -i #{ssh_key} #{root_user}@#{server.public_ip_address}\n"
206
238
  if create_ebs_volume
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.40
4
+ version: 0.1.41
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Brehovsky
@@ -10,22 +10,22 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-04-19 00:00:00.000000000 Z
13
+ date: 2021-05-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - "~>"
19
+ - - '='
20
20
  - !ruby/object:Gem::Version
21
- version: 1.17.3
21
+ version: 2.2.10
22
22
  type: :development
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
- - - "~>"
26
+ - - '='
27
27
  - !ruby/object:Gem::Version
28
- version: 1.17.3
28
+ version: 2.2.10
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: rake
31
31
  requirement: !ruby/object:Gem::Requirement
@@ -200,14 +200,14 @@ dependencies:
200
200
  requirements:
201
201
  - - "~>"
202
202
  - !ruby/object:Gem::Version
203
- version: 1.8.5
203
+ version: 1.10.8
204
204
  type: :runtime
205
205
  prerelease: false
206
206
  version_requirements: !ruby/object:Gem::Requirement
207
207
  requirements:
208
208
  - - "~>"
209
209
  - !ruby/object:Gem::Version
210
- version: 1.8.5
210
+ version: 1.10.8
211
211
  - !ruby/object:Gem::Dependency
212
212
  name: signet
213
213
  requirement: !ruby/object:Gem::Requirement