Skip to content

Commit

Permalink
Merge pull request spinnaker#1 from spinnaker/master
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
bfarrell committed Mar 11, 2016
2 parents 2ba8572 + 59bdf98 commit d31bd43
Show file tree
Hide file tree
Showing 660 changed files with 12,083 additions and 8,838 deletions.
2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ API_HOST=http://localhost:8084 npm start

== Building & Deploying

To build the application, run `npm run build`. The built application lives in `dist/`.
To build the application, run `npm run build`. The built application lives in `build/`.

== Conventions

Expand Down
7 changes: 6 additions & 1 deletion app/scripts/modules/amazon/aws.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module.exports = angular.module('spinnaker.aws', [
require('../core/pipeline/config/stages/resizeAsg/aws/awsResizeAsgStage.js'),
require('../core/pipeline/config/stages/scaleDownCluster/aws/awsScaleDownClusterStage.js'),
require('../core/pipeline/config/stages/shrinkCluster/aws/awsShrinkClusterStage.js'),
require('../core/subnet/subnet.module.js'),
require('./serverGroup/details/serverGroup.details.module.js'),
require('./serverGroup/serverGroup.transformer.js'),
require('./serverGroup/configure/wizard/CloneServerGroup.aws.controller.js'),
Expand All @@ -37,7 +38,7 @@ module.exports = angular.module('spinnaker.aws', [
require('./securityGroup/configure/EditSecurityGroupCtrl.js'),
require('./securityGroup/securityGroup.transformer.js'),
require('./securityGroup/securityGroup.reader.js'),
require('./subnet/subnet.module.js'),
require('./subnet/subnet.renderer.js'),
require('./validation/applicationName.validator.js'),
require('./vpc/vpc.module.js'),
require('./image/image.reader.js'),
Expand All @@ -46,6 +47,7 @@ module.exports = angular.module('spinnaker.aws', [
])
.config(function(cloudProviderRegistryProvider) {
cloudProviderRegistryProvider.registerProvider('aws', {
v2wizard: true,
name: 'Amazon',
logo: {
path: require('./logo/amazon.logo.svg'),
Expand Down Expand Up @@ -85,6 +87,9 @@ module.exports = angular.module('spinnaker.aws', [
createSecurityGroupTemplateUrl: require('./securityGroup/configure/createSecurityGroup.html'),
createSecurityGroupController: 'awsCreateSecurityGroupCtrl',
},
subnet: {
renderer: 'awsSubnetRenderer',
},
search: {
resultFormatter: 'awsSearchResultFormatter',
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = angular.module('spinnaker.aws.cache.initializer', [
require('../../core/loadBalancer/loadBalancer.read.service.js'),
require('../../core/instance/instanceTypeService.js'),
require('../../core/securityGroup/securityGroup.read.service.js'),
require('../subnet/subnet.read.service.js'),
require('../../core/subnet/subnet.read.service.js'),
require('../vpc/vpc.read.service.js'),
])
.factory('awsCacheConfigurer', function ($q,
Expand Down
61 changes: 0 additions & 61 deletions app/scripts/modules/amazon/instance/awsInstanceType.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,91 +167,30 @@ module.exports = angular.module('spinnaker.aws.instanceType.service', [
{
type: 'general',
label: 'General Purpose',
description: 'Instances that provide a balance of compute, memory, and network resources',
families: [ m3 ],
icon: 'hdd'
},
{
type: 'memory',
label: 'High Memory',
description: 'Instances that are optimized for memory-intensive applications',
families: [ r3 ],
icon: 'hdd'
},
{
type: 'micro',
label: 'Micro Utility',
description: 'Instances that provide relatively small amounts of memory and CPU power',
families: [t2, m3micro],
icon: 'hdd'
},
{
type: 'custom',
label: 'Custom Type',
description: 'Select the instance type below.',
families: [],
icon: 'asterisk'
}
];

function calculateStorage(type) {
if (!type || !type.storage) {
return 0;
}
return type.storage.count * type.storage.size;
}

function buildStats(category) {
var stats = {
cpu: {
min: Number.MAX_VALUE,
max: -Number.MAX_VALUE
},
memory: {
min: Number.MAX_VALUE,
max: -Number.MAX_VALUE
},
storage: {
min: Number.MAX_VALUE,
max: -Number.MAX_VALUE
},
costFactor: {
min: Number.MAX_VALUE,
max: -Number.MAX_VALUE
},
families: []
};

if (category.families && category.families.length) {
category.families.forEach(function(family) {
stats.families.push(family.type);
var cpuMin = _.min(family.instanceTypes, 'cpu').cpu || Number.MAX_VALUE,
cpuMax = _.max(family.instanceTypes, 'cpu').cpu || -Number.MAX_VALUE,
memoryMin = _.min(family.instanceTypes, 'memory').memory || Number.MAX_VALUE,
memoryMax = _.max(family.instanceTypes, 'memory').memory || -Number.MAX_VALUE,
storageMin = calculateStorage(_.min(family.instanceTypes, calculateStorage)) || Number.MAX_VALUE,
storageMax = calculateStorage(_.max(family.instanceTypes, calculateStorage)) || -Number.MAX_VALUE,
costFactorMin = _.min(family.instanceTypes, 'costFactor').costFactor || Number.MAX_VALUE,
costFactorMax = _.max(family.instanceTypes, 'costFactor').costFactor || -Number.MAX_VALUE;

stats.cpu.min = Math.min(stats.cpu.min, cpuMin);
stats.cpu.max = Math.max(stats.cpu.max, cpuMax);
stats.memory.min = Math.min(stats.memory.min, memoryMin);
stats.memory.max = Math.max(stats.memory.max, memoryMax);
stats.storage.min = Math.min(stats.storage.min, storageMin);
stats.storage.max = Math.max(stats.storage.max, storageMax);
stats.costFactor.min = Math.min(stats.costFactor.min, costFactorMin);
stats.costFactor.max = Math.max(stats.costFactor.max, costFactorMax);
});
}

return stats;
}

function getCategories() {
categories.map(function(category) {
category.stats = buildStats(category);
});
return $q.when(categories);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ module.exports = angular.module('spinnaker.instance.detail.aws.controller', [
account = instance.account;
region = instance.region;
} else {
app.serverGroups.some(function (serverGroup) {
app.serverGroups.data.some(function (serverGroup) {
return serverGroup.instances.some(function (possibleInstance) {
if (possibleInstance.id === instance.instanceId) {
instanceSummary = possibleInstance;
Expand All @@ -83,7 +83,7 @@ module.exports = angular.module('spinnaker.instance.detail.aws.controller', [
});
if (!instanceSummary) {
// perhaps it is in a server group that is part of another app
app.loadBalancers.some(function (loadBalancer) {
app.loadBalancers.data.some(function (loadBalancer) {
return loadBalancer.instances.some(function (possibleInstance) {
if (possibleInstance.id === instance.instanceId) {
instanceSummary = possibleInstance;
Expand All @@ -97,7 +97,7 @@ module.exports = angular.module('spinnaker.instance.detail.aws.controller', [
});
if (!instanceSummary) {
// perhaps it is in a disabled server group via a load balancer
app.loadBalancers.some(function(loadBalancer) {
app.loadBalancers.data.some(function(loadBalancer) {
return loadBalancer.serverGroups.some(function(serverGroup) {
if (!serverGroup.isDisabled) {
return false;
Expand Down Expand Up @@ -362,14 +362,17 @@ module.exports = angular.module('spinnaker.instance.detail.aws.controller', [
);
};

retrieveInstance().then(() => {
let initialize = app.isStandalone ?
retrieveInstance() :
$q.all([app.serverGroups.ready(), app.loadBalancers.ready()]).then(retrieveInstance);

initialize.then(() => {
// Two things to look out for here:
// 1. If the retrieveInstance call completes *after* the user has navigated away from the view, there
// is no point in subscribing to the autoRefreshStream
// is no point in subscribing to the refresh
// 2. If this is a standalone instance, there is no application that will refresh
if (!$scope.$$destroyed && !app.isStandalone) {
let refreshWatcher = app.autoRefreshStream.subscribe(retrieveInstance);
$scope.$on('$destroy', () => refreshWatcher.dispose());
app.serverGroups.onRefresh($scope, retrieveInstance);
}
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';


describe('Controller: awsInstanceDetailsCtrl', function () {

var controller;
Expand All @@ -9,33 +8,26 @@ describe('Controller: awsInstanceDetailsCtrl', function () {
var $q;
var rx;
var refreshStream;
var applicationReader;

beforeEach(
window.module(
require('./instance.details.controller'),
require('../../../core/utils/rx')
require('../../../core/utils/rx'),
require('../../../core/application/service/applications.read.service')
)
);

beforeEach(
window.inject(function ($rootScope, $controller, _instanceReader_, _$q_, _rx_) {
window.inject(function ($rootScope, $controller, _instanceReader_, _$q_, _rx_, _applicationReader_) {
scope = $rootScope.$new();
instanceReader = _instanceReader_;
$q = _$q_;
rx = _rx_;
refreshStream = new rx.Subject();

controller = $controller('awsInstanceDetailsCtrl', {
$scope: scope,
instance: {},
app: {
autoRefreshStream: refreshStream
},
overrides: {},
});
applicationReader = _applicationReader_;

this.createController = function(application, instance) {
application.autoRefreshStream = application.autoRefreshStream || refreshStream;
controller = $controller('awsInstanceDetailsCtrl', {
$scope: scope,
instance: instance,
Expand Down Expand Up @@ -67,22 +59,28 @@ describe('Controller: awsInstanceDetailsCtrl', function () {
}
})
);
var application = {
serverGroups: [
{
account: 'test',
region: 'us-west-1',
instances: [
{
id: 'i-123',
health: [
{ type: 'Discovery', status: 'Down', reason: 'original reason'}
]
}
]
}
]
};
var application = {};

applicationReader.addSectionToApplication({key: 'loadBalancers', lazy: true}, application);
application.loadBalancers.data = [];
application.loadBalancers.loaded = true;

applicationReader.addSectionToApplication({key: 'serverGroups', lazy: true}, application);
application.serverGroups.data = [
{
account: 'test',
region: 'us-west-1',
instances: [
{
id: 'i-123',
health: [
{ type: 'Discovery', status: 'Down', reason: 'original reason'}
]
}
]
}
];
application.serverGroups.loaded = true;

this.createController(application, params);
scope.$digest();
Expand All @@ -109,22 +107,28 @@ describe('Controller: awsInstanceDetailsCtrl', function () {
})
);

var application = {
serverGroups: [
{
account: 'test',
region: 'us-west-1',
instances: [
{
id: 'i-123',
health: [
{ type: 'Discovery', state: 'Up', reason: 'original reason'}
]
}
]
}
]
};
var application = {};

applicationReader.addSectionToApplication({key: 'loadBalancers', lazy: true}, application);
application.loadBalancers.data = [];
application.loadBalancers.loaded = true;

applicationReader.addSectionToApplication({key: 'serverGroups', lazy: true}, application);
application.serverGroups.data = [
{
account: 'test',
region: 'us-west-1',
instances: [
{
id: 'i-123',
health: [
{ type: 'Discovery', state: 'Up', reason: 'original reason'}
]
}
]
}
];
application.serverGroups.loaded = true;

this.createController(application, params);
scope.$digest();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<div class="form-group">
<div class="col-md-8 nest">

<div class="form-group">
<div class="col-md-6 sm-label-right">
<b>Timeout</b><help-field key="loadBalancer.advancedSettings.healthTimeout"/>
</div>
<div class="col-md-4">
<input class="form-control input-sm" type="number" min="0" ng-model="loadBalancer.healthTimeout"/>
</div>
</div>

<div class="form-group">
<div class="col-md-6 sm-label-right">
<b>Interval</b><help-field key="loadBalancer.advancedSettings.healthInterval"/>
</div>
<div class="col-md-4">
<input class="form-control input-sm" type="number" min="0" ng-model="loadBalancer.healthInterval"/>
</div>
</div>

<div class="form-group">
<div class="col-md-6 sm-label-right">
<b>Healthy Threshold</b><help-field key="loadBalancer.advancedSettings.healthyThreshold"/>
</div>
<div class="col-md-4">
<input class="form-control input-sm" type="number" min="0" ng-model="loadBalancer.healthyThreshold"/>
</div>
</div>

<div class="form-group">
<div class="col-md-6 sm-label-right">
<b>Unhealthy Threshold</b><help-field key="loadBalancer.advancedSettings.unhealthyThreshold"/>
</div>
<div class="col-md-4">
<input class="form-control input-sm" type="number" min="0" ng-model="loadBalancer.unhealthyThreshold"/>
</div>
</div>


</div>
</div>
Loading

0 comments on commit d31bd43

Please sign in to comment.