Sha256: 26be96d5f152fa0510b1022edc2d4d53a16f189562a65fbfd08b2e471aff6f61

Contents?: true

Size: 1.24 KB

Versions: 4

Compression:

Stored size: 1.24 KB

Contents

module Vcloud
  module Launcher
    class VmOrchestrator

      def initialize vcloud_vm, vapp
        vm_id = vcloud_vm[:href].split('/').last
        @vm = Core::Vm.new(vm_id, vapp)
      end

      def customize(vm_config)
        @vm.update_name(@vm.vapp_name)
        @vm.configure_network_interfaces vm_config[:network_connections]
        @vm.update_storage_profile(vm_config[:storage_profile]) if vm_config[:storage_profile]
        if vm_config[:hardware_config]
          @vm.update_cpu_count(vm_config[:hardware_config][:cpu])
          @vm.update_memory_size_in_mb(vm_config[:hardware_config][:memory])
        end
        @vm.add_extra_disks(vm_config[:extra_disks])
        @vm.update_metadata(vm_config[:metadata])
        if vm_config.key?(:independent_disks)
          Vcloud::Launcher::IndependentDiskOrchestrator.new(@vm).attach(vm_config.fetch(:independent_disks))
        end

        preamble = vm_config[:bootstrap] ? generate_preamble(vm_config) : ''

        @vm.configure_guest_customization_section(preamble) unless preamble.nil? || preamble.empty?
      end

      private

      def generate_preamble(vm_config)
        preamble = ::Vcloud::Launcher::Preamble.new(@vm.vapp_name, vm_config)
        preamble.generate
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vcloud-launcher-2.1.1 lib/vcloud/launcher/vm_orchestrator.rb
vcloud-launcher-2.1.0 lib/vcloud/launcher/vm_orchestrator.rb
vcloud-launcher-2.0.0 lib/vcloud/launcher/vm_orchestrator.rb
vcloud-launcher-1.1.0 lib/vcloud/launcher/vm_orchestrator.rb