lib/process/cloud/process/keypairs.rb in lorj_cloud-0.1.0 vs lib/process/cloud/process/keypairs.rb in lorj_cloud-0.1.1
- old
+ new
@@ -37,11 +37,11 @@
# - :public_key_file : String. Path to local public key file
# - :public_key : String. Public key content. (config[:public_key] is
# also set - Used to import it)
#
def forj_get_or_create_keypair(sCloudObj, hParams)
- keypair_name = hParams[:keypair_name]
+ keypair_name = hParams['credentials#keypair_name']
PrcLib.state("Searching for keypair '%s'", keypair_name)
keypair = forj_get_keypair(sCloudObj, keypair_name, hParams)
if keypair.empty?
loc_kpair = keypair_detect(keypair_name, hParams[:keypair_path],
@@ -100,11 +100,11 @@
:get_e => :forj_get_keypair
# :delete_e => :forj_delete_keypair
)
obj_needs :CloudObject, :compute_connection
- obj_needs :data, :keypair_name, :for => [:create_e]
+ obj_needs :data, 'credentials#keypair_name', :for => [:create_e]
obj_needs :data, :keypair_path
obj_needs :data, :keypair_base
# By default optional. But required by the import case if needed.
obj_needs_optional
@@ -172,22 +172,24 @@
keypair[:coherent] = coherent_keypair?(loc_kpair, keypair)
end
def keypair_import(hParams, loc_kpair)
PrcLib.fatal(1, "Unable to import keypair '%s'. "\
- 'Public key file is not found. '\
+ "Public key file '%s' is not found. "\
"Please run 'forj setup %s'",
- hParams[:keypair_name],
+ hParams['credentials#keypair_name'],
+ File.join(loc_kpair[:keypair_path],
+ loc_kpair[:public_key_name]),
config[:account_name]) unless loc_kpair[:public_key_exist?]
public_key_file = File.join(loc_kpair[:keypair_path],
loc_kpair[:public_key_name])
begin
public_key = File.read(public_key_file)
rescue => e
PrcLib.fatal(1, "Unable to import keypair '%s'. '%s' is "\
- "unreadable.\n%s", hParams[:keypair_name],
+ "unreadable.\n%s", hParams['credentials#keypair_name'],
loc_kpair[:public_key_file],
e.message)
end
keypair = create_keypair(:keypairs, :public_key => public_key)
@@ -198,11 +200,11 @@
keypair
end
def create_keypair(sCloudObj, hParams)
- key_name = hParams[:keypair_name]
+ key_name = hParams['credentials#keypair_name']
PrcLib.state("Importing keypair '%s'", key_name)
ssl_error_obj = SSLErrorMgt.new
begin
keypair = controller_create(sCloudObj, hParams)
PrcLib.info("Keypair '%s' imported.", keypair[:name])
@@ -272,10 +274,10 @@
end
[found_ext, files]
end
def get_keypairs_path(hParams, hKeys)
- keypair_name = hParams[:keypair_name]
+ keypair_name = hParams['credentials#keypair_name']
if hKeys[:private_key_exist?]
hParams[:private_key_file] = File.join(hKeys[:keypair_path],
hKeys[:private_key_name])
PrcLib.info("Openssh private key file '%s' exists.",