Class: Staypuft::Deployment::NeutronService

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

Defined Under Namespace

Modules: CorePlugin, Ml2Mechanisms, Mtu, NetworkSegmentation, TenantVlanRanges Classes: Cisconexus, Jail, N1kvIpAddressValidator, NeutronVlanRangesValidator

Constant Summary collapse

SEGMENTATION_LIST =
['vxlan', 'vlan', 'gre']
VLAN_HELP =
N_('[1-4094] (e.g. 10:15)')
ML2MECHANISM_TYPES =
:ml2_openvswitch, :ml2_l2population, :ml2_cisco_nexus, :ml2_cisco_n1kv
N1KV_PARAMS =
:n1kv_vsm_ip, :n1kv_vsm_password

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)


121
122
123
# File 'app/models/staypuft/deployment/neutron_service.rb', line 121

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

#cisco_n1kv_mechanism?Boolean

Returns:

  • (Boolean)


194
195
196
# File 'app/models/staypuft/deployment/neutron_service.rb', line 194

def cisco_n1kv_mechanism?
  self.ml2_cisco_n1kv == "true"
end

#cisco_nexus_mechanism?Boolean

Returns:

  • (Boolean)


190
191
192
# File 'app/models/staypuft/deployment/neutron_service.rb', line 190

def cisco_nexus_mechanism?
  self.ml2_cisco_nexus == "true"
end

#compute_cisco_nexus_configObject



210
211
212
# File 'app/models/staypuft/deployment/neutron_service.rb', line 210

def compute_cisco_nexus_config
  Hash[nexuses.map { |nexus| [nexus.hostname, nexus.config_hash] }]
end

#compute_network_device_mtuObject



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

def compute_network_device_mtu
  # Note: This should only be used for setting the puppet params, not for the
  # physical interfaces
  (self.enable_tunneling? && self.network_device_mtu.present?) ? "#{self.network_device_mtu.to_i - 50}" : self.network_device_mtu
end

#compute_ovs_bridge_mappings(host) ⇒ Object



139
140
141
# File 'app/models/staypuft/deployment/neutron_service.rb', line 139

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


143
144
145
# File 'app/models/staypuft/deployment/neutron_service.rb', line 143

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

#compute_vlan_rangesObject



147
148
149
# File 'app/models/staypuft/deployment/neutron_service.rb', line 147

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

#core_plugin_moduleObject



206
207
208
# File 'app/models/staypuft/deployment/neutron_service.rb', line 206

def core_plugin_module
  CorePlugin::MODULES[self.core_plugin]
end

#enable_tunneling?Boolean

Returns:

  • (Boolean)


159
160
161
# File 'app/models/staypuft/deployment/neutron_service.rb', line 159

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

#external_interface_name(host) ⇒ Object



167
168
169
# File 'app/models/staypuft/deployment/neutron_service.rb', line 167

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

#l2population_mechanism?Boolean

Returns:

  • (Boolean)


186
187
188
# File 'app/models/staypuft/deployment/neutron_service.rb', line 186

def l2population_mechanism?
  self.ml2_l2population == "true"
end

#l3_haObject



218
219
220
# File 'app/models/staypuft/deployment/neutron_service.rb', line 218

def l3_ha
  (deployment.network_query.controllers.size > 1) && !l2population_mechanism?
end

#ml2_mechanismsObject



214
215
216
# File 'app/models/staypuft/deployment/neutron_service.rb', line 214

def ml2_mechanisms
  Ml2Mechanisms::TYPES.map { |ml2_type| ml2_type if self.send("#{ml2_type}_mechanism?") }.compact
end

#ml2_plugin?Boolean

Returns:

  • (Boolean)


198
199
200
# File 'app/models/staypuft/deployment/neutron_service.rb', line 198

def ml2_plugin?
  self.core_plugin == CorePlugin::ML2
end

#n1kv_plugin?Boolean

Returns:

  • (Boolean)


202
203
204
# File 'app/models/staypuft/deployment/neutron_service.rb', line 202

def n1kv_plugin?
  self.core_plugin == CorePlugin::N1KV
end

#network_segmentation_listObject

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



127
128
129
# File 'app/models/staypuft/deployment/neutron_service.rb', line 127

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

#networker_ovs_bridge_mappings(host) ⇒ Object



131
132
133
# File 'app/models/staypuft/deployment/neutron_service.rb', line 131

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


135
136
137
# File 'app/models/staypuft/deployment/neutron_service.rb', line 135

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



151
152
153
# File 'app/models/staypuft/deployment/neutron_service.rb', line 151

def networker_vlan_ranges
  compute_vlan_ranges << "physnet-external"
end

#openvswitch_mechanism?Boolean

Returns:

  • (Boolean)


182
183
184
# File 'app/models/staypuft/deployment/neutron_service.rb', line 182

def openvswitch_mechanism?
  self.ml2_openvswitch == "true"
end

#ovs_tunnel_typesObject



171
172
173
174
175
176
177
178
179
180
# File 'app/models/staypuft/deployment/neutron_service.rb', line 171

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

#param_hashObject



222
223
224
225
226
227
228
229
230
231
232
233
# File 'app/models/staypuft/deployment/neutron_service.rb', line 222

def param_hash
  { 'network_segmentation'       => network_segmentation,
    'core_plugin'                => core_plugin,
    'tenant_vlan_ranges'         => tenant_vlan_ranges,
    'ml2_openvswitch'            => ml2_openvswitch,
    'ml2_l2population'           => ml2_l2population,
    'ml2_cisco_nexus'            => ml2_cisco_nexus,
    'ml2_cisco_n1kv'             => ml2_cisco_n1kv,
    'nexuses'                    => nexuses,
    'n1kv_vsm_ip'                => n1kv_vsm_ip,
    'n1kv_vsm_password'          => n1kv_vsm_password }
end

#set_defaultsObject



111
112
113
114
115
116
117
118
119
# File 'app/models/staypuft/deployment/neutron_service.rb', line 111

def set_defaults
  self.network_segmentation   = NetworkSegmentation::VXLAN
  self.core_plugin = CorePlugin::ML2
  self.ml2_openvswitch = "true"
  self.ml2_l2population = "false"
  self.ml2_cisco_nexus = "false"
  self.ml2_cisco_n1kv = "false"
  self.network_device_mtu = nil
end

#tenant_iface(host) ⇒ Object



163
164
165
# File 'app/models/staypuft/deployment/neutron_service.rb', line 163

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

#vlan_segmentation?Boolean

Returns:

  • (Boolean)


155
156
157
# File 'app/models/staypuft/deployment/neutron_service.rb', line 155

def vlan_segmentation?
  network_segmentation == NetworkSegmentation::VLAN
end