aboutsummaryrefslogtreecommitdiffstats
path: root/environments/neutron-nsx.yaml
blob: eb1dcec6e175cfec54abd5a009224bb97ce53e00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# A Heat environment that can be used to deploy NSX Services
# extensions, configured via puppet
resource_registry:
  # NSX doesn't require dhcp, l3, metadata, and ovs agents
  OS::TripleO::Services::NeutronDhcpAgent: OS::Heat::None
  OS::TripleO::Services::NeutronL3Agent: OS::Heat::None
  OS::TripleO::Services::NeutronMetadataAgent: OS::Heat::None
  OS::TripleO::Services::NeutronOvsAgent: OS::Heat::None
  OS::TripleO::Services::ComputeNeutronOvsAgent: OS::Heat::None
  # Override the Neutron core plugin to use NSX
  OS::TripleO::Services::NeutronCorePlugin: OS::TripleO::Services::NeutronCorePluginNSX
  OS::TripleO::Services::ComputeNeutronCorePlugin: OS::Heat::None

parameter_defaults:
  NeutronCorePlugin: vmware_nsx.plugin.NsxV3Plugin
hing (assuming we don't have CIDR conflicts). This change maintains backwards compatibility: - if fabric is specified via reclass model, it will be used as-is; - if fabric is not specified via reclass model, we try to deduce it based on CIDR; if no match is found, the old default ('') is used; Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com> Signed-off-by: Guillermo Herrero <Guillermo.Herrero@enea.com> --- diff --git a/_modules/maas.py b/_modules/maas.py --- a/_modules/maas.py +++ b/_modules/maas.py @@ -126,6 +126,8 @@ def process_single(name, config_data): self._update = False + if isinstance(config_data, dict) and 'name' in config_data: + name = config_data['name'] try: data = self.fill_data(name, config_data, **extra) if data is None: @@ -198,7 +198,8 @@ def fill_data(self, name, subnet, fabrics): data = { 'name': name, - 'fabric': str(fabrics[subnet.get('fabric', '')]), + 'fabric': str(fabrics[subnet.get('fabric', + self._get_fabric_from_cidr(subnet.get('cidr')))]), 'cidr': subnet.get('cidr'), 'gateway_ip': subnet['gateway_ip'], } @@ -215,6 +216,13 @@ self._process_iprange(res_json['id']) return response + def _get_fabric_from_cidr(self, cidr): + subnets = json.loads(self._maas.get(u'api/2.0/subnets/').read()) + for subnet in subnets: + if subnet['cidr'] == cidr: + return subnet['vlan']['fabric'] + return '' + def _process_iprange(self, subnet_id): ipranges = json.loads(self._maas.get(u'api/2.0/ipranges/').read()) LOG.warn('all %s ipranges %s', subnet_id, ipranges)