Class: Staypuft::Deployment::NeutronService

Inherits:
AbstractParamScope show all
Defined in:
app/models/staypuft/deployment/neutron_service.rb

Defined Under Namespace

Modules: NetworkSegmentation, TenantVlanRanges Classes: Jail, NeutronVlanRangesValidator

Constant Summary collapse

SEGMENTATION_LIST =
['vxlan', 'vlan', 'gre', 'flat']
VLAN_HELP =
N_('[1-4094] (e.g. 10:15)')

Instance Attribute Summary

Attributes inherited from AbstractParamScope

#deployment

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractParamScope

#attributes=, #hostgroup, #initialize, #marked_for_destruction?

Methods included from AttributeParamStorage

#param_attr, #param_attr_array, #param_scope

Constructor Details

This class inherits a constructor from Staypuft::Deployment::AbstractParamScope

Class Method Details

.param_scopeObject



3
4
5
# File 'app/models/staypuft/deployment/neutron_service.rb', line 3

def self.param_scope
  'neutron'
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'app/models/staypuft/deployment/neutron_service.rb', line 51

def active?
  deployment.networking == Deployment::Networking::NEUTRON
end

#compute_ovs_bridge_mappings(host) ⇒ Object



69
70
71
# File 'app/models/staypuft/deployment/neutron_service.rb', line 69

def compute_ovs_bridge_mappings(host)
  [*("physnet-tenants:br-#{tenant_iface(host)}" if !enable_tunneling?)]
end


73
74
75
# File 'app/models/staypuft/deployment/neutron_service.rb', line 73

def compute_ovs_bridge_uplinks(host)
  [*("br-#{tenant_iface(host)}:#{tenant_iface(host)}" if !enable_tunneling?)]
end

#compute_vlan_rangesObject



77
78
79
# File 'app/models/staypuft/deployment/neutron_service.rb', line 77

def compute_vlan_ranges
  [*("physnet-tenants:#{tenant_vlan_ranges}" if vlan_segmentation?)]
end

#enable_tunneling?Boolean

Returns:

  • (Boolean)


89
90
91
# File 'app/models/staypuft/deployment/neutron_service.rb', line 89

def enable_tunneling?
  [NetworkSegmentation::VXLAN, NetworkSegmentation::GRE].include?(network_segmentation)
end

#external_interface_name(host) ⇒ Object



97
98
99
# File 'app/models/staypuft/deployment/neutron_service.rb', line 97

def external_interface_name(host)
  deployment.network_query.interface_for_host(Staypuft::SubnetType::EXTERNAL, host)
end

#network_segmentation_listObject

return list of supported segmentation options with selected option at the beginning of the list



57
58
59
# File 'app/models/staypuft/deployment/neutron_service.rb', line 57

def network_segmentation_list
  [network_segmentation, *(SEGMENTATION_LIST - [network_segmentation])]
end

#networker_ovs_bridge_mappings(host) ⇒ Object



61
62
63
# File 'app/models/staypuft/deployment/neutron_service.rb', line 61

def networker_ovs_bridge_mappings(host)
  compute_ovs_bridge_mappings(host) + [*('physnet-external:br-ex' if external_interface_name(host))]
end


65
66
67
# File 'app/models/staypuft/deployment/neutron_service.rb', line 65

def networker_ovs_bridge_uplinks(host)
  compute_ovs_bridge_uplinks(host) + [*("br-ex:#{external_interface_name(host)}" if external_interface_name(host))]
end

#networker_vlan_rangesObject



81
82
83
# File 'app/models/staypuft/deployment/neutron_service.rb', line 81

def networker_vlan_ranges
  compute_vlan_ranges << "physnet-external"
end

#ovs_tunnel_typesObject



101
102
103
104
105
106
107
108
109
110
# File 'app/models/staypuft/deployment/neutron_service.rb', line 101

def ovs_tunnel_types
  case network_segmentation
  when NetworkSegmentation::VXLAN
    ['vxlan']
  when NetworkSegmentation::GRE
    ['gre']
  else
    []
  end
end

#param_hashObject



112
113
114
115
# File 'app/models/staypuft/deployment/neutron_service.rb', line 112

def param_hash
  { 'network_segmentation'       => network_segmentation,
    'tenant_vlan_ranges'         => tenant_vlan_ranges }
end

#set_defaultsObject



47
48
49
# File 'app/models/staypuft/deployment/neutron_service.rb', line 47

def set_defaults
  self.network_segmentation   = NetworkSegmentation::VXLAN
end

#tenant_iface(host) ⇒ Object



93
94
95
# File 'app/models/staypuft/deployment/neutron_service.rb', line 93

def tenant_iface(host)
  deployment.network_query.interface_for_host(Staypuft::SubnetType::TENANT, host)
end

#vlan_segmentation?Boolean

Returns:

  • (Boolean)


85
86
87
# File 'app/models/staypuft/deployment/neutron_service.rb', line 85

def vlan_segmentation?
  network_segmentation == NetworkSegmentation::VLAN
end