Skip to content

Commit

Permalink
Feat(provider/openstack): Add Scheduler Hints and Availability Zone S…
Browse files Browse the repository at this point in the history
…elect (#4740)

Update help text for availability zones
  • Loading branch information
Niximacco authored and edwinavalos committed Jan 31, 2018
1 parent efbeef4 commit 1265376
Show file tree
Hide file tree
Showing 8 changed files with 179 additions and 127 deletions.
2 changes: 2 additions & 0 deletions app/scripts/modules/openstack/src/help/openstack.help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ const helpContents: {[key: string]: string} = {
'openstack.network.floatingip': '<p>Whether or not each instance in the server group should be assigned a floating ip.</p><p>Default: <b>No</b></p>',
'openstack.network.floatpool': 'The network from which to allocate a floating ip',
'openstack.serverGroup.userData': '<p>Provides a script that will run when each server group instance starts.</p>',
'openstack.serverGroup.availabilityZones': 'Creates a Senlin Zone Placement Policy that balances equally across the selected zones.',
'openstack.serverGroup.tags': '<p>Key-value pairs of metadata that will be associate to each server group instance.</p>',
'openstack.serverGroup.schedulerHints': '<p>Key-value pairs for server scheduling hints</p>'
};

export const OPENSTACK_HELP = 'spinnaker.openstack.help.contents';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ module.exports = angular.module('spinnaker.openstack.serverGroup.configure', [
require('./wizard/location/ServerGroupBasicSettings.controller.js').name,
require('./wizard/instance/ServerGroupInstanceSettings.controller.js').name,
require('./wizard/access/AccessSettings.controller.js').name,
require('./wizard/advanced/advancedSettings.component.js').name,
require('./wizard/advanced/advancedSettings.controller.js').name,
require('./wizard/Clone.controller.js').name,
]);
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,63 @@
<div class="modal-body">
<ng-form name="accessSettings" novalidate>

<div class="col-md-12" ng-if="command.viewState.dirty.loadBalancers">
<div class="alert alert-warning">
<p><i class="fa fa-exclamation-triangle"></i>
The following load balancers could not be found in the selected namespace and were removed:
</p>
<ul>
<li ng-repeat="loadBalancer in command.viewState.dirty.loadBalancers">{{loadBalancer}}</li>
</ul>
<p class="text-right">
<a class="btn btn-sm btn-default dirty-flag-dismiss" href ng-click="command.viewState.dirty.loadBalancers = null">Okay</a>
</p>
<div class="col-md-12" ng-if="command.viewState.dirty.loadBalancers">
<div class="alert alert-warning">
<p><i class="fa fa-exclamation-triangle"></i>
The following load balancers could not be found in the selected namespace and were removed:
</p>
<ul>
<li ng-repeat="loadBalancer in command.viewState.dirty.loadBalancers">{{loadBalancer}}</li>
</ul>
<p class="text-right">
<a class="btn btn-sm btn-default dirty-flag-dismiss" href
ng-click="command.viewState.dirty.loadBalancers = null">Okay</a>
</p>
</div>
</div>
</div>

<os-cache-backed-multi-select-field label="Load Balancers"
cache="allLoadBalancers"
refresh-cache="updateLoadBalancers"
required="false"
model="command.loadBalancers"></os-cache-backed-multi-select-field>
<os-cache-backed-multi-select-field
label="Load Balancers"
cache="allLoadBalancers"
refresh-cache="updateLoadBalancers"
required="false"
model="command.loadBalancers">
</os-cache-backed-multi-select-field>

<os-cache-backed-multi-select-field label="Security Groups"
cache="allSecurityGroups"
refresh-cache="updateSecurityGroups"
required="true"
model="command.securityGroups"></os-cache-backed-multi-select-field>
<os-cache-backed-multi-select-field
label="Security Groups"
cache="allSecurityGroups"
refresh-cache="updateSecurityGroups"
required="true"
model="command.securityGroups">
</os-cache-backed-multi-select-field>

<div class="form-group">
<div class="col-md-5 sm-label-left">
<b>Associate Floating IP Address</b>
<help-field key="openstack.network.floatingip"></help-field>
<div class="form-group">
<div class="col-md-5 sm-label-left">
<b>Associate Floating IP Address</b>
<help-field key="openstack.network.floatingip"></help-field>
</div>
<div class="col-md-2 radio">
<label>
<input type="radio" ng-model="command.associatePublicIpAddress" ng-value="true"/>
Yes
</label>
</div>
<div class="col-md-2 radio">
<label>
<input type="radio" ng-model="command.associatePublicIpAddress" ng-value="false"/>
No
</label>
</div>
</div>
<div class="col-md-2 radio">
<label>
<input type="radio" ng-model="command.associatePublicIpAddress" ng-value="true"/>
Yes
</label>
</div>
<div class="col-md-2 radio">
<label>
<input type="radio" ng-model="command.associatePublicIpAddress" ng-value="false"/>
No
</label>
</div>
</div>
</div>
</div>

<div ng-if="command.associatePublicIpAddress === true" class="form-group">
<network-select-field label="Network"
model="command.floatingNetworkId"
help-key="openstack.network.floatpool"
filter="{ account: command.credentials }"></network-select-field>
</div>
</ng-form>
<div ng-if="command.associatePublicIpAddress === true" class="form-group">
<network-select-field label="Network"
model="command.floatingNetworkId"
help-key="openstack.network.floatpool"
filter="{ account: command.credentials }"></network-select-field>
</div>
</ng-form>
</div>
</div>

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
'use strict';

const angular = require('angular');

import {V2_MODAL_WIZARD_SERVICE} from '@spinnaker/core';

module.exports = angular
.module('spinnaker.openstack.serverGroup.configure.wizard.advancedSettings', [
require('@uirouter/angularjs').default,
require('angular-ui-bootstrap'),
require('../../../../common/cacheBackedMultiSelectField.directive.js').name,
])
.controller('openstackServerGroupAdvancedSettingsCtrl', function ($scope, v2modalWizardService) {

$scope.selectedAZs = $scope.command.zones ?
$scope.command.zones.map(i => {
return {id: i, name: i};
}) : [];

$scope.updateAvailabilityZones = function () {
$scope.allAvailabilityZones = getAvailabilityZones();
};

$scope.selectedAZsChanged = function () {
$scope.command.zones = _.map($scope.selectedAZs, 'id');
};

$scope.$watch('selectedAZs', $scope.selectedAZsChanged);

$scope.$watch(function () {
return _.map(getAvailabilityZones(), 'id').join(',');
}, function () {
$scope.selectedAZs = [];
$scope.updateAvailabilityZones();
});

$scope.$watch('command.credentials', $scope.updateAvailabilityZones);
$scope.$watch('command.region', $scope.updateAvailabilityZones);

function getAvailabilityZones() {
var account = $scope.command.credentials;
var region = $scope.command.region;
if (!account || !region) {
return [];
} else {
var ids = _.get($scope.command, ['backingData', 'credentialsKeyedByAccount', account, 'regionToZones', region], []);
return ids.map(i => {
return {id: i, name: i};
});
}
}

});
Original file line number Diff line number Diff line change
@@ -1,7 +1,72 @@
<div class="clearfix">
<div class="row">
<div class="col-md-12">
<openstack-server-group-advanced-settings command="command" application="application"></openstack-server-group-advanced-settings>
</div>
<div class="container-fluid form-horizontal" ng-controller="openstackServerGroupAdvancedSettingsCtrl as advancedSettingsCtrl">
<div class="modal-body">
<ng-form name="advancedSettings" novalidate>
<div class="form-group">
<div class="sm-label-left">
<b>User Data (optional)</b>
<help-field key="openstack.serverGroup.userData"></help-field>
</div>
</div>
<div class="form-group">
<div class="col-md-3 sm-label-right"><b>User Data Type</b></div>
<div class="col-md-7">
<ui-select ng-model="command.userDataType" class="form-control input-sm">
<ui-select-match placeholder="Select...">{{$select.selected}}</ui-select-match>
<ui-select-choices repeat="userDataType in command.backingData.userDataTypes | filter: $select.search">
<span ng-bind-html="userDataType | highlight: $select.search"></span>
</ui-select-choices>
</ui-select>
</div>
</div>
<div class="form-group">
<div class="col-md-3 sm-label-right">User Data Value</div>
<div class="col-md-9 no-spel">
<input type="text"
class="form-control"
ng-model="command.userData"
placeholder="A url that points to a script"
ng-if="command.userDataType == 'URL'">
<input type="text"
class="form-control"
ng-model="command.userData"
placeholder="A swift object that contains a script, e.g. '<container>:<my/object>'"
ng-if="command.userDataType == 'Swift'">
<textarea class="form-control nospel"
ng-model="command.userData"
ng-if="command.userDataType=='Text' || !command.userDataType"
rows="3"
placeholder="A raw plaintext script">
</textarea>
</div>
</div>
<div class="form-group">
<div class="sm-label-left">
<b>Zone Placement (optional)</b>
<help-field key="openstack.serverGroup.availabilityZones"></help-field>
</div>
<os-cache-backed-multi-select-field
label="Zones"
cache="allAvailabilityZones"
refresh-cache="updateAvailabilityZones"
required="false"
model="selectedAZs"
on-change="selectedAZsChanged()">
</os-cache-backed-multi-select-field>
</div>
<div class="form-group">
<div class="sm-label-left">
<b>Scheduler Hints (optional)</b>
<help-field key="openstack.serverGroup.schedulerHints"></help-field>
</div>
<map-editor model="command.schedulerHints" allow-empty="true"></map-editor>
</div>
<div class="form-group">
<div class="sm-label-left">
<b>Tags (optional)</b>
<help-field key="openstack.serverGroup.tags"></help-field>
</div>
<map-editor model="command.tags" allow-empty="true"></map-editor>
</div>
</ng-form>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<ng-include src="pages.accessSettings"></ng-include>
</v2-wizard-page>
<v2-wizard-page key="advanced-settings" label="Advanced Settings" mark-complete-on-view="false" done="true" mandatory="false">
<ng-include src="pages.advancedSettings"></ng-include>
<ng-include src="pages.advancedSettings"></ng-include>
</v2-wizard-page>
</v2-modal-wizard>
<div class="modal-footer" ng-if="state.loaded">
Expand Down

0 comments on commit 1265376

Please sign in to comment.