Sha256: c06227ed6248e5e69d5c5ecb6d44f8bd8c3c9eb26bbcbcce00ae74e2b2874455

Contents?: true

Size: 1.12 KB

Versions: 2

Compression:

Stored size: 1.12 KB

Contents

require "i18n"

module VagrantPlugins
  module VCloud
    module Action
      class PowerOn
        def initialize(app, env)
          @app = app
          @logger = Log4r::Logger.new("vagrant_vcloud::action::power_on")
        end

        def call(env)
          @env = env


          cfg = env[:machine].provider_config
          cnx = cfg.vcloud_cnx.driver
          vmName = env[:machine].name
          vAppId = env[:machine].get_vapp_id

	      env[:ui].info("Booting VM...")

        testIp = cnx.get_vapp_edge_public_ip(vAppId)

        poweronVM = cnx.poweron_vm(env[:machine].id)
        cnx.wait_task_completion(poweronVM)

        if testIp.nil? && cfg.vdc_edge_gateway_ip && cfg.vdc_edge_gateway
          @logger.debug("This is our first boot, we should map ports on org edge!")

          env[:ui].info("Creating NAT rules on [#{cfg.vdc_edge_gateway}] for IP [#{cfg.vdc_edge_gateway_ip}].")

          edgeMap = cnx.set_edge_gateway_rules(cfg.vdc_edge_gateway, cfg.vdc_id, cfg.vdc_edge_gateway_ip, vAppId)
          cnx.wait_task_completion(edgeMap)
        end




          @app.call(env)
        end
      end
    end
  end
end



Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vagrant-vcloud-0.1.2 lib/vagrant-vcloud/action/power_on.rb
vagrant-vcloud-0.1.1 lib/vagrant-vcloud/action/power_on.rb