linode_cluster 0.1.3 → 0.1.4

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: 76d8513c30fa24709943079ead3d46f854fa6e62
4
- data.tar.gz: a443a5a5f03832ca79b55fe884d7e178cfade458
3
+ metadata.gz: b3eb2f30c56b38b7494bc50a9d08608a9afd41e4
4
+ data.tar.gz: 78c34ae4e48a32b2fe155c8f6c35031c7d5804ad
5
5
  SHA512:
6
- metadata.gz: 88fbb6548afbd32dca64be46bedba48efabfd07bb0f1715143ff914c3e62afedcbc9765cebffa7a90ffc3569013126f32d0bb5f45b7930d69e74cd322aa3686a
7
- data.tar.gz: 32d43fbb54773cf7ac451cd8693b06916bbc4c67085ec35cbf0227b8b49bdb5a5937bf3033f0a6d8a60b266bb7976279dc1a7212c7195d1b5e4a89bad75ca273
6
+ metadata.gz: 5d2ff7af03d1a23aba4d1b7d0765d97ba69b880a9c0ac72de953cabbd2c2188b1bc7f043733411b68c9fc846f8231a3fc8c98b1eb004dde7106ccfe2ea346954
7
+ data.tar.gz: c1cc51d905f2d3d0f24a33558bf7a0840d3a5d3c975e056717b18375f94bafed585a10de70ceb5927932d4df48237fcacf47b2489e52884e7f7ec120f5b81c67
data/.gitignore CHANGED
@@ -10,3 +10,4 @@
10
10
 
11
11
  # rspec failure tracking
12
12
  .rspec_status
13
+ *.gem
@@ -6,7 +6,7 @@ require 'linode'
6
6
  module LinodeCluster
7
7
  # Cluster class
8
8
  class Cluster
9
- attr_accessor :client, :ansible_ssh_user, :app_name, :stage
9
+ attr_accessor :client, :ansible_ssh_user, :app_name, :stage, :image_name
10
10
 
11
11
  def initialize(api_key, app_name, stage, options)
12
12
  @node_groups = {}
@@ -14,6 +14,7 @@ module LinodeCluster
14
14
  @stage = stage || ''
15
15
  @client = ClientWrapper.new(Linode.new(api_key: api_key))
16
16
  @ansible_ssh_user = options[:ansible_ssh_user] || 'root'
17
+ @image_name = options[:image_name]
17
18
 
18
19
  raise 'app name cannot be blank' if app_name.empty?
19
20
  raise 'stage cannot be blank' if stage.empty?
@@ -21,7 +22,7 @@ module LinodeCluster
21
22
 
22
23
  def add_node_group(name, region, size, count, options = {})
23
24
  raise "Group with name '#{name}' already exists" if @node_groups[name]
24
- @node_groups[name] = NodeGroup.new(name, name_prefix, region, size, count, self, default_options(options))
25
+ @node_groups[name] = NodeGroup.new(name, name_prefix, region, size, count, image_name, self, default_options(options))
25
26
  end
26
27
 
27
28
  def create!
@@ -5,9 +5,6 @@ require 'securerandom'
5
5
  module LinodeCluster
6
6
  # node factory class
7
7
  class NodeFactory
8
- # DEFAULT_IMAGE_NAME = 'Ubuntu 16.04 LTS'.freeze
9
- DEFAULT_IMAGE_NAME = 'Ubuntu 14.04 LTS'.freeze
10
-
11
8
  attr_accessor :client
12
9
 
13
10
  def initialize(client)
@@ -42,6 +39,8 @@ module LinodeCluster
42
39
  linode_attributes = { datacenterid: find_datacenter_id(attributes[:region]),
43
40
  planid: find_plan_id(attributes[:size]) }
44
41
 
42
+ image_name = attributes[:image_name] || 'Ubuntu 14.04 LTS'.freeze
43
+
45
44
  result = client.linode.create(linode_attributes)
46
45
 
47
46
  begin
@@ -63,8 +62,8 @@ module LinodeCluster
63
62
 
64
63
  os_disk = client.linode.disk.createfromdistribution(
65
64
  linodeid: result.linodeid,
66
- distributionid: find_distribution_id_by_name(DEFAULT_IMAGE_NAME),
67
- label: DEFAULT_IMAGE_NAME,
65
+ distributionid: find_distribution_id_by_name(image_name),
66
+ label: image_name,
68
67
  rootpass: SecureRandom.hex,
69
68
  size: new_node.totalhd - 512,
70
69
  rootsshkey: File.read("#{ENV.fetch('HOME')}/.ssh/id_rsa.pub")
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LinodeCluster
4
- NodeGroup = Struct.new(:name, :group_name_prefix, :region, :size, :count, :cluster, :options) do
4
+ NodeGroup = Struct.new(:name, :group_name_prefix, :region, :size, :count, :image_name, :cluster, :options) do
5
5
  def names
6
6
  Array.new(count) { |i| "#{name_prefix}#{i}" }
7
7
  end
@@ -51,7 +51,7 @@ module LinodeCluster
51
51
 
52
52
  def create_node(name)
53
53
  puts "Creating #{name}"
54
- cluster.create_node(name: name, region: region, size: size, group_name: group_name)
54
+ cluster.create_node(name: name, region: region, size: size, group_name: group_name, image_name: image_name)
55
55
  end
56
56
 
57
57
  def check_node_specs(node)
@@ -1,3 +1,3 @@
1
1
  module LinodeCluster
2
- VERSION = '0.1.3'.freeze
2
+ VERSION = '0.1.4'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: linode_cluster
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruben Stranders
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-07 00:00:00.000000000 Z
11
+ date: 2018-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: linode
@@ -112,9 +112,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  version: '0'
113
113
  requirements: []
114
114
  rubyforge_project:
115
- rubygems_version: 2.6.10
115
+ rubygems_version: 2.6.14
116
116
  signing_key:
117
117
  specification_version: 4
118
118
  summary: A simple wrapper library for creating a cluster of Linodes.
119
119
  test_files: []
120
- has_rdoc: