j-enc 0.0.3 → 0.0.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: 11f103fbe09b9ea005115b40859c2b86c9955cc5
4
- data.tar.gz: 0ce7e1100496653823345f409e60aaec3b7fe915
3
+ metadata.gz: 4b119e89fd119c52ca0b22f718178e0eb8243f6f
4
+ data.tar.gz: 553f320981ed7767e89c4e859370eb58e07b3d35
5
5
  SHA512:
6
- metadata.gz: 6cd2104e8df103b63a7a6199f9aee3b45081b5731ca66c84023f9a58156f7a6475a3e95d8e2356e4b67a27f027d4e1387cc4dca76e235ed7a35772ef971e18b8
7
- data.tar.gz: bb5fab3502a0ecd844d1011c19d72fc6dfca281de9ef93b7053cfb67c313478598ed65a09c886bc436c2804168c7c584c1dc25ff938355c0b12af20aaf3d8fd9
6
+ metadata.gz: 5acedb1aa0c490b7e5c865f0a25fbc96594b24a8b90a92afad68fad84dac32a87a9ce3cc766d006b00d0f6774edfc4ac036fa4741cccf00023a12b83319017e8
7
+ data.tar.gz: c715d02dd40797c9a74c70df74e3d765af9460a0ff8daa38f90807aefba3106b939054edcf24a7899586a73d063ba768456f4258e74d24f7a97ea408790c30e0
@@ -10,6 +10,7 @@ module Enc
10
10
 
11
11
  class TooManyAssets < Exception; end
12
12
  class NoAssets < Exception; end
13
+ class AssetNotConfigured < Exception; end
13
14
  class AssetNotValid < Exception; end
14
15
  class CannotConnect < Exception; end
15
16
 
@@ -35,6 +36,7 @@ module Enc
35
36
  raise TooManyAssets, 'Too many assets' if response.count > 1
36
37
  raise NoAssets, 'No assets found' if response.first.nil? or response.first.empty?
37
38
  asset = CollinsHelper::Node::NodeAsset.from_json(response.first)
39
+ raise AssetNotConfigured, 'Asset is missing required tags' if (not asset.is_valid? and asset.uses_enc?)
38
40
  raise AssetNotValid, 'Asset is not valid' unless asset.is_valid?
39
41
  asset
40
42
  end
@@ -30,7 +30,6 @@ module Enc
30
30
  connection = Enc::CollinsHelper::Connection.new(@config)
31
31
  return connection.api.safe_find(:hostname => hostname, :details => true), true
32
32
  rescue Enc::CollinsHelper::Api::TooManyAssets,
33
- Enc::CollinsHelper::Api::AssetNotValid,
34
33
  Enc::CollinsHelper::Api::CannotConnect,
35
34
  Collins::AuthenticationError,
36
35
  Collins::RequestError
@@ -40,6 +39,11 @@ module Enc
40
39
  rescue Enc::CollinsHelper::Api::NoAssets
41
40
  logger.info("Did not find any assets with hostname #{hostname}, saving an empty asset to the cache")
42
41
  return Enc::CollinsHelper::Node::NodeAsset.new, true
42
+ rescue Enc::CollinsHelper::Api::AssetNotValid => e
43
+ logger.error("Asset with hostname #{hostname} is not valid: #{e}, saving an empty asset to the cache")
44
+ return Enc::CollinsHelper::Node::NodeAsset.new, true
45
+ rescue Enc::CollinsHelper::Api::AssetNotConfigured => e
46
+ bail("Asset with hostname #{hostname} is configured to use the ENC but does not have all the required tags", e)
43
47
  end
44
48
  begin
45
49
  return @cache.read(hostname), false
@@ -1,3 +1,3 @@
1
1
  module Enc
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -23,6 +23,7 @@ describe 'ENC Builder' do
23
23
  expect(YAML.load(builder.to_yaml)).to be_an_instance_of(Hash)
24
24
  expect(YAML.load(builder.to_yaml)['parameters']['deployment_environment']).to eq(node.get_deployment_environment)
25
25
  expect(YAML.load(builder.to_yaml)['parameters']['datacenter']).to eq(node.get_datacenter)
26
+ expect(YAML.load(builder.to_yaml)['parameters']['roles'].split(',')).to eq(node.get_roles)
26
27
  expect(YAML.load(builder.to_yaml)['parameters']['roles']).to eq(node.get_roles.join(','))
27
28
  expect(YAML.load(builder.to_yaml)['parameters']['role1']).to eq(node.get_roles_by_index[0])
28
29
  expect(YAML.load(builder.to_yaml)['parameters']['role2']).to eq(node.get_roles_by_index[1])
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: j-enc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jestin Woods
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-11 00:00:00.000000000 Z
11
+ date: 2014-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler