Skip to content

Commit

Permalink
Added option to display info if instances are in VPC only.
Browse files Browse the repository at this point in the history
#115

* scrape.py - added extra field to instance object
* render.py - extra function to deal with data based on instance type
* mako - extra table column
* js - upate default sorting to reflect sorting by linux price
* .gitignore for virtualenv
  • Loading branch information
Michał Sochoń committed Dec 12, 2015
1 parent e550dbf commit ab9904b
Show file tree
Hide file tree
Showing 7 changed files with 248 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.pyc
*.DS_store
.idea
env
4 changes: 4 additions & 0 deletions in/index.html.mako
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
<abbr title="Adding additional IPs requires launching the instance in a VPC.">Max IPs</abbr>
</th>
<th class="enhanced-networking">Enhanced Networking</th>
<th class="vpc-only">VPC Only</th>
<th class="linux-virtualization">Linux Virtualization</th>

<th class="cost-ondemand-linux">Linux On Demand cost</th>
Expand Down Expand Up @@ -222,6 +223,9 @@
<td class="enhanced-networking">
${'Yes' if inst['enhanced_networking'] else 'No'}
</td>
<td class="vpc-only">
${'VPC only' if inst['vpc_only'] else 'VPC and EC2Classic'}
</td>
<td class="linux-virtualization">
% if inst['linux_virtualization_types']:
${', '.join(inst['linux_virtualization_types'])}
Expand Down
19 changes: 19 additions & 0 deletions render.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ def pretty_name(inst):
extra = 'Quadruple'
elif short.startswith('2x'):
extra = 'Double'
elif short.startswith('10x'):
extra = 'Deca'
elif short.startswith('x'):
extra = ''
bits = [prefix]
Expand All @@ -42,6 +44,7 @@ def pretty_name(inst):

return ' '.join([b for b in bits if b])


def network_sort(inst):
perf = inst['network_performance']
network_rank = [
Expand All @@ -61,17 +64,33 @@ def network_sort(inst):
sort += 1
return sort


def add_cpu_detail(i):
# special burstable instances
if i['instance_type'] in ('t1.micro', 't2.micro', 't2.small', 't2.medium', 't2.large'):
i['burstable'] = True
i['ECU'] = i['vCPU'] # a reasonable ECU to display
i['ECU_per_core'] = i['ECU'] / i['vCPU']


def add_vpconly_detail(i):
# specific instances can be lanuched in VPC only
# http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html
# https://github.com/powdahound/ec2instances.info/issues/115
instance_types = ()
instance_types += ('c4.large', 'c4.xlarge', 'c4.2xlarge', 'c4.4xlarge')
instance_types += ('m4.large', 'm4.xlarge', 'm4.2xlarge', 'm4.4xlarge', 'm4.10xlarge')
instance_types += ('t2.micro', 't2.small', 't2.medium', 't2.large')
if i['instance_type'] in instance_types:
i['vpc_only'] = True


def add_render_info(i):
i['network_sort'] = network_sort(i)
i['pretty_name'] = pretty_name(i)
add_cpu_detail(i)
add_vpconly_detail(i)


def render(data_file, template_file, destination_file):
"""Build the HTML content from scraped data"""
Expand Down
5 changes: 4 additions & 1 deletion scrape.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ def __init__(self):
self.ebs_throughput = 0
self.ebs_iops = 0
self.ebs_max_bandwidth = 0
# self.hvm_only = False
self.vpc_only = False

def to_dict(self):
d = dict(family=self.family,
Expand All @@ -31,7 +33,8 @@ def to_dict(self):
pricing=self.pricing,
vpc=self.vpc,
linux_virtualization_types=self.linux_virtualization_types,
generation=self.generation)
generation=self.generation,
vpc_only=self.vpc_only)
if self.ebs_only:
d['storage'] = None
else:
Expand Down
2 changes: 1 addition & 1 deletion www/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function init_data_table() {
],
// default sort by linux cost
"aaSorting": [
[ 14, "asc" ]
[ 15, "asc" ]
],
'initComplete': function() {
// fire event in separate context so that calls to get_data_table()
Expand Down
Loading

0 comments on commit ab9904b

Please sign in to comment.