[maas] Adopt maas.machines.storage 31/57831/1
authorting wu <ting.wu@enea.com>
Thu, 3 May 2018 10:28:06 +0000 (12:28 +0200)
committerAlexandru Avadanii <Alexandru.Avadanii@enea.com>
Thu, 24 May 2018 16:16:50 +0000 (16:16 +0000)
Replace MAAS CLI set_disk_layout with the
new maas.machines.storage state

JIRA: FUEL-364

Change-Id: I4d8cd9f473c5386ee7b32ad378ca1e02989233ca
Signed-off-by: ting wu <ting.wu@enea.com>
(cherry picked from commit 96019123adad087bc0d744a6785ceebb7b21476d)

mcp/config/states/maas
mcp/reclass/classes/cluster/mcp-pike-common-ha/infra/maas_pdf.yml.j2
mcp/salt-formulas/maas/machines/set_storage_layout.sls [deleted file]

index 10cfd01..ec24582 100755 (executable)
@@ -57,16 +57,7 @@ function maas_fixup() {
     sleep 10
   done
   if [ -n "${fdnodes}" ] || [ -n "${rnodes}" ]; then
-    for node_system_id in ${fdnodes} ${rnodes}; do
-      # For now, we allocate 30GB (fixed) for / on cmp nodes
-      local node_hostname=$(echo "${statusout}" | \
-        grep -Pzo 'hostname: \K.+(?=\n.+\n\s+system_id: '"${node_system_id}"')')
-      if [[ "${node_hostname}" =~ ^cmp ]]; then
-        salt -C 'mas01*' state.apply maas.machines.set_storage_layout \
-          pillar="{'system_id': '${node_system_id}', 'lv_size': '32212254720'}"
-        sleep 10
-      fi
-    done
+    salt -C 'mas01*' state.apply maas.machines.storage
     salt -C 'mas01*' state.apply maas.machines.deploy
     return 1
   fi
index 335b9c7..986bb06 100644 (file)
@@ -80,5 +80,13 @@ parameters:
           architecture: {{ node.node.arch | dpkg_arch }}/generic
           distro_series: xenial
           hwe_kernel: ${_param:hwe_kernel}
+          {%- if loop.index0 >= node_roles.index('cmp001')  %}
+          disk_layout:
+            type: lvm
+            root_device: sda
+            volume_group: vgroot
+            volume_name: lvroot
+            volume_size: 100
+          {%- endif %}
       {%- endif %}
       {%- endfor %}
diff --git a/mcp/salt-formulas/maas/machines/set_storage_layout.sls b/mcp/salt-formulas/maas/machines/set_storage_layout.sls
deleted file mode 100644 (file)
index 0b7e371..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-##############################################################################
-# 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 "maas/map.jinja" import region with context %}
-
-maas_login_admin:
-  cmd.run:
-  - name: "maas-region apikey --username {{ region.admin.username }} > /var/lib/maas/.maas_credentials"
-  - unless: 'test -e /var/lib/maas/.maas_credentials'
-
-# TODO: implement set_storage_layout via _modules/maas.py
-set_storage_layout:
-  cmd.run:
-  - name: "maas login {{ region.admin.username }} http://{{ region.bind.host }}:5240/MAAS/api/2.0 - < /var/lib/maas/.maas_credentials && maas opnfv machine set-storage-layout {{ pillar['system_id'] }} storage_layout={{ pillar['storage_layout'] | default('lvm') }} lv_size={{ pillar['lv_size'] | default('100%') }}"
-  - require:
-    - cmd: maas_login_admin