Class: VagrantPlugins::VCloud::Action::PowerOn
- Inherits:
-
Object
- Object
- VagrantPlugins::VCloud::Action::PowerOn
- Defined in:
- lib/vagrant-vcloud/action/power_on.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ PowerOn
constructor
A new instance of PowerOn.
Constructor Details
#initialize(app, env) ⇒ PowerOn
Returns a new instance of PowerOn.
5 6 7 8 |
# File 'lib/vagrant-vcloud/action/power_on.rb', line 5 def initialize(app, env) @app = app @logger = Log4r::Logger.new('vagrant_vcloud::action::power_on') end |
Instance Method Details
#call(env) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/vagrant-vcloud/action/power_on.rb', line 10 def call(env) @env = env cfg = env[:machine].provider_config cnx = cfg.vcloud_cnx.driver vapp_id = env[:machine].get_vapp_id env[:ui].info('Booting VM...') if cfg.network_bridge.nil? test_ip = cnx.get_vapp_edge_public_ip(vapp_id) end poweron_vm = cnx.poweron_vm(env[:machine].id) cnx.wait_task_completion(poweron_vm) if test_ip.nil? && \ cfg.vdc_edge_gateway_ip && \ cfg.vdc_edge_gateway && \ cfg.network_bridge.nil? @logger.debug( 'This is our first boot, we should map ports on the ' \ 'Organization vDC vShield Edge Gateway!' ) ### TMP FIX: tsugliani ### We need to verify the vShield Edge Gateway rules don't already ### exist. ### Removing any rule previously set for that same source IP # ---- if cfg.vdc_edge_gateway_ip && cfg.vdc_edge_gateway env[:ui].info( "Removing NAT rules on [#{cfg.vdc_edge_gateway}] " + "for IP [#{cfg.vdc_edge_gateway_ip}]." ) @logger.debug( 'Cleaning possible conflicting Edge Gateway rules - ' + "Organization vDC id: #{cfg.vdc_id}" ) edge_remove = cnx.remove_edge_gateway_rules( cfg.vdc_edge_gateway, cfg.vdc_id, cfg.vdc_edge_gateway_ip, vapp_id ) cnx.wait_task_completion(edge_remove) end # ---- env[:ui].info( "Creating NAT rules on [#{cfg.vdc_edge_gateway}] " + "for IP [#{cfg.vdc_edge_gateway_ip}]." ) # Set the vShield Edge Gateway rules edge_map = cnx.set_edge_gateway_rules( cfg.vdc_edge_gateway, cfg.vdc_id, cfg.vdc_edge_gateway_ip, vapp_id ) # Wait for task to complete. cnx.wait_task_completion(edge_map) end @app.call(env) end |