From 1a3de82cabbe02f24bc66f888bc94621da50d14f Mon Sep 17 00:00:00 2001 From: semedi Date: Wed, 5 Jul 2017 16:30:25 +0200 Subject: [PATCH] F #5189 az_driver ask for CERTIFICATE ATT --- src/cli/one_helper/onehost_helper.rb | 23 ++++++++++++++++++ src/vmm_mad/remotes/az/az_driver.rb | 35 +++++++++++++++++++++++++++- 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/src/cli/one_helper/onehost_helper.rb b/src/cli/one_helper/onehost_helper.rb index 4efc658899..c60d8b2d83 100644 --- a/src/cli/one_helper/onehost_helper.rb +++ b/src/cli/one_helper/onehost_helper.rb @@ -42,6 +42,29 @@ class OneHostHelper < OpenNebulaHelper::OneHelper # #----------------------------------------------------------------------- EOT + }, + :az => { + :help => <<-EOT.unindent, + #----------------------------------------------------------------------- + # Supported AZURE AUTH ATTRIBUTTES: + # + # CERTIFICATE = + # + # + # + # + # + # + # + # + # + # + # + # + # + # + #----------------------------------------------------------------------- + EOT } } diff --git a/src/vmm_mad/remotes/az/az_driver.rb b/src/vmm_mad/remotes/az/az_driver.rb index 896186f79d..80cbfb022d 100755 --- a/src/vmm_mad/remotes/az/az_driver.rb +++ b/src/vmm_mad/remotes/az/az_driver.rb @@ -33,6 +33,7 @@ require 'yaml' require 'rubygems' require 'azure' require 'uri' +require 'tempfile' $: << RUBY_LIB_LOCATION @@ -161,15 +162,47 @@ class AzureDriver @region['management_endpoint']="https://management.core.windows.net" end + file = Tempfile.new("certificate") + file << get_connect_info(host) + file.close + Azure.configure do |config| - config.management_certificate = @region['pem_management_cert'] + config.management_certificate = file.path config.subscription_id = @region['subscription_id'] config.management_endpoint = @region['management_endpoint'] end + file.unlink # deletes the temp file + + @azure_vms = Azure::VirtualMachineManagementService.new end + def get_connect_info(host) + conn_opts={} + client = OpenNebula::Client.new + + pool = OpenNebula::HostPool.new(OpenNebula::Client.new) + pool.info + objects=pool.select {|object| object.name==host } + xmlhost = objects.first + + system = OpenNebula::System.new(client) + config = system.get_configuration + if OpenNebula.is_error?(config) + puts "Error getting oned configuration : #{config.message}" + exit -1 + end + token = config["ONE_KEY"] + + conn_opts = { + :cert => xmlhost["TEMPLATE/CERTIFICATE"] + } + + return xmlhost["TEMPLATE/CERTIFICATE"]#gsub(/ñ/,"\n") + + end + # DEPLOY action def deploy(id, host, xml_text, lcm_state, deploy_id) if lcm_state == "BOOT" || lcm_state == "BOOT_FAILURE"