Class: Staypuft::NetworkQuery

Inherits:
Object
  • Object
show all
Defined in:
app/lib/staypuft/network_query.rb

Defined Under Namespace

Classes: Jail

Constant Summary collapse

VIP_NAMES =
{
  :ceilometer_admin_vip   => Staypuft::SubnetType::ADMIN_API,
  :ceilometer_private_vip => Staypuft::SubnetType::MANAGEMENT,
  :ceilometer_public_vip  => Staypuft::SubnetType::PUBLIC_API,
  :cinder_admin_vip       => Staypuft::SubnetType::ADMIN_API,
  :cinder_private_vip     => Staypuft::SubnetType::MANAGEMENT,
  :cinder_public_vip      => Staypuft::SubnetType::PUBLIC_API,
  :db_vip                 => Staypuft::SubnetType::MANAGEMENT,
  :glance_admin_vip       => Staypuft::SubnetType::ADMIN_API,
  :glance_private_vip     => Staypuft::SubnetType::MANAGEMENT,
  :glance_public_vip      => Staypuft::SubnetType::PUBLIC_API,
  :heat_admin_vip         => Staypuft::SubnetType::ADMIN_API,
  :heat_private_vip       => Staypuft::SubnetType::MANAGEMENT,
  :heat_public_vip        => Staypuft::SubnetType::PUBLIC_API,
  :heat_cfn_admin_vip     => Staypuft::SubnetType::ADMIN_API,
  :heat_cfn_private_vip   => Staypuft::SubnetType::MANAGEMENT,
  :heat_cfn_public_vip    => Staypuft::SubnetType::PUBLIC_API,
  :horizon_admin_vip      => Staypuft::SubnetType::ADMIN_API,
  :horizon_private_vip    => Staypuft::SubnetType::MANAGEMENT,
  :horizon_public_vip     => Staypuft::SubnetType::PUBLIC_API,
  :keystone_admin_vip     => Staypuft::SubnetType::ADMIN_API,
  :keystone_private_vip   => Staypuft::SubnetType::MANAGEMENT,
  :keystone_public_vip    => Staypuft::SubnetType::PUBLIC_API,
  :loadbalancer_vip       => Staypuft::SubnetType::PUBLIC_API,
  :neutron_admin_vip      => Staypuft::SubnetType::ADMIN_API,
  :neutron_private_vip    => Staypuft::SubnetType::MANAGEMENT,
  :neutron_public_vip     => Staypuft::SubnetType::PUBLIC_API,
  :nova_admin_vip         => Staypuft::SubnetType::ADMIN_API,
  :nova_private_vip       => Staypuft::SubnetType::MANAGEMENT,
  :nova_public_vip        => Staypuft::SubnetType::PUBLIC_API,
  :amqp_vip               => Staypuft::SubnetType::MANAGEMENT,
  :swift_public_vip       => Staypuft::SubnetType::PUBLIC_API,
  :keystone_private_vip   => Staypuft::SubnetType::MANAGEMENT
}
COUNT =
VIP_NAMES.size

Instance Method Summary collapse

Constructor Details

#initialize(deployment, host = nil) ⇒ NetworkQuery

Returns a new instance of NetworkQuery.



40
41
42
43
# File 'app/lib/staypuft/network_query.rb', line 40

def initialize(deployment, host=nil)
  @deployment = deployment
  @host       = host
end

Instance Method Details

#controller_fqdnsObject



90
91
92
# File 'app/lib/staypuft/network_query.rb', line 90

def controller_fqdns
  controllers.map &:fqdn
end

#controller_ips(subnet_type_name) ⇒ Object



86
87
88
# File 'app/lib/staypuft/network_query.rb', line 86

def controller_ips(subnet_type_name)
  controllers.map { |controller| ip_for_host(subnet_type_name, controller) }
end

#controller_lb_backend_shortnamesObject



98
99
100
101
102
# File 'app/lib/staypuft/network_query.rb', line 98

def controller_lb_backend_shortnames
  controllers.map do |controller|
    "lb-backend-"+controller.shortname
  end
end

#controller_pcmk_shortnamesObject



104
105
106
107
108
# File 'app/lib/staypuft/network_query.rb', line 104

def controller_pcmk_shortnames
  controllers.map do |controller|
    "pcmk-"+controller.shortname
  end
end

#controller_shortnamesObject



94
95
96
# File 'app/lib/staypuft/network_query.rb', line 94

def controller_shortnames
  controllers.map &:shortname
end

#controllersObject



82
83
84
# File 'app/lib/staypuft/network_query.rb', line 82

def controllers
  @controllers ||= @deployment.controller_hostgroup.hosts.order(:id)
end

#gateway_interface(host = @host) ⇒ Object



74
75
76
# File 'app/lib/staypuft/network_query.rb', line 74

def gateway_interface(host=@host)
  gateway_hash_for_host(host)[:interface]
end

#gateway_interface_mac(host = @host) ⇒ Object



78
79
80
# File 'app/lib/staypuft/network_query.rb', line 78

def gateway_interface_mac(host=@host)
  gateway_hash_for_host(host)[:mac]
end

#gateway_subnet(host = @host) ⇒ Object



70
71
72
# File 'app/lib/staypuft/network_query.rb', line 70

def gateway_subnet(host=@host)
  gateway_hash_for_host(host)[:subnet]
end

#get_vip(vip_name) ⇒ Object



110
111
112
113
114
115
# File 'app/lib/staypuft/network_query.rb', line 110

def get_vip(vip_name)
  if VIP_NAMES[vip_name]
    interface = @deployment.vip_nics.where(:tag => vip_name).first
    interface.ip if interface
  end
end

#interface_for_host(subnet_type_name, host = @host) ⇒ Object



49
50
51
# File 'app/lib/staypuft/network_query.rb', line 49

def interface_for_host(subnet_type_name, host=@host)
  interface_hash_for_host(subnet_type_name, host)[:interface]
end

#ip_for_host(subnet_type_name, host = @host) ⇒ Object



45
46
47
# File 'app/lib/staypuft/network_query.rb', line 45

def ip_for_host(subnet_type_name, host=@host)
  interface_hash_for_host(subnet_type_name, host)[:ip]
end

#mtu_for_tenant_subnetObject



62
63
64
# File 'app/lib/staypuft/network_query.rb', line 62

def mtu_for_tenant_subnet
  mtu = @deployment.neutron_networking? ? @deployment.neutron.network_device_mtu : @deployment.nova.network_device_mtu
end

#network_address_for_host(subnet_type_name, host = @host) ⇒ Object



53
54
55
56
# File 'app/lib/staypuft/network_query.rb', line 53

def network_address_for_host(subnet_type_name, host=@host)
  subnet = subnet_for_host(subnet_type_name, host)
  subnet.network_address if subnet
end

#subnet_for_host(subnet_type_name, host = @host) ⇒ Object



58
59
60
# File 'app/lib/staypuft/network_query.rb', line 58

def subnet_for_host(subnet_type_name, host=@host)
  interface_hash_for_host(subnet_type_name, host)[:subnet]
end

#tenant_subnet?(subnet, host = @host) ⇒ Boolean

Returns:

  • (Boolean)


66
67
68
# File 'app/lib/staypuft/network_query.rb', line 66

def tenant_subnet?(subnet, host=@host)
  subnet == subnet_for_host(Staypuft::SubnetType::TENANT, host)
end