aboutsummaryrefslogtreecommitdiffstats
path: root/mcp
diff options
context:
space:
mode:
authorAlexandru Avadanii <Alexandru.Avadanii@enea.com>2018-06-29 16:12:36 +0000
committerGerrit Code Review <gerrit@opnfv.org>2018-06-29 16:12:36 +0000
commit1e76bad68ffc8f4235d11599fdf074b38ac76c7b (patch)
treeebd7fc83d27c790129546965ae85a1fc811a05f4 /mcp
parentfa26dabea271cee86c71b95f7d4650ef53eb2419 (diff)
parent1d4dc408b0109e871797a10f48482633a1bcfa30 (diff)
Merge "[patch] MaaS: fabric ID from CIDR"
Diffstat (limited to 'mcp')
-rw-r--r--mcp/patches/0001-maasng-Allow-fabric-ID-to-be-determined-from-CIDR.patch87
-rw-r--r--mcp/patches/patches.list1
-rw-r--r--mcp/reclass/classes/cluster/mcp-common-ha/infra/maas.yml.j23
3 files changed, 88 insertions, 3 deletions
diff --git a/mcp/patches/0001-maasng-Allow-fabric-ID-to-be-determined-from-CIDR.patch b/mcp/patches/0001-maasng-Allow-fabric-ID-to-be-determined-from-CIDR.patch
new file mode 100644
index 000000000..674813574
--- /dev/null
+++ b/mcp/patches/0001-maasng-Allow-fabric-ID-to-be-determined-from-CIDR.patch
@@ -0,0 +1,87 @@
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+: Copyright (c) 2018 Mirantis Inc., Enea AB and others.
+:
+: All rights reserved. This program and the accompanying materials
+: are made available under the terms of the Apache License, Version 2.0
+: which accompanies this distribution, and is available at
+: http://www.apache.org/licenses/LICENSE-2.0
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
+Date: Fri, 29 Jun 2018 02:48:55 +0200
+Subject: [PATCH] maasng: Allow fabric ID to be determined from CIDR
+
+MaaS usually creates network resources (e.g. subnets, fabrics)
+automatically based on existing network interface definitions.
+However, the fabric naming is not guaranteed across deployments,
+so the same interface/subnet CIDR might end up as 'fabric-2' or
+'fabric-5' depending on non-deterministic factors.
+
+To allow configuring VLAN DHCP on such network segments we need a
+mechanism that does not hardcode the fabric ID in pillar data, but
+instead determines it at runtime based on subnet CIDR.
+
+maasng module: Fix 'name' arg in update_vlan
+
+name argument is silently overridden to use the state name if the
+value passed is not a string, leading to all kinds of breakage.
+
+While at it, default to using the VLAN ID as the name if not
+explicitly set.
+
+Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
+---
+ _modules/maasng.py | 7 ++++++-
+ maas/region.sls | 15 ++++++++++++++-
+ 3 files changed, 39 insertions(+), 3 deletions(-)
+
+diff --git a/_modules/maasng.py b/_modules/maasng.py
+index ce8e99e..706c0ec 100644
+--- a/_modules/maasng.py
++++ b/_modules/maasng.py
+@@ -966,7 +966,12 @@ def get_fabricid(fabric):
+ try:
+ return list_fabric()[fabric]['id']
+ except KeyError:
+- return {"error": "Frabic not found on MaaS server"}
++ # fabric might be specified as CIDR, try to find the actual fabric ID
++ maas_subnets = list_subnet()
++ for subnet in maas_subnets.keys():
++ if maas_subnets[subnet]['cidr'] == fabric:
++ return maas_subnets[subnet]['vlan']['fabric_id']
++ return {"error": "Fabric not found on MaaS server"}
+
+
+ def update_vlan(name, fabric, vid, description, primary_rack, dhcp_on=False):
+diff --git a/maas/region.sls b/maas/region.sls
+index f50b901..71bfefa 100644
+--- a/maas/region.sls
++++ b/maas/region.sls
+@@ -305,6 +305,19 @@ maas_create_subnet_{{ subnet_name }}:
+ {%- endif %}
+ {%- endfor %}
+
++{%- for subnet_name, subnet in region.subnets.iteritems() %}
++{%- for vid, vlan in subnet.get('vlan', {}).items() %}
++maas_update_vlan_for_{{ subnet_name }}_{{ vid }}:
++ maasng.update_vlan:
++ - vid: {{ vid }}
++ - fabric: {{ subnet.cidr }}
++ - name: '{{ vlan.get('name', vid) }}'
++ - description: {{ vlan.description }}
++ - primary_rack: {{ region.maas_config.maas_name }}
++ - dhcp_on: {{ vlan.get('dhcp','False') }}
++{%- endfor %}
++{%- endfor %}
++
+ {%- for subnet_name, subnet in region.subnets.iteritems() %}
+ {%- if subnet.get('multiple') == True %}
+ {%- for range_name, iprange in subnet.get('iprange',{}).items() %}
+@@ -375,7 +388,7 @@ maas_update_vlan_for_{{ fabric_name }}_{{ vid }}:
+ maasng.update_vlan:
+ - vid: {{ vid }}
+ - fabric: {{ fabric_name }}
+- - name: {{ vlan.get('name','') }}
++ - name: '{{ vlan.get('name', vid) }}'
+ - description: {{ vlan.description }}
+ - primary_rack: {{ region.maas_config.maas_name }}
+ - dhcp_on: {{ vlan.get('dhcp','False') }}
diff --git a/mcp/patches/patches.list b/mcp/patches/patches.list
index a17fd694c..17573d95e 100644
--- a/mcp/patches/patches.list
+++ b/mcp/patches/patches.list
@@ -5,6 +5,7 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
+/usr/share/salt-formulas/env: 0001-maasng-Allow-fabric-ID-to-be-determined-from-CIDR.patch
/usr/share/salt-formulas/env: 0002-maas-region-skip-credentials-update.patch
/usr/share/salt-formulas/env: 0007-network.interface-Fix-ifup-OVS-port-with-route.patch
/usr/share/salt-formulas/env: 0008-Handle-extra-environment-variables.patch
diff --git a/mcp/reclass/classes/cluster/mcp-common-ha/infra/maas.yml.j2 b/mcp/reclass/classes/cluster/mcp-common-ha/infra/maas.yml.j2
index 6c11994e8..81934e2d2 100644
--- a/mcp/reclass/classes/cluster/mcp-common-ha/infra/maas.yml.j2
+++ b/mcp/reclass/classes/cluster/mcp-common-ha/infra/maas.yml.j2
@@ -62,9 +62,6 @@ parameters:
start: {{ nm.net_admin_pool_start }}
end: {{ nm.net_admin_pool_end }}
type: dynamic
- fabrics:
- fabric-2:
- description: "Fabric Admin"
vlan:
0:
description: "VLAN 0"