Skip to content

Commit

Permalink
[orchestrator] Search service volume by name
Browse files Browse the repository at this point in the history
  • Loading branch information
vladostp committed Feb 23, 2021
1 parent bfaf978 commit fba5e80
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
9 changes: 5 additions & 4 deletions orchestrator/src/docker.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,22 +271,23 @@ class Docker {
}
}

async getContainerById (id) {
async getContainerById (nameOrId) {
try {
const containers = await this.docker.listContainers({ all: true });
// return containers;
return containers.find(element => {
return element.Id.startsWith(id) ? element : false;
return element.Id.startsWith(nameOrId) || (element.Names.length > 0 && element.Names[0].includes(nameOrId)) ? element : false;
});
} catch (error) {
debug('getContainerById', error);
throw error;
}
}

async getMountThatContains (id, str) {
async getMountThatContains (nameOrId, str) {
try {
const container = await this.getContainerById(id);
const container = await this.getContainerById(nameOrId);

if (container) {
return container.Mounts.find(element => {
return element.Source.includes(str) ? element : false;
Expand Down
18 changes: 9 additions & 9 deletions orchestrator/src/orchestrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -718,11 +718,11 @@ class Orchestrator {
} else if (action === 'download-stats') {
console.log('Sending stats only!');
const stats = await this.download.getStats();
stats['downloadRunning'] = this.downloadRunning;
stats['downloadPaused'] = this.downloadPaused;
stats['downloadSuccess'] = this.downloadSuccess;
stats['downloadState'] = this.downloadState;
stats['downloadError'] = this.downloadError;
stats.downloadRunning = this.downloadRunning;
stats.downloadPaused = this.downloadPaused;
stats.downloadSuccess = this.downloadSuccess;
stats.downloadState = this.downloadState;
stats.downloadError = this.downloadError;
return JSON.stringify(stats);
// Restore service database
} else if (action === 'restore') {
Expand All @@ -745,10 +745,10 @@ class Orchestrator {
// Restore database process statistics
} else if (action === 'restore-stats') {
const stats = {};
stats['databaseRestoreRunning'] = this.databaseRestoreRunning;
stats['databaseRestoreSuccess'] = this.databaseRestoreSuccess;
stats['databaseRestoreError'] = this.databaseRestoreError;
stats['databaseRestoreProgress'] = this.databaseRestoreProgress;
stats.databaseRestoreRunning = this.databaseRestoreRunning;
stats.databaseRestoreSuccess = this.databaseRestoreSuccess;
stats.databaseRestoreError = this.databaseRestoreError;
stats.databaseRestoreProgress = this.databaseRestoreProgress;
return JSON.stringify(stats);
} else {
throw Error('Unknown action.');
Expand Down

0 comments on commit fba5e80

Please sign in to comment.