Skip to content

Commit

Permalink
Complete AWS Listing using CCF data
Browse files Browse the repository at this point in the history
Signed-off-by: Gnanakeethan Balasubramaniam <[email protected]>
  • Loading branch information
gnanakeethan committed Oct 10, 2023
1 parent af4514a commit ad696ea
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/lib/cloud-instance-metadata/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
import {describe, expect, jest, test} from '@jest/globals';
import {CloudInstanceMetadataModel} from './index';

jest.setTimeout(30000);

describe('ccf:configure test', () => {
test('initialize and test', async () => {
const model = await new CloudInstanceMetadataModel().configure('ccf', {});
expect(model).toBeInstanceOf(CloudInstanceMetadataModel);
await expect(
model.calculate([
{
'cloud-instance-type': 't2.micro',
'cloud-vendor': 'aws',
},
])
).resolves.toStrictEqual(
expect.arrayContaining([
{
'cloud-instance-type': 't2.micro',
'cloud-vendor': 'aws',
'physical-processor': 'Intel Xeon E5-2676 v3',
'vcpus-allocated': '1',
'vcpus-total': '48',
},
])
);
});
});
22 changes: 22 additions & 0 deletions src/lib/cloud-instance-metadata/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,28 @@ export class CloudInstanceMetadataModel implements IImpactModelInterface {
'Each observation must contain a cloud-instance-type key'
);
}

const instance = AWS_INSTANCES.find(
instance => instance['Instance type'] === instance_type
);
if (instance) {
console.log(instance);
console.log(vendor);
observation['vcpus-allocated'] = instance['Instance vCPU'];
observation['vcpus-total'] = instance['Platform Total Number of vCPU'];
const cpuType = instance['Platform CPU Name'];
let platform = '';
if (cpuType.startsWith('EPYC')) {
platform = 'AMD';
} else if (cpuType.startsWith('Xeon')) {
platform = 'Intel';
} else if (cpuType.startsWith('Graviton')) {
platform = 'AWS';
} else if (cpuType.startsWith('Core')) {
platform = 'Intel';
}
observation['physical-processor'] = `${platform} ${cpuType}`;
}
return observation;
});
}
Expand Down

0 comments on commit ad696ea

Please sign in to comment.