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
remove direct access to profile #1086
Conversation
src/lib/network/network_autoyast.rb
Outdated
@@ -144,7 +144,7 @@ def activate_s390_devices(section = nil) | |||
def configure_hosts(write: false) | |||
log.info("NetworkAutoYast: Hosts configuration") | |||
|
|||
unless ay_current_profile.key? "host" | |||
if ay_current_profile.empty? |
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 rewrite is strange, originally it was call only if "host" section was present, and now if the profile is empty? at least is what the call and variable name suggest..
# Returns current AY profile in the internal representation | ||
# | ||
# @return [Hash] hash representing current profile or empty hash | ||
def ay_current_profile |
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.
But then, there is no ay_current_profile
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.
yep, it is correct. Previously it was typo.
src/lib/network/network_autoyast.rb
Outdated
@@ -144,7 +144,7 @@ def activate_s390_devices(section = nil) | |||
def configure_hosts(write: false) | |||
log.info("NetworkAutoYast: Hosts configuration") | |||
|
|||
unless ay_current_profile.key? "host" | |||
if ay_current_profile.empty? |
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.
if ay_current_profile.empty? | |
if ay_host_section.empty? |
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.
yes, it should just check host section. In fact change should be valid as it do some tricks with hosts config, but if section is empty it should be asme as if it is not there at all, not?
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.
yep, that is what I would expect
src/lib/network/network_autoyast.rb
Outdated
# Returns global section of current AY profile | ||
def ay_general_section | ||
return {} if ay_current_profile["general"].nil? | ||
attr_writer :ay_networking_section |
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 guess we plan to use the Y2Network::AutoinstProfile::NetworkingSection object:
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.
To be honest I am not sure and I do not want to break it more then it is already.
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, we could do a intermediate step before adapting it completely.
@@ -77,6 +77,8 @@ def change | |||
end | |||
|
|||
def import(profile) | |||
Yast::NetworkAutoYast.instance.ay_networking_section = profile |
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.
Yast::NetworkAutoYast.instance.ay_networking_section = profile | |
Yast::NetworkAutoYast.instance.ay_networking_section = | |
AutoinstProfile::NetworkingSection.new_from_hashes(profile) |
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.
well, does networking section act like Hash? Otherwise I will have to adapt also rest of code.
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.
Not really, and we probably use some defaults already, but then we have to document it very well to not be confused as we could expect an Y2Network::AutoinstProfile::NetworkingSection
object instead of hash and vice versa.
@@ -159,6 +160,8 @@ def Import(settings) | |||
set_names(ip, names) | |||
end | |||
|
|||
NetworkAutoYast.instance.ay_host_section = settings |
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.
Similar approach commented below
I guess that at some point we could even get rid of the direct check of sections and rely on the imported config. Although there could be exceptions and also host section is independent of networking one, so in general I think that the current approach storing the imported sections in the NetworkAutoyast instance looks ok. @imobachgs what do you think? |
I agree with your POV, it should be the solution at long-term. |
@@ -168,6 +168,12 @@ def keep_net_config? | |||
ret | |||
end | |||
|
|||
# setter for networking section. Should be done during import. |
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.
Please document the type of the variables.
In general looks good to me, although we have to take in mind removed sections that could be cached in the NetworkAutoyast instance and could be a problem if it is done before auto_setup |
src/lib/network/network_autoyast.rb
Outdated
@@ -169,9 +169,11 @@ def keep_net_config? | |||
end | |||
|
|||
# setter for networking section. Should be done during import. | |||
# @param [Hash] networking section hash |
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.
# @param [Hash] networking section hash | |
# @param value [Hash] networking section hash |
src/lib/network/network_autoyast.rb
Outdated
attr_writer :ay_networking_section | ||
|
||
# setter for host section. Should be done during import. | ||
# @param [Hash] host section hash |
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.
# @param [Hash] host section hash | |
# @param value [Hash] host section hash |
9d00495
to
738b2fb
Compare
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.
LGTM
✔️ Public Jenkins job #165 successfully finished |
trello: https://trello.com/c/kCfh7Ylo/1941-5-drop-references-to-profilecurrent