-
Notifications
You must be signed in to change notification settings - Fork 66
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
Adding the user_agent when is creating the connection #96
Conversation
b02ea0d
to
5f1df73
Compare
704290a
to
680d30e
Compare
0139819
to
3b3cbc3
Compare
@@ -20,10 +20,11 @@ def connect(options = {}) | |||
host = options[:host] || address | |||
port = options[:port] || self.port | |||
auth_type = AUTH_TYPES[options[:auth_type]] | |||
user_agent_label = "ManageIQ/#{MiqServer.first.version}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rodneyhbrown7 @ManasaRaoK using cloudforms MiqServer.first.version
will show the version of the cloudforms? Doesn't make sense to me expose the branch in this label. Do you have any particular request for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't make any sense for me...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The goal is to be able to identify what client was communicating with LXCA. The version is just a way to identify what version of the client was used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oooh, now it's clear for me! Thanks @rodneyhbrown7 :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, @AndreyMenezes, @walteraa and @rodneyhbrown7 Could you review this PR, please? 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rodneyhbrown7 I understand this, but for ManageIQ this call will get fine-3
, fine-4
, etc, depends on the branch of manageIQ. In cloudforms this call will return 4.5, 4.6, etc? Just to understand the expectancy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should change the user_agent_label to "CFME/#{MiqServer.first.version}"
@miq-bot add_label gaprindashvili/yes |
@@ -20,10 +20,11 @@ def connect(options = {}) | |||
host = options[:host] || address | |||
port = options[:port] || self.port | |||
auth_type = AUTH_TYPES[options[:auth_type]] | |||
user_agent_label = "ManageIQ/#{MiqServer.first.version}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once it always will be the same value and it isn't defined through options, I recommend it should be a constant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I can accept the constant. But it shouldn't be the first.version
, because when the build change MIQ create another entry to this table. So, it should be last.version
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree with you @AndreyMenezes. This value is coming from a file named VERSION
which is in the ManageIQ root, the point is: how to know what ManageIQ is instantiating the client, it could be the first, the last or another between both of them.
It is coming from this stack:
manageiq/app/models/miq_server.rb
class MiqServer < ApplicationRecord
(...)
self.version = Vmdb::Appliance.VERSION
end
(...)
manageiq/lib/vmdb/appliance.rb
module Vmdb
module Appliance
def self.VERSION
@EVM_VERSION ||= File.read(File.join(File.expand_path(Rails.root), "VERSION")).strip
end
(...)
end
end
manageiq/lib/vmdb/appliance.rb
@rodneyhbrown7 @CharlleDaniel is there a way to know what server is instantiating the client and then perform a kind of MiqServer.find
and then getting the .version
variable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@walteraa I got it! the find
should be perfect! I'm thinking we only can have the last build server, but I'm wrong!
@@ -4,6 +4,7 @@ | |||
describe ManageIQ::Providers::Lenovo::PhysicalInfraManager do | |||
before :all do | |||
@auth = { :user => 'admin', :pass => 'smartvm', :host => 'localhost', :port => '3000' } | |||
FactoryGirl.create(:miq_server, :version=>'master') | |||
end | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't interesting add a test to check the :user_agent_label
, I mean, is it possible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should make sure that the :user_agent_label matches the :version added by FactoryGirl. Is that possible Charlle?
3b3cbc3
to
ac18ab4
Compare
ac18ab4
to
26fdd51
Compare
LGTM |
@miq-bot assign @juliancheal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Charlle the spec test for this seems to have gone away? Is there anything we can do to do some spec testing here?
@@ -4,6 +4,7 @@ | |||
describe ManageIQ::Providers::Lenovo::PhysicalInfraManager do | |||
before :all do | |||
@auth = { :user => 'admin', :pass => 'smartvm', :host => 'localhost', :port => '3000' } | |||
FactoryGirl.create(:miq_server, :version=>'master') | |||
end | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should make sure that the :user_agent_label matches the :version added by FactoryGirl. Is that possible Charlle?
@@ -8,6 +8,8 @@ module ManageIQ::Providers::Lenovo::ManagerMixin | |||
nil => 'basic_auth' | |||
}.freeze | |||
|
|||
USER_AGENT = "CFME/#{MiqServer.last&.version}".freeze |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not use the string "CFME" as part of the user agent string. CFME is a downstream Red Hat thing only, and upstream you should use ManageIQ. You can get the correct string by using I18n.t("product.name")
. That being said, you probably should not access the i18n catalog at the class-level context, so I recommend putting this into a method instead. On that note, this seems like something that might be useful for every provider, so I would be OK with a class method in the core repo to get the user agent string.
Additionally, don't use MiqServer.last as you are technically then getting a random server object. Instead, if you are going for the version, prefer Vmdb::Appliance::VERSION
or if you want the build number, Vmdb::Appliance::BUILD
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Fryguy and @juliancheal thanks for help me, I will work on this.
I've created two PRs that we could use (once they're merged)
It would be called by |
@juliancheal should you label them for the G-release because of this PR? |
This pull request is not mergeable. Please rebase and repush. |
@@ -8,6 +8,8 @@ module ManageIQ::Providers::Lenovo::ManagerMixin | |||
nil => 'basic_auth' | |||
}.freeze | |||
|
|||
USER_AGENT = "CFME/#{MiqServer.last&.version}".freeze |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be CFME, we should change this to a variable configurable from the settings. I think there might be something already like that.
maybe build
would be ok to use?
I've posted a question in gitter.
ManageIQ/manageiq#16410 is merged now. You can use |
b1f155a
to
6557415
Compare
6557415
to
940987a
Compare
Vmdb::Appliance.USER_AGENT was called with ::USER_AGENT not .USER_AGENT
9419175
to
8f00e70
Compare
Checked commits CharlleDaniel/manageiq-providers-lenovo@940987a~...8f00e70 with ruby 2.3.3, rubocop 0.47.1, haml-lint 0.20.0, and yamllint 1.10.0 |
My bad, waiting on ManageIQ/manageiq#16556 to be merged. THEN we'll be good to go. |
This PR is able to: