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

remove direct access to profile #1086

Merged
merged 7 commits into from Jul 16, 2020
Merged

remove direct access to profile #1086

merged 7 commits into from Jul 16, 2020

Conversation

jreidinger
Copy link
Member

@@ -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?
Copy link
Contributor

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
Copy link
Contributor

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

Copy link
Member Author

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.

@@ -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?
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if ay_current_profile.empty?
if ay_host_section.empty?

Copy link
Member Author

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?

Copy link
Contributor

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

# Returns global section of current AY profile
def ay_general_section
return {} if ay_current_profile["general"].nil?
attr_writer :ay_networking_section
Copy link
Contributor

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:

https://github.com/yast/yast-network/blob/master/src/lib/y2network/autoinst_profile/networking_section.rb#L37

Copy link
Member Author

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.

Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Yast::NetworkAutoYast.instance.ay_networking_section = profile
Yast::NetworkAutoYast.instance.ay_networking_section =
AutoinstProfile::NetworkingSection.new_from_hashes(profile)

Copy link
Member Author

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.

Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar approach commented below

@teclator
Copy link
Contributor

teclator commented Jul 9, 2020

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?

@imobachgs
Copy link
Contributor

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.

@jreidinger jreidinger marked this pull request as ready for review July 16, 2020 07:27
@jreidinger jreidinger changed the title RFC: remove direct access to profile remove direct access to profile Jul 16, 2020
@coveralls
Copy link

coveralls commented Jul 16, 2020

Coverage Status

Coverage increased (+0.06%) to 71.528% when pulling 738b2fb on remove_profile_current into 1441831 on master.

@@ -168,6 +168,12 @@ def keep_net_config?
ret
end

# setter for networking section. Should be done during import.
Copy link
Contributor

@teclator teclator Jul 16, 2020

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.

@teclator
Copy link
Contributor

teclator commented Jul 16, 2020

@imobachgs @jreidinger

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

@@ -169,9 +169,11 @@ def keep_net_config?
end

# setter for networking section. Should be done during import.
# @param [Hash] networking section hash
Copy link
Contributor

@teclator teclator Jul 16, 2020

Choose a reason for hiding this comment

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

Suggested change
# @param [Hash] networking section hash
# @param value [Hash] networking section hash

attr_writer :ay_networking_section

# setter for host section. Should be done during import.
# @param [Hash] host section hash
Copy link
Contributor

@teclator teclator Jul 16, 2020

Choose a reason for hiding this comment

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

Suggested change
# @param [Hash] host section hash
# @param value [Hash] host section hash

Copy link
Contributor

@teclator teclator left a comment

Choose a reason for hiding this comment

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

LGTM

@jreidinger jreidinger merged commit 92600cd into master Jul 16, 2020
@jreidinger jreidinger deleted the remove_profile_current branch July 16, 2020 10:08
@yast-bot
Copy link
Contributor

✔️ Public Jenkins job #165 successfully finished
✔️ Created OBS submit request #821263

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants