зеркало из https://github.com/docker/kitematic.git
Merge pull request #874 from FrenchBen/iso-fix
URGENT: Fixed iso and version issues
This commit is contained in:
Коммит
c4d89d3b80
|
@ -14,10 +14,10 @@ var DockerMachine = {
|
||||||
name: function () {
|
name: function () {
|
||||||
return NAME;
|
return NAME;
|
||||||
},
|
},
|
||||||
isoversion: function () {
|
isoversion: function (machineName = this.name()) {
|
||||||
try {
|
try {
|
||||||
var data = fs.readFileSync(path.join(util.home(), '.docker', 'machine', 'machines', NAME, 'boot2docker.iso'), 'utf8');
|
var data = fs.readFileSync(path.join(util.home(), '.docker', 'machine', 'machines', machineName, 'boot2docker-virtualbox.iso'), 'utf8');
|
||||||
var match = data.match(/Boot2Docker-v(\d+\.\d+\.\d+)/);
|
var match = data.match(/Docker v(\d+\.\d+\.\d+)/);
|
||||||
if (match) {
|
if (match) {
|
||||||
return match[1];
|
return match[1];
|
||||||
} else {
|
} else {
|
||||||
|
@ -27,7 +27,7 @@ var DockerMachine = {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
info: function () {
|
info: function (machineName = this.name()) {
|
||||||
return util.exec([this.command(), 'ls']).then(stdout => {
|
return util.exec([this.command(), 'ls']).then(stdout => {
|
||||||
var lines = stdout.trim().split('\n').filter(line => line.indexOf('time=') === -1);
|
var lines = stdout.trim().split('\n').filter(line => line.indexOf('time=') === -1);
|
||||||
var machines = {};
|
var machines = {};
|
||||||
|
@ -41,50 +41,50 @@ var DockerMachine = {
|
||||||
};
|
};
|
||||||
machines[machine.name] = machine;
|
machines[machine.name] = machine;
|
||||||
});
|
});
|
||||||
if (machines[NAME]) {
|
if (machines[machineName]) {
|
||||||
return Promise.resolve(machines[NAME]);
|
return Promise.resolve(machines[machineName]);
|
||||||
} else {
|
} else {
|
||||||
return Promise.reject(new Error('Machine does not exist.'));
|
return Promise.reject(new Error('Machine does not exist.'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
exists: function () {
|
exists: function (machineName = this.name()) {
|
||||||
return this.info().then(() => {
|
return this.info(machineName).then(() => {
|
||||||
return true;
|
return true;
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
create: function () {
|
create: function (machineName = this.name()) {
|
||||||
return util.exec([this.command(), '-D', 'create', '-d', 'virtualbox', '--virtualbox-memory', '2048', NAME]);
|
return util.exec([this.command(), '-D', 'create', '-d', 'virtualbox', '--virtualbox-memory', '2048', machineName]);
|
||||||
},
|
},
|
||||||
start: function () {
|
start: function (machineName = this.name()) {
|
||||||
return util.exec([this.command(), '-D', 'start', NAME]);
|
return util.exec([this.command(), '-D', 'start', machineName]);
|
||||||
},
|
},
|
||||||
stop: function () {
|
stop: function (machineName = this.name()) {
|
||||||
return util.exec([this.command(), 'stop', NAME]);
|
return util.exec([this.command(), 'stop', machineName]);
|
||||||
},
|
},
|
||||||
upgrade: function () {
|
upgrade: function (machineName = this.name()) {
|
||||||
return util.exec([this.command(), 'upgrade', NAME]);
|
return util.exec([this.command(), 'upgrade', machineName]);
|
||||||
},
|
},
|
||||||
rm: function () {
|
rm: function (machineName = this.name()) {
|
||||||
return util.exec([this.command(), 'rm', '-f', NAME]);
|
return util.exec([this.command(), 'rm', '-f', machineName]);
|
||||||
},
|
},
|
||||||
ip: function () {
|
ip: function (machineName = this.name()) {
|
||||||
return util.exec([this.command(), 'ip', NAME]).then(stdout => {
|
return util.exec([this.command(), 'ip', machineName]).then(stdout => {
|
||||||
return Promise.resolve(stdout.trim().replace('\n', ''));
|
return Promise.resolve(stdout.trim().replace('\n', ''));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
regenerateCerts: function () {
|
regenerateCerts: function (machineName = this.name()) {
|
||||||
return util.exec([this.command(), 'tls-regenerate-certs', '-f', NAME]);
|
return util.exec([this.command(), 'tls-regenerate-certs', '-f', machineName]);
|
||||||
},
|
},
|
||||||
state: function () {
|
state: function (machineName = this.name()) {
|
||||||
return this.info().then(info => {
|
return this.info(machineName).then(info => {
|
||||||
return info ? info.state : null;
|
return info ? info.state : null;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
disk: function () {
|
disk: function (machineName = this.name()) {
|
||||||
return util.exec([this.command(), 'ssh', NAME, 'df']).then(stdout => {
|
return util.exec([this.command(), 'ssh', machineName, 'df']).then(stdout => {
|
||||||
try {
|
try {
|
||||||
var lines = stdout.split('\n');
|
var lines = stdout.split('\n');
|
||||||
var dataline = _.find(lines, function (line) {
|
var dataline = _.find(lines, function (line) {
|
||||||
|
@ -107,8 +107,8 @@ var DockerMachine = {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
memory: function () {
|
memory: function (machineName = this.name()) {
|
||||||
return util.exec([this.command(), 'ssh', NAME, 'free -m']).then(stdout => {
|
return util.exec([this.command(), 'ssh', machineName, 'free -m']).then(stdout => {
|
||||||
try {
|
try {
|
||||||
var lines = stdout.split('\n');
|
var lines = stdout.split('\n');
|
||||||
var dataline = _.find(lines, function (line) {
|
var dataline = _.find(lines, function (line) {
|
||||||
|
@ -133,8 +133,8 @@ var DockerMachine = {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
stats: function () {
|
stats: function (machineName = this.name()) {
|
||||||
this.state().then(state => {
|
this.state(machineName).then(state => {
|
||||||
if (state === 'Stopped') {
|
if (state === 'Stopped') {
|
||||||
return Promise.resolve({state: state});
|
return Promise.resolve({state: state});
|
||||||
}
|
}
|
||||||
|
@ -148,10 +148,10 @@ var DockerMachine = {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
dockerTerminal: function (cmd) {
|
dockerTerminal: function (cmd, machineName = this.name()) {
|
||||||
if(util.isWindows()) {
|
if(util.isWindows()) {
|
||||||
cmd = cmd || '';
|
cmd = cmd || '';
|
||||||
this.info().then(machine => {
|
this.info(machineName).then(machine => {
|
||||||
util.exec('start powershell.exe ' + cmd,
|
util.exec('start powershell.exe ' + cmd,
|
||||||
{env: {
|
{env: {
|
||||||
'DOCKER_HOST' : machine.url,
|
'DOCKER_HOST' : machine.url,
|
||||||
|
@ -162,7 +162,7 @@ var DockerMachine = {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
cmd = cmd || process.env.SHELL;
|
cmd = cmd || process.env.SHELL;
|
||||||
this.info().then(machine => {
|
this.info(machineName).then(machine => {
|
||||||
util.exec([resources.terminal(), `DOCKER_HOST=${machine.url} DOCKER_CERT_PATH=${path.join(util.home(), '.docker/machine/machines/' + machine.name)} DOCKER_TLS_VERIFY=1 ${cmd}`]).then(() => {});
|
util.exec([resources.terminal(), `DOCKER_HOST=${machine.url} DOCKER_CERT_PATH=${path.join(util.home(), '.docker/machine/machines/' + machine.name)} DOCKER_TLS_VERIFY=1 ${cmd}`]).then(() => {});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче