Class: Wire::DownCommand
- Inherits:
-
UpDownCommand
- Object
- BaseCommand
- UpDownCommand
- Wire::DownCommand
- Defined in:
- lib/wire/commands/down_command.rb
Overview
DownCommand reads yaml, parses model elements and brings all defined model elements “down”, that is stopping and removing bridges, containers etc.
-
:target_dir
Instance Attribute Summary collapse
-
#handler ⇒ Object
readonly
allow to get access to handler object.
Attributes inherited from BaseCommand
Instance Method Summary collapse
-
#initialize ⇒ DownCommand
constructor
initializes DownCommand, creates handler.
-
#run_on_zone(zone_name) ⇒ Object
run in given zone: returns: - bool: true if successful, false otherwise.
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 ⇒ DownCommand
initializes DownCommand, creates handler
18 19 20 21 |
# File 'lib/wire/commands/down_command.rb', line 18 def initialize super @handler = DownCommandHandler.new end |
Instance Attribute Details
#handler ⇒ Object (readonly)
allow to get access to handler object
15 16 17 |
# File 'lib/wire/commands/down_command.rb', line 15 def handler @handler end |
Instance Method Details
#run_on_zone(zone_name) ⇒ Object
run in given zone: returns:
-
bool: true if successful, false otherwise
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 |
# File 'lib/wire/commands/down_command.rb', line 26 def run_on_zone(zone_name) b_result = true networks = @project.get_element('networks') # select appgroups in this zone and take them down first appgroups_in_zone = objects_in_zone('appgroups', zone_name) appgroups_in_zone.each do |appgroup_name, appgroup_data| $log.debug("Processing appgroup \'#{appgroup_name}\'") # process network attachments zone_networks = objects_in_zone('networks', zone_name) success = handler.(zone_name, zone_networks, appgroup_name, appgroup_data, @project.target_dir) b_result &= success # then take down containers success = handler.handle_appgroup(zone_name, appgroup_name, appgroup_data, @project.target_dir) b_result &= success end # 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 down network #{network_name}") # if we have dhcp, unconfigure dnsmasq b_result &= default_handle_dhcp(zone_name, network_name, network_data, @handler) # if we have a host ip on that bridge, take it down first b_result &= default_handle_hostip(network_name, network_data, @handler) # we should have a bridge with that name. success = @handler.handle_bridge(network_name) b_result &= success end b_result end |