2025-01-13 06:13:25 +00:00
|
|
|
// ovftool.js
|
|
|
|
// Namhyeon Go <abuse@catswords.net>
|
|
|
|
// https://github.com/gnh1201/welsonjs
|
|
|
|
//
|
2025-01-15 06:38:25 +00:00
|
|
|
// Download OVFTool (Open Virtualization Format (OVF) Tool):
|
|
|
|
// https://developer.broadcom.com/tools/open-virtualization-format-ovf-tool/latest
|
|
|
|
//
|
2025-01-13 06:13:25 +00:00
|
|
|
var SHELL = require("lib/shell");
|
|
|
|
var CRED = require("lib/credentials");
|
|
|
|
|
|
|
|
function OVFObject() {
|
2025-01-15 06:18:36 +00:00
|
|
|
this.binPath = "bin\\x64\\VMware-ovftool-4.6.3-24031167-win.x86_64\\ovftool\\ovftool.exe";
|
2025-01-13 06:13:25 +00:00
|
|
|
this.hostname = "";
|
2025-01-15 06:38:25 +00:00
|
|
|
this.port = 443;
|
2025-01-13 06:13:25 +00:00
|
|
|
this.resourceName = "";
|
|
|
|
|
|
|
|
this.setBinPath = function(binPath) {
|
|
|
|
this.binPath = binPath;
|
|
|
|
};
|
2025-01-15 04:58:54 +00:00
|
|
|
|
2025-01-15 06:18:36 +00:00
|
|
|
this.setHostName = function(hostname) {
|
2025-01-15 04:58:54 +00:00
|
|
|
this.hostname = hostname;
|
|
|
|
};
|
2025-01-15 06:38:25 +00:00
|
|
|
|
|
|
|
this.setPort = function(port) {
|
|
|
|
this.port = port;
|
|
|
|
};
|
2025-01-15 04:58:54 +00:00
|
|
|
|
|
|
|
this.setResourceName = function(resourceName) {
|
|
|
|
this.resourceName = resourceName;
|
|
|
|
};
|
|
|
|
|
2025-01-15 06:18:36 +00:00
|
|
|
this.saveTo = function(filename) {
|
2025-01-13 06:13:25 +00:00
|
|
|
var cred = CRED.get("password", "ovftool");
|
|
|
|
var connectionString = "vi://" +
|
2025-01-15 06:18:36 +00:00
|
|
|
encodeURIComponent(cred.username) + ":" +
|
2025-01-15 04:58:54 +00:00
|
|
|
encodeURIComponent(cred.password) + "@" +
|
2025-01-15 06:18:36 +00:00
|
|
|
this.hostname + (this.port == 443 ? "" : ":" + this.port) +
|
2025-01-15 04:58:54 +00:00
|
|
|
this.resourceName
|
|
|
|
;
|
|
|
|
var cmd = [
|
|
|
|
this.binPath,
|
|
|
|
connectionString,
|
2025-01-15 06:18:36 +00:00
|
|
|
filename
|
2025-01-15 04:58:54 +00:00
|
|
|
];
|
2025-01-15 06:38:25 +00:00
|
|
|
|
|
|
|
console.log("Use this connection string:", connectionString);
|
2025-01-13 06:13:25 +00:00
|
|
|
|
2025-01-15 04:58:54 +00:00
|
|
|
// run the command synchronously
|
|
|
|
SHELL.show(cmd, false);
|
2025-01-13 06:13:25 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function setCredential(username, password) {
|
|
|
|
CRED.push("password", "ovftool", {
|
|
|
|
"username": username,
|
2025-01-15 06:18:36 +00:00
|
|
|
"password": password
|
2025-01-13 06:13:25 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function create() {
|
|
|
|
return new OVFObject();
|
|
|
|
}
|
|
|
|
|
|
|
|
exports.setCredential = setCredential;
|
|
|
|
exports.create = create;
|
|
|
|
|
2025-01-15 06:18:36 +00:00
|
|
|
exports.VERSIONINFO = "Broadcom/VMware OVF Tool interface (ovftool.js) version 0.1.2";
|
2025-01-13 06:13:25 +00:00
|
|
|
exports.AUTHOR = "abuse@catswords.net";
|
|
|
|
exports.global = global;
|
|
|
|
exports.require = global.require;
|