File 0001-Add-config-for-default-create-volume-option.patch of Package openstack-dashboard
From 9f20fbce02eb6558f8b11766d9d27f90b5e15040 Mon Sep 17 00:00:00 2001
From: Mohammed Naser <mnaser@vexxhost.com>
Date: Wed, 25 Jan 2017 11:53:09 -0500
Subject: [PATCH] Add config for default create volume option
This patch adds the ability to configure the default "create volume"
value when launching an instance with Cinder enabled.
Co-Authored-By: Rob Cresswell <robert.cresswell@outlook.com>
Closes-Bug: 1678109
Change-Id: I272f7f1b20cc1276976c464a82d1776de92d17e7
(cherry picked from commit d734f482ece979018801f38242933dd627e8cd2d)
---
doc/source/topics/settings.rst | 5 +++++
.../launch-instance-model.service.js | 5 +++++
.../launch-instance-model.service.spec.js | 25 +++++++++++++++++++++-
.../launch-instance/source/source.controller.js | 3 ++-
.../source/source.controller.spec.js | 2 +-
.../local/local_settings.py.example | 1 +
.../notes/bug-1678109-4440ebe90908647d.yaml | 5 +++++
7 files changed, 43 insertions(+), 3 deletions(-)
create mode 100644 releasenotes/notes/bug-1678109-4440ebe90908647d.yaml
Index: horizon-10.0.6.dev4/doc/source/topics/settings.rst
===================================================================
--- horizon-10.0.6.dev4.orig/doc/source/topics/settings.rst
+++ horizon-10.0.6.dev4/doc/source/topics/settings.rst
@@ -674,6 +674,7 @@ Default::
"disable_instance_snapshot": False,
"disable_volume": False,
"disable_volume_snapshot": False,
+ "create_volume": True,
}
A dictionary of settings which can be used to provide the default values for
@@ -685,6 +686,10 @@ Drive property.
The ``enable_scheduler_hints`` setting specifies whether or not Scheduler Hints
can be provided when launching an instance.
+The ``create_volume`` setting allows you to specify the default value for the
+option of creating a new volume in the workflow for image and instance snapshot
+sources.
+
The ``disable_image`` setting disables Images as a valid boot source for launching
instances. Image sources won't show up in the Launch Instance modal.
Index: horizon-10.0.6.dev4/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.js
===================================================================
--- horizon-10.0.6.dev4.orig/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.js
+++ horizon-10.0.6.dev4/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.js
@@ -181,6 +181,7 @@
// REQUIRED for JS logic (image | snapshot | volume | volume_snapshot)
source_type: null,
source: [],
+ create_volume_default: true,
// REQUIRED for JS logic
vol_create: false,
// May be null
@@ -261,6 +262,10 @@
if ('config_drive' in defaults) {
model.newInstanceSpec.config_drive = defaults.config_drive;
}
+ if ('create_volume' in defaults) {
+ // Append "_default" to distinguish from the 'vol_create' item
+ model.newInstanceSpec.create_volume_default = defaults.create_volume;
+ }
}
/**
Index: horizon-10.0.6.dev4/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.spec.js
===================================================================
--- horizon-10.0.6.dev4.orig/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.spec.js
+++ horizon-10.0.6.dev4/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.spec.js
@@ -158,6 +158,7 @@
beforeEach(function () {
settings = {
LAUNCH_INSTANCE_DEFAULTS: {
+ create_volume: true,
config_drive: false,
disable_image: false,
disable_instance_snapshot: false,
@@ -481,6 +482,22 @@
expect(model.newInstanceSpec.config_drive).toBe(true);
});
+ it('should default create_volume to true if setting not provided', function() {
+ delete settings.LAUNCH_INSTANCE_DEFAULTS.create_volume;
+ model.initialize(true);
+ scope.$apply();
+
+ expect(model.newInstanceSpec.create_volume_default).toBe(true);
+ });
+
+ it('should default create_volume to false based on setting', function() {
+ settings.LAUNCH_INSTANCE_DEFAULTS.create_volume = false;
+ model.initialize(true);
+ scope.$apply();
+
+ expect(model.newInstanceSpec.create_volume_default).toBe(false);
+ });
+
it('should not set availability zone if the zone list is empty', function () {
spyOn(novaApi, 'getAvailabilityZones').and.callFake(function () {
var deferred = $q.defer();
@@ -579,6 +596,7 @@
});
it('should have proper allowedBootSources if specific settings missing', function() {
+ delete settings.LAUNCH_INSTANCE_DEFAULTS.create_volume;
delete settings.LAUNCH_INSTANCE_DEFAULTS.disable_image;
delete settings.LAUNCH_INSTANCE_DEFAULTS.disable_instance_snapshot;
delete settings.LAUNCH_INSTANCE_DEFAULTS.disable_volume;
@@ -591,6 +609,7 @@
expect(model.allowedBootSources).toContain(INSTANCE_SNAPSHOT);
expect(model.allowedBootSources).toContain(VOLUME);
expect(model.allowedBootSources).toContain(VOLUME_SNAPSHOT);
+ expect(model.newInstanceSpec.create_volume_default).toBe(true);
});
it('should have no images if disable_image is set to true', function() {
@@ -746,7 +765,7 @@
// This is here to ensure that as people add/change items, they
// don't forget to implement tests for them.
it('has the right number of properties', function() {
- expect(Object.keys(model.newInstanceSpec).length).toBe(21);
+ expect(Object.keys(model.newInstanceSpec).length).toBe(22);
});
it('sets availability zone to null', function() {
@@ -761,6 +780,10 @@
expect(model.newInstanceSpec.config_drive).toBe(false);
});
+ it('sets create volume to true', function() {
+ expect(model.newInstanceSpec.create_volume_default).toBe(true);
+ });
+
it('sets user data to an empty string', function() {
expect(model.newInstanceSpec.user_data).toBe('');
});
Index: horizon-10.0.6.dev4/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/source/source.controller.js
===================================================================
--- horizon-10.0.6.dev4.orig/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/source/source.controller.js
+++ horizon-10.0.6.dev4/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/source/source.controller.js
@@ -419,7 +419,8 @@
ctrl.currentBootSource = selectedSource;
if ((selectedSource === bootSourceTypes.IMAGE ||
selectedSource === bootSourceTypes.INSTANCE_SNAPSHOT) && $scope.model.volumeBootable) {
- $scope.model.newInstanceSpec.vol_create = true;
+ $scope.model.newInstanceSpec.vol_create =
+ $scope.model.newInstanceSpec.create_volume_default;
} else {
$scope.model.newInstanceSpec.vol_create = false;
}
Index: horizon-10.0.6.dev4/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/source/source.controller.spec.js
===================================================================
--- horizon-10.0.6.dev4.orig/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/source/source.controller.spec.js
+++ horizon-10.0.6.dev4/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/source/source.controller.spec.js
@@ -50,7 +50,7 @@
scope.model = {
allowedBootSources: [{type: 'image', label: 'Image'}],
- newInstanceSpec: { source: [], source_type: '' },
+ newInstanceSpec: { source: [], source_type: '', create_volume_default: true },
images: [ { id: 'image-1' }, { id: 'image-2' } ],
imageSnapshots: [ { id: 'imageSnapshot-1' } ],
volumes: [ { id: 'volume-1' }, { id: 'volume-2' } ],
Index: horizon-10.0.6.dev4/openstack_dashboard/local/local_settings.py.example
===================================================================
--- horizon-10.0.6.dev4.orig/openstack_dashboard/local/local_settings.py.example
+++ horizon-10.0.6.dev4/openstack_dashboard/local/local_settings.py.example
@@ -271,6 +271,7 @@ OPENSTACK_KEYSTONE_BACKEND = {
# 'disable_instance_snapshot': False,
# 'disable_volume': False,
# 'disable_volume_snapshot': False,
+# 'create_volume': True,
#}
# The Xen Hypervisor has the ability to set the mount point for volumes
Index: horizon-10.0.6.dev4/releasenotes/notes/bug-1678109-4440ebe90908647d.yaml
===================================================================
--- /dev/null
+++ horizon-10.0.6.dev4/releasenotes/notes/bug-1678109-4440ebe90908647d.yaml
@@ -0,0 +1,5 @@
+---
+features:
+ - Added a new ``create_volume`` setting under the
+ ``LAUNCH_INSTANCE_DEFAULTS`` dict. This allows you to set the default value
+ of "Create Volume", when Cinder is available.