Module: Staypuft::Concerns::HostInterfaceManagement
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/staypuft/concerns/host_interface_management.rb
Instance Method Summary collapse
- #build_vips(parameters) ⇒ Object
- #clean_vlan_interfaces ⇒ Object
- #interfaces_identifiers ⇒ Object
- #make_all_interfaces_managed ⇒ Object
- #network_query ⇒ Object
Instance Method Details
#build_vips(parameters) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/models/staypuft/concerns/host_interface_management.rb', line 27 def build_vips(parameters) deployment = self.hostgroup.deployment typings = deployment.subnet_typings types = SubnetType.where(:name => parameters.values).all n = 0 parameters.each do |parameter, subnet_type| type = types.find { |t| t.name == subnet_type } raise "unable to find subnet type with name #{subnet_type}" if type.nil? subnet = typings.where(:subnet_type_id => type.id).first.subnet raise "unable to find subnet assigned to type #{subnet_type} in deployment #{deployment.name}" if subnet.nil? interface = self.interfaces.build(:type => 'Nic::Managed') interface.identifier = "vip#{n}" interface.subnet = subnet interface.managed = false interface.mac = "00:00:00:00:00:#{n.to_s(16).rjust(2, '0')}" interface.tag = parameter n += 1 end end |
#clean_vlan_interfaces ⇒ Object
10 11 12 |
# File 'app/models/staypuft/concerns/host_interface_management.rb', line 10 def clean_vlan_interfaces self.interfaces.virtual.map(&:destroy) end |
#interfaces_identifiers ⇒ Object
14 15 16 17 18 |
# File 'app/models/staypuft/concerns/host_interface_management.rb', line 14 def interfaces_identifiers interfaces = [ self.primary_interface ] interfaces += self.respond_to?(:interfaces) ? self.interfaces.where("type <> 'Nic::BMC'").non_vip.physical.map(&:identifier) : [] interfaces end |
#make_all_interfaces_managed ⇒ Object
20 21 22 23 24 25 |
# File 'app/models/staypuft/concerns/host_interface_management.rb', line 20 def make_all_interfaces_managed self.interfaces.non_vip.each do |interface| interface.managed = true interface.save! end end |
#network_query ⇒ Object
50 51 52 |
# File 'app/models/staypuft/concerns/host_interface_management.rb', line 50 def network_query @network_query || NetworkQuery.new(self.hostgroup.deployment, self) end |