示例#1
0
                        configmgmtDao.getChefServerDetails(cloudFormation.infraManagerId, function (err, chefDetails) {
                            if (err) {
                                logger.debug("Failed to fetch ChefServerDetails ", err);
                                res.status(500).send(errorResponses.chef.corruptChefData);
                                return;
                            }
                            var chef = new Chef({
                                userChefRepoLocation: chefDetails.chefRepoLocation,
                                chefUserName: chefDetails.loginname,
                                chefUserPemFile: chefDetails.userpemfile,
                                chefValidationPemFile: chefDetails.validatorpemfile,
                                hostedChefUrl: chefDetails.url,
                            });
                            instancesDao.getInstancesByCloudformationId(cloudFormation.id, function (err, instances) {
                                if (err) {
                                    res.status(500).send(errorResponses.db.error);
                                    return;
                                }
                                var instanceIds = [];
                                for (var i = 0; i < instances.length; i++) {
                                    instanceIds.push(instances[i].id);
                                    chef.deleteNode(instances[i].chef.chefNodeName, function (err, nodeData) {
                                        if (err) {
                                            logger.debug("Failed to delete node ", err);
                                            if (err.chefStatusCode && err.chefStatusCode === 404) {

                                            } else {

                                            }
                                            return;
                                        }
                                        logger.debug("Successfully removed instance from db.");
                                    });
                                }

                                instancesDao.removeInstancebyCloudFormationId(cloudFormation.id, function (err, deletedData) {
                                    if (err) {
                                        logger.error("Unable to delete stack instances from db", err);
                                        res.status(500).send({
                                            message: "Unable to delete stack from aws"
                                        });
                                        return;
                                    }
                                    CloudFormation.removeById(cloudFormation.id, function (err, deletedStack) {
                                        if (err) {
                                            logger.error("Unable to delete stack from db", err);
                                            res.status(500).send({
                                                message: "Unable to delete stack from db"
                                            });
                                            return;
                                        }
                                        res.send(200, {
                                            message: "deleted",
                                            instanceIds: instanceIds
                                        });
                                    });
                                });

                            });
                        });
示例#2
0
        CloudFormation.getById(req.params.cfId, function(err, cloudFormation) {
            if (err) {
                res.status(500).send(errorResponses.db.error);
                return;
            }
            if (cloudFormation) {
                instancesDao.getInstancesByCloudformationId(cloudFormation.id, function(err, instances) {
                    if (err) {
                        res.status(500).send(errorResponses.db.error);
                        return;
                    }
                    res.send(200, instances);
                });
            } else {
                res.send(404, {
                    message: "stack not found"
                });
            }

        });