From 41433b26db5d2420c124bde8c1c8b84bd00d1fb4 Mon Sep 17 00:00:00 2001 From: Bogdan Dobrelya Date: Mon, 3 Aug 2015 10:23:08 +0200 Subject: [PATCH] Add nova comp libvirt resource Signed-off-by: Bogdan Dobrelya --- example-puppet.py | 7 ++ .../nova_compute_libvirt_puppet/README.md | 84 +++++++++++++++++++ .../actions/remove.pp | 1 + .../actions/run.pp | 56 +++++++++++++ .../nova_compute_libvirt_puppet/meta.yaml | 63 ++++++++++++++ 5 files changed, 211 insertions(+) create mode 100644 resources/nova_compute_libvirt_puppet/README.md create mode 100644 resources/nova_compute_libvirt_puppet/actions/remove.pp create mode 100644 resources/nova_compute_libvirt_puppet/actions/run.pp create mode 100644 resources/nova_compute_libvirt_puppet/meta.yaml diff --git a/example-puppet.py b/example-puppet.py index 685d9173..8919162d 100644 --- a/example-puppet.py +++ b/example-puppet.py @@ -374,6 +374,11 @@ def deploy(): signals.connect(node2, nova_puppet2) signals.connect(node2, nova_compute_puppet) + # NOVA COMPUTE LIBVIRT + # NOTE(bogdando): changes nova config, so should notify nova compute service + nova_compute_libvirt_puppet = vr.create('nova_compute_libvirt_puppet', 'resources/nova_compute_libvirt_puppet', {})[0] + signals.connect(node2, nova_compute_libvirt_puppet) + # signals.connect(keystone_puppet, nova_network_puppet, {'ip': 'keystone_host', 'port': 'keystone_port'}) # signals.connect(keystone_puppet, nova_keystone_service_endpoint, {'ip': 'keystone_host', 'admin_port': 'keystone_port', 'admin_token': 'admin_token'}) # signals.connect(rabbitmq_service1, nova_network_puppet, {'ip': 'rabbitmq_host', 'port': 'rabbitmq_port'}) @@ -504,6 +509,7 @@ def deploy(): actions.resource_action(nova_conductor_puppet, 'run') actions.resource_action(nova_puppet2, 'run') + actions.resource_action(nova_compute_libvirt_puppet, 'run') actions.resource_action(nova_compute_puppet, 'run') actions.resource_action(glance_db, 'run') @@ -536,6 +542,7 @@ def undeploy(): 'nova_api_puppet', 'nova_puppet', 'nova_compute_puppet', + 'nova_compute_libvirt_puppet', 'nova_puppet2', 'cinder_volume_puppet', 'cinder_scheduler_puppet', diff --git a/resources/nova_compute_libvirt_puppet/README.md b/resources/nova_compute_libvirt_puppet/README.md new file mode 100644 index 00000000..12a5928e --- /dev/null +++ b/resources/nova_compute_libvirt_puppet/README.md @@ -0,0 +1,84 @@ +# Nova compute libvirt resource for puppet handler + +Install and manage nova-compute guests managed by libvirt. +Cannot be used separately from nova compute resource and +should share the same node. +Libvirt service name defaults are given for Debian OS family. + +# Parameters + +source https://github.com/openstack/puppet-nova_compute_libvirt/blob/5.1.0/manifests/compute/libvirt.pp + + ``libvirt_virt_type`` + (optional) Libvirt domain type. Options are: kvm, lxc, qemu, uml, xen + Replaces libvirt_type + Defaults to 'kvm' + + ``vncserver_listen`` + (optional) IP address on which instance vncservers should listen + Defaults to '127.0.0.1' + + ``migration_support`` + (optional) Whether to support virtual machine migration + Defaults to false + + ``libvirt_cpu_mode`` + (optional) The libvirt CPU mode to configure. Possible values + include custom, host-model, none, host-passthrough. + Defaults to 'host-model' if libvirt_virt_type is set to either + kvm or qemu, otherwise defaults to 'none'. + + ``libvirt_disk_cachemodes`` + (optional) A list of cachemodes for different disk types, e.g. + ["file=directsync", "block=none"] + If an empty list is specified, the disk_cachemodes directive + will be removed from nova.conf completely. + Defaults to an empty list + + ``libvirt_inject_password`` + (optional) Inject the admin password at boot time, without an agent. + Defaults to false + + ``libvirt_inject_key`` + (optional) Inject the ssh public key at boot time. + Defaults to false + + ``libvirt_inject_partition`` + (optional) The partition to inject to : -2 => disable, -1 => inspect + (libguestfs only), 0 => not partitioned, >0 => partition + number (integer value) + Defaults to -2 + + ``remove_unused_base_images`` + (optional) Should unused base images be removed? + If undef is specified, remove the line in nova.conf + otherwise, use a boolean to remove or not the base images. + Defaults to undef + + ``remove_unused_kernels`` + (optional) Should unused kernel images be removed? + This is only safe to enable if all compute nodes + have been updated to support this option. + If undef is specified, remove the line in nova.conf + otherwise, use a boolean to remove or not the kernels. + Defaults to undef + + ``remove_unused_resized_minimum_age_seconds`` + (optional) Unused resized base images younger + than this will not be removed + If undef is specified, remove the line in nova.conf + otherwise, use a integer or a string to define after + how many seconds it will be removed. + Defaults to undef + + ``remove_unused_original_minimum_age_seconds`` + (optional) Unused unresized base images younger + than this will not be removed + If undef is specified, remove the line in nova.conf + otherwise, use a integer or a string to define after + how many seconds it will be removed. + Defaults to undef + + ``libvirt_service_name`` + (optional) libvirt service name. + Defaults to $::nova::params::libvirt_service_name diff --git a/resources/nova_compute_libvirt_puppet/actions/remove.pp b/resources/nova_compute_libvirt_puppet/actions/remove.pp new file mode 100644 index 00000000..b575edb8 --- /dev/null +++ b/resources/nova_compute_libvirt_puppet/actions/remove.pp @@ -0,0 +1 @@ +notify { 'Remove action is not supported upstream': } \ No newline at end of file diff --git a/resources/nova_compute_libvirt_puppet/actions/run.pp b/resources/nova_compute_libvirt_puppet/actions/run.pp new file mode 100644 index 00000000..a33a7761 --- /dev/null +++ b/resources/nova_compute_libvirt_puppet/actions/run.pp @@ -0,0 +1,56 @@ +$resource = hiera($::resource_name) + +$libvirt_virt_type = $resource['input']['libvirt_virt_type']['value'] +$vncserver_listen = $resource['input']['vncserver_listen']['value'] +$migration_support = $resource['input']['migration_support']['value'] +$libvirt_cpu_mode = $resource['input']['libvirt_cpu_mode']['value'] +$libvirt_disk_cachemodes = $resource['input']['libvirt_disk_cachemodes']['value'] +$libvirt_inject_password = $resource['input']['libvirt_inject_password']['value'] +$libvirt_inject_key = $resource['input']['libvirt_inject_key']['value'] +$libvirt_inject_partition = $resource['input']['libvirt_inject_partition']['value'] +$remove_unused_base_images = $resource['input']['remove_unused_base_images']['value'] +$remove_unused_kernels = $resource['input']['remove_unused_kernels']['value'] +$remove_unused_resized_minimum_age_seconds = $resource['input']['remove_unused_resized_minimum_age_seconds']['value'] +$remove_unused_original_minimum_age_seconds = $resource['input']['remove_unused_original_minimum_age_seconds']['value'] +$libvirt_service_name = $resource['input']['libvirt_service_name']['value'] +$libvirt_type = $resource['input']['libvirt_type']['value'] + +class { 'nova::compute::libvirt': + libvirt_virt_type => $libvirt_virt_type, + vncserver_listen => $vncserver_listen, + migration_support => $migration_support, + libvirt_cpu_mode => $libvirt_cpu_mode, + libvirt_disk_cachemodes => $libvirt_disk_cachemodes, + libvirt_inject_password => $libvirt_inject_password, + libvirt_inject_key => $libvirt_inject_key, + libvirt_inject_partition => $libvirt_inject_partition, + remove_unused_base_images => $remove_unused_base_images, + remove_unused_kernels => $remove_unused_kernels, + remove_unused_resized_minimum_age_seconds => $remove_unused_resized_minimum_age_seconds, + remove_unused_original_minimum_age_seconds => $remove_unused_original_minimum_age_seconds, + libvirt_service_name => $libvirt_service_name, + libvirt_type => $libvirt_type, +} + +#exec { 'networking-refresh': +# command => '/sbin/ifdown -a ; /sbin/ifup -a', +#} + +#exec { 'post-nova_config': +# command => '/bin/echo "Nova config has changed"', +#} + +include nova::params + +service { 'nova-compute': + name => $::nova::params::compute_service_name, +} + +package { 'nova-compute': + name => $::nova::params::compute_package_name, +} + +package { 'nova-common': + name => $nova::params::common_package_name, + ensure => $ensure_package, +} diff --git a/resources/nova_compute_libvirt_puppet/meta.yaml b/resources/nova_compute_libvirt_puppet/meta.yaml new file mode 100644 index 00000000..62ae7b25 --- /dev/null +++ b/resources/nova_compute_libvirt_puppet/meta.yaml @@ -0,0 +1,63 @@ +id: nova_compute_libvirt +handler: puppet +puppet_module: nova +version: 1.0.0 +input: + libvirt_virt_type: + schema: str + value: 'kvm' + vncserver_listen: + schema: str + value: '127.0.0.1' + migration_support: + schema: bool + value: false + libvirt_cpu_mode: + schema: str + value: '' + libvirt_disk_cachemodes: + schema: [str] + value: [] + libvirt_inject_password: + schema: str! + value: 'changeme' + libvirt_inject_key: + schema: bool + value: false + libvirt_inject_partition: + schema: str + value: '-2' + remove_unused_base_images: + schema: str + value: '' + remove_unused_kernels: + schema: str + value: '' + remove_unused_resized_minimum_age_seconds: + schema: str + value: '' + remove_unused_original_minimum_age_seconds: + schema: str + value: '' + libvirt_service_name: + schema: str + value: 'libvirt-bin' + libvirt_type: + schema: bool + value: false + + git: + schema: {repository: str!, branch: str!} + value: {repository: 'https://github.com/openstack/puppet-nova', branch: '5.1.0'} + + ip: + schema: str! + value: + ssh_key: + schema: str! + value: + ssh_user: + schema: str! + value: + +tags: [resource/nova_compute_libvirt_service, resources/nova_compute_libvirt, resources/nova_compute, resources/nova]