Merge "Update nova-compute to support baremetal case"
diff --git a/metadata/service/compute/ironic.yml b/metadata/service/compute/ironic.yml
new file mode 100644
index 0000000..c776dde
--- /dev/null
+++ b/metadata/service/compute/ironic.yml
@@ -0,0 +1,52 @@
+applications:
+- nova
+classes:
+- service.nova.support
+parameters:
+  nova:
+    compute:
+      version: ${_param:nova_version}
+      enabled: true
+      compute_driver: 'ironic.IronicDriver'
+      ram_allocation_ratio: 1.0
+      force_config_drive: True
+      config_drive_format: 'iso9660'
+      database:
+        engine: mysql
+        host: ${_param:cluster_vip_address}
+        port: 3306
+        name: nova
+        user: nova
+        password: ${_param:mysql_nova_password}
+      identity:
+        engine: keystone
+        region: RegionOne
+        host: ${_param:cluster_vip_address}
+        port: 35357
+        user: nova
+        password: ${_param:keystone_nova_password}
+        tenant: service
+      message_queue:
+        engine: rabbitmq
+        host: ${_param:cluster_vip_address}
+        port: 5672
+        user: openstack
+        password: ${_param:rabbitmq_openstack_password}
+        virtual_host: '/openstack'
+      image:
+        engine: glance
+        host: ${_param:cluster_vip_address}
+        port: 9292
+      network:
+        engine: neutron
+        region: RegionOne
+        host: ${_param:cluster_vip_address}
+        port: 9696
+      ironic:
+        region: RegionOne
+        host: ${_param:ironic_service_host}
+        port: 6385
+        user: ironic
+        tenant: service
+        password: ${_param:keystone_ironic_password}
+        auth_type: password
diff --git a/nova/compute.sls b/nova/compute.sls
index b16c97a..7c60447 100644
--- a/nova/compute.sls
+++ b/nova/compute.sls
@@ -29,47 +29,6 @@
     - service: nova_compute_services
 {%- endif %}
 
-{%- if not salt['user.info']('nova') %}
-# MOS9 libvirt fix to create group
-group_libvirtd:
-  group.present:
-    - name: libvirtd
-    - system: True
-    - require_in:
-      - user: user_nova_compute
-
-user_nova_compute:
-  user.present:
-  - name: nova
-  - home: /var/lib/nova
-  {%- if compute.user is defined %}
-  - shell: /bin/bash
-  {%- else %}
-  - shell: /bin/false
-  {%- endif %}
-  - uid: 303
-  - gid: 303
-  - system: True
-  - groups:
-    {%- if salt['group.info']('libvirtd') %}
-    - libvirtd
-    {%- endif %}
-    - nova
-  - require_in:
-    - pkg: nova_compute_packages
-    {%- if compute.user is defined %}
-    - file: /var/lib/nova/.ssh/id_rsa
-    {%- endif %}
-
-group_nova_compute:
-  group.present:
-    - name: nova
-    - gid: 303
-    - system: True
-    - require_in:
-      - user: user_nova_compute
-{%- endif %}
-
 {%- if compute.user is defined %}
 
 nova_auth_keys:
@@ -155,6 +114,47 @@
 
 {%- if compute.virtualization == 'kvm' %}
 
+{%- if not salt['user.info']('nova') %}
+# MOS9 libvirt fix to create group
+group_libvirtd:
+  group.present:
+    - name: libvirtd
+    - system: True
+    - require_in:
+      - user: user_nova_compute
+
+user_nova_compute:
+  user.present:
+  - name: nova
+  - home: /var/lib/nova
+  {%- if compute.user is defined %}
+  - shell: /bin/bash
+  {%- else %}
+  - shell: /bin/false
+  {%- endif %}
+  - uid: 303
+  - gid: 303
+  - system: True
+  - groups:
+    {%- if salt['group.info']('libvirtd') %}
+    - libvirtd
+    {%- endif %}
+    - nova
+  - require_in:
+    - pkg: nova_compute_packages
+    {%- if compute.user is defined %}
+    - file: /var/lib/nova/.ssh/id_rsa
+    {%- endif %}
+
+group_nova_compute:
+  group.present:
+    - name: nova
+    - gid: 303
+    - system: True
+    - require_in:
+      - user: user_nova_compute
+{%- endif %}
+
 {% if compute.ceph is defined %}
 
 ceph_package:
diff --git a/nova/files/newton/nova-compute.conf.Debian b/nova/files/newton/nova-compute.conf.Debian
index d80f8ec..aed1670 100644
--- a/nova/files/newton/nova-compute.conf.Debian
+++ b/nova/files/newton/nova-compute.conf.Debian
@@ -11,7 +11,7 @@
 compute_manager=nova.compute.manager.ComputeManager
 network_device_mtu=65000
 use_neutron = True
-config_drive_format=vfat
+config_drive_format={{ compute.get('config_drive_format', 'vfat') }}
 force_config_drive=True
 force_raw_images=True
 notify_api_faults=False
@@ -42,7 +42,10 @@
 auth_strategy = keystone
 
 neutron_url_timeout = 300
-compute_driver = libvirt.LibvirtDriver
+compute_driver = {{ compute.get('compute_driver', 'libvirt.LibvirtDriver') }}
+{%- if compute.ram_allocation_ratio is defined %}
+ram_allocation_ratio = {{ compute.ram_allocation_ratio }}
+{%- endif %}
 
 heal_instance_info_cache_interval = {{ compute.heal_instance_info_cache_interval }}
 
@@ -166,7 +169,9 @@
 
 
 [glance]
+{%- if compute.image is defined %}
 api_servers=http://{{ compute.image.host }}:9292
+{%- endif %}
 
 [neutron]
 username={{ compute.network.user }}
@@ -185,3 +190,14 @@
 os_region_name = {{ compute.identity.region }}
 catalog_info=volumev2:cinderv2:internalURL
 
+{%- if compute.ironic is defined %}
+[ironic]
+api_endpoint=http://{{ compute.ironic.host }}:{{ compute.ironic.get('port', 6385) }}
+auth_type={{ compute.ironic.auth_type }}
+auth_url=http://{{ compute.identity.host }}:{{ compute.identity.port }}/v3
+project_name={{ compute.identity.get('tenant', 'service') }}
+project_domain_name={{ compute.ironic.get('project_domain_name', 'Default') }}
+username={{ compute.ironic.user }}
+user_domain_name={{ compute.ironic.get('user_domain_name', 'Default') }}
+password={{ compute.ironic.password }}
+{%- endif %}
diff --git a/nova/files/ocata/nova-compute.conf.Debian b/nova/files/ocata/nova-compute.conf.Debian
index eefa31c..c42d000 100644
--- a/nova/files/ocata/nova-compute.conf.Debian
+++ b/nova/files/ocata/nova-compute.conf.Debian
@@ -165,7 +165,7 @@
 # * ``hyperv.HyperVDriver``
 #  (string value)
 #compute_driver=<None>
-compute_driver = libvirt.LibvirtDriver
+compute_driver = {{ compute.get('compute_driver', 'libvirt.LibvirtDriver') }}
 
 #
 # Allow destination machine to match source for resize. Useful when
@@ -382,7 +382,7 @@
 # backing files will not be used.
 #  (boolean value)
 #use_cow_images=true
-{%- if compute.image.use_cow is defined %}
+{%- if compute.image is defined and compute.image.use_cow is defined %}
 use_cow_images = {{ compute.image.use_cow }}
 {%- endif %}
 
@@ -574,7 +574,11 @@
 # * Any valid positive integer or float value
 #  (floating point value)
 # Minimum value: 0
+{%- if compute.ram_allocation_ratio is defined %}
+ram_allocation_ratio = {{ compute.ram_allocation_ratio }}
+{%- else  %}
 #ram_allocation_ratio=0.0
+{%- endif %}
 
 #
 # This option helps you specify virtual disk to physical disk
@@ -1253,7 +1257,7 @@
 #  (string value)
 # Allowed values: iso9660, vfat
 #config_drive_format=iso9660
-config_drive_format=vfat
+config_drive_format={{ compute.get('config_drive_format', 'vfat') }}
 
 #
 # Force injection to take place on a config drive
@@ -5003,7 +5007,9 @@
 #   (i.e. "http://10.0.1.0:9292" or "https://my.glance.server/image").
 #  (list value)
 #api_servers=<None>
+{%- if compute.image is defined %}
 api_servers=http://{{ compute.image.host }}:9292
+{% endif %}
 
 #
 # Enable insecure SSL (https) requests to glance.
@@ -5454,6 +5460,7 @@
 #filesystems =
 
 
+{% if compute.ironic is defined -%}
 [ironic]
 #
 # Configuration options for Ironic driver (Bare Metal).
@@ -5471,7 +5478,7 @@
 #
 
 # URL override for the Ironic API endpoint. (string value)
-#api_endpoint=http://ironic.example.org:6385/
+api_endpoint=http://{{ compute.ironic.host }}:{{ compute.ironic.port }}
 
 #
 # The number of times to retry when a request conflicts.
@@ -5517,13 +5524,13 @@
 
 # Authentication type to load (string value)
 # Deprecated group/name - [ironic]/auth_plugin
-#auth_type=<None>
+auth_type={{ compute.ironic.auth_type }}
 
 # Config Section from which to load plugin specific options (string value)
 #auth_section=<None>
 
 # Authentication URL (string value)
-#auth_url=<None>
+auth_url=http://{{ compute.identity.host }}:{{ compute.identity.port }}/v3
 
 # Domain ID to scope to (string value)
 #domain_id=<None>
@@ -5535,13 +5542,13 @@
 #project_id=<None>
 
 # Project name to scope to (string value)
-#project_name=<None>
+project_name={{ compute.identity.tenant }}
 
 # Domain ID containing project (string value)
 #project_domain_id=<None>
 
 # Domain name containing project (string value)
-#project_domain_name=<None>
+project_domain_name={{ compute.ironic.project_domain_name }}
 
 # Trust ID (string value)
 #trust_id=<None>
@@ -5551,16 +5558,17 @@
 
 # Username (string value)
 # Deprecated group/name - [ironic]/user-name
-#username=<None>
+username={{ compute.ironic.user }}
 
 # User's domain id (string value)
 #user_domain_id=<None>
 
 # User's domain name (string value)
-#user_domain_name=<None>
+user_domain_name={{ compute.ironic.user_domain_name }}
 
 # User's password (string value)
-#password=<None>
+password={{ compute.ironic.password }}
+{%- endif %}
 
 
 [key_manager]
@@ -9036,7 +9044,9 @@
 # * update html5proxy_base_url
 # * update server_proxyclient_address
 enabled = false
+{%- if compute.vncproxy_url is defined %}
 html5proxy_base_url = {{ compute.vncproxy_url }}/spice_auto.html
+{%- endif %}
 #
 # From nova.conf
 #
@@ -9817,10 +9827,16 @@
 # From nova.conf
 #
 enabled = true
+{%- if compute.vncproxy_url is defined %}
 novncproxy_base_url={{ compute.vncproxy_url }}/vnc_auto.html
+{%- endif %}
+{%- if compute.bind is defined and compute.bind.vnc_port is defined %}
 novncproxy_port={{ compute.bind.vnc_port }}
+{%- endif %}
 vncserver_listen=0.0.0.0
+{%- if compute.bind is defined and compute.bind.vnc_address is defined %}
 vncserver_proxyclient_address={{ compute.bind.vnc_address }}
+{%- endif %}
 keymap = {{ compute.get('vnc_keymap', 'en-us') }}
 
 #
diff --git a/nova/meta/sphinx.yml b/nova/meta/sphinx.yml
index 9ccaa84..6a3a4cb 100644
--- a/nova/meta/sphinx.yml
+++ b/nova/meta/sphinx.yml
@@ -13,9 +13,11 @@
         virtualization:
           name: "Virtualization type"
           value: {{ compute.virtualization }}
+        {%- if compute.vncproxy_url is defined %}
         vncproxy_url:
           name: "VNC proxy URL"
           value: {{ compute.vncproxy_url }}
+        {%- endif %}
         {%- if compute.reserved_host_memory_mb is defined %}
         reserved_host_memory_mb:
           name: "Reserved Host Memmory"
@@ -27,9 +29,11 @@
         network_host:
           name: "Network service"
           value: {{ compute.network.host }}:{{ compute.network.port }}
+        {%- if compute.image is defined %}
         glance_host:
           name: "Image service"
           value: {{ compute.image.host }}:{{ compute.image.port }}
+        {%- endif %}
         message_queue_ip:
           name: "Message queue"
           value: {{ compute.message_queue.user }}@{{ compute.message_queue.host }}:{{ compute.message_queue.port }}{{ compute.message_queue.virtual_host }}