From 9761cecdc88300511aa87f18ecfc3c61058f7877 Mon Sep 17 00:00:00 2001 From: ts Date: Fri, 5 Oct 2018 17:26:09 +0100 Subject: [PATCH] ovirt authz now passed as a parameter, added to example.conf --- example.conf | 1 + lib/helpers/ovirt.rb | 11 +++++------ secgen.rb | 3 +++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/example.conf b/example.conf index fc5f84b11..87d6b096b 100644 --- a/example.conf +++ b/example.conf @@ -1,5 +1,6 @@ --ovirtuser test --ovirtpass test --ovirt-url https://test.ac.uk/ +--ovirtauthz @test.ac.uk-authz --ovirt-cluster test --ovirt-network test \ No newline at end of file diff --git a/lib/helpers/ovirt.rb b/lib/helpers/ovirt.rb index 2407de88a..2121c2103 100644 --- a/lib/helpers/ovirt.rb +++ b/lib/helpers/ovirt.rb @@ -6,9 +6,8 @@ require_relative './print.rb' class OVirtFunctions - # TODO supply this as a parameter/option instead - def self.authz - '@aet.leedsbeckett.ac.uk-authz' + def self.authz(options) + options[:ovirtauthz] end # @param [Hash] options -- command-line opts @@ -167,7 +166,7 @@ class OVirtFunctions def self.assign_permissions(options, scenario_path, vm_names) ovirt_connection = get_ovirt_connection(options) username = options[:prefix].chomp - user = get_user(ovirt_connection, username) + user = get_user(options, ovirt_connection, username) if user vms = [] @@ -208,9 +207,9 @@ class OVirtFunctions # @param [String] username # @return [OvirtUser] - def self.get_user(ovirt_connection, username) + def self.get_user(options, ovirt_connection, username) un = username.chomp - search_string = "usrname=#{un}#{authz}" + search_string = "usrname=#{un}#{authz(options)}" puts "Searching for VMs owned by #{un}" user = users_service(ovirt_connection).list(search: search_string).first if user diff --git a/secgen.rb b/secgen.rb index 8225722b6..9d052ba2f 100644 --- a/secgen.rb +++ b/secgen.rb @@ -406,6 +406,9 @@ opts.each do |opt, arg| when '--ovirt-url' Print.info "Ovirt API url : #{arg}" options[:ovirturl] = arg + when '--ovirtauthz' + Print.info "Ovirt Authz: #{arg}" + options[:ovirtauthz] = arg when '--ovirt-cluster' Print.info "Ovirt Cluster : #{arg}" options[:ovirtcluster] = arg