cyclid 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ea995b9c7270ae9d3e38e97ad81397ceb4b73e13
4
- data.tar.gz: 7642bb2b0a8703a0199e092858091de720d9bb19
3
+ metadata.gz: 489faa5033ce922ff61b7ab00b4cd161e7f66ae8
4
+ data.tar.gz: 2b0c1803c1f1dd3d82c3b906402b8ddbfbdb3c50
5
5
  SHA512:
6
- metadata.gz: b4e2f3529858bdba00c9be839fff1c6a0a7091355abdf7ec002781c44d0acad9764f37b39f1eb322ea0fe63f5c9141a536cd34dea6126252f0bd8fdcf1464717
7
- data.tar.gz: f3e00484f2d3491f56424612bc317b178b936109403ccbca9f802899b62fc5d69f9ceeff8f8720d02771209345c6883af60536749aa0f38d021f38de2feff2b1
6
+ metadata.gz: a0158078cf6a1b6da24afd01b2250c8171b5477f87c0cd52fd4b552c76a894dc50ced3c682988040b207fa3439404550ae130596ad3f84144df85e304c632429
7
+ data.tar.gz: cc3c14a58a141da1e819636f0d7eb1451be01d50549b902b5470f00b126241d06b5ba553bd2c55ab24eaf2c5909043781b75189291b391e9ce4bc9b7caebb960
@@ -59,11 +59,15 @@ module Cyclid
59
59
  release = 'trusty'
60
60
  end
61
61
 
62
+ # Get the instance size, or a default if there isn't one
63
+ size = args[:size] || 'micro'
64
+ machine_type = map_machine_type(size)
65
+
62
66
  name = create_name
63
67
 
64
- source_image, size = find_source_image(distro, release)
65
- disk = create_disk(name, size, source_image)
66
- instance = create_instance(name, disk)
68
+ source_image, disk_size = find_source_image(distro, release)
69
+ disk = create_disk(name, disk_size, source_image)
70
+ instance = create_instance(name, disk, machine_type)
67
71
 
68
72
  Cyclid.logger.debug "instance=#{instance.inspect}"
69
73
 
@@ -132,6 +136,18 @@ module Cyclid
132
136
  "#{base}-#{SecureRandom.hex(16)}"
133
137
  end
134
138
 
139
+ # Map the generic size to a machine type
140
+ def map_machine_type(size)
141
+ map = { 'default' => @config[:machine_type],
142
+ 'micro' => 'f1-micro',
143
+ 'mini' => 'g1-small',
144
+ 'small' => 'n1-standard-1',
145
+ 'medium' => 'n1-standard-2',
146
+ 'large' => 'n1-standard-4' }
147
+
148
+ map[size]
149
+ end
150
+
135
151
  # Map the distro & release to a source image
136
152
  def find_source_image(distro, release)
137
153
  Cyclid.logger.debug 'attempting to find source image'
@@ -177,11 +193,11 @@ module Cyclid
177
193
  end
178
194
 
179
195
  # Create a compute instance
180
- def create_instance(name, disk)
196
+ def create_instance(name, disk, machine_type)
181
197
  Cyclid.logger.info "creating instance #{name}"
182
198
  instance = @api.servers.bootstrap(name: name,
183
199
  disks: [disk],
184
- machine_type: @config[:machine_type],
200
+ machine_type: machine_type,
185
201
  zone_name: @config[:zone],
186
202
  network: @config[:network],
187
203
  username: @config[:username],
@@ -159,6 +159,8 @@ module Cyclid
159
159
  notifier.completion(success)
160
160
 
161
161
  return success
162
+ ensure
163
+ ::ActiveRecord::Base.clear_active_connections!
162
164
  end
163
165
  end
164
166
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module Cyclid
3
3
  module Api
4
- VERSION = '0.3.1'
4
+ VERSION = '0.3.2'
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cyclid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kristian Van Der Vliet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-06 00:00:00.000000000 Z
11
+ date: 2017-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj