Преглед изворни кода

Virt disk and net profiles

tags/0.4
Ales Komarek пре 8 година
родитељ
комит
14c3d8d829
6 измењених фајлова са 54 додато и 67 уклоњено
  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 Прегледај датотеку

@@ -7,12 +7,15 @@ parameters:
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

+ 18
- 2
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 @@ salt_control_virt_packages:

{%- 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 @@ salt_control_virt_{{ cluster_name }}_{{ node_name }}:
- 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

+ 29
- 0
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

+ 0
- 17
salt/files/virt.conf Прегледај датотеку

@@ -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

+ 1
- 1
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': {},
},

+ 0
- 44
salt/virt/init.sls Прегледај датотеку

@@ -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



Loading…
Откажи
Сачувај