Adding more comples provision details for vms
This commit is contained in:
2
dist/qmi-cloud/index.html
vendored
2
dist/qmi-cloud/index.html
vendored
@@ -9,5 +9,5 @@
|
||||
<link rel="stylesheet" href="styles.b356f37e1927dfccb0b3.css"></head>
|
||||
<body>
|
||||
<app-root></app-root>
|
||||
<script src="runtime.689ba4fd6cadb82c1ac2.js" defer></script><script src="polyfills-es5.f752a17531a45fe93c1f.js" nomodule defer></script><script src="polyfills.06ba8d1a3d9dd3a8e8b9.js" defer></script><script src="scripts.6866cf66954a0b739d41.js" defer></script><script src="main.ec7d40a5ad63a7fed25f.js" defer></script></body>
|
||||
<script src="runtime.689ba4fd6cadb82c1ac2.js" defer></script><script src="polyfills-es5.f752a17531a45fe93c1f.js" nomodule defer></script><script src="polyfills.06ba8d1a3d9dd3a8e8b9.js" defer></script><script src="scripts.6866cf66954a0b739d41.js" defer></script><script src="main.f989c7a633327a878aa9.js" defer></script></body>
|
||||
</html>
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -58,19 +58,35 @@ const plan = function( provMongo, user ) {
|
||||
var processStream = fs.createWriteStream(provMongo.logFile, {flags:'a'});
|
||||
//var processStream = process.stdout;
|
||||
let exec = ['terraform', 'plan', '-no-color', '-input=false', '-out=tfplan', '-var-file=scenario.tfvars', '-var', `provision_id=${provMongo._id}`, '-var', `user_id=${user}`];
|
||||
if ( provMongo.vmType ) {
|
||||
|
||||
|
||||
if ( provMongo.vmType && !provMongo.vmImage) {
|
||||
exec.push('-var');
|
||||
exec.push(`vm_type=${provMongo.vmType}`);
|
||||
}
|
||||
|
||||
if ( provMongo.nodeCount ) {
|
||||
if ( provMongo.nodeCount && !provMongo.vmImage) {
|
||||
exec.push('-var');
|
||||
exec.push(`agent_count=${provMongo.nodeCount}`);
|
||||
}
|
||||
|
||||
if ( provMongo.vmImage && provMongo.vmImage.image ) {
|
||||
exec.push('-var');
|
||||
exec.push(`image_reference=${provMongo.vmImage.image}`);
|
||||
if ( provMongo.vmImage ) {
|
||||
for (let key in provMongo.vmImage) {
|
||||
if (provMongo.vmImage[key].nodeCount) {
|
||||
exec.push('-var');
|
||||
exec.push(`agent_count_${key}=${provMongo[key].nodeCount}`);
|
||||
}
|
||||
|
||||
if (provMongo.vmImage[key].vmType) {
|
||||
exec.push('-var');
|
||||
exec.push(`vm_type_${key}=${provMongo.vmImage[key].vmType}`);
|
||||
}
|
||||
|
||||
if (provMongo.vmImage[key].version) {
|
||||
exec.push('-var');
|
||||
exec.push(`image_reference_${key}=${provMongo.vmImage[key].version.image}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return docker.run(DOCKERIMAGE, exec, processStream, {
|
||||
@@ -131,19 +147,33 @@ const destroy = function(destroyMongo, provMongo) {
|
||||
var processStream = fs.createWriteStream(destroyMongo.logFile, {flags:'a'});
|
||||
let exec = ['terraform', 'destroy', '-auto-approve', '-no-color', '-var-file=scenario.tfvars', "-var", `provision_id=${destroyMongo.provId}`];
|
||||
|
||||
if (provMongo.vmType) {
|
||||
exec.push("-var");
|
||||
if ( provMongo.vmType && !provMongo.vmImage) {
|
||||
exec.push('-var');
|
||||
exec.push(`vm_type=${provMongo.vmType}`);
|
||||
}
|
||||
|
||||
if ( provMongo.nodeCount ) {
|
||||
if ( provMongo.nodeCount && !provMongo.vmImage) {
|
||||
exec.push('-var');
|
||||
exec.push(`agent_count=${provMongo.nodeCount}`);
|
||||
}
|
||||
|
||||
if ( provMongo.vmImage && provMongo.vmImage.image ) {
|
||||
exec.push('-var');
|
||||
exec.push(`image_reference=${provMongo.vmImage.image}`);
|
||||
if ( provMongo.vmImage ) {
|
||||
for (let key in provMongo.vmImage) {
|
||||
if (provMongo.vmImage[key].nodeCount) {
|
||||
exec.push('-var');
|
||||
exec.push(`agent_count_${key}=${provMongo[key].nodeCount}`);
|
||||
}
|
||||
|
||||
if (provMongo.vmImage[key].vmType) {
|
||||
exec.push('-var');
|
||||
exec.push(`vm_type_${key}=${provMongo.vmImage[key].vmType}`);
|
||||
}
|
||||
|
||||
if (provMongo.vmImage[key].version) {
|
||||
exec.push('-var');
|
||||
exec.push(`image_reference_${key}=${provMongo.vmImage[key].version.image}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return docker.run(DOCKERIMAGE, exec, processStream, {
|
||||
|
||||
@@ -9,27 +9,23 @@
|
||||
<div class="modal-body">
|
||||
<h5>{{scenario.title}}</h5>
|
||||
<div class="md-form">
|
||||
<div *ngIf="scenario.availableProductVersions && scenario.availableProductVersions.length">
|
||||
<div *ngFor="let server of scenario.availableProductVersions">
|
||||
<div>
|
||||
<label>Product version: (*)</label>
|
||||
<label>Product version for {{server.product}}: (*)</label>
|
||||
</div>
|
||||
<select id="pversion" class="browser-default custom-select" [(ngModel)]="sendData.selectedProductVersion">
|
||||
<option *ngFor="let item of scenario.availableProductVersions" [value]="item.name">{{item.name}}</option>
|
||||
<select id="pversion" class="browser-default custom-select" [(ngModel)]="selectedProductVersion[server.index]">
|
||||
<option *ngFor="let v of server.versions" [value]="v.name">{{v.name}}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<div>
|
||||
<label>VM size: (*)</label>
|
||||
<label>VM size for {{server.product}}: (*)</label>
|
||||
</div>
|
||||
<select id="vmtype" class="browser-default custom-select" [(ngModel)]="sendData.selectedVmType">
|
||||
<select id="vmtype" class="browser-default custom-select" [(ngModel)]="selectedVmType[server.index]">
|
||||
<option *ngFor="let item of vmTypes" [value]="item.type">{{item.type}} ({{item.desc}})</option>
|
||||
</select>
|
||||
</div>
|
||||
<div *ngIf="scenario.nodeCount" >
|
||||
<div>
|
||||
<div *ngIf="server.nodeCount">
|
||||
<label>Num. nodes: (*)</label>
|
||||
</div>
|
||||
<select id="pnodes" class="browser-default custom-select" [(ngModel)]="sendData.selectedNodeCount">
|
||||
<select *ngIf="scenario.nodeCount" id="pnodes" class="browser-default custom-select" [(ngModel)]="selectedNodeCount[server.index]">
|
||||
<option *ngFor="let item of [1,2,3,4,5,6]" [value]="item">{{item}}</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@@ -15,25 +15,31 @@ export class NewProvisionConfirmComponent implements OnInit, OnDestroy {
|
||||
shortDesc: string;
|
||||
sendData = {
|
||||
description: "",
|
||||
selectedProductVersion: null,
|
||||
selectedVmType: null,
|
||||
selectedNodeCount: null
|
||||
servers: null
|
||||
};
|
||||
selectedProductVersion: any = {};
|
||||
selectedVmType: any = {};
|
||||
selectedNodeCount: any = {};
|
||||
vmTypesSub: Subscription;
|
||||
vmTypes: any;
|
||||
|
||||
servers: any = {};
|
||||
constructor( public modalRef: MDBModalRef, private _scenariosService: ScenariosService ) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.vmTypesSub = this._scenariosService.getScenarioVmtypes().subscribe ( res => {
|
||||
this.vmTypes = res;
|
||||
|
||||
this.sendData.selectedVmType = this.scenario.vmTypeDefault || this.scenario.vmTypes[0].type;
|
||||
this.sendData.selectedNodeCount = this.scenario.nodeCount;
|
||||
|
||||
|
||||
if ( this.scenario.availableProductVersions.length ) {
|
||||
let lastIndex = this.scenario.availableProductVersions.length - 1;
|
||||
this.sendData.selectedProductVersion = this.scenario.productVersionDefault || this.scenario.availableProductVersions[lastIndex].name;
|
||||
this.scenario.availableProductVersions.forEach(server => {
|
||||
this.selectedVmType[server.index] = server.vmTypeDefault;
|
||||
this.selectedNodeCount[server.index] = server.nodeCount;
|
||||
let lastIndex = server.versions.length - 1;
|
||||
this.selectedProductVersion[server.index] = server.productVersionDefault? server.productVersionDefault : server.versions[lastIndex].name;
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
this.vmTypesSub.unsubscribe();
|
||||
@@ -48,6 +54,22 @@ export class NewProvisionConfirmComponent implements OnInit, OnDestroy {
|
||||
if (!this.sendData.description || this.sendData.description.trim() === "") {
|
||||
return;
|
||||
}
|
||||
this.sendData.servers = {};
|
||||
for (let key in this.selectedVmType){
|
||||
if (!this.sendData.servers[key]) {
|
||||
this.sendData.servers[key] = {};
|
||||
}
|
||||
this.sendData.servers[key].vmType = this.selectedVmType[key];
|
||||
this.sendData.servers[key].nodeCount = this.selectedNodeCount[key];
|
||||
|
||||
this.scenario.availableProductVersions.forEach(server => {
|
||||
server.versions.forEach(v=> {
|
||||
if (v.name === this.selectedProductVersion[key]){
|
||||
this.sendData.servers[key].version = v;
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
this.action.next(this.sendData);
|
||||
this.modalRef.hide();
|
||||
}
|
||||
|
||||
@@ -54,20 +54,13 @@ export class ScenariosComponent implements OnInit, OnDestroy {
|
||||
|
||||
const postData = {
|
||||
scenario: scenario.name,
|
||||
description: data.description,
|
||||
vmType: data.selectedVmType
|
||||
description: data.description
|
||||
};
|
||||
|
||||
if ( data.selectedNodeCount !== undefined ) {
|
||||
postData["nodeCount"] = data.selectedNodeCount;
|
||||
}
|
||||
|
||||
if ( data.selectedProductVersion ) {
|
||||
let found = scenario.availableProductVersions.filter(pv => pv.name === data.selectedProductVersion);
|
||||
if ( found && found.length ) {
|
||||
postData["vmImage"] = found[0];
|
||||
}
|
||||
|
||||
if ( data.servers ) {
|
||||
|
||||
postData["vmImage"] = data.servers;
|
||||
|
||||
}
|
||||
|
||||
console.log("postData", postData);
|
||||
|
||||
Reference in New Issue
Block a user