Browse Source

Virt disk and net profiles

tags/0.4
Ales Komarek 8 years ago
parent
commit
14c3d8d829
6 changed files with 54 additions and 67 deletions
  1. +6
    -3
      metadata/service/control/virt.yml
  2. +18
    -2
      salt/control/virt.sls
  3. +29
    -0
      salt/files/_virt.conf
  4. +0
    -17
      salt/files/virt.conf
  5. +1
    -1
      salt/map.jinja
  6. +0
    -44
      salt/virt/init.sls

+ 6
- 3
metadata/service/control/virt.yml View File

small: small:
cpu: 1 cpu: 1
ram: 2 ram: 2
hdd: 10
disk_profile: default
net_profile: default
medium: medium:
cpu: 2 cpu: 2
ram: 4 ram: 4
hdd: 20
disk_profile: default
net_profile: default
large: large:
cpu: 4 cpu: 4
ram: 8 ram: 8
hdd: 70
disk_profile: default
net_profile: default

+ 18
- 2
salt/control/virt.sls View File

{% from "salt/map.jinja" import control with context %} {% from "salt/map.jinja" import control with context %}
{%- if control.enabled and control.virt_enabled is defined %} {%- if control.enabled and control.virt_enabled is defined %}


include:
- salt.minion

salt_control_virt_packages: salt_control_virt_packages:
pkg.installed: pkg.installed:
- names: {{ control.virt_pkgs }} - names: {{ control.virt_pkgs }}

{# {#
{%- for package in control.virt_pips %} {%- for package in control.virt_pips %}




{%- endfor %} {%- 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() %} {%- for cluster_name, cluster in control.cluster.iteritems() %}


{%- if cluster.engine == "virt" %} {%- if cluster.engine == "virt" %}
- mem: {{ size.ram }} - mem: {{ size.ram }}
- image: salt://{{ node.image }} - image: salt://{{ node.image }}
- start: True - start: True
- disk: {{ node.disk_profile }}
- nic: {{ node.net_profile }}
- disk: {{ size.disk_profile }}
- nic: {{ size.net_profile }}
- kwargs: - kwargs:
seed: True seed: True
serial_type: pty serial_type: pty

+ 29
- 0
salt/files/_virt.conf View File

{% 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

+ 0
- 17
salt/files/virt.conf View File

{% 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

+ 1
- 1
salt/map.jinja View File

'cloud_pips': ['apache-libcloud', 'netaddr'], 'cloud_pips': ['apache-libcloud', 'netaddr'],
'cloud_pkgs': ['python-netaddr', 'python-libcloud'], 'cloud_pkgs': ['python-netaddr', 'python-libcloud'],
'virt_pips': ['libvirt-python',], 'virt_pips': ['libvirt-python',],
'virt_pkgs': ['libvirt-dev', 'pkg-config'],
'virt_pkgs': ['libvirt-dev', 'pkg-config', 'libguestfs-tools'],
'maas_pkgs': ['python-maas-client',], 'maas_pkgs': ['python-maas-client',],
'cluster': {}, 'cluster': {},
}, },

+ 0
- 44
salt/virt/init.sls View File


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



Loading…
Cancel
Save