Fix maas dhcp update
* TODO: currently, formula not able to set domain name for
rackd|maas server.
Change-Id: Iebb59200949fbdf7acaca8bbb004996d1581deaf
diff --git a/README.rst b/README.rst
index c8556ab..4cc62bd 100644
--- a/README.rst
+++ b/README.rst
@@ -60,6 +60,8 @@
name: 'vlan 0'
description: Deploy VLAN
dhcp: true
+ # FIXME: after refactoring domain module, it should be
+ # fixed exactly for FQDN, not only 'hostname'
primary_rack: "${linux:network:hostname}"
subnets:
@@ -168,7 +170,7 @@
commissioning_scripts:
00-maas-05-simplify-network-interfaces: /etc/maas/files/commisioning_scripts/00-maas-05-simplify-network-interfaces
maas_config:
- domain: mydomain.local
+ # domain: mydomain.local # This function broken
http_proxy: http://192.168.0.10:3142
commissioning_distro_series: xenial
default_distro_series: xenial
diff --git a/_modules/maasng.py b/_modules/maasng.py
index 128457a..65c5a0f 100644
--- a/_modules/maasng.py
+++ b/_modules/maasng.py
@@ -1095,13 +1095,9 @@
"name": name,
"dhcp_on": str(dhcp_on),
"description": description,
- "primary_rack": primary_rack,
+ "primary_rack": list_racks()[primary_rack]['system_id'],
}
vlan = str(vlan)
- # FIXME: primary_rack definition not work in 2.3.3-6498-ge4db91d.
- # Use default, auto-select:
- LOG.warning("Ignoring parameter primary_rack:{}".format(primary_rack))
- data.pop('primary_rack', '')
maas = _create_maas_client()
fabric_id = get_fabricid(fabric)
try:
@@ -1671,7 +1667,7 @@
return {"error": "rack:{} not found on MaaS server".format(hostname)}
-def list_racks():
+def list_racks(sort_by='hostname'):
"""
Get list of all rack controllers from maas server
@@ -1686,7 +1682,7 @@
json_res = json.loads(
maas.get(u"/api/2.0/rackcontrollers/").read() or 'null')
for item in json_res:
- racks[item["hostname"]] = item
+ racks[item[sort_by]] = item
return racks
diff --git a/_states/maasng.py b/_states/maasng.py
index c381a18..7b14f99 100644
--- a/_states/maasng.py
+++ b/_states/maasng.py
@@ -332,8 +332,7 @@
return ret
-def vlan_present_in_fabric(name, fabric, vlan, description='',
- primary_rack='', dhcp_on=False):
+def vlan_present_in_fabric(name, fabric, vlan, primary_rack, description='', dhcp_on=False):
"""
:param name: Name of vlan
diff --git a/maas/region.sls b/maas/region.sls
index c6fe233..0f82cd8 100644
--- a/maas/region.sls
+++ b/maas/region.sls
@@ -396,14 +396,17 @@
- cmd: maas_login_admin
{%- endif %}
-maas_domain:
- module.run:
- - name: maas.process_domain
- - require:
- - cmd: maas_login_admin
- {%- if grains.get('kitchen-test') %}
- - onlyif: /bin/false
- {%- endif %}
+# FIXME
+# This function usless since broken API logic in module.
+# Should be refactored to be able work with regaiond-domain structure.
+#maas_domain:
+# module.run:
+# - name: maas.process_domain
+# - require:
+# - cmd: maas_login_admin
+# {%- if grains.get('kitchen-test') %}
+# - onlyif: /bin/false
+# {%- endif %}
{%- if region.get('sshprefs', False) %}