diff --git a/src/host/Host.cc b/src/host/Host.cc index 17187acd4d..1dc1e75b45 100644 --- a/src/host/Host.cc +++ b/src/host/Host.cc @@ -726,6 +726,9 @@ int Host::post_update_template(string& error) string ec2_access; string ec2_secret; + string az_id; + string az_cert; + string crypted; get_template_attribute("VCENTER_PASSWORD", vcenter_password); @@ -755,6 +758,22 @@ int Host::post_update_template(string& error) replace_template_attribute("EC2_SECRET", crypted); } + get_template_attribute("AZ_ID", az_id); + + if (!az_id.empty()) + { + nebula_crypt(az_id, crypted); + replace_template_attribute("AZ_ID", crypted); + } + + get_template_attribute("AZ_CERT", az_cert); + + if (!az_cert.empty()) + { + nebula_crypt(az_cert, crypted); + replace_template_attribute("AZ_CERT", crypted); + } + get_template_attribute("IM_MAD", new_im_mad); get_template_attribute("VM_MAD", new_vm_mad); diff --git a/src/vmm_mad/remotes/az/az_driver.rb b/src/vmm_mad/remotes/az/az_driver.rb index 62c8326347..4122f8b2ad 100755 --- a/src/vmm_mad/remotes/az/az_driver.rb +++ b/src/vmm_mad/remotes/az/az_driver.rb @@ -136,6 +136,7 @@ class AzureDriver # Azure constructor, loads credentials and endpoint def initialize(host) @host = host + @to_inst ={} @public_cloud_az_conf = YAML::load(File.read(AZ_DRIVER_CONF)) @@ -144,6 +145,9 @@ class AzureDriver end @instance_types = @public_cloud_az_conf['instance_types'] + @instance_types.keys.each{ |key| + @to_inst[key.upcase] = key + } certificate = Tempfile.new("certificate") conn_opts = get_connect_info(host) @@ -158,7 +162,6 @@ class AzureDriver #DEPRECATE ############################################################# regions = @public_cloud_az_conf['regions'] - @region = regions[host] || regions["default"] # Sanitize region data if certificate.nil? @@ -211,7 +214,7 @@ class AzureDriver :cert => xmlhost["TEMPLATE/AZ_CERT"], :id => xmlhost["TEMPLATE/AZ_ID"] } - conn_opts = OpenNebula.encrypt(conn_opts, token) + #conn_opts = OpenNebula.encrypt(conn_opts, token) conn_opts = OpenNebula.decrypt(conn_opts, token) conn_opts[:region] = xmlhost["TEMPLATE/REGION_NAME"] @@ -372,9 +375,10 @@ private # Get the associated capacity of the instance_type as cpu (in 100 percent # e.g. 800 for 8 cores) and memory (in KB) def instance_type_capacity(name) - return 0, 0 if @instance_types[name].nil? - return (@instance_types[name]['cpu'].to_f * 100).to_i , - (@instance_types[name]['memory'].to_f * 1024 * 1024).to_i + resource = @instance_types[@to_inst[name]] || @instance_types[name] + return 0, 0 if resource.nil? + return (resource['cpu'].to_f * 100).to_i , + (resource['memory'].to_f * 1024 * 1024).to_i end # Get the Azure section of the template. If more than one Azure section @@ -389,6 +393,7 @@ private # First, let's see if we have an Azure location that matches # our host name all_az_elements.each { |element| + cloud_host = element.elements["LOCATION"] type = element.elements["TYPE"].text