Method: BuildCloud::SecurityGroup#create

Defined in:
lib/build-cloud/securitygroup.rb

#createObject



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
67
68
69
70
71
72
73
# File 'lib/build-cloud/securitygroup.rb', line 38

def create

    options = @options.dup

    authorized_ranges = []
    if options[:authorized_ranges]
        authorized_ranges = options[:authorized_ranges]
        options.delete(:authorized_ranges)
    end

    if exists?
        # If exists update tags
        if options[:tags]
            create_tags(options[:tags])
        end
    else

        @log.info( "Creating security group #{@options[:name]}" )

        unless options[:vpc_id]

            options[:vpc_id] = BuildCloud::VPC.get_id_by_name( options[:vpc_name] )
            options.delete(:vpc_name)

        end

        security_group = @compute.security_groups.new( options )
        security_group.save

        @log.debug( security_group.inspect )

    end

    rationalise_rules( authorized_ranges )

end