Merge "Adding Network MTU parameter to VLANs"
diff --git a/.kitchen.yml b/.kitchen.yml
index 9d4e118..4cd5d08 100644
--- a/.kitchen.yml
+++ b/.kitchen.yml
@@ -77,9 +77,9 @@
       #pillars-from-files:
         #maas.sls: tests/pillar/maas_mirror.sls
 
-  #- name: maas_region
-    #provisioner:
-      #pillars-from-files:
-        #maas.sls: tests/pillar/maas_region.sls
+#  - name: maas_region
+#    provisioner:
+#      pillars-from-files:
+#        maas.sls: tests/pillar/maas_region.sls
 
 # vim: ft=yaml sw=2 ts=2 sts=2 tw=125
diff --git a/README.rst b/README.rst
index ea7c7d6..225d863 100644
--- a/README.rst
+++ b/README.rst
@@ -473,8 +473,8 @@
         MA==
         =dtMN
         -----END PGP PUBLIC KEY BLOCK-----
-      saltstack_repo_xenial: "http://${_param:local_repo_url}/ubuntu-xenial stable salt"
-      saltstack_repo_trusty: "http://${_param:local_repo_url}/ubuntu-trusty stable salt"
+      saltstack_repo_xenial: "deb [arch=amd64] http://${_param:local_repo_url}/ubuntu-xenial stable salt"
+      saltstack_repo_trusty: "deb [arch=amd64] http://${_param:local_repo_url}/ubuntu-trusty stable salt"
 
 Single MAAS cluster service [multiple racks]
 
diff --git a/_states/maasng.py b/_states/maasng.py
index 85df2f4..c574f22 100644
--- a/_states/maasng.py
+++ b/_states/maasng.py
@@ -570,7 +570,7 @@
 
     if __opts__['test']:
         ret['result'] = None
-        ret['comment'] = 'fabric {0} will be updated for {1}'.format(vlan, name)
+        ret['comment'] = 'fabric {0} will be updated'.format(name)
         return ret
     # All requested subnets
     _r_subnets = __salt__['config.get']('maas').get('region', {}).get('subnets',
diff --git a/maas/cluster.sls b/maas/cluster.sls
index ad15c63..bfb584f 100644
--- a/maas/cluster.sls
+++ b/maas/cluster.sls
@@ -40,7 +40,12 @@
 
 /etc/maas/rackd.conf:
   file.line:
-  - content: 'maas_url: http://{{ cluster.region.host }}/MAAS'
+{%- if cluster.region.get('port', False)  %}
+  {%- set maas_url = 'http://' + cluster.region.host|string + ':' + cluster.region.port|string + '/MAAS' -%}
+{%- else %}
+  {%- set maas_url = 'http://' + cluster.region.host|string + '/MAAS' -%}
+{%- endif %}
+  - content: "maas_url: {{ maas_url }}"
   - match: 'maas_url*'
   - mode: replace
   - location: end
diff --git a/maas/files/curtin_userdata_amd64_generic_trusty b/maas/files/curtin_userdata_amd64_generic_trusty
index 1ff17dd..3c817fa 100644
--- a/maas/files/curtin_userdata_amd64_generic_trusty
+++ b/maas/files/curtin_userdata_amd64_generic_trusty
@@ -18,15 +18,18 @@
 late_commands:
   maas: [wget, '--no-proxy', {{node_disable_pxe_url|escape.json}}, '--post-data', {{node_disable_pxe_data|escape.json}}, '-O', '/dev/null']
 {% endraw %}
-{%- if not cluster.saltstack_repo_key == 'none' %}
-{% set salt_repo_key = salt['hashutil.base64_b64encode'](cluster.saltstack_repo_key) %}
+{%- if cluster.get('saltstack_repo_key', False) %}
+  {% set salt_repo_key = salt['hashutil.base64_b64encode'](cluster.saltstack_repo_key) %}
   apt_00_set_gpg: ["curtin", "in-target", "--", "sh", "-c", "echo '{{salt_repo_key}}' | base64 -d | apt-key add -"]
 {%- endif %}
-  apt_01_set_repo: ["curtin", "in-target", "--", "sh", "-c", "echo 'deb [arch=amd64] {{ cluster.saltstack_repo_trusty }}' >> /etc/apt/sources.list"]
-{% raw %}
+{% if cluster.saltstack_repo_trusty.startswith('deb') %}
+  {%- set saltstack_repo = cluster.saltstack_repo_trusty -%}
+{%- else %}
+  {%- set saltstack_repo = 'deb [arch=amd64]' + cluster.region.host|string + '/MAAS' -%}
+{%- endif %}
+  apt_01_set_repo: ["curtin", "in-target", "--", "sh", "-c", "echo '{{ saltstack_repo }}' >> /etc/apt/sources.list.d/mcp_saltstack.list"]
   apt_03_update: ["curtin", "in-target", "--", "apt-get", "update"]
   salt_01_install: ["curtin", "in-target", "--", "apt-get", "-y", "install", "salt-minion"]
-{% endraw %}
   salt_02_hostname_set: ["curtin", "in-target", "--", "echo", "{% raw %}{{node.hostname}}{% endraw %}.{{pillar.linux.system.domain}}"]
   salt_03_hostname_get: ["curtin", "in-target", "--", "sh", "-c", "echo 'id: {% raw %}{{node.hostname}}{% endraw %}.{{pillar.linux.system.domain}}' >> /etc/salt/minion"]
   salt_04_master: ["curtin", "in-target", "--", "sh", "-c", "echo 'master: {{ salt_master_ip }}' >> /etc/salt/minion"]
@@ -40,4 +43,4 @@
   driver_06_depmod: ["curtin", "in-target", "--", "depmod"]
   driver_07_update_initramfs: ["curtin", "in-target", "--", "update-initramfs", "-u"]
 {{endif}}
-{% endraw %}
\ No newline at end of file
+{% endraw %}
diff --git a/maas/files/curtin_userdata_amd64_generic_xenial b/maas/files/curtin_userdata_amd64_generic_xenial
index 55e0901..6152827 100644
--- a/maas/files/curtin_userdata_amd64_generic_xenial
+++ b/maas/files/curtin_userdata_amd64_generic_xenial
@@ -18,15 +18,18 @@
 late_commands:
   maas: [wget, '--no-proxy', {{node_disable_pxe_url|escape.json}}, '--post-data', {{node_disable_pxe_data|escape.json}}, '-O', '/dev/null']
 {% endraw %}
-{%- if not cluster.saltstack_repo_key == 'none' %}
-{% set salt_repo_key = salt['hashutil.base64_b64encode'](cluster.saltstack_repo_key) %}
+{%- if cluster.get('saltstack_repo_key', False) %}
+  {% set salt_repo_key = salt['hashutil.base64_b64encode'](cluster.saltstack_repo_key) %}
   apt_00_set_gpg: ["curtin", "in-target", "--", "sh", "-c", "echo '{{salt_repo_key}}' | base64 -d | apt-key add -"]
 {%- endif %}
-  apt_01_set_repo: ["curtin", "in-target", "--", "sh", "-c", "echo 'deb [arch=amd64] {{ cluster.saltstack_repo_xenial }}' >> /etc/apt/sources.list"]
-{% raw %}
+{% if cluster.saltstack_repo_xenial.startswith('deb') %}
+  {%- set saltstack_repo = cluster.saltstack_repo_xenial -%}
+{%- else %}
+  {%- set saltstack_repo = 'deb [arch=amd64]' + cluster.region.host|string + '/MAAS' -%}
+{%- endif %}
+  apt_01_set_repo: ["curtin", "in-target", "--", "sh", "-c", "echo '{{ saltstack_repo }}' >> /etc/apt/sources.list.d/mcp_saltstack.list"]
   apt_03_update: ["curtin", "in-target", "--", "apt-get", "update"]
   salt_01_install: ["curtin", "in-target", "--", "apt-get", "-y", "install", "salt-minion"]
-{% endraw %}
   salt_02_hostname_set: ["curtin", "in-target", "--", "echo", "{% raw %}{{node.hostname}}{% endraw %}.{{pillar.linux.system.domain}}"]
   salt_03_hostname_get: ["curtin", "in-target", "--", "sh", "-c", "echo 'id: {% raw %}{{node.hostname}}{% endraw %}.{{pillar.linux.system.domain}}' >> /etc/salt/minion"]
   salt_04_master: ["curtin", "in-target", "--", "sh", "-c", "echo 'master: {{ salt_master_ip }}' >> /etc/salt/minion"]
@@ -40,4 +43,4 @@
   driver_06_depmod: ["curtin", "in-target", "--", "depmod"]
   driver_07_update_initramfs: ["curtin", "in-target", "--", "update-initramfs", "-u"]
 {{endif}}
-{% endraw %}
\ No newline at end of file
+{% endraw %}
diff --git a/maas/files/curtin_userdata_arm64_generic_xenial b/maas/files/curtin_userdata_arm64_generic_xenial
index 21877b2..a04d575 100644
--- a/maas/files/curtin_userdata_arm64_generic_xenial
+++ b/maas/files/curtin_userdata_arm64_generic_xenial
@@ -18,16 +18,19 @@
 late_commands:
   maas: [wget, '--no-proxy', {{node_disable_pxe_url|escape.json}}, '--post-data', {{node_disable_pxe_data|escape.json}}, '-O', '/dev/null']
 {% endraw %}
-{%- if not cluster.saltstack_repo_key == 'none' %}
-{% set salt_repo_key = salt['hashutil.base64_b64encode'](cluster.saltstack_repo_key) %}
+{%- if cluster.get('saltstack_repo_key', False) %}
+  {% set salt_repo_key = salt['hashutil.base64_b64encode'](cluster.saltstack_repo_key) %}
   apt_00_set_gpg: ["curtin", "in-target", "--", "sh", "-c", "echo '{{salt_repo_key}}' | base64 -d | apt-key add -"]
 {%- endif %}
+{% if cluster.saltstack_repo_xenial.startswith('deb') %}
+  {%- set saltstack_repo = cluster.saltstack_repo_xenial -%}
+{%- else %}
+  {%- set saltstack_repo = 'deb [arch=amd64]' + cluster.region.host|string + '/MAAS' -%}
+{%- endif %}
 {#- NOTE: Re-use amd64 repos on arm64 since most packages are arch independent #}
-  apt_01_set_repo: ["curtin", "in-target", "--", "sh", "-c", "echo 'deb [arch=amd64] {{ cluster.saltstack_repo_xenial }}' >> /etc/apt/sources.list"]
-{% raw %}
+  apt_01_set_repo: ["curtin", "in-target", "--", "sh", "-c", "echo '{{ saltstack_repo }}' >> /etc/apt/sources.list.d/mcp_saltstack.list"]
   apt_03_update: ["curtin", "in-target", "--", "apt-get", "update"]
-  salt_01_install: ["curtin", "in-target", "--", "apt-get", "-y", "install", "python-futures", "salt-minion"]
-{% endraw %}
+  salt_01_install: ["curtin", "in-target", "--", "apt-get", "-y", "install", "salt-minion", "python-futures"]
   salt_02_hostname_set: ["curtin", "in-target", "--", "echo", "{% raw %}{{node.hostname}}{% endraw %}.{{pillar.linux.system.domain}}"]
   salt_03_hostname_get: ["curtin", "in-target", "--", "sh", "-c", "echo 'id: {% raw %}{{node.hostname}}{% endraw %}.{{pillar.linux.system.domain}}' >> /etc/salt/minion"]
   salt_04_master: ["curtin", "in-target", "--", "sh", "-c", "echo 'master: {{ salt_master_ip }}' >> /etc/salt/minion"]
diff --git a/metadata/service/cluster/single.yml b/metadata/service/cluster/single.yml
index a307dcc..de8cf8a 100644
--- a/metadata/service/cluster/single.yml
+++ b/metadata/service/cluster/single.yml
@@ -41,5 +41,5 @@
         MA==
         =dtMN
         -----END PGP PUBLIC KEY BLOCK-----
-      saltstack_repo_trusty: "http://repo.saltstack.com/apt/ubuntu/14.04/amd64/2016.3/ trusty main"
-      saltstack_repo_xenial: "http://repo.saltstack.com/apt/ubuntu/16.04/amd64/2016.3/ xenial main"
+      saltstack_repo_trusty: "deb [arch=amd64] http://repo.saltstack.com/apt/ubuntu/14.04/amd64/2016.3/ trusty main"
+      saltstack_repo_xenial: "deb [arch=amd64] http://repo.saltstack.com/apt/ubuntu/16.04/amd64/2016.3/ xenial main"
diff --git a/tests/pillar/maas_cluster.sls b/tests/pillar/maas_cluster.sls
index 641cfb6..fedb491 100644
--- a/tests/pillar/maas_cluster.sls
+++ b/tests/pillar/maas_cluster.sls
@@ -37,8 +37,8 @@
       MA==
       =dtMN
       -----END PGP PUBLIC KEY BLOCK-----
-    saltstack_repo_trusty: "http://repo.saltstack.com/apt/ubuntu/14.04/amd64/2016.3/ trusty main"
-    saltstack_repo_xenial: "http://repo.saltstack.com/apt/ubuntu/16.04/amd64/2016.3/ xenial main"
+    saltstack_repo_trusty: "deb [arch=amd64] http://repo.saltstack.com/apt/ubuntu/14.04/amd64/2016.3/ trusty main"
+    saltstack_repo_xenial: "deb [arch=amd64] http://repo.saltstack.com/apt/ubuntu/16.04/amd64/2016.3/ xenial main"
   region:
     theme: mirantis
     bind:
diff --git a/tests/pillar/maas_region.sls b/tests/pillar/maas_region.sls
index 607b472..a150389 100644
--- a/tests/pillar/maas_region.sls
+++ b/tests/pillar/maas_region.sls
@@ -3,13 +3,15 @@
     enabled: true
     region:
       host: localhost
+      port: 80
     role: master
     enable_iframe: True
   region:
-    theme: theme
+    enabled: true
     bind:
       host: localhost
       port: 80
+    theme: theme
     admin:
       username: admin
       password: password
@@ -20,5 +22,4 @@
       name: maasdb
       password: password
       username: maas
-    enabled: true
     salt_master_ip: 127.0.0.1