build-cloud 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZTBkMTNmNzg0OTkyNjViOTZkNWQxOGM0NjNlNmI5MDZiZWM4Yjg4Mw==
4
+ MzNmNjcyYmQxZDhkNGY1NTNkYTJhMmI1MDI4YjQ5NzJjOTg4MzUyMQ==
5
5
  data.tar.gz: !binary |-
6
- YWQ2YTBkZTdlZjAxYTUxMWQwNDg4NzY5YTM1N2MyYTI4YzQ0MDk4Mg==
6
+ MTNhZTJlMDAzYmYzODFiMjgwOWVjZTEwN2IzZDA3Mjg5M2YyODljMw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OTVhZjUxYTQ1MDY4OGEzZmI3MzFmZDI1OTBhOTNhNGZlN2Q3NTk3NWIyZTA5
10
- ZDUwNDViOGFjNmJmYTE3NjViNzA4ODAyMjcwNjhmMDhiYmQyMzJmMGIzZDlk
11
- OTRlMTViMGJlZDhiNzVlNGJjNjdlZGM2ZjNmOTNhMDUxMWU4MGI=
9
+ ZTI2ZTQ4MTBhMWU0MTFkMmEyOGI4NTUxNzJmMThmZDg0MTRhNjNlMjRmZTdk
10
+ OTZjOWE3NTA3NDUxMjc1ZDI5YmIxYjUzY2E1ZTc3NDhmY2M1YmQ1NWM1ODRm
11
+ OWI1YTM1MjI3MmZlZmI4YzkwODZhYmQxOTNmZmM1Y2RjYzVjYzg=
12
12
  data.tar.gz: !binary |-
13
- ZDFiNDU2MjVjM2U1NjVhZDg2NWEwMGY4MzYzOTFmOTAwODA0NDQ0ZjNmNmY5
14
- MTc2OWYzMmEzZWE3NmExMDY5ZWNhMDZhYTVjZWJkNWE2NTgwODZlMDIwZmZj
15
- Nzc0ODhlODMyYWI3YjBlOWQwNDVmYThlNzFjMDMxNDlkYTgyMmQ=
13
+ OTA1Y2NhZWI3ZTIwM2U2MzBiOTlmMWQ4NGQ5Yjc1Y2RlYTZmOGQyYTFlODdm
14
+ YWI2MTJjMmNlYTc5OThjNTMzYjkyNjcyY2U2MDc4MzcwZGRlYTk4YTU3YmI1
15
+ ZTY5M2QxM2JkMjYzMzVlODM2ZDJjNjc0YmYyYjY2ZmU4ZmIxMjQ=
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Build::Cloud
2
2
 
3
- Tools for building resources in AWS}
3
+ Tools for building resources in AWS
4
4
 
5
5
  ## Installation
6
6
 
@@ -22,6 +22,8 @@ See the command line help for `build-cloud`.
22
22
 
23
23
  ## Changelog
24
24
 
25
+ 2014-12-12 - version 0.0.9 - bugfixes to file path resolution. It is worth noting that when multiple files are passed to `--config` they're treated as relative to the CWD - this is what you'd expect from referencing a file in a command line option. When file(s) are specified in an `:include` key in the given YAML file, relative paths given there are considered to be relative to the location of the YAML file given to `--config` - this is to ensure consistent behaviour regardless of what $CWD is when calling build-cloud.
26
+
25
27
  2014-12-01 - version 0.0.8 - when multiple files are passed to `--config`, any top-level elements in the second and subsequent files which are arrays are merged into the arrays from previously read in files. This means, for examples, that you can have lists of instances or security groups in multiple files, and they will all be read in. Previously, subsequent files overwrote what was in previous files. Note that this only applies for top level elements of YAML files which are arrays - the previous overwriting behaviour applies still to strings.
26
28
 
27
29
  2014-10-03 - version 0.0.7 - instance creation previously had a 30 second wait to transition from pending to running state. This was insufficient, and has been increased to 60 seconds.
data/build-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 = "build-cloud"
7
- spec.version = "0.0.8"
7
+ spec.version = "0.0.9"
8
8
  spec.authors = ["The Scale Factory"]
9
9
  spec.email = ["info@scalefactory.com"]
10
10
  spec.summary = %q{Tools for building resources in AWS}
data/lib/build-cloud.rb CHANGED
@@ -3,7 +3,6 @@ require 'yaml'
3
3
  require 'pry'
4
4
  require 'logger'
5
5
  require 'pp'
6
- require 'pathname'
7
6
 
8
7
  class BuildCloud
9
8
 
@@ -16,29 +15,77 @@ class BuildCloud
16
15
 
17
16
  @log = options[:logger] or Logger.new( STDERR )
18
17
  @mock = options[:mock] or false
19
-
20
- first_config_file = options[:config].shift
21
18
 
19
+ # Parse the first config file. We'll merge the remainder (if any) into
20
+ # this one, regardless of whether they're passed on the command line
21
+ # or in the YAML for this file itself.
22
+ first_config_file = options[:config].shift
22
23
  @config = YAML::load( File.open( first_config_file ) )
23
24
 
24
- include_files = options[:config]
25
+ # include_files is going to be a list of files that we're going to
26
+ # merge in to the first file.
27
+ include_files = []
28
+
29
+ # Work out the full, standardised pathnames for any further files
30
+ # specified on the command line. note that options[:config] only
31
+ # contains the extra files at this point, as we shifted the first
32
+ # one off the array earlier.
33
+ #
34
+ # IMPORTANT: relative paths given on the command line are considered
35
+ # to be relative to $CWD. This decision is based on the principle of
36
+ # least surprise, as that is how everything else works.
37
+ cli_include_files = options[:config]
38
+ cli_include_files.each do |inc|
39
+ include_files << File.absolute_path( inc )
40
+ end
41
+
42
+ # Now look in the :include key in the YAML of the first file for
43
+ # either a single, or an array of files to include. Work out the
44
+ # standardised paths for each of these files, and push them onto
45
+ # the include_files array.
46
+ #
47
+ # IMPORTANT: relative paths given in the :include key in the YAML
48
+ # are considered to be relative to the config file specified, not
49
+ # $CWD. This is to ensure consistency of application and backwards
50
+ # compatibility. If this were relative to $CWD, a relative path
51
+ # specified in the file could have different meanings, and would end
52
+ # up being unpredictable.
25
53
  if include_yaml = @config.delete(:include)
26
54
  if include_yaml.is_a?(Array)
27
- include_files.concat(include_yaml)
55
+ # the :include key is an array, we need to iterate over it
56
+ include_yaml.each do |yml|
57
+ include_files << File.expand_path( yml, File.dirname( File.absolute_path(first_config_file) ) )
58
+ end
28
59
  else
29
- include_files.push(include_yaml)
60
+ # the :include key is a scalar, so just standardise that path
61
+ include_files.push( File.expand_path( include_yaml, File.dirname( File.absolute_path(first_config_file) ) ) )
30
62
  end
31
63
  end
32
64
 
33
- include_files.each do |include_file|
34
-
35
- include_path = Pathname.new(File.join( File.dirname( first_config_file ), include_file)).realpath
65
+ include_files.each do |include_path|
36
66
 
37
67
  if File.exists?( include_path )
38
68
  @log.info( "Including YAML file #{include_path}" )
39
69
  included_conf = YAML::load( File.open( include_path ) )
40
70
  @config = @config.merge(included_conf) do |keys, oldval, newval|
41
- (newval.is_a?(Array) ? (oldval + newval) : (oldval << newval)).uniq
71
+ # we're iterating over elements that are in both the
72
+ # config we've parsed so far, and the new file.
73
+ (newval.is_a?(Array) ? (oldval + newval).uniq : newval)
74
+ # oldval is from the existing config, newval is the incoming
75
+ # value from this file. if newval is an array, merge it in with
76
+ # what we already have, and make it unique. if newval is a
77
+ # string, the new value takes precedence over what we have
78
+ # already.
79
+ #
80
+ # edge cases:
81
+ # 1. if we have a key :foo which is a scalar, and then a
82
+ # :foo in a subsequent file which is an array (or v.v.)
83
+ # then this will blow up. I think this is acceptable.
84
+ # 2. if we have, eg. an instance, defined twice in
85
+ # separate files, then the behaviour of uniq is to use
86
+ # the entire hash as a test for uniqueness. Therefore
87
+ # if the definition of those instances varies slightly,
88
+ # the attempt to create those instances will likely fail.
42
89
  end
43
90
 
44
91
  end
@@ -99,6 +99,11 @@ class BuildCloud::NetworkInterface
99
99
  @compute.associate_address(nil, ip.public_ip, interface.network_interface_id, allocation_id )
100
100
  end
101
101
 
102
+ unless options[:source_dest_check].nil?
103
+ ### Need to use the request here, since the model doesn't support the source_dest_check attribute
104
+ @compute.modify_network_interface_attribute(interface.network_interface_id, 'sourceDestCheck', options[:source_dest_check])
105
+ end
106
+
102
107
  @log.debug( interface.inspect )
103
108
  @log.debug( interface_tag.inspect )
104
109
  @log.debug( ip.inspect ) unless ! options[:assign_new_public_ip]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: build-cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Scale Factory
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-01 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
@@ -127,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
127
  version: '0'
128
128
  requirements: []
129
129
  rubyforge_project:
130
- rubygems_version: 2.4.1
130
+ rubygems_version: 2.4.4
131
131
  signing_key:
132
132
  specification_version: 4
133
133
  summary: Tools for building resources in AWS