Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module KIR
- module Validation
- class AttachedDevicePrimaryIPCheck
- def self.make(validator)
- new(validator.device.network_environment)
- end
- def initialize(environment)
- @environment = environment
- end
- def run
- 'the following attached devices are missing primary ip #{attached_device_ids.map(&:number).join(",")}' unless attached_device_with_no_primary.present?
- end
- # private
- def attached_device_with_no_primary
- @environment.network_devices.reject do |d|
- d.ip_addresses.any? { |ip| ip.is_primary? }
- end
- end
- def attached_device_ids
- attached_device_with_no_primary.map {|d| d.id} unless attached_device_with_no_primary.present?
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment