Skip to content

Commit

Permalink
F #19: check one auth prior to major actions
Browse files Browse the repository at this point in the history
Signed-off-by: Neal Hansen <[email protected]>
  • Loading branch information
onenhansen committed Jun 25, 2024
1 parent f03f0b6 commit 8efe6d8
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions oneswap_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,14 @@ def format_list
end
end

def check_one_connectivity
user = OpenNebula::User.new_with_id(OpenNebula::User::SELF, @client)
rc = user.info
if rc.class == OpenNebula::Error
raise 'Failed to get User info, indicating authentication failed'
end
end

def cleanup_passwords
puts "Deleting password files."
File.delete("#{@options[:work_dir]}/vpassfile")
Expand Down Expand Up @@ -1479,6 +1487,7 @@ def add_one_nics(vm_template, vc_nics, vc_nic_backing)
# @param options [Hash] User CLI options
# @param object [Hash] Object Type
def list(options)
check_one_connectivity
case options[:object]
when 'datacenters'
list_datacenters(options)
Expand All @@ -1496,6 +1505,7 @@ def list(options)
# @param name [Hash] Object Name
# @param options [Hash] User CLI options
def convert(name, options)
check_one_connectivity
if !Dir.exist?(options[:work_dir])
raise 'Provided working directory '\
"#{options[:work_dir]} doesn't exist"
Expand Down

0 comments on commit 8efe6d8

Please sign in to comment.