def update_minion_data(minion, data)
      unless minion.public_ip.nil? && minion.private_ip.nil? && minion.cloud_id.nil?
        raise("#{minion.machine_name} has previously defined ip address(es) or id, can not change.  As a safety measure, you will need to manually remove any old data")
      end
      if minion.machine.public_ip.nil? || minion.machine.private_ip.nil? || minion.machine.id.nil?
        raise("New public IP address (#{minion.machine.public_ip}) or private IP address (#{minion.machine.private_ip}) or cloud_id (#{minion.machine.id}) are not valid.")
      end


      replacement = "\\1\\2\n\\1public_ip = '#{minion.machine.public_ip}'\n\\1private_ip = '#{minion.machine.private_ip}'\n\\1cloud_id = '#{minion.machine.id}'"
      new_data = data.sub(/( *)(name\s*=\s*['"]#{Regexp.quote(minion.machine_name)}['"])/, replacement)
      raise "Unable to update minion data for #{minion.machine_name}." if data == new_data

      # replacement = "$1$2\n$1public_ip = '#{ip_addresses.public}'\n$1private_ip = '#{ip_addresses.private}'"
      # new_data = data.sub(/( *)(name\s*=\s*['"]staging-lb['"])/) do |match|
      #   "#{$1}#{$2}\n#{$1}public_ip = '#{ip_addresses.public}'\n#{$1}private_ip = '#{ip_addresses.private}'"
      # end
      # puts new_data


      Pvcglue.logger.debug("Updated configuration for machine named #{minion.machine_name}.")
      new_data
    end
def update_minion_data(minion, data)
      unless minion.public_ip.nil? && minion.private_ip.nil? && minion.cloud_id.nil?
        raise("#{minion.machine_name} has previously defined ip address(es) or id, can not change.  As a safety measure, you will need to manually remove any old data")
      end
      if minion.machine.public_ip.nil? || minion.machine.private_ip.nil? || minion.machine.id.nil?
        raise("New public IP address (#{minion.machine.public_ip}) or private IP address (#{minion.machine.private_ip}) or cloud_id (#{minion.machine.id}) are not valid.")
      end


      replacement = "\\1\\2\n\\1public_ip = '#{minion.machine.public_ip}'\n\\1private_ip = '#{minion.machine.private_ip}'\n\\1cloud_id = '#{minion.machine.id}'"
      new_data = data.sub(/( *)(name\s*=\s*['"]#{Regexp.quote(minion.machine_name)}['"])/, replacement)
      raise "Unable to update minion data for #{minion.machine_name}." if data == new_data

      # replacement = "$1$2\n$1public_ip = '#{ip_addresses.public}'\n$1private_ip = '#{ip_addresses.private}'"
      # new_data = data.sub(/( *)(name\s*=\s*['"]staging-lb['"])/) do |match|
      #   "#{$1}#{$2}\n#{$1}public_ip = '#{ip_addresses.public}'\n#{$1}private_ip = '#{ip_addresses.private}'"
      # end
      # puts new_data


      Pvcglue.logger.debug("Updated configuration for machine named #{minion.machine_name}.")
      new_data
    end
def update_minion_data(minion, ip_addresses, cloud_id, data)