firmament-docker
Version:
Typescript classes for performing Docker operations
136 lines • 5.4 kB
JavaScript
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
const inversify_1 = require("inversify");
const inversify_config_1 = require("../../inversify.config");
let VmwareCommandImpl = class VmwareCommandImpl {
constructor(vmwareMake) {
this.vmwareMake = vmwareMake;
this.aliases = [];
this.command = '';
this.commandDesc = '';
this.handler = (argv) => {
};
this.options = {};
this.subCommands = [];
this.buildCommandTree();
}
buildCommandTree() {
this.aliases = ['vmware'];
this.command = '<subCommand>';
this.commandDesc = 'Support for importing and exporting OVA machines to ESXi server';
this.pushExportCommand();
this.pushImportCommand();
this.pushUninstallOvfToolCommand();
}
;
pushUninstallOvfToolCommand() {
const me = this;
let uninstallOvfToolCommand = inversify_config_1.default.get('CommandImpl');
uninstallOvfToolCommand.aliases = ['uninstall-ovf-tool', 'u'];
uninstallOvfToolCommand.commandDesc = `Uninstall VMware 'ovftool'`;
uninstallOvfToolCommand.handler = me.vmwareMake.uninstallOvfTool.bind(me.vmwareMake);
this.subCommands.push(uninstallOvfToolCommand);
}
;
pushImportCommand() {
const me = this;
let importCommand = inversify_config_1.default.get('CommandImpl');
importCommand.aliases = ['import', 'i'];
importCommand.commandDesc = 'Import virtual machine from an OVA file to an ESXi server';
importCommand.options = {
name: {
alias: 'n',
default: 'OVA filename',
type: 'string',
desc: 'Name VM will have in ESXi inventory'
},
powerOn: {
alias: 'p',
default: false,
type: 'boolean',
desc: `If 'true' then machine will be powered on after being imported`
},
datastore: {
alias: 'd',
default: 'datastore1',
type: 'string',
desc: 'ESXi datastore to put the VM into'
},
ovaUrl: {
type: 'string',
default: 'https://s3.amazonaws.com/merlin-jreeme/base-ubu16.04-8-32.ova',
desc: 'Url of OVA file'
},
esxiHost: {
type: 'string',
required: true,
desc: 'ESXi Server Hostname/IP address'
},
esxiUser: {
type: 'string',
required: true,
desc: 'User to perform action as on ESXi server'
},
esxiPassword: {
type: 'string',
required: true,
desc: 'Password for ESXi User'
}
};
importCommand.handler = me.vmwareMake.import.bind(me.vmwareMake);
this.subCommands.push(importCommand);
}
;
pushExportCommand() {
const me = this;
let exportCommand = inversify_config_1.default.get('CommandImpl');
exportCommand.aliases = ['export'];
exportCommand.commandDesc = 'Export virtual machine as an OVA file from ESXi server';
exportCommand.options = {
name: {
alias: 'n',
default: 'OVA filename',
type: 'string',
desc: 'Name of the VM in ESXi inventory'
},
esxiHost: {
type: 'string',
required: true,
desc: 'ESXi Server Hostname/IP address'
},
esxiUser: {
type: 'string',
required: true,
desc: 'User to perform action as on ESXi server'
},
esxiPassword: {
type: 'string',
required: true,
desc: 'Password for ESXi User'
}
};
exportCommand.handler = me.vmwareMake.export.bind(me.vmwareMake);
this.subCommands.push(exportCommand);
}
;
};
VmwareCommandImpl.defaultConfigFilename = 'vmware-control.json';
VmwareCommandImpl = __decorate([
inversify_1.injectable(),
__param(0, inversify_1.inject('VmwareMake')),
__metadata("design:paramtypes", [Object])
], VmwareCommandImpl);
exports.VmwareCommandImpl = VmwareCommandImpl;
//# sourceMappingURL=vmware-command-impl.js.map