Class: Wire::UpCommand
- Inherits:
-
UpDownCommand
- Object
- BaseCommand
- UpDownCommand
- Wire::UpCommand
- Defined in:
- lib/wire/commands/up_command.rb
Overview
UpCommand reads yaml, parses model elements and brings all defined model elements “up”, that is starting bridges, containers etc.
Instance Attribute Summary collapse
-
#handler ⇒ Object
readonly
allow to get access to handler object.
Attributes inherited from BaseCommand
Instance Method Summary collapse
-
#initialize ⇒ UpCommand
constructor
initialize.
-
#run_on_zone(zone_name) ⇒ Object
run in given
zone_name: returns: - bool: true if successful, false otherwise rubocop:disable CyclomaticComplexity.
Methods inherited from UpDownCommand
#default_handle_dhcp, #default_handle_hostip, get_networks_for_zone, #run_on_project, #run_on_project_zones
Methods inherited from BaseCommand
#check_user, #default_handle_resource, #dump_state, #ensure_hostip_netmask, #objects_in_zone, #outputs, #run, #state
Constructor Details
#initialize ⇒ UpCommand
initialize
17 18 19 |
# File 'lib/wire/commands/up_command.rb', line 17 def initialize @handler = UpCommandHandler.new end |
Instance Attribute Details
#handler ⇒ Object (readonly)
allow to get access to handler object
14 15 16 |
# File 'lib/wire/commands/up_command.rb', line 14 def handler @handler end |
Instance Method Details
#run_on_zone(zone_name) ⇒ Object
run in given zone_name: returns:
-
bool: true if successful, false otherwise
rubocop:disable CyclomaticComplexity
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 |
# File 'lib/wire/commands/up_command.rb', line 25 def run_on_zone(zone_name) b_result = true networks = @project.get_element('networks') # select networks in current zone only networks_in_zone = UpDownCommand.get_networks_for_zone(networks, zone_name) networks_in_zone.each do |network_name, network_data| $log.debug("Bringing up network #{network_name}") success = @handler.handle_bridge(network_name) b_result &= success if success # if we have a host ip on that bridge, take it down first b_result &= default_handle_hostip(network_name, network_data, @handler) # if we have dhcp, configure dnsmasq b_result &= default_handle_dhcp(zone_name, network_name, network_data, @handler) else $log.debug("Will not touch dependant objects of #{network_name} due to previous error(s)") end end # select appgroups in this zone and bring them up appgroups_in_zone = objects_in_zone('appgroups', zone_name) appgroups_in_zone.each do |appgroup_name, appgroup_data| $log.debug("Processing appgroup \'#{appgroup_name}\'") success = handler.handle_appgroup(zone_name, appgroup_name, appgroup_data, @project.target_dir) b_result &= success # process network attachments zone_networks = objects_in_zone('networks', zone_name) success = handler.(zone_name, zone_networks, appgroup_name, appgroup_data, @project.target_dir, @project.vartmp_dir) b_result &= success end b_result end |