From df8e4ec1703795a4f34bfe66d598ace98238b897 Mon Sep 17 00:00:00 2001 From: David Justice Date: Tue, 2 Dec 2014 09:55:56 -0800 Subject: [PATCH] patch azure so vhd names do not overlap --- lib/vagrant-azure/monkey_patch/azure.rb | 45 +++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 lib/vagrant-azure/monkey_patch/azure.rb diff --git a/lib/vagrant-azure/monkey_patch/azure.rb b/lib/vagrant-azure/monkey_patch/azure.rb new file mode 100644 index 0000000..270aefb --- /dev/null +++ b/lib/vagrant-azure/monkey_patch/azure.rb @@ -0,0 +1,45 @@ + +require 'azure' + +Azure::VirtualMachineManagement::Serialization.module_eval do + def self.role_to_xml(params, options) + builder = Nokogiri::XML::Builder.new do |xml| + xml.PersistentVMRole( + 'xmlns' => 'http://schemas.microsoft.com/windowsazure', + 'xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance' + ) do + xml.RoleName { xml.text params[:vm_name] } + xml.OsVersion('i:nil' => 'true') + xml.RoleType 'PersistentVMRole' + + xml.ConfigurationSets do + provisioning_configuration_to_xml(xml, params, options) + xml.ConfigurationSet('i:type' => 'NetworkConfigurationSet') do + xml.ConfigurationSetType 'NetworkConfiguration' + xml.InputEndpoints do + default_endpoints_to_xml(xml, options) + tcp_endpoints_to_xml( + xml, + options[:tcp_endpoints], + options[:existing_ports] + ) if options[:tcp_endpoints] + end + if options[:virtual_network_name] && options[:subnet_name] + xml.SubnetNames do + xml.SubnetName options[:subnet_name] + end + end + end + end + xml.AvailabilitySetName options[:availability_set_name] + xml.Label Base64.encode64(params[:vm_name]).strip + xml.OSVirtualHardDisk do + xml.MediaLink 'http://' + options[:storage_account_name] + '.blob.core.windows.net/vhds/' + (Time.now.strftime('disk_%Y_%m_%d_%H_%M_%S_%L')) + '.vhd' + xml.SourceImageName params[:image] + end + xml.RoleSize options[:vm_size] + end + end + builder.doc + end +end \ No newline at end of file