Merge "New parameter with default value cinder for ceph storage in secret.xml"
diff --git a/FORMULA b/FORMULA
new file mode 100644
index 0000000..02bd0ef
--- /dev/null
+++ b/FORMULA
@@ -0,0 +1,8 @@
+name: nova
+os: Debian, RedHat
+os_family: Debian, RedHat
+version: 201606
+release: 1
+summary: Formula for installing and configuring nova
+description: Formula for installing and configuring nova
+top_level_dir: nova
diff --git a/README.rst b/README.rst
index 87f1d75..d415871 100644
--- a/README.rst
+++ b/README.rst
@@ -3,7 +3,10 @@
 Nova
 ==============
 
-OpenStack Nova provides a cloud computing fabric controller, supporting a wide variety of virtualization technologies, including KVM, Xen, LXC, VMware, and more. In addition to its native API, it includes compatibility with the commonly encountered Amazon EC2 and S3 APIs.
+OpenStack Nova provides a cloud computing fabric controller, supporting a wide
+variety of virtualization technologies, including KVM, Xen, LXC, VMware, and
+more. In addition to its native API, it includes compatibility with the
+commonly encountered Amazon EC2 and S3 APIs.
 
 Sample pillars
 ==============
@@ -154,7 +157,6 @@
           max_files: 4096
           max_processes: 4096
 
-
 Nova services on compute node with OpenContrail
 
 .. code-block:: yaml
@@ -202,10 +204,43 @@
       ....
 
 
+Nova with ephemeral configured with Ceph
 
-Read more
-=========
+.. code-block:: yaml
 
-* http://docs.openstack.org/developer/nova/
-* http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
-* http://bugs.launchpad.net/nova
+    nova:
+      compute:
+        enabled: true
+        ...
+        ceph:
+          ephemeral: yes
+          rbd_pool: nova
+          rbd_user: nova
+          secret_uuid: 03006edd-d957-40a3-ac4c-26cd254b3731
+
+
+Documentation and Bugs
+============================
+
+To learn how to deploy OpenStack Salt, consult the documentation available
+online at:
+
+    https://wiki.openstack.org/wiki/OpenStackSalt
+
+In the unfortunate event that bugs are discovered, they should be reported to
+the appropriate bug tracker. If you obtained the software from a 3rd party
+operating system vendor, it is often wise to use their own bug tracker for
+reporting problems. In all other cases use the master OpenStack bug tracker,
+available at:
+
+    http://bugs.launchpad.net/openstack-salt
+
+Developers wishing to work on the OpenStack Salt project should always base
+their work on the latest formulas code, available from the master GIT
+repository at:
+
+    https://git.openstack.org/cgit/openstack/salt-formula-nova
+
+Developers should also join the discussion on the IRC list, at:
+
+    https://wiki.openstack.org/wiki/Meetings/openstack-salt
diff --git a/nova/controller.sls b/nova/controller.sls
index 90c721f..1cde73a 100644
--- a/nova/controller.sls
+++ b/nova/controller.sls
@@ -63,6 +63,8 @@
   - require:
     - pkg: nova_controller_packages
 
+{%- if not grains.get('noservices', False) %}
+
 nova_controller_syncdb:
   cmd.run:
   - names:
@@ -84,3 +86,16 @@
     - file: /etc/nova/api-paste.ini
 
 {%- endif %}
+
+{%- if grains.get('virtual_subtype', None) == "Docker" %}
+
+nova_entrypoint:
+  file.managed:
+  - name: /entrypoint.sh
+  - template: jinja
+  - source: salt://nova/files/entrypoint.sh
+  - mode: 755
+
+{%- endif %}
+
+{%- endif %}
diff --git a/nova/files/entrypoint.sh b/nova/files/entrypoint.sh
new file mode 100644
index 0000000..35c88fc
--- /dev/null
+++ b/nova/files/entrypoint.sh
@@ -0,0 +1,37 @@
+{%- from "nova/map.jinja" import controller with context -%}
+#!/bin/bash -e
+
+cat /srv/salt/pillar/nova-controller.sls | envsubst > /tmp/nova-controller.sls
+mv /tmp/nova-controller.sls /srv/salt/pillar/nova-controller.sls
+
+salt-call --local --retcode-passthrough state.highstate
+
+{% for service in controller.services %}
+service {{ service }} stop || true
+{% endfor %}
+
+if [ "$1" == "api" ]; then
+    echo "starting nova-api"
+    su nova --shell=/bin/sh -c '/usr/bin/nova-api --config-file=/etc/nova/nova.conf'
+elif [ "$1" == "scheduler" ]; then
+    echo "starting nova-scheduler"
+    su nova --shell=/bin/sh -c '/usr/bin/nova-scheduler --config-file=/etc/nova/nova.conf'
+elif [ "$1" == "conductor" ]; then
+    echo "starting nova-conductor"
+    su nova --shell=/bin/sh -c '/usr/bin/nova-conductor --config-file=/etc/nova/nova.conf'
+elif [ "$1" == "consoleauth" ]; then
+    echo "starting nova-consoleauth"
+    su nova --shell=/bin/sh -c '/usr/bin/nova-consoleauth --config-file=/etc/nova/nova.conf'
+elif [ "$1" == "cert" ]; then
+    echo "starting nova-cert"
+    su nova --shell=/bin/sh -c '/usr/bin/nova-cert --config-file=/etc/nova/nova.conf'
+elif [ "$1" == "novncproxy" ]; then
+    echo "starting nova-novncproxy"
+    su nova --shell=/bin/sh -c '/usr/bin/nova-novncproxy --config-file=/etc/nova/nova.conf'
+else
+    echo "No parameter submitted, don't know what to start" 1>&2
+fi
+
+{#-
+vim: syntax=jinja
+-#}
\ No newline at end of file
diff --git a/nova/files/heka.toml b/nova/files/heka.toml
index e15af73..ebbc8e6 100644
--- a/nova/files/heka.toml
+++ b/nova/files/heka.toml
@@ -1,10 +1,11 @@
 [logstreamer_nova]
 type = "LogstreamerInput"
 log_directory = "/var/log/nova"
-file_match = '(?P<Service>.+)\.log\.?(?P<Seq>\d*)$'
+file_match = '(?P<Service>.+)\.log\.?(?P<Index>\d*)?(.gz)?'
 differentiator = ['nova','_','Service']
 priority = ["^Index"]
 decoder = "openstack"
+oldest_duration = "168h"
 
 [openstack]
 type = "SandboxDecoder"
diff --git a/nova/files/juno/nova-compute.conf.Debian b/nova/files/juno/nova-compute.conf.Debian
index 08e5e10..bb4dba5 100644
--- a/nova/files/juno/nova-compute.conf.Debian
+++ b/nova/files/juno/nova-compute.conf.Debian
@@ -22,7 +22,11 @@
 reserved_host_memory_mb = {{ compute.reserved_host_memory_mb }}
 {%- endif %}
 
+{%- if compute.get('ceph', {}).ephemeral is defined %}
+live_migration_flag="VIR_MIGRATE_UNDEFINE_SOURCE,VIR_MIGRATE_PEER2PEER,VIR_MIGRATE_LIVE,VIR_MIGRATE_PERSIST_DEST,VIR_MIGRATE_TUNNELLED"
+{%- else %}
 live_migration_flag=VIR_MIGRATE_UNDEFINE_SOURCE,VIR_MIGRATE_PEER2PEER,VIR_MIGRATE_LIVE
+{%- endif %}
 live_migration_retry_count=30
 
 #Neutron
@@ -127,3 +131,18 @@
 auth_port = {{ compute.identity.port }}
 auth_protocol=http
 auth_uri=http://{{ compute.identity.host }}:5000
+
+{%- if compute.get('ceph', {}).ephemeral is defined %}
+[libvirt]
+images_type=rbd
+images_rbd_pool={{ compute.ceph.rbd_pool }}
+images_rbd_ceph_conf=/etc/ceph/ceph.conf
+rbd_user={{ compute.ceph.rbd_user }}
+rbd_secret_uuid={{ compute.ceph.secret_uuid }}
+libvirt_inject_password=false
+libvirt_inject_key=false
+libvirt_inject_partition=-2
+{%- endif %}
+
+[cinder]
+catalog_info=volumev2:cinderv2:internalURL
diff --git a/nova/files/juno/nova-controller.conf.Debian b/nova/files/juno/nova-controller.conf.Debian
index d861cfc..8e8d138 100644
--- a/nova/files/juno/nova-controller.conf.Debian
+++ b/nova/files/juno/nova-controller.conf.Debian
@@ -151,3 +151,6 @@
 connection_debug = 10
 pool_timeout = 120
 connection = {{ controller.database.engine }}://{{ controller.database.user }}:{{ controller.database.password }}@{{ controller.database.host }}/{{ controller.database.name }}
+
+[cinder]
+catalog_info=volumev2:cinderv2:internalURL
diff --git a/nova/files/kilo/nova-compute.conf.Debian b/nova/files/kilo/nova-compute.conf.Debian
index 9c4a352..4f19730 100644
--- a/nova/files/kilo/nova-compute.conf.Debian
+++ b/nova/files/kilo/nova-compute.conf.Debian
@@ -16,6 +16,8 @@
 api_paste_config=/etc/nova/api-paste.ini
 volumes_path=/var/lib/nova/volumes
 enabled_apis=ec2,osapi_compute,metadata
+vnc_keymap = {{ compute.get('vnc_keymap', 'en-us') }}
+
 
 {%- if compute.image.use_cow is defined %}
 use_cow_images = {{ compute.image.use_cow }}
@@ -27,7 +29,11 @@
 
 allow_resize_to_same_host=True
 
+{%- if compute.get('ceph', {}).ephemeral is defined %}
+live_migration_flag="VIR_MIGRATE_UNDEFINE_SOURCE,VIR_MIGRATE_PEER2PEER,VIR_MIGRATE_LIVE,VIR_MIGRATE_PERSIST_DEST,VIR_MIGRATE_TUNNELLED"
+{%- else %}
 live_migration_flag=VIR_MIGRATE_UNDEFINE_SOURCE,VIR_MIGRATE_PEER2PEER,VIR_MIGRATE_LIVE
+{%- endif %}
 live_migration_retry_count=30
 
 #Neutron
@@ -170,3 +176,16 @@
 
 [cinder]
 os_region_name = {{ compute.identity.region }}
+catalog_info=volumev2:cinderv2:internalURL
+
+{%- if compute.get('ceph', {}).ephemeral is defined %}
+[libvirt]
+images_type=rbd
+images_rbd_pool={{ compute.ceph.rbd_pool }}
+images_rbd_ceph_conf=/etc/ceph/ceph.conf
+rbd_user={{ compute.ceph.rbd_user }}
+rbd_secret_uuid={{ compute.ceph.secret_uuid }}
+libvirt_inject_password=false
+libvirt_inject_key=false
+libvirt_inject_partition=-2
+{%- endif %}
diff --git a/nova/files/kilo/nova-controller.conf.Debian b/nova/files/kilo/nova-controller.conf.Debian
index fe39363..e61da50 100644
--- a/nova/files/kilo/nova-controller.conf.Debian
+++ b/nova/files/kilo/nova-controller.conf.Debian
@@ -24,6 +24,7 @@
 ram_allocation_ratio = {{ controller.ram_allocation_ratio }}
 disk_allocation_ratio = {{ controller.disk_allocation_ratio }}
 scheduler_default_filters = {{ controller.scheduler_default_filters }}
+vnc_keymap = {{ controller.get('vnc_keymap', 'en-us') }}
 
 allow_resize_to_same_host = True
 
@@ -208,3 +209,4 @@
 
 [cinder]
 os_region_name = {{ controller.identity.region }}
+catalog_info=volumev2:cinderv2:internalURL
diff --git a/nova/files/liberty/nova-compute.conf.Debian b/nova/files/liberty/nova-compute.conf.Debian
index 85ed88b..5f36af6 100644
--- a/nova/files/liberty/nova-compute.conf.Debian
+++ b/nova/files/liberty/nova-compute.conf.Debian
@@ -27,7 +27,11 @@
 
 allow_resize_to_same_host=True
 
+{%- if compute.get('ceph', {}).ephemeral is defined %}
+live_migration_flag="VIR_MIGRATE_UNDEFINE_SOURCE,VIR_MIGRATE_PEER2PEER,VIR_MIGRATE_LIVE,VIR_MIGRATE_PERSIST_DEST,VIR_MIGRATE_TUNNELLED"
+{%- else %}
 live_migration_flag=VIR_MIGRATE_UNDEFINE_SOURCE,VIR_MIGRATE_PEER2PEER,VIR_MIGRATE_LIVE
+{%- endif %}
 live_migration_retry_count=30
 
 #Neutron
@@ -170,3 +174,19 @@
 
 [cinder]
 os_region_name = {{ compute.identity.region }}
+catalog_info=volumev2:cinderv2:internalURL
+
+{%- if compute.get('ceph', {}).ephemeral is defined %}
+[libvirt]
+images_type=rbd
+images_rbd_pool={{ compute.ceph.rbd_pool }}
+images_rbd_ceph_conf=/etc/ceph/ceph.conf
+rbd_user={{ compute.ceph.rbd_user }}
+rbd_secret_uuid={{ compute.ceph.secret_uuid }}
+libvirt_inject_password=false
+libvirt_inject_key=false
+libvirt_inject_partition=-2
+{%- endif %}
+
+[vnc]
+keymap = {{ compute.get('vnc_keymap', 'en-us') }}
diff --git a/nova/files/liberty/nova-controller.conf.Debian b/nova/files/liberty/nova-controller.conf.Debian
index d0b970b..864a778 100644
--- a/nova/files/liberty/nova-controller.conf.Debian
+++ b/nova/files/liberty/nova-controller.conf.Debian
@@ -207,3 +207,7 @@
 
 [cinder]
 os_region_name = {{ controller.identity.region }}
+catalog_info=volumev2:cinderv2:internalURL
+
+[vnc]
+keymap = {{ controller.get('vnc_keymap', 'en-us') }}
diff --git a/nova/files/mitaka/nova-compute.conf.Debian b/nova/files/mitaka/nova-compute.conf.Debian
index ef8c184..a4cd639 100644
--- a/nova/files/mitaka/nova-compute.conf.Debian
+++ b/nova/files/mitaka/nova-compute.conf.Debian
@@ -26,7 +26,11 @@
 
 allow_resize_to_same_host=True
 
+{%- if compute.get('ceph', {}).ephemeral is defined %}
+live_migration_flag="VIR_MIGRATE_UNDEFINE_SOURCE,VIR_MIGRATE_PEER2PEER,VIR_MIGRATE_LIVE,VIR_MIGRATE_PERSIST_DEST,VIR_MIGRATE_TUNNELLED"
+{%- else %}
 live_migration_flag=VIR_MIGRATE_UNDEFINE_SOURCE,VIR_MIGRATE_PEER2PEER,VIR_MIGRATE_LIVE
+{%- endif %}
 live_migration_retry_count=30
 
 auth_strategy = keystone
@@ -133,13 +137,31 @@
 host = {{ compute.image.host }}
 
 [neutron]
-auth_strategy = keystone
-admin_username={{ compute.network.user }}
-admin_password={{ compute.network.password }}
-admin_tenant_name={{ compute.identity.tenant }}
-admin_auth_url=http://{{ compute.identity.host }}:{{ compute.identity.port }}/v{% if compute.identity.get('version', 2) == 2 %}2.0{% else %}3{% endif %}
+username={{ compute.network.user }}
+password={{ compute.network.password }}
+project_name={{ compute.identity.tenant }}
+auth_url=http://{{ compute.identity.host }}:{{ compute.identity.port }}
 url=http://{{ compute.network.host }}:{{ compute.network.port }}
 region_name= {{ compute.network.region }}
+auth_type = password
+project_domain_name = default
+user_domain_name = default
 
 [cinder]
 os_region_name = {{ compute.identity.region }}
+catalog_info=volumev2:cinderv2:internalURL
+
+{%- if compute.get('ceph', {}).ephemeral is defined %}
+[libvirt]
+images_type=rbd
+images_rbd_pool={{ compute.ceph.rbd_pool }}
+images_rbd_ceph_conf=/etc/ceph/ceph.conf
+rbd_user={{ compute.ceph.rbd_user }}
+rbd_secret_uuid={{ compute.ceph.secret_uuid }}
+libvirt_inject_password=false
+libvirt_inject_key=false
+libvirt_inject_partition=-2
+{%- endif %}
+
+[vnc]
+keymap = {{ compute.get('vnc_keymap', 'en-us') }}
diff --git a/nova/files/mitaka/nova-controller.conf.Debian b/nova/files/mitaka/nova-controller.conf.Debian
index 37a72a3..e38f50a 100644
--- a/nova/files/mitaka/nova-controller.conf.Debian
+++ b/nova/files/mitaka/nova-controller.conf.Debian
@@ -166,17 +166,19 @@
 host = {{ controller.glance.host }}
 
 [neutron]
-auth_strategy = keystone
-admin_auth_url = http://{{ controller.identity.host }}:35357/v{% if controller.identity.get('version', 2) == 2 %}2.0{% else %}3{% endif %}
+auth_type = password
+project_domain_name = default
+user_domain_name = default
+auth_url = http://{{ controller.identity.host }}:35357
 {% if pillar.neutron is defined %}
-admin_password={{ pillar.neutron.server.identity.password }}
-admin_tenant_name={{ pillar.neutron.server.identity.tenant }}
-admin_username={{ pillar.neutron.server.identity.user }}
+password={{ pillar.neutron.server.identity.password }}
+project_name={{ pillar.neutron.server.identity.tenant }}
+username={{ pillar.neutron.server.identity.user }}
 region_name= {{ pillar.neutron.server.identity.region }}
 {%- else %}
-admin_password={{ controller.network.password }}
-admin_tenant_name={{ controller.network.tenant }}
-admin_username={{ controller.network.user }}
+password={{ controller.network.password }}
+project_name={{ controller.network.tenant }}
+username={{ controller.network.user }}
 region_name= {{ controller.network.region }}
 {%- endif %}
 url=http://{{ controller.network.host }}:{{ controller.network.port }}
@@ -185,3 +187,7 @@
 
 [cinder]
 os_region_name = {{ controller.identity.region }}
+catalog_info=volumev2:cinderv2:internalURL
+
+[vnc]
+keymap = {{ controller.get('vnc_keymap', 'en-us') }}
diff --git a/nova/map.jinja b/nova/map.jinja
index d8d7f36..96f8976 100644
--- a/nova/map.jinja
+++ b/nova/map.jinja
@@ -7,7 +7,7 @@
 
 {% set controller = salt['grains.filter_by']({
     'Debian': {
-        'pkgs': ['nova-novncproxy', 'novnc', 'nova-api', 'nova-ajax-console-proxy', 'nova-cert', 'nova-conductor', 'nova-consoleauth', 'nova-doc', 'nova-scheduler', 'python-novaclient', 'python-memcache'],
+        'pkgs': ['nova-novncproxy', 'novnc', 'nova-api', 'nova-ajax-console-proxy', 'nova-cert', 'nova-conductor', 'nova-consoleauth', 'nova-doc', 'nova-scheduler', 'python-novaclient', 'python-memcache', 'gettext-base'],
         'services': ['nova-api', 'nova-cert', 'nova-consoleauth', 'nova-scheduler', 'nova-conductor', 'nova-novncproxy'],
         'debug': false,
     },
@@ -20,7 +20,7 @@
 
 {% set compute = salt['grains.filter_by']({
     'Debian': {
-        'pkgs': ['nova-compute-kvm', 'python-novaclient', 'pm-utils', 'sysfsutils', 'sg3-utils', 'libvirt-bin', 'python-memcache', 'qemu-kvm','python-guestfs'],
+        'pkgs': ['nova-compute-kvm', 'python-novaclient', 'pm-utils', 'sysfsutils', 'sg3-utils', 'libvirt-bin', 'python-memcache', 'qemu-kvm','python-guestfs', 'gettext-base'],
         'services': ['nova-compute'],
         'libvirt_config': 'libvirtd.conf',
         'libvirt_service': 'libvirtd',
diff --git a/nova/meta/salt.yml b/nova/meta/salt.yml
new file mode 100644
index 0000000..ab7047e
--- /dev/null
+++ b/nova/meta/salt.yml
@@ -0,0 +1,11 @@
+orchestrate:
+  compute:
+    priority: 570
+    require:
+    - salt: nova.controller
+  controller:
+    priority: 560
+    batch: 1
+    require:
+    - salt: keystone.server
+
diff --git a/tests/pillar/compute_cluster.sls b/tests/pillar/compute_cluster.sls
index bbfb87c..d4085e1 100644
--- a/tests/pillar/compute_cluster.sls
+++ b/tests/pillar/compute_cluster.sls
@@ -5,6 +5,7 @@
     virtualization: kvm
     heal_instance_info_cache_interval: 60
     vncproxy_url: openstack:6080
+    vnc_keymap: en-gb
     bind:
       vnc_address: 127.0.0.1
       vnc_port: 6080
diff --git a/tests/pillar/compute_single.sls b/tests/pillar/compute_single.sls
index fa22905..b7bb345 100644
--- a/tests/pillar/compute_single.sls
+++ b/tests/pillar/compute_single.sls
@@ -5,6 +5,7 @@
     virtualization: kvm
     heal_instance_info_cache_interval: 60
     vncproxy_url: openstack:6080
+    vnc_keymap: en-gb
     bind:
       vnc_address: 127.0.0.1
       vnc_port: 6080
diff --git a/tests/pillar/control_cluster.sls b/tests/pillar/control_cluster.sls
index 5ee0ab2..f680154 100644
--- a/tests/pillar/control_cluster.sls
+++ b/tests/pillar/control_cluster.sls
@@ -4,6 +4,7 @@
     networking: default
     version: liberty
     vncproxy_url: 127.0.0.1
+    vnc_keymap: en-gb
     security_group: false
     dhcp_domain: novalocal
     scheduler_default_filters: "DifferentHostFilter,RetryFilter,AvailabilityZoneFilter,RamFilter,CoreFilter,DiskFilter,ComputeFilter,ComputeCapabilitiesFilter,ImagePropertiesFilter,ServerGroupAntiAffinityFilter,ServerGroupAffinityFilter"
diff --git a/tests/pillar/control_single.sls b/tests/pillar/control_single.sls
index 8a06a7d..fb1bbf0 100644
--- a/tests/pillar/control_single.sls
+++ b/tests/pillar/control_single.sls
@@ -5,6 +5,7 @@
     version: liberty
     security_group: false
     vncproxy_url: 127.0.0.1
+    vnc_keymap: en-gb
     dhcp_domain: novalocal
     scheduler_default_filters: "DifferentHostFilter,RetryFilter,AvailabilityZoneFilter,RamFilter,CoreFilter,DiskFilter,ComputeFilter,ComputeCapabilitiesFilter,ImagePropertiesFilter,ServerGroupAntiAffinityFilter,ServerGroupAffinityFilter"
     cpu_allocation_ratio: 16.0
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index 6710a50..8c07e58 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -18,7 +18,7 @@
 SALT_CONFIG_DIR=${SALT_CONFIG_DIR:-${BUILDDIR}/salt}
 SALT_CACHE_DIR=${SALT_CACHE_DIR:-${SALT_CONFIG_DIR}/cache}
 
-SALT_OPTS="${SALT_OPTS} --retcode-passthrough --local -c ${SALT_CONFIG_DIR}"
+SALT_OPTS="${SALT_OPTS} --retcode-passthrough --local -c ${SALT_CONFIG_DIR} --log-file=/dev/null"
 
 if [ "x${SALT_VERSION}" != "x" ]; then
     PIP_SALT_VERSION="==${SALT_VERSION}"