build-cloud 0.0.4 → 0.0.5

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
- MThiNDI5ODkyNTAyNjc1ZjZjZjAzM2M2NzczYWU5NjRhNDI4ZWMyYg==
4
+ YjA3NTgxYzZmOTAyMGQ3YWE4NjE3MWVkYjhjYmNlMTIzYjFmNDRlZg==
5
5
  data.tar.gz: !binary |-
6
- YTc1OGUzNjc3MGZmNTFlMTllYjEyZDJhMWM5YWFmNmNlODE5ZjlmMA==
6
+ ODRhZjVjNWQ2ZDYzNjEzODhlNDM4ZGYzYzczMDI3NWZkODJjZTk4Yw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NzhmYTkwNWRiMmYxNTE2Njg4M2JmMmYzZmI2YjdhNjkxZmM2YmExZTY0ZTYx
10
- YWE2M2Y4NTBiOTUyMjNhMWEyMWFkZjAyOTFjMzg0OTEyZDhkYzA4OGVkYjll
11
- NDYwOTM4OTE4ZmU5MjhlNGI4ZjcyOGIyZTMxN2EyMWJmNzU3YmM=
9
+ M2E0NjBhYjUxMDFlZjc4MDRiZmY2OWU4ZDg2MmEwMDRhOGJkNThlNmU1MWE4
10
+ NWRkZWJjODAyYmUwODNhYmM1NmQxMmZhNzA4Y2RiZmE3NDJiNTg1ZDExMTgz
11
+ YjkyMGI2ZTUyYThhODdkYjE1NDI1NzgyNTY5MzMzNTYzOWFmYjU=
12
12
  data.tar.gz: !binary |-
13
- M2VmMzFlZGI1OGJlZjE1N2EyZThiZjg5NzA3M2Y2OWM2OTQ3MTUwNWFjZTFj
14
- N2RhNTgzYzQ5MDlkODQ0MGRiMDdlNzBjMjhkMjE4YWI4NTIwMjA4YjczYTA4
15
- NGVjYjMwNTA4ZmQ1MzgzMGRkODEwODQ2NmNlMDUxNDk3YWE1ODM=
13
+ MTNhYjg4NzQyOTg0OThlNzNjNjkyZWFmMWVhOTUxNWNkZmUwODQxZDdkMGZk
14
+ NTU0OTdiMjY1MzI4YWMzY2M1ODFjMTRkYmI0ZDliY2E0NTE3MThiMTc4NTQ3
15
+ MmI1NDRmZGVmY2Q3NDhkN2NlZmNkYTZjYjRkNjI4NWY4Yjg5OGU=
data/README.md CHANGED
@@ -22,6 +22,8 @@ See the command line help for `build-cloud`.
22
22
 
23
23
  ## Changelog
24
24
 
25
+ 2014-09-16 - version 0.0.5 - now supports creation of DHCP Options Sets, and specifying them using the `:dhcp_options_set_name` key to a VPC.
26
+
25
27
  2014-09-15 - version 0.0.4 - files can now be passed to `--config` with a path. It is no longer assumed that all files will be in the same directory.
26
28
 
27
29
  2014-09-15 - version 0.0.3 - now accepts multiple files to `--config`. The second and subsequent files are merged into the first YAML file in order, ahead of any files specified in a `:include` list in the first YAML file.
data/bin/build-cloud CHANGED
@@ -28,6 +28,8 @@ require 'build-cloud/instance'
28
28
  require 'build-cloud/ebsvolume'
29
29
  require 'build-cloud/networkinterface'
30
30
  require 'build-cloud/internetgateway'
31
+ require 'build-cloud/dhcpoptionsset'
32
+
31
33
 
32
34
  options = {}
33
35
  optparse = OptionParser.new do |opts|
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.4"
7
+ spec.version = "0.0.5"
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
@@ -97,34 +97,36 @@ class BuildCloud
97
97
  def self.dispatch
98
98
 
99
99
  {
100
- :vpcs => BuildCloud::VPC,
101
- :internet_gateways => BuildCloud::InternetGateway,
102
- :subnets => BuildCloud::Subnet,
103
- :route_tables => BuildCloud::RouteTable,
104
- :zones => BuildCloud::Zone,
105
- :security_groups => BuildCloud::SecurityGroup,
106
- :network_interfaces => BuildCloud::NetworkInterface,
107
- :routes => BuildCloud::Route,
108
- :launch_configurations => BuildCloud::LaunchConfiguration,
109
- :load_balancers => BuildCloud::LoadBalancer,
110
- :as_groups => BuildCloud::ASGroup,
111
- :r53_record_sets => BuildCloud::R53RecordSet,
112
- :rds_servers => BuildCloud::RDSServer,
113
- :db_subnet_groups => BuildCloud::DbSubnetGroup,
114
- :db_parameter_groups => BuildCloud::DbParameterGroup,
115
- :cache_subnet_groups => BuildCloud::CacheSubnetGroup,
116
- :cache_clusters => BuildCloud::CacheCluster,
100
+ :vpcs => BuildCloud::VPC,
101
+ :internet_gateways => BuildCloud::InternetGateway,
102
+ :subnets => BuildCloud::Subnet,
103
+ :route_tables => BuildCloud::RouteTable,
104
+ :zones => BuildCloud::Zone,
105
+ :security_groups => BuildCloud::SecurityGroup,
106
+ :network_interfaces => BuildCloud::NetworkInterface,
107
+ :routes => BuildCloud::Route,
108
+ :launch_configurations => BuildCloud::LaunchConfiguration,
109
+ :load_balancers => BuildCloud::LoadBalancer,
110
+ :as_groups => BuildCloud::ASGroup,
111
+ :r53_record_sets => BuildCloud::R53RecordSet,
112
+ :rds_servers => BuildCloud::RDSServer,
113
+ :db_subnet_groups => BuildCloud::DbSubnetGroup,
114
+ :db_parameter_groups => BuildCloud::DbParameterGroup,
115
+ :cache_subnet_groups => BuildCloud::CacheSubnetGroup,
116
+ :cache_clusters => BuildCloud::CacheCluster,
117
117
  :cache_parameter_groups => BuildCloud::CacheParameterGroup,
118
- :iam_roles => BuildCloud::IAMRole,
119
- :s3_buckets => BuildCloud::S3Bucket,
120
- :instances => BuildCloud::Instance,
121
- :ebs_volumes => BuildCloud::EBSVolume,
118
+ :iam_roles => BuildCloud::IAMRole,
119
+ :s3_buckets => BuildCloud::S3Bucket,
120
+ :instances => BuildCloud::Instance,
121
+ :ebs_volumes => BuildCloud::EBSVolume,
122
+ :dhcp_options_sets => BuildCloud::DHCPOptionsSet,
122
123
  }
123
124
 
124
125
  end
125
126
 
126
127
  def self.create_order
127
128
  [
129
+ :dhcp_options_sets,
128
130
  :vpcs,
129
131
  :internet_gateways,
130
132
  :iam_roles,
@@ -0,0 +1,77 @@
1
+ class BuildCloud::DHCPOptionsSet
2
+
3
+ include ::BuildCloud::Component
4
+
5
+ @@objects = []
6
+
7
+ def self.get_id_by_name( name )
8
+
9
+ dhcp_option = self.search( :name => name ).first
10
+
11
+ unless dhcp_option
12
+ raise "Couldn't get a DHCP Options Set object for #{name} - is it defined?"
13
+ end
14
+
15
+ dhcp_option_fog = dhcp_option.read
16
+
17
+ unless dhcp_option_fog
18
+ raise "Couldn't get a DHCP Options Set fog object for #{name} - is it created?"
19
+ end
20
+
21
+ dhcp_option_fog.id
22
+
23
+ end
24
+
25
+ def initialize ( fog_interfaces, log, options = {} )
26
+
27
+ @compute = fog_interfaces[:compute]
28
+ @log = log
29
+ @options = options
30
+
31
+ @log.debug( options.inspect )
32
+
33
+ required_options(:dhcp_configuration_set)
34
+
35
+ end
36
+
37
+ def create
38
+
39
+ return if exists?
40
+
41
+ @log.info( "Creating new DHCP Options Set for #{@options[:name]}" )
42
+
43
+ options = @options.dup
44
+
45
+ options[:tags] = { 'Name' => options.delete(:name) }
46
+
47
+ dhcp_option = @compute.dhcp_options.new( options )
48
+ dhcp_option.save
49
+
50
+ @compute.create_tags( dhcp_option.id, options[:tags] )
51
+
52
+ @log.debug( dhcp_option.inspect )
53
+
54
+ end
55
+
56
+ def read
57
+ @compute.dhcp_options.select { |d| d.tag_set['Name'] == @options[:name] }.first
58
+ end
59
+
60
+ alias_method :fog_object, :read
61
+
62
+ def delete
63
+
64
+ return unless exists?
65
+
66
+ @log.info( "Deleting DHCP Options Set for #{@options[:name]}" )
67
+
68
+ fog_object.destroy
69
+
70
+ end
71
+
72
+ def [](key)
73
+ @options[key]
74
+ end
75
+
76
+ end
77
+
@@ -114,7 +114,13 @@ class BuildCloud::Instance
114
114
  elsif options[:user_data_template]
115
115
 
116
116
  variable_hash = options[:user_data_variables]
117
- user_data_template_path = File.join( Dir.pwd, options[:user_data_template])
117
+
118
+ user_data_template_path = ''
119
+ if options[:user_data_template].include? '/'
120
+ user_data_template_path = options[:user_data_template]
121
+ else
122
+ user_data_template_path = File.join( Dir.pwd, options[:user_data_template])
123
+ end
118
124
 
119
125
  if File.exists?( user_data_template_path )
120
126
  template = File.read( user_data_template_path )
@@ -58,7 +58,13 @@ class BuildCloud::LaunchConfiguration
58
58
  elsif options[:user_data_template]
59
59
 
60
60
  variable_hash = options[:user_data_variables]
61
- user_data_template_path = File.join( Dir.pwd, options[:user_data_template])
61
+
62
+ user_data_template_path = ''
63
+ if options[:user_data_template].include? '/'
64
+ user_data_template_path = options[:user_data_template]
65
+ else
66
+ user_data_template_path = File.join( Dir.pwd, options[:user_data_template])
67
+ end
62
68
 
63
69
  if File.exists?( user_data_template_path )
64
70
  template = File.read( user_data_template_path )
@@ -42,6 +42,14 @@ class BuildCloud::VPC
42
42
 
43
43
  vpc = @compute.vpcs.new( @options )
44
44
  vpc.save
45
+ wait_until_ready
46
+
47
+ if @options[:dhcp_options_set_name]
48
+ dhcp_option_set_id = BuildCloud::DHCPOptionsSet.get_id_by_name( @options[:dhcp_options_set_name] )
49
+ @log.info( "Associating DHCP Options Set #{dhcp_option_set_id} with new VPC ID #{vpc.id}" )
50
+ @compute.associate_dhcp_options( dhcp_option_set_id,
51
+ vpc.id )
52
+ end
45
53
 
46
54
  @log.debug( vpc.inspect )
47
55
 
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.4
4
+ version: 0.0.5
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-09-15 00:00:00.000000000 Z
11
+ date: 2014-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -90,6 +90,7 @@ files:
90
90
  - lib/build-cloud/dbparametergroup.rb
91
91
  - lib/build-cloud/dbparameters.rb
92
92
  - lib/build-cloud/dbsubnetgroup.rb
93
+ - lib/build-cloud/dhcpoptionsset.rb
93
94
  - lib/build-cloud/ebsvolume.rb
94
95
  - lib/build-cloud/iamrole.rb
95
96
  - lib/build-cloud/instance.rb