Class: Wire::VerifyCommandHandler
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- Wire::VerifyCommandHandler
- Defined in:
- lib/wire/commands/verify_command_handler.rb
Overview
handle_xxx methods for VerifyCommand
Instance Attribute Summary
Attributes inherited from BaseCommand
Instance Method Summary collapse
-
#default_handle_resource(resource, resource_type, resource_desc_str) ⇒ Object
asks given
resourceif it is up. -
#handle_appgroup(_zone_name, appgroup_name, appgroup_entry, target_dir) ⇒ Object
runs verification for appgroups Returns - [Bool] true if appgroup setup is ok.
-
#handle_bridge(bridge_name) ⇒ Object
runs verification for a bridge resource identified by
bridge_nameReturns - [Bool] true if bridge exists. -
#handle_dhcp(zone_name, network_name, network_entry, address_start, address_end) ⇒ Object
runs verification for dnsmasqs dhcp resource Returns - [Bool] true if dhcp setup is valid.
-
#handle_hostip(bridge_name, hostip) ⇒ Object
runs verification for a ip resource identified by
bridge_nameandhost_ipReturns - [Bool] true if hostip if up on bridge. -
#handle_network_attachments(_zone_name, networks, appgroup_name, appgroup_entry, target_dir) ⇒ Object
runs verification for container network attachment Params:
_zone_name: Name of zonenetworks: Array of networks names, what to attachappgroup_name: Name of appgroupappgroup_entry: appgroup hashtarget_dir: project target dir Returns - [Bool] true if appgroup setup is ok.
Methods inherited from BaseCommand
#check_user, #dump_state, #ensure_hostip_netmask, #objects_in_zone, #outputs, #run, #state
Instance Method Details
#default_handle_resource(resource, resource_type, resource_desc_str) ⇒ Object
asks given resource if it is up. Writes states, outputs state Params: resource: Resource object, i.e. BridgeResource resource_type: Resource type symbol, i.e. :bridge resource_desc_str: Description to dump out Returns
- Bool
-
true = resource is up, false otherwise
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/wire/commands/verify_command_handler.rb', line 18 def default_handle_resource(resource, resource_type, resource_desc_str) if resource.up? outputs 'VERIFY', "#{resource_desc_str} is up.", :ok state.update(resource_type, resource.name, :up) return true else outputs 'VERIFY', "#{resource_desc_str} is not up.", :err state.update(resource_type, resource.name, :down) return false end end |
#handle_appgroup(_zone_name, appgroup_name, appgroup_entry, target_dir) ⇒ Object
runs verification for appgroups Returns
- Bool
-
true if appgroup setup is ok
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/wire/commands/verify_command_handler.rb', line 64 def handle_appgroup(_zone_name, appgroup_name, appgroup_entry, target_dir) # get path controller_entry = appgroup_entry[:controller] if controller_entry[:type] == 'fig' fig_path = File.join(File.(target_dir), controller_entry[:file]) resource = Wire::Resource::ResourceFactory .instance.create(:figadapter, "#{appgroup_name}", fig_path) return default_handle_resource(resource, :appgroup, "Fig Appgroup \'#{appgroup_name}\'") end $log.error "Appgroup not handled, unknown controller type #{controller_entry[:type]}" false end |
#handle_bridge(bridge_name) ⇒ Object
runs verification for a bridge resource identified by bridge_name Returns
- Bool
-
true if bridge exists
34 35 36 37 |
# File 'lib/wire/commands/verify_command_handler.rb', line 34 def handle_bridge(bridge_name) bridge_resource = Wire::Resource::ResourceFactory.instance.create(:ovsbridge, bridge_name) default_handle_resource(bridge_resource, :bridge, "Bridge \'#{bridge_name}\'") end |
#handle_dhcp(zone_name, network_name, network_entry, address_start, address_end) ⇒ Object
runs verification for dnsmasqs dhcp resource Returns
- Bool
-
true if dhcp setup is valid
53 54 55 56 57 58 59 |
# File 'lib/wire/commands/verify_command_handler.rb', line 53 def handle_dhcp(zone_name, network_name, network_entry, address_start, address_end) resource = Wire::Resource::ResourceFactory .instance.create(:dhcpconfig, "wire__#{zone_name}", network_name, network_entry, address_start, address_end) default_handle_resource(resource, :dnsmasq, "dnsmasq/dhcp config on network \'#{network_name}\'") end |
#handle_hostip(bridge_name, hostip) ⇒ Object
runs verification for a ip resource identified by bridge_name and host_ip Returns
- Bool
-
true if hostip if up on bridge
43 44 45 46 47 48 |
# File 'lib/wire/commands/verify_command_handler.rb', line 43 def handle_hostip(bridge_name, hostip) hostip_resource = Wire::Resource::ResourceFactory .instance.create(:bridgeip, hostip, bridge_name) default_handle_resource(hostip_resource, :hostip, "IP \'#{hostip}\' on bridge \'#{bridge_name}\'") end |
#handle_network_attachments(_zone_name, networks, appgroup_name, appgroup_entry, target_dir) ⇒ Object
runs verification for container network attachment Params: _zone_name: Name of zone networks: Array of networks names, what to attach appgroup_name: Name of appgroup appgroup_entry: appgroup hash target_dir: project target dir Returns
- Bool
-
true if appgroup setup is ok
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/wire/commands/verify_command_handler.rb', line 90 def (_zone_name, networks, appgroup_name, appgroup_entry, target_dir) # query container ids of containers running here # get path controller_entry = appgroup_entry[:controller] container_ids = [] if controller_entry[:type] == 'fig' fig_path = File.join(File.(target_dir), controller_entry[:file]) resource = Wire::Resource::ResourceFactory .instance.create(:figadapter, "#{appgroup_name}", fig_path) container_ids = resource.up_ids || [] $log.debug "Got #{container_ids.size} container id(s) from adapter" end # resource = Wire::Resource::ResourceFactory .instance.create(:networkinjection, appgroup_name, networks, container_ids) default_handle_resource(resource, :network_injection, "Network(s) \'#{networks.keys.join(',')}\' in " \ "appgroup \'#{appgroup_name}\'") end |