lib/security.rb in forj-0.0.18 vs lib/security.rb in forj-0.0.19

- old
+ new

@@ -22,40 +22,32 @@ # create a security group for each blueprint module SecurityGroup def create_security_group(name) - security_groups = Connection.network.security_groups.all({:name => name}) - security_group = nil - - if security_groups.length >= 1 - security_group = security_groups[0] - else - description = 'Security group for blueprint %s' % [name] - security_group = Connection.network.security_groups.create( - :name => name, - :description => description - ) - end - security_group + description = 'Security group for blueprint %s' % [name] + Connection.network.security_groups.create( + :name => name, + :description => description + ) end def delete_security_group(security_group_id) Connection.network.security_groups.get(security_group_id).destroy end def create_security_group_rule(security_group_id, protocol, port_min, port_max) begin - rule = Connection.network.security_group_rules.create( + Connection.network.security_group_rules.create( :security_group_id => security_group_id, :direction => 'ingress', :protocol => protocol, :port_range_min => port_min, :port_range_max => port_max, :remote_ip_prefix => '0.0.0.0/0' ) - rescue StandardError => e + rescue StandardError puts 'error creating the rule for port %s' % [port_min] end end @@ -68,10 +60,10 @@ home = File.expand_path('~') path = home + '/.hpcloud/' + name # this will create a new keypair key_pair = Connection.compute.key_pairs.create(:name => name) key_pair.write(path) - rescue StandardError => e + rescue StandardError puts 'error uploading the keypair' end end end \ No newline at end of file