in app/scripts/modules/google/instance/details/instance.details.controller.js [66:174]
function retrieveInstance() {
var extraData = {};
var instanceSummary, loadBalancers, account, region, vpcId;
if (!app.serverGroups) {
// standalone instance
instanceSummary = {};
loadBalancers = [];
account = instance.account;
region = instance.region;
} else {
app.serverGroups.data.some(function (serverGroup) {
return serverGroup.instances.some(function (possibleInstance) {
if (possibleInstance.id === instance.instanceId) {
instanceSummary = possibleInstance;
loadBalancers = serverGroup.loadBalancers;
account = serverGroup.account;
region = serverGroup.region;
extraData.serverGroup = serverGroup.name;
return true;
}
});
});
if (!instanceSummary) {
// perhaps it is in a server group that is part of another application
app.loadBalancers.data.some(function (loadBalancer) {
return loadBalancer.instances.some(function (possibleInstance) {
if (possibleInstance.id === instance.instanceId) {
instanceSummary = possibleInstance;
loadBalancers = [loadBalancer.name];
account = loadBalancer.account;
region = loadBalancer.region;
vpcId = loadBalancer.vpcId;
return true;
}
});
});
if (!instanceSummary) {
// perhaps it is in a disabled server group via a load balancer
app.loadBalancers.data.some(function (loadBalancer) {
return loadBalancer.serverGroups.some(function (serverGroup) {
if (!serverGroup.isDisabled) {
return false;
}
return serverGroup.instances.some(function (possibleInstance) {
if (possibleInstance.id === instance.instanceId) {
instanceSummary = possibleInstance;
loadBalancers = [loadBalancer.name];
account = loadBalancer.account;
region = loadBalancer.region;
vpcId = loadBalancer.vpcId;
return true;
}
});
});
});
}
}
}
if (instanceSummary && account && region) {
extraData.account = account;
extraData.region = region;
recentHistoryService.addExtraDataToLatest('instances', extraData);
return instanceReader.getInstanceDetails(account, region, instance.instanceId).then(function(details) {
$scope.state.loading = false;
extractHealthMetrics(instanceSummary, details);
$scope.instance = _.defaults(details, instanceSummary);
$scope.instance.account = account;
$scope.instance.region = region;
$scope.instance.vpcId = vpcId;
$scope.instance.loadBalancers = gceHttpLoadBalancerUtils.normalizeLoadBalancerNamesForAccount(
loadBalancers,
account,
app.getDataSource('loadBalancers').data);
$scope.instance.internalDnsName = $scope.instance.instanceId;
$scope.instance.internalIpAddress = $scope.instance.networkInterfaces[0].networkIP;
if ($scope.instance.networkInterfaces[0].accessConfigs) {
$scope.instance.externalIpAddress = $scope.instance.networkInterfaces[0].accessConfigs[0].natIP;
}
$scope.baseIpAddress = $scope.instance.externalIpAddress || $scope.instance.internalIpAddress;
$scope.instance.network = getNetwork();
$scope.instance.subnet = getSubnet();
$scope.instance.sshLink =
$scope.instance.selfLink.replace(/www.googleapis.com\/compute\/(alpha|beta|v1)/, 'cloudssh.developers.google.com') + '?authuser=0&hl=en_US';
var pathSegments = $scope.instance.selfLink.split('/');
var projectId = pathSegments[pathSegments.indexOf('projects') + 1];
$scope.instance.logsLink =
'https://console.developers.google.com/project/' + projectId + '/logs?service=gce_instance&minLogLevel=0&filters=text:' + $scope.instance.instanceId;
$scope.instance.gcloudSSHCommand = 'gcloud compute ssh --project ' + projectId + ' --zone ' + $scope.instance.placement.availabilityZone + ' ' + instance.instanceId;
augmentTagsWithHelp();
},
autoClose
);
}
if (!instanceSummary) {
$scope.instanceIdNotFound = instance.instanceId;
$scope.state.loading = false;
}
return $q.when(null);
}