diff options
Diffstat (limited to 'mcp/patches')
8 files changed, 228 insertions, 7 deletions
diff --git a/mcp/patches/0002-maas-region-skip-credentials-update.patch b/mcp/patches/0002-maas-region-skip-credentials-update.patch index f2104e51f..59fe457b5 100644 --- a/mcp/patches/0002-maas-region-skip-credentials-update.patch +++ b/mcp/patches/0002-maas-region-skip-credentials-update.patch @@ -24,7 +24,7 @@ index d3227ca..8a2243d 100644 - - group: maas + file.replace: + - pattern: ^maas_url.*$ -+ - repl: "maas_url: http://{{ region.bind.host }}/MAAS" ++ - repl: "maas_url: http://{{ region.bind.host }}:5240/MAAS" - require: - pkg: maas_region_packages diff --git a/mcp/patches/0003-maas-region-force-artifact-download.patch b/mcp/patches/0003-maas-region-force-artifact-download.patch index 72114bb48..f0ce50fa0 100644 --- a/mcp/patches/0003-maas-region-force-artifact-download.patch +++ b/mcp/patches/0003-maas-region-force-artifact-download.patch @@ -15,16 +15,17 @@ Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com> --- diff --git a/maas/region.sls b/maas/region.sls -index d3227ca..8a2243d 100644 --- a/maas/region.sls +++ b/maas/region.sls -@@ -109,11 +109,17 @@ +@@ -109,11 +109,19 @@ cmd.run: - name: "maas-region apikey --username {{ region.admin.username }} > /var/lib/maas/.maas_credentials" +maas_force_artifact_sync: -+ cmd.run: -+ - name: "maas login {{ region.admin.username }} http://{{ region.bind.host }}/MAAS/api/2.0 - < /var/lib/maas/.maas_credentials && while ! grep -qzE '(Unable to probe for DHCP servers|DHCP probe complete).*Rack controller' /var/log/maas/rackd.log; do sleep 5; echo -n '.'; done && maas opnfv boot-resources import && while maas opnfv boot-resources is-importing | grep -q -e 'true'; do sleep 5; echo -n '.'; done && maas opnfv rack-controllers import-boot-images && while ! test -d /var/lib/maas/boot-resources/current/ubuntu; do sleep 5; echo -n '.'; done" ++ cmd.script: ++ - name: salt://maas/files/maas-artifact-sync.sh ++ - template: jinja ++ - shell: /bin/bash + - require: + - cmd: maas_login_admin + @@ -37,3 +38,29 @@ index d3227ca..8a2243d 100644 maas_commissioning_scripts: module.run: +diff --git a/maas/files/maas-artifact-sync.sh b/maas/files/maas-artifact-sync.sh +new file mode 100644 +--- /dev/null ++++ b/maas/files/maas-artifact-sync.sh +@@ -0,0 +1,21 @@ ++{%- from "maas/map.jinja" import region with context %} ++#!/bin/bash ++function wait_for { ++ local total_attempts=$1; shift ++ local cmdstr=$@ ++ local sleep_time=10 ++ echo -e "\n[NOTE] Waiting for cmd to return success: ${cmdstr}\n" ++ for attempt in $(seq "${total_attempts}"); do ++ eval "${cmdstr}" && break || true ++ echo -n '.'; sleep "${sleep_time}" ++ done ++} ++maas login {{ region.admin.username }} \ ++ http://{{ region.bind.host }}:5240/MAAS/api/2.0 - < \ ++ /var/lib/maas/.maas_credentials || exit 1 ++# wait max 15 min for service up / image download, 5 min region to rack sync ++wait_for 90 "grep -qzE '(Unable to probe for DHCP servers|DHCP probe complete).*Rack controller' /var/log/maas/rackd.log" ++maas opnfv boot-resources import || exit 2 ++wait_for 90 "! maas opnfv boot-resources is-importing | grep -q 'true'" ++maas opnfv rack-controllers import-boot-images || exit 3 ++wait_for 30 "test -d /var/lib/maas/boot-resources/current/ubuntu/amd64" diff --git a/mcp/patches/0004-maas-region-use-authorized_keys-1st-entry.patch b/mcp/patches/0004-maas-region-use-authorized_keys-1st-entry.patch new file mode 100644 index 000000000..b7322e3d2 --- /dev/null +++ b/mcp/patches/0004-maas-region-use-authorized_keys-1st-entry.patch @@ -0,0 +1,34 @@ +From: Charalampos Kominos <Charalampos.Kominos@enea.com> +Date: Sat, 5 Aug 2017 02:03:01 +0200 +Subject: [PATCH] maas: region: use authorized_keys 1st entry + +MaaS custom py modules accepts the "sshprefs" variable via pillar, +however we want to read it from ~ubuntu/.ssh/authorized_keys. + +Bypass the py module and call MaaS CLI directly, passing the first +authorized key, which should be mcp.rsa.pub. + +Signed-off-by: Charalampos Kominos <Charalampos.Kominos@enea.com> +--- + +diff --git a/maas/region.sls b/maas/region.sls +index d3227ca..8a2243d 100644 +--- a/maas/region.sls ++++ b/maas/region.sls +@@ -179,8 +179,14 @@ + - module: maas_config + + maas_sshprefs: +- module.run: +- - name: maas.process_sshprefs ++# NOTE(armband): maas.process_sshprefs also works, but we need to read the key ++# from authorized_keys. Should be reworked at some point. ++# module.run: ++# - name: maas.process_sshprefs ++# - require: ++ cmd.run: ++ - name: "maas login {{ region.admin.username }} http://{{ region.bind.host }}:5240/MAAS/api/2.0 - < /var/lib/maas/.maas_credentials && SSH_KEY=$(cat authorized_keys | head -1) && maas opnfv sshkeys create \"key=$SSH_KEY\"" ++ - cwd: "/home/ubuntu/.ssh" + - require: + - module: maas_config + diff --git a/mcp/patches/0005-maas-module-Obtain-fabric-ID-from-CIDR.patch b/mcp/patches/0005-maas-module-Obtain-fabric-ID-from-CIDR.patch new file mode 100644 index 000000000..5c77a63da --- /dev/null +++ b/mcp/patches/0005-maas-module-Obtain-fabric-ID-from-CIDR.patch @@ -0,0 +1,49 @@ +From: Alexandru Avadanii <Alexandru.Avadanii@enea.com> +Date: Sat, 19 Aug 2017 02:03:01 +0200 +Subject: [PATCH] maas: module: Obtain fabric ID from CIDR + +MaaS subnet update requires specifying the correct fabric via reclass, +which we used to hardcode in our OPNFV reclass model to fabric-2. +However, fabric index numbers are not deterministic, so the old +method is unreliable. + +Update MaaS custom py module to determine fabric name/ID on the +fly, based on CIDR matching (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 +index d3227ca..8a2243d 100644 +--- a/_modules/maas.py ++++ b/_modules/maas.py +@@ -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) diff --git a/mcp/patches/0006-maas-module-Add-VLAN-DHCP-enable-support.patch b/mcp/patches/0006-maas-module-Add-VLAN-DHCP-enable-support.patch new file mode 100644 index 000000000..704f64038 --- /dev/null +++ b/mcp/patches/0006-maas-module-Add-VLAN-DHCP-enable-support.patch @@ -0,0 +1,81 @@ +From: Alexandru Avadanii <Alexandru.Avadanii@enea.com> +Date: Sat, 19 Aug 2017 02:03:01 +0200 +Subject: [PATCH] maas: module: Add VLAN DHCP enable support + +MaaS custom py module does not support VLAN configuration. +This should be implemented by adding a dedicated class for VLAN. +However, we are only interested in updating an existign VLAN to +enable DHCP on an existing IP range (set up via subnet configuration), +so extend existing subnet handling to include basic VLAN update. + +NOTE: Design-wise, this is hacky, and its only purpose is to allow +setting 'dhcp_on=True' for an existing VLAN. + +Example reclass model usage: +maas: + region: + subnets: + 192.168.11.0/24: + # ... + vlans: + untagged: + vid: 0 + dhcp_on: true + primary_rack: mas01 + +Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com> +--- + +diff --git a/_modules/maas.py b/_modules/maas.py +index d3227ca..8a2243d 100644 +--- a/_modules/maas.py ++++ b/_modules/maas.py +@@ -204,6 +204,7 @@ + 'gateway_ip': subnet['gateway_ip'], + } + self._iprange = subnet['iprange'] ++ self._vlans = subnet['vlans'] + return data + + def update(self, new, old): +@@ -214,6 +215,7 @@ + response = super(Subnet, self).send(data) + res_json = json.loads(response) + self._process_iprange(res_json['id']) ++ self._process_dhcp_vlans_update(data) + return response + + def _get_fabric_from_cidr(self, cidr): +@@ -248,6 +250,32 @@ + else: + self._maas.post(u'api/2.0/ipranges/', None, **data) + ++ def _process_dhcp_vlans_update(self, subnet_data): ++ fabric_vlans = json.loads(self._maas.get(u'api/2.0/fabrics/{0}/vlans/' ++ .format(subnet_data['fabric'])).read()) ++ LOG.warn('all fabric %s vlans %s', subnet_data['fabric'], fabric_vlans) ++ for vlan_name, vlan_data in self._vlans.iteritems(): ++ update = False ++ old_data = None ++ for fabric_vlan in fabric_vlans: ++ if fabric_vlan['vid'] == vlan_data['vid']: ++ update = True ++ old_data = fabric_vlan ++ break ++ data = { ++ 'mtu': str(vlan_data.get('mtu', 1500)), ++ 'dhcp_on': str(vlan_data.get('dhcp_on')), ++ 'primary_rack': str(vlan_data.get('primary_rack')), ++ 'secondary_rack': str(vlan_data.get('secondary_rack', '')) ++ } ++ if update: ++ LOG.warn('UPDATING %s %s', data, old_data) ++ self._maas.put(u'api/2.0/fabrics/{0}/vlans/{1}/' ++ .format(subnet_data['fabric'], old_data['vid']), ++ **data) ++ else: ++ LOG.warn('MISSING vlan %s, not doing anything', data) ++ + + class DHCPSnippet(MaasObject): + def __init__(self): diff --git a/mcp/patches/0007-linux.network.interface-noifupdown-support.patch b/mcp/patches/0007-linux.network.interface-noifupdown-support.patch new file mode 100644 index 000000000..5d9ce7be5 --- /dev/null +++ b/mcp/patches/0007-linux.network.interface-noifupdown-support.patch @@ -0,0 +1,26 @@ +From: Alexandru Avadanii <Alexandru.Avadanii@enea.com> +Date: Sat, 5 Aug 2017 02:03:01 +0200 +Subject: [PATCH] linux.network.interface: noifupdown support + +According to [1], salt states/network supports "noifupdown" as a +parameter for each interface. +Adjust salt formula part for `linux.network.interface`, by extending +the "interface_params" in <linux/map.jinja> accordingly. + +Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com> +Signed-off-by: Charalampos Kominos <Charalampos.Kominos@enea.com> +Signed-off-by: Guillermo Herrero <Guillermo.Herrero@enea.com> +--- + +diff --git a/linux/map.jinja b/linux/map.jinja +index d3227ca..8a2243d 100644 +--- a/linux/map.jinja ++++ b/linux/map.jinja +@@ -92,6 +92,7 @@ + 'updelay', + 'hashing-algorithm', + 'hardware-dma-ring-rx', ++ 'noifupdown', + ] %} + + {% set network = salt['grains.filter_by']({ diff --git a/mcp/patches/patches.list b/mcp/patches/patches.list index e55e67984..1a651cfe0 100644 --- a/mcp/patches/patches.list +++ b/mcp/patches/patches.list @@ -1,3 +1,7 @@ /usr/share/salt-formulas/env: 0001-opendaylight-formula-neutron.patch /usr/share/salt-formulas/env: 0002-maas-region-skip-credentials-update.patch /usr/share/salt-formulas/env: 0003-maas-region-force-artifact-download.patch +/usr/share/salt-formulas/env: 0004-maas-region-use-authorized_keys-1st-entry.patch +/usr/share/salt-formulas/env: 0005-maas-module-Obtain-fabric-ID-from-CIDR.patch +/usr/share/salt-formulas/env: 0006-maas-module-Add-VLAN-DHCP-enable-support.patch +/usr/share/salt-formulas/env: 0007-linux.network.interface-noifupdown-support.patch diff --git a/mcp/patches/reclass-system-salt-model/0001-Bring-in-opendaylight-support.patch b/mcp/patches/reclass-system-salt-model/0001-Bring-in-opendaylight-support.patch index 15f23db34..adf07eb81 100644 --- a/mcp/patches/reclass-system-salt-model/0001-Bring-in-opendaylight-support.patch +++ b/mcp/patches/reclass-system-salt-model/0001-Bring-in-opendaylight-support.patch @@ -8,8 +8,8 @@ Change-Id: I3efec9a8b586a6c75b1c1635ad2a7024d73d9ad2 neutron/control/opendaylight/single.yml | 16 ++++++++++++++++ neutron/gateway/opendaylight/single.yml | 8 ++++++++ opendaylight/server/single.yml | 2 ++ - .../storage/system/opendaylight_control_single.yml | 15 +++++++++++++++ - 5 files changed, 60 insertions(+) + .../storage/system/opendaylight_control_single.yml | 13 +++++++++++++ + 5 files changed, 58 insertions(+) create mode 100644 neutron/control/opendaylight/cluster.yml create mode 100644 neutron/control/opendaylight/single.yml create mode 100644 neutron/gateway/opendaylight/single.yml |