Virt disk and net profiles
diff --git a/metadata/service/control/virt.yml b/metadata/service/control/virt.yml
index 63050ea..05e1591 100644
--- a/metadata/service/control/virt.yml
+++ b/metadata/service/control/virt.yml
@@ -7,12 +7,15 @@
small:
cpu: 1
ram: 2
- hdd: 10
+ disk_profile: default
+ net_profile: default
medium:
cpu: 2
ram: 4
- hdd: 20
+ disk_profile: default
+ net_profile: default
large:
cpu: 4
ram: 8
- hdd: 70
+ disk_profile: default
+ net_profile: default
diff --git a/salt/control/virt.sls b/salt/control/virt.sls
index 38a3810..378b2b8 100644
--- a/salt/control/virt.sls
+++ b/salt/control/virt.sls
@@ -1,9 +1,13 @@
{% from "salt/map.jinja" import control with context %}
{%- if control.enabled and control.virt_enabled is defined %}
+include:
+- salt.minion
+
salt_control_virt_packages:
pkg.installed:
- names: {{ control.virt_pkgs }}
+
{#
{%- for package in control.virt_pips %}
@@ -14,6 +18,18 @@
{%- endfor %}
#}
+
+/etc/salt/minion.d/_virt.conf:
+ file.managed:
+ - source: salt://salt/files/_virt.conf
+ - user: root
+ - group: root
+ - template: jinja
+ - require:
+ - pkg: salt_control_virt_packages
+ - watch_in:
+ - service: salt_minion_service
+
{%- for cluster_name, cluster in control.cluster.iteritems() %}
{%- if cluster.engine == "virt" %}
@@ -32,8 +48,8 @@
- mem: {{ size.ram }}
- image: salt://{{ node.image }}
- start: True
- - disk: {{ node.disk_profile }}
- - nic: {{ node.net_profile }}
+ - disk: {{ size.disk_profile }}
+ - nic: {{ size.net_profile }}
- kwargs:
seed: True
serial_type: pty
diff --git a/salt/files/_virt.conf b/salt/files/_virt.conf
new file mode 100644
index 0000000..cf15dea
--- /dev/null
+++ b/salt/files/_virt.conf
@@ -0,0 +1,29 @@
+{% from "salt/map.jinja" import control with context %}
+
+virt:
+ nic:
+ {%- for item_name, item in control.get('net_profile', {}).iteritems() %}
+ {{ item_name }}:
+ {%- for iface_name, iface in item.iteritems() %}
+ {{ iface_name }}:
+ {%- if iface.bridge is defined %}
+ bridge: {{ iface.bridge }}
+ {%- endif %}
+ {%- if iface.network is defined %}
+ network: {{ iface.network }}
+ {%- endif %}
+ {%- if iface.model is defined %}
+ model: {{ iface.model }}
+ {%- endif %}
+ {%- endfor %}
+ disk:
+ {%- for item_name, item in control.get('disk_profile', {}).iteritems() %}
+ {{ item_name }}:
+ {%- for disk_name, disk in item.iteritems() %}
+ - {{ disk }}:
+ {%- if disk.size is defined %}
+ size: {{ disk.size }}
+ {%- endif %}
+ {%- endfor %}
+
+virt.images: /var/lib/libvirt/images
\ No newline at end of file
diff --git a/salt/files/virt.conf b/salt/files/virt.conf
deleted file mode 100644
index dae1fae..0000000
--- a/salt/files/virt.conf
+++ /dev/null
@@ -1,17 +0,0 @@
-{% from "salt/map.jinja" import control with context %}
-
-virt:
- nic:
- test:
- eth0:
- bridge: virbr0
- model: virtio
- eth0:
- bridge: virbr0
- model: virtio
- disk:
- database:
- - system:
- size: 8192
- - data:
- size: 30720
diff --git a/salt/map.jinja b/salt/map.jinja
index ec88187..efbcbcd 100644
--- a/salt/map.jinja
+++ b/salt/map.jinja
@@ -113,7 +113,7 @@
'cloud_pips': ['apache-libcloud', 'netaddr'],
'cloud_pkgs': ['python-netaddr', 'python-libcloud'],
'virt_pips': ['libvirt-python',],
- 'virt_pkgs': ['libvirt-dev', 'pkg-config'],
+ 'virt_pkgs': ['libvirt-dev', 'pkg-config', 'libguestfs-tools'],
'maas_pkgs': ['python-maas-client',],
'cluster': {},
},
diff --git a/salt/virt/init.sls b/salt/virt/init.sls
deleted file mode 100644
index 5811e85..0000000
--- a/salt/virt/init.sls
+++ /dev/null
@@ -1,44 +0,0 @@
-
-wlan0:
- network.managed:
- - enabled: True
- - type: eth
- - bridge: br0
-
-br0:
- network.managed:
- - enabled: True
- - type: bridge
- - proto: dhcp
- - require:
- - network: wlan0
-
-libvirt:
- pkg.installed: []
- file.managed:
- - name: /etc/sysconfig/libvirtd
- - contents: 'LIBVIRTD_ARGS="--listen"'
- - require:
- - pkg: libvirt
- libvirt.keys:
- - require:
- - pkg: libvirt
- service.running:
- - name: libvirtd
- - require:
- - pkg: libvirt
- - network: br0
- - libvirt: libvirt
- - watch:
- - file: libvirt
-
-libvirt-python:
- pkg.installed: []
-
-libguestfs:
- pkg.installed:
- - pkgs:
- - libguestfs
- - libguestfs-tools
-
-