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

- old
+ new

@@ -1,6 +1,7 @@ #!/usr/bin/env ruby +# encoding: UTF-8 # (c) Copyright 2014 Hewlett-Packard Development Company, L.P. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,16 +18,17 @@ require 'require_relative' require_relative 'connection.rb' include Connection -# create a security group for each blueprint - +# +# SecurityGroup module +# module SecurityGroup def create_security_group(name) - description = 'Security group for blueprint %s' % [name] + description = format('Security group for blueprint %{name}', name: name) Connection.network.security_groups.create( :name => name, :description => description ) end @@ -44,27 +46,13 @@ :port_range_min => port_min, :port_range_max => port_max, :remote_ip_prefix => '0.0.0.0/0' ) rescue StandardError - puts 'error creating the rule for port %s' % [port_min] + puts format('error creating the rule for port %{port_min}', port_min: port_min) end - end def delete_security_group_rule(rule_id) Connection.network.security_group_rules.get(rule_id).destroy end - - def upload_keypair(name) - begin - 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 - puts 'error uploading the keypair' - end - end - -end \ No newline at end of file +end