Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve instance_types.rake logic #301

Merged
merged 3 commits into from
Sep 27, 2017
Merged

Conversation

jameswnl
Copy link
Contributor

@jameswnl jameswnl commented Sep 21, 2017

I have submitted this PR. That PR will enhance the site's json output so that we can eliminate the tedious manual step to curl and using 3rd party site to convert html to csv

Meanwhile we can use my forked copy and run python scrape.py locally to generate the json file.

update

The PR to http://ec2instances.info has been merged

@jameswnl
Copy link
Contributor Author

@durandom Would like to get your input on this before un-wip it.

@miq-bot add_label wip, enhancement

@jameswnl jameswnl force-pushed the instancetypes2 branch 2 times, most recently from 1449476 to e4257da Compare September 21, 2017 18:23
Copy link
Member

@durandom durandom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great idea to add the parsing to ec2instances upstream!

:virtualization_type => [:hvm],
:network_performance => :low,
:physical_processor => "Intel Xeon family",
:processor_clock_speed => 3.3,
:processor_clock_speed => "up to 3.3",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a problem, that this is now a string?
is the db a string?
will it impact UI sorting?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original code was

o[:processor_clock_speed] = row[:clock_speed_ghz].scan(/[\d\.]/).join

And that won't work because some of the new values of row[:clock_speed_ghz] are like '2.3 to 2.7'. The scan will return '2.32.7' which doesn't make sense and also breaks the numeric field.

This is the part need your help. Do you know how we use this? Or who would know that I can ask?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this won't matter, the db doesn't care about this, it only cares about

new_result = {
      :type                     => ManageIQ::Providers::Amazon::CloudManager::Flavor.name,
      :ems_ref                  => uid,
      :name                     => name,
      :description              => flavor[:description],
      :enabled                  => !flavor[:disabled],
      :cpus                     => cpus,
      :cpu_cores                => 1,
      :memory                   => flavor[:memory],
      :supports_32_bit          => flavor[:architecture].include?(:i386),
      :supports_64_bit          => flavor[:architecture].include?(:x86_64),
      :supports_hvm             => flavor[:virtualization_type].include?(:hvm),
      :supports_paravirtual     => flavor[:virtualization_type].include?(:paravirtual),
      :block_storage_based_only => flavor[:ebs_only],
      :cloud_subnet_required    => flavor[:vpc_only],
      :ephemeral_disk_size      => flavor[:instance_store_size],
      :ephemeral_disk_count     => flavor[:instance_store_volumes]
    }

as in parsing code here

:instance_store_volumes => 1, # SSD
:architecture => [:x86_64],
:virtualization_type => [],
:network_performance => :high,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is :network_performance a free text? IIRC it should be rather a set of [:high, :low, etc]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, there are new values breaking the original parsing logic which was

 -    o[:network_performance] = case i[:network_performance]
 -                              when '10 Gigabit', '20 Gigabit'
 -                                :very_high
 -                              else
 -                                i[:network_performance].downcase.tr(' ', '_').to_sym
 -                              end

Yes, AWS use free text for this field. So it's hard to parse it into structured type.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think we actually use this.

else
i[:network_performance].downcase.tr(' ', '_').to_sym
end
# see https://github.com/ManageIQ/manageiq/issues/741#issuecomment-57353290
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd leave this comment in the code as a pointer to what 'ebs_only' means

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, done!

@@ -5,9 +5,6 @@ task :instance_types => [:environment] do
# This task creates a instance_types.rb file in the current directory based upon the current
# instance_types.rb file and data from
# curl https://raw.githubusercontent.com/powdahound/ec2instances.info/master/www/instances.json > lib/tasks_private/instance_types_data/instances.json
# https://aws.amazon.com/ec2/instance-types/#instance-type-matrix > lib/tasks_private/instance_types_data/instance_types.csv
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that this is now included in ec2instances.info, which is great

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, they just merged my vantage-sh/ec2instances.info#270 hours ago 😉

@@ -5,9 +5,6 @@ task :instance_types => [:environment] do
# This task creates a instance_types.rb file in the current directory based upon the current
# instance_types.rb file and data from
# curl https://raw.githubusercontent.com/powdahound/ec2instances.info/master/www/instances.json > lib/tasks_private/instance_types_data/instances.json
# https://aws.amazon.com/ec2/instance-types/#instance-type-matrix > lib/tasks_private/instance_types_data/instance_types.csv
# https://aws.amazon.com/ec2/previous-generation/#Previous_Generation_Instance_Details_and_Pricing_ > lib/tasks_private/instance_types_data/instance_types_previous.csv
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but this isnt included...
did you remove it, because we assume that previous generations do not change anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original output from ec2instance.info already has a field generation which has value either 'current' or 'previous'. So that's how I determine it.

@miq-bot
Copy link
Member

miq-bot commented Sep 22, 2017

Checked commits jameswnl/manageiq-providers-amazon@e5b8c2a~...20fa57d with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
4 files checked, 4 offenses detected

app/models/manageiq/providers/amazon/instance_types.rb

@jameswnl
Copy link
Contributor Author

@miq-bot remove_label wip

@jameswnl jameswnl changed the title [WIP] Improve instance_types.rake logic Improve instance_types.rake logic Sep 22, 2017
@miq-bot miq-bot removed the wip label Sep 22, 2017
Copy link
Member

@durandom durandom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it :)

@bronaghs I had a quick search for :network_performance and :processor_clock_speed and it seems changing them from numerical to free text has no impact, because they are not really used in the UI.

So, please merge if you like

@bronaghs bronaghs merged commit 48cac42 into ManageIQ:master Sep 27, 2017
@bronaghs bronaghs added this to the Sprint 70 Ending Oct 2, 2017 milestone Sep 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants