mirror of
https://github.com/yldio/copilot.git
synced 2024-11-28 14:10:04 +02:00
fix(portal-api): update import logic to assign dg.services
This commit is contained in:
parent
0ec4acce1e
commit
2b552360e0
@ -2038,7 +2038,7 @@ class Data extends EventEmitter {
|
|||||||
this._triton.stopMachine(instance.machine_id, next);
|
this._triton.stopMachine(instance.machine_id, next);
|
||||||
},
|
},
|
||||||
inputs: instances
|
inputs: instances
|
||||||
}, (err, results) => {
|
}, (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return cb(err);
|
return cb(err);
|
||||||
}
|
}
|
||||||
@ -2113,7 +2113,7 @@ class Data extends EventEmitter {
|
|||||||
this._triton.rebootMachine(instance.machine_id, next);
|
this._triton.rebootMachine(instance.machine_id, next);
|
||||||
},
|
},
|
||||||
inputs: instances
|
inputs: instances
|
||||||
}, (err, results) => {
|
}, (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return cb(err);
|
return cb(err);
|
||||||
}
|
}
|
||||||
@ -2338,34 +2338,78 @@ class Data extends EventEmitter {
|
|||||||
});
|
});
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
|
const handleNewInstances = ({ id }, next) => {
|
||||||
|
return (err, result) => {
|
||||||
|
if (err) {
|
||||||
|
return next(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
this._server.log(['debug'], `-> created Instances ${Util.inspect(result.successes)}`);
|
||||||
|
|
||||||
|
this.updateService({
|
||||||
|
id,
|
||||||
|
instances: result.successes
|
||||||
|
}, next);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleNewService = ({ instances, deploymentGroupId }, next) => {
|
||||||
|
return (err, service) => {
|
||||||
|
if (err) {
|
||||||
|
return next(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
VAsync.forEachParallel({
|
||||||
|
inputs: instances,
|
||||||
|
func: (instance, next) => {
|
||||||
|
return this.createInstance(Object.assign(instance, {
|
||||||
|
deploymentGroupId,
|
||||||
|
serviceId: service.id
|
||||||
|
}), next);
|
||||||
|
}
|
||||||
|
}, handleNewInstances(service, next));
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
const createService = (deploymentGroupId) => {
|
const createService = (deploymentGroupId) => {
|
||||||
return (serviceId, next) => {
|
return (serviceIndex, next) => {
|
||||||
const service = services[serviceId];
|
const service = services[serviceIndex];
|
||||||
|
|
||||||
this._server.log(['debug'], `-> creating Service ${Util.inspect(service)}`);
|
this._server.log(['debug'], `-> creating Service ${Util.inspect(service)}`);
|
||||||
|
|
||||||
VAsync.forEachParallel({
|
this.createService(Object.assign(service, {
|
||||||
inputs: service.instances,
|
deploymentGroupId
|
||||||
func: (instance, next) => {
|
}), handleNewService({
|
||||||
return this.createInstance(Object.assign(instance, {
|
instances: service.instances,
|
||||||
deploymentGroupId
|
deploymentGroupId
|
||||||
}), next);
|
}, next));
|
||||||
}
|
|
||||||
}, (err, results) => {
|
|
||||||
if (err) {
|
|
||||||
return cb(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
this._server.log(['debug'], `-> created Instances ${Util.inspect(results.successes)}`);
|
|
||||||
|
|
||||||
this.createService(Object.assign(service, {
|
|
||||||
instances: results.successes,
|
|
||||||
deploymentGroupId
|
|
||||||
}), next);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleNewServices = (deploymentGroupId) => {
|
||||||
|
return (err, result) => {
|
||||||
|
if (err) {
|
||||||
|
return cb(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.updateDeploymentGroup({
|
||||||
|
id: deploymentGroupId,
|
||||||
|
services: result.successes
|
||||||
|
}, cb);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleNewDeploymentGroup = (err, dg) => {
|
||||||
|
if (err) {
|
||||||
|
return cb(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
VAsync.forEachParallel({
|
||||||
|
inputs: Object.keys(services),
|
||||||
|
func: createService(dg.id)
|
||||||
|
}, handleNewServices(dg.id));
|
||||||
|
};
|
||||||
|
|
||||||
const deploymentGroup = {
|
const deploymentGroup = {
|
||||||
name: tags[DEPLOYMENT_GROUP],
|
name: tags[DEPLOYMENT_GROUP],
|
||||||
slug: ParamCase(tags[DEPLOYMENT_GROUP]),
|
slug: ParamCase(tags[DEPLOYMENT_GROUP]),
|
||||||
@ -2375,18 +2419,7 @@ class Data extends EventEmitter {
|
|||||||
|
|
||||||
this._server.log(['debug'], `-> creating DeploymentGroup ${Util.inspect(deploymentGroup)}`);
|
this._server.log(['debug'], `-> creating DeploymentGroup ${Util.inspect(deploymentGroup)}`);
|
||||||
|
|
||||||
this.createDeploymentGroup(deploymentGroup, (err, dg) => {
|
this.createDeploymentGroup(deploymentGroup, handleNewDeploymentGroup);
|
||||||
if (err) {
|
|
||||||
return cb(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
VAsync.forEachParallel({
|
|
||||||
inputs: Object.keys(services),
|
|
||||||
func: createService(dg.id)
|
|
||||||
}, (err) => {
|
|
||||||
return cb(err, dg);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user