Class: BuildCloud

Inherits:
Object
  • Object
show all
Defined in:
lib/build-cloud.rb

Defined Under Namespace

Modules: Component Classes: ASGroup, CacheCluster, CacheParameterGroup, CacheSubnetGroup, DHCPOptionsSet, DbParameterGroup, DbSubnetGroup, EBSVolume, IAMRole, Instance, InternetGateway, LaunchConfiguration, LoadBalancer, NetworkInterface, R53RecordSet, RDSServer, Route, RouteTable, S3Bucket, SecurityGroup, Subnet, VPC, Zone

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ BuildCloud

Returns a new instance of BuildCloud.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/build-cloud.rb', line 14

def initialize( options )

    @log = options[:logger] or Logger.new( STDERR )
    @mock = options[:mock] or false
    
    first_config_file = options[:config].shift

    @config = YAML::load( File.open( first_config_file ) )

    include_files = options[:config]
    if include_yaml = @config.delete(:include)
        if include_yaml.is_a?(Array)
            include_files.concat(include_yaml)
        else
            include_files.push(include_yaml)
        end
    end
    
    include_files.each do |include_file|

        include_path = ''
        if include_file.include? '/'
            include_path = include_file
        else
            include_path = File.join( File.dirname( first_config_file ), include_file)
        end

        if File.exists?( include_path )
            @log.info( "Including YAML file #{include_path}" )
            included_conf = YAML::load( File.open( include_path ) )
            @config = @config.merge( included_conf )
        end

    end

    @log.debug( @config.inspect )

    new_config = recursive_interpolate_config(@config)
    @config = new_config

    @log.debug( @config.inspect )

    connect_fog

    BuildCloud::dispatch.each_pair do |component, klass|

        if @config.has_key?(component)
            klass.load( @config[component], @fog_interfaces, @log )
        end

    end

end

Instance Method Details

#allObject



82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/build-cloud.rb', line 82

def all

    objects = []

    BuildCloud::create_order.each do |component|
        next unless BuildCloud::dispatch.has_key?( component )
        objects.concat BuildCloud::dispatch[component].objects()
    end

    objects

end

#find(component, options) ⇒ Object



72
73
74
75
76
77
78
79
80
# File 'lib/build-cloud.rb', line 72

def find( component, options )

    if BuildCloud::dispatch.has_key?( component )
        BuildCloud::dispatch[component].search(options)
    else
        []
    end

end

#pryObject



68
69
70
# File 'lib/build-cloud.rb', line 68

def pry
    binding.pry
end