Template Generator: Add support for OS::Designate::Zone
Add support for OS::Designate::Zone as a new resource, which you can use from Template Generator. Change-Id: Ie98b2d7b5b6446cb527af14e0e417cca023a79a8 Task: #19673 Story: #2002032
This commit is contained in:
parent
a65f0928bb
commit
a2df0bbcca
@ -31,6 +31,7 @@
|
||||
'uuid_nohyphen': /^[a-f0-9]{32}$/,
|
||||
'mac_address': /^([A-Fa-f0-9]{2}[:-]){5}([A-Fa-f0-9]{2})$/,
|
||||
'cidr': /^(([0-9.]{1,15})(\/([0-9]|[1-2][0-9]|3[0-2]))?)|(([A-Fa-f0-9:]{1,39})(\/([0-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8]))?)$/,
|
||||
'zone': /^[a-zA-Z0-9_.-]{1,127}\.$/,
|
||||
})
|
||||
;
|
||||
|
||||
|
@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" version="1.0" width="55" height="55" preserveAspectRatio="xMidYMid meet" style="background-color: #FFFFFF;" viewBox="0 0 55 55">
|
||||
<g class="currentLayer" style=""><title>Layer 1</title><circle class="frame" r="25" style="fill:white;fill-opacity=0.0;stroke-width:3;stroke: #3f51b5" cy="27.395854949951172" cx="28.040435791015625" id="svg_2"/><g transform="translate(0,300) scale(0.10000000149011612,-0.10000000149011612) " fill="#000" stroke="none" id="svg_1" class="selected">
|
||||
</g></g><g class="currentLayer" style=""><title>Layer 1</title><text x="15.098859399557114" y="24.90114063024521" style="fill: #3f51b5; stroke: #3f51b5; font-size: 12px;font-family:Helvetica;" id="svg_1" class="">DNS</text><text x="15.351358662724476" y="41.57414920051434" style="fill: #3f51b5; stroke: #3f51b5; font-size: 10px;font-family:Helvetica; " id="svg_2" class="" transform="matrix(1.0821652412414549,0,0,1.0666701793670652,-3.13361918926239,-5.300277292728424) ">ZONE</text></g></svg>
|
After Width: | Height: | Size: 1011 B |
@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" version="1.0" width="55" height="55" preserveAspectRatio="xMidYMid meet" style="background-color: #FFFFFF;" viewBox="0 0 55 55">
|
||||
<g class="currentLayer" style=""><title>Layer 1</title><circle class="frame" r="25" style="fill:white;fill-opacity=0.0;stroke-width:3;stroke:gray" cy="27.395854949951172" cx="28.040435791015625" id="svg_2"/><g transform="translate(0,300) scale(0.10000000149011612,-0.10000000149011612) " fill="#000" stroke="none" id="svg_1" class="selected">
|
||||
</g></g><g class="currentLayer" style=""><title>Layer 1</title><text x="15.098859399557114" y="24.90114063024521" style="fill: #808080; stroke: #808080; font-size: 12px;font-family:Helvetica;" id="svg_1" class="">DNS</text><text x="15.351358662724476" y="41.57414920051434" style="fill: #808080; stroke: #808080; font-size: 10px;font-family:Helvetica; " id="svg_2" class="" transform="matrix(1.0821652412414549,0,0,1.0666701793670652,-3.13361918926239,-5.300277292728424) ">ZONE</text></g></svg>
|
After Width: | Height: | Size: 1007 B |
@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" version="1.0" width="55" height="55" preserveAspectRatio="xMidYMid meet" style="background-color: #FFFFFF;" viewBox="0 0 55 55">
|
||||
<g class="currentLayer" style=""><title>Layer 1</title><circle class="frame" r="25" style="fill:white;fill-opacity=0.0;stroke-width:3;stroke:green" cy="27.395854949951172" cx="28.040435791015625" id="svg_2"/><g transform="translate(0,300) scale(0.10000000149011612,-0.10000000149011612) " fill="#000" stroke="none" id="svg_1" class="selected">
|
||||
</g></g><g class="currentLayer" style=""><title>Layer 1</title><text x="15.098859399557114" y="24.90114063024521" style="fill: green; stroke: green; font-size: 12px;font-family:Helvetica;" id="svg_1" class="">DNS</text><text x="15.351358662724476" y="41.57414920051434" style="fill: green; stroke: green; font-size: 10px;font-family:Helvetica; " id="svg_2" class="" transform="matrix(1.0821652412414549,0,0,1.0666701793670652,-3.13361918926239,-5.300277292728424) ">ZONE</text></g></svg>
|
After Width: | Height: | Size: 1000 B |
@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" version="1.0" width="55" height="55" preserveAspectRatio="xMidYMid meet" style="background-color: #FFFFFF;" viewBox="0 0 55 55">
|
||||
<g class="currentLayer" style=""><title>Layer 1</title><circle class="frame" r="25" style="fill:white;fill-opacity=0.0;stroke-width:3;stroke: #C82128" cy="27.395854949951172" cx="28.040435791015625" id="svg_2"/><g transform="translate(0,300) scale(0.10000000149011612,-0.10000000149011612) " fill="#000" stroke="none" id="svg_1" class="selected">
|
||||
</g></g><g class="currentLayer" style=""><title>Layer 1</title><text x="15.098859399557114" y="24.90114063024521" style="fill: #C82128; stroke: #C82128; font-size: 12px;font-family:Helvetica;" id="svg_1" class="">DNS</text><text x="15.351358662724476" y="41.57414920051434" style="fill: #C82128; stroke: #C82128; font-size: 10px;font-family:Helvetica; " id="svg_2" class="" transform="matrix(1.0821652412414549,0,0,1.0666701793670652,-3.13361918926239,-5.300277292728424) ">ZONE</text></g></svg>
|
After Width: | Height: | Size: 1011 B |
@ -0,0 +1,71 @@
|
||||
<md-tabs md-dynamic-height md-stretch-tabs="always" md-border-bottom>
|
||||
<md-tab label="Properties" >
|
||||
<md-content layout-padding>
|
||||
<md-input-container class="md-block">
|
||||
<label>Name</label>
|
||||
<input ng-model="$ctrl.zone.name" name="name" type="text" required ng-pattern="validate_zone" md-maxlength="255">
|
||||
<div ng-messages="$ctrl.formReference.name.$error" role="alert" multiple>
|
||||
<div ng-message="required" class="my-message">You must supply a name.</div>
|
||||
<div ng-message="pattern" class="my-message">That doesn't look like a valid name.
|
||||
</div>
|
||||
<div ng-message="md-maxlength" class="my-message">
|
||||
Too long name.
|
||||
</div>
|
||||
</div>
|
||||
</md-input-container>
|
||||
<md-input-container class="md-block">
|
||||
<label>Email</label>
|
||||
<input ng-model="$ctrl.zone.email" name="email" type="text" required>
|
||||
<div ng-messages="$ctrl.formReference.email.$error" role="alert" multiple>
|
||||
<div ng-message="required" class="my-message">You must supply an email.</div>
|
||||
</div>
|
||||
</md-input-container>
|
||||
<md-input-container class="md-block">
|
||||
<label>TTL</label>
|
||||
<input ng-model="$ctrl.zone.ttl" name="ttl" type="number">
|
||||
</md-input-container>
|
||||
<md-input-container class="md-block">
|
||||
<label>Description</label>
|
||||
<input ng-model="$ctrl.zone.description" name="description" type="text" md-maxlength="255">
|
||||
<div ng-messages="$ctrl.formReference.description.$error" role="alert" multiple>
|
||||
<div ng-message="md-maxlength" class="my-message">
|
||||
Too long description.
|
||||
</div>
|
||||
</div>
|
||||
</md-input-container>
|
||||
</md-content>
|
||||
|
||||
<md-switch class="md-primary" name="show_more" ng-model="show_more">
|
||||
{$ 'Show More Properties' | translate $}
|
||||
</md-switch>
|
||||
</md-tab>
|
||||
|
||||
<md-tab label="More Properties" ng-if="show_more">
|
||||
<md-content layout-padding>
|
||||
<md-input-container class="md-block" flex-gt-xs>
|
||||
<label>Type</label>
|
||||
<md-select ng-model="$ctrl.zone.type">
|
||||
<md-option ng-repeat="type in options.types" ng-value="type.id">
|
||||
{$ type.name $}
|
||||
</md-option>
|
||||
</md-select>
|
||||
</md-input-container>
|
||||
<md-input-container class="md-block" flex-gt-xs>
|
||||
<label>Masters</label>
|
||||
<md-chips ng-model="$ctrl.zone.masters"
|
||||
placeholder="+ master"
|
||||
readonly="false"
|
||||
md-removeable="true"
|
||||
md-transform-chip="validate_master($chip)">
|
||||
</md-chips>
|
||||
</md-input-container>
|
||||
|
||||
</md-content>
|
||||
</md-tab>
|
||||
|
||||
<md-tab label="Depends on">
|
||||
<md-content layout-padding>
|
||||
<depends-on dependson='dependson'></depends-on>
|
||||
</md-content>
|
||||
</md-tab>
|
||||
</md-tabs>
|
@ -0,0 +1,94 @@
|
||||
(function(angular) {
|
||||
'use strict';
|
||||
|
||||
// OS::Designate::Zone
|
||||
angular.module('horizon.dashboard.project.heat_dashboard.template_generator').value('osDesignateZoneSettings',
|
||||
{
|
||||
resource_key: "OS__Designate__Zone",
|
||||
admin: false,
|
||||
icon: {
|
||||
class: 'fa-key ',
|
||||
name: 'OS::Designate::Zone',
|
||||
code: '\uf084',
|
||||
color: '#483dff'
|
||||
},
|
||||
label: 'name',
|
||||
modal_component: '<os-designate-zone zone="resource" dependson="dependson" form-reference="resourceForm"></os-designate-zone>',
|
||||
edge_settings: null,
|
||||
necessary_properties: {
|
||||
'name': null,
|
||||
'email': null
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
angular.module('horizon.dashboard.project.heat_dashboard.template_generator')
|
||||
.run(['osDesignateZoneSettings', 'hotgenGlobals', function( osDesignateZoneSettings, hotgenGlobals){
|
||||
hotgenGlobals.update_resource_icons(
|
||||
osDesignateZoneSettings.resource_key,
|
||||
osDesignateZoneSettings.icon);
|
||||
|
||||
hotgenGlobals.update_resource_components(
|
||||
osDesignateZoneSettings.resource_key,
|
||||
osDesignateZoneSettings.modal_component);
|
||||
|
||||
hotgenGlobals.update_edge_directions(
|
||||
osDesignateZoneSettings.resource_key,
|
||||
osDesignateZoneSettings.edge_settings);
|
||||
|
||||
hotgenGlobals.update_node_labels(
|
||||
osDesignateZoneSettings.resource_key,
|
||||
osDesignateZoneSettings.label);
|
||||
}]);
|
||||
|
||||
|
||||
function osDesignateZoneController($scope, hotgenGlobals, hotgenNotify, validationRules){
|
||||
$scope.options = hotgenGlobals.get_resource_options();
|
||||
|
||||
$scope.options.types = [
|
||||
{'id': 'PRIMARY', 'name': 'PRIMARY'},
|
||||
{'id': 'SECONDARY', 'name': 'SECONDARY'}
|
||||
];
|
||||
|
||||
$scope.admin = $scope.options.auth.admin;
|
||||
this.$onInit = function(){
|
||||
if (typeof this.zone.masters === 'undefined'){
|
||||
this.zone.masters = [];
|
||||
}
|
||||
$scope.dependson = this.dependson;
|
||||
}
|
||||
|
||||
$scope.validate_zone = validationRules['zone'];
|
||||
|
||||
$scope.validate_master = function (input_string){
|
||||
var re = /^[A-Za-z0-9_.-]+$/;
|
||||
var match = re.exec(input_string);
|
||||
if (match){
|
||||
return input_string;
|
||||
} else{
|
||||
hotgenNotify.show_error('Invalid master value.');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
osDesignateZoneController.$inject = ['$scope', 'hotgenGlobals', 'hotgenNotify',
|
||||
'horizon.dashboard.project.heat_dashboard.template_generator.validationRules',
|
||||
];
|
||||
osDesignateZonePath.$inject = ['horizon.dashboard.project.heat_dashboard.template_generator.basePath'];
|
||||
|
||||
function osDesignateZonePath(basePath){
|
||||
return basePath + 'js/resources/os__designate__zone/os__designate__zone.html';
|
||||
}
|
||||
|
||||
angular.module('horizon.dashboard.project.heat_dashboard.template_generator').component('osDesignateZone', {
|
||||
templateUrl: osDesignateZonePath,
|
||||
controller: osDesignateZoneController,
|
||||
bindings:{
|
||||
'zone': '=',
|
||||
'dependson': '=',
|
||||
'formReference': '<',
|
||||
}
|
||||
});
|
||||
|
||||
})(window.angular);
|
@ -0,0 +1,54 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
describe('component os-designate-zone', function(){
|
||||
|
||||
beforeEach(module('horizon.dashboard.project.heat_dashboard.template_generator'));
|
||||
|
||||
beforeEach(module('appTemplates'));
|
||||
|
||||
var $scope, $isolateScope, $compile;
|
||||
var element;
|
||||
|
||||
beforeEach(inject(function($injector) {
|
||||
$scope = $injector.get('$rootScope').$new();
|
||||
$compile = $injector.get('$compile');
|
||||
|
||||
$scope.resource = {};
|
||||
$scope.dependson = [];
|
||||
$scope.resourceForm = {};
|
||||
|
||||
// element will enable you to test your directive's element on the DOM
|
||||
element = $compile(angular.element('<os-designate-zone zone="resource" '+
|
||||
'dependson="dependson" form-reference="resourceForm">'+
|
||||
'</os-designate-zone>'))($scope);
|
||||
|
||||
// Digest needs to be called to set any values on the directive's scope
|
||||
$scope.$digest();
|
||||
|
||||
$isolateScope = element.isolateScope();
|
||||
}));
|
||||
|
||||
it('find tab title Properties', function() {
|
||||
expect(element.find('span').html()).toContain("Properties");
|
||||
});
|
||||
|
||||
it('find tab title Properties with resource properties set', function() {
|
||||
$scope.resource = { masters: [], attributes: []};
|
||||
element = $compile(angular.element('<os-designate-zone zone="resource" '+
|
||||
'dependson="dependson" form-reference="resourceForm">'+
|
||||
'</os-designate-zone>'))($scope);
|
||||
|
||||
$scope.$digest();
|
||||
|
||||
expect(element.find('span').html()).toContain("Properties");
|
||||
});
|
||||
|
||||
it('test validate master function', function() {
|
||||
expect($isolateScope.validate_master('192.168.1.1')).toEqual('192.168.1.1');
|
||||
expect($isolateScope.validate_master('localhost')).toEqual('localhost');
|
||||
expect($isolateScope.validate_master('xxx@gmail.com')).toEqual(null);
|
||||
});
|
||||
});
|
||||
|
||||
})();
|
@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" version="1.0" width="55" height="55" preserveAspectRatio="xMidYMid meet" style="background-color: #FFFFFF;" viewBox="0 0 55 55">
|
||||
<g class="currentLayer" style=""><title>Layer 1</title><circle class="frame" r="25" style="fill:white;fill-opacity=0.0;stroke-width:3;stroke:black" cy="27.395854949951172" cx="28.040435791015625" id="svg_2"/><g transform="translate(0,300) scale(0.10000000149011612,-0.10000000149011612) " fill="#000" stroke="none" id="svg_1" class="selected">
|
||||
</g></g><g class="currentLayer" style=""><title>Layer 1</title><text x="15.098859399557114" y="24.90114063024521" style="fill: #000000; stroke: #000; font-size: 12px;font-family:Helvetica;" id="svg_1" class="">DNS</text><text x="15.351358662724476" y="41.57414920051434" style="fill: #000000; stroke: #000; font-size: 10px;font-family:Helvetica; " id="svg_2" class="" transform="matrix(1.0821652412414549,0,0,1.0666701793670652,-3.13361918926239,-5.300277292728424) ">ZONE</text></g></svg>
|
After Width: | Height: | Size: 1002 B |
Loading…
Reference in New Issue
Block a user