lib/setup.rb in forj-0.0.18 vs lib/setup.rb in forj-0.0.19
- old
+ new
@@ -14,93 +14,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
module Setup
def setup
- create_dir
- create_credentials_file
-
- file = get_credentials_file
- template = YAML.load_file(file)
-
- # access key
- begin
- access_key = template['default']['access_key']
- rescue
- puts 'which access key to use'
- access_key = $stdin.gets.chomp
- save_to_credentials_file('access_key', access_key)
- end
-
- # secret key
- begin
- secret_key = template['default']['secret_key']
- rescue
- puts 'which secret_key key to use'
- secret_key = $stdin.gets.chomp
- save_to_credentials_file('secret_key', secret_key)
- end
-
- # auth uri
- begin
- auth_uri = template['default']['auth_uri']
- rescue
- puts 'which auth url to use'
- auth_uri = $stdin.gets.chomp
- save_to_credentials_file('auth_uri', auth_uri)
- end
-
- # tenant id
- begin
- tenant_id = template['default']['tenant_id']
- rescue
- puts 'which tenant id to use'
- tenant_id = $stdin.gets.chomp
- save_to_credentials_file('tenant_id', tenant_id)
- end
-
- # availability zone
- begin
- availability_zone = template['default']['availability_zone']
- rescue
- puts 'which availability zone to use'
- availability_zone = $stdin.gets.chomp
- save_to_credentials_file('availability_zone', availability_zone)
- end
-
+ Kernel.system('hpcloud account:setup')
+ Kernel.system('hpcloud keypairs:add nova')
end
end
-
-def create_credentials_file
- home = File.expand_path('~')
- file = home + '/.hpcloud/.hpcloud'
-
- unless File.file?(file)
- File.open(file, 'w') do |f|
- f.write('default:' + "\n")
- end
- end
-end
-
-
-def create_dir
- home = File.expand_path('~')
- path = home + '/.hpcloud'
- unless File.directory?(path) do
- Dir.mkdir(path)
- end
- end
-end
-
-def get_credentials_file
- home = File.expand_path('~')
- file = home + '/.hpcloud/.hpcloud'
-end
-
-def save_to_credentials_file(key, value)
- home = File.expand_path('~')
- file = home + '/.hpcloud/.hpcloud'
-
- File.open(file, 'a') do |f|
- f.write(' ' + key + ': ' + value + "\n")
- end
-end
\ No newline at end of file