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

Implement persistent state #77

Merged
merged 8 commits into from
Aug 21, 2018
Merged

Conversation

tyll
Copy link
Member

@tyll tyll commented Jul 31, 2018

This is still WIP, it still needs docs and example updates. Just want to use the CI to test the code.

@coveralls
Copy link

coveralls commented Jul 31, 2018

Pull Request Test Coverage Report for Build 172

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 802 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+1.07%) to 38.698%

Files with Coverage Reduction New Missed Lines %
/home/travis/build/linux-system-roles/network/library/network_connections.py 802 19.04%
Totals Coverage Status
Change from base Build 151: 1.07%
Covered Lines: 779
Relevant Lines: 2013

💛 - Coveralls

@tyll tyll force-pushed the persistent_state branch 8 times, most recently from 6ab9ea2 to 1be058b Compare August 2, 2018 12:19
@tyll tyll force-pushed the persistent_state branch 2 times, most recently from 3e986b4 to 0b7c0c0 Compare August 13, 2018 17:27
@tyll
Copy link
Member Author

tyll commented Aug 13, 2018

@pcahyna I updated the README and tests, can you please review?

@tyll tyll requested review from pcahyna and thom311 August 13, 2018 17:28
README.md Outdated
It defines whether the profile is activated (`up`) or deactivated (`down`). If
it is unset, the profile's runtime state will not be changed.

The `interface_state` setting is either `present` (default) or `absent`. If the
Copy link
Member

Choose a reason for hiding this comment

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

ITYM persistent_state, not interface_state.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

README.md Outdated

The `interface_state` setting is either `present` (default) or `absent`. If the
connection profile contains a `type` setting, the profile will be created or
updated if the `interface_state` is `present`. If the profile is incomplete,
Copy link
Member

Choose a reason for hiding this comment

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

ditto. (also should probably read "if persistent_state is present" or "if the persistent_state setting is present".)

Copy link
Member Author

Choose a reason for hiding this comment

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

done

README.md Outdated
with the given configuration. It has implicitly `state` `present`, due to the
presence of `type`. On the other hand, the `present` state requires at least a `type`
variable.
with the given configuration. It has implicitly `persisntent_state` `present`.
Copy link
Member

Choose a reason for hiding this comment

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

tyop

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

README.md Outdated
Connection will complete in the background, for example after a DHCP lease was
received. `wait: <SECONDS>` is a timeout for how long we give the device to
activate. The default is `wait=-1` which uses a suitable timeout. Note that
this argument only makes sense for NetworkManager.
**TODO** `wait` different from zero is not yet implemented.
Copy link
Member

Choose a reason for hiding this comment

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

wait different from zero is not yet implemented. - but the default is -1, is this not implemented?

Copy link
Member Author

Choose a reason for hiding this comment

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

From what I understand, it does not seem to be possibly to specify wait:-1. Since there is no change for the behavior in the code and I just fixed the wording here we should probably investigate this later.

Copy link
Member Author

Choose a reason for hiding this comment

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

I filed #79 for this.

Copy link
Member

Choose a reason for hiding this comment

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

it does not seem to be possibly to specify wait:-1

Can we then write "The default is to use a suitable timeout." without referring to the special -1 value?

Copy link
Member Author

Choose a reason for hiding this comment

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

changed

README.md Outdated
@@ -358,7 +363,7 @@ Device types like `bridge`, `bond`, `team` work similar:
network_connections:
- name: "br0"
Copy link
Member

Choose a reason for hiding this comment

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

If quotes were removed around eth0 above, they should be here as well for consistency.

Copy link
Member Author

Choose a reason for hiding this comment

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

I removed the quotes from other appearances as well.

@@ -3,27 +3,32 @@
- hosts: all
name: Setup for test running
tasks:
# FIXME: change with_items to loop when test-harness is updated
- name: Install EPEL if necessary
Copy link
Member

Choose a reason for hiding this comment

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

I would say "if necessary to get python2-mock", because that's the intent, right?

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, changed

@@ -612,7 +611,8 @@ def _validate_post(self, value, name, result):

class ArgValidator_DictConnection(ArgValidatorDict):

VALID_STATES = ["up", "down", "present", "absent", "wait"]
VALID_STATES = ["up", "down"]
VALID_PERSISTENT_STATES = ["absent", "present"]
Copy link
Member

Choose a reason for hiding this comment

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

Is it correct that "wait" has disappeared?

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 was not documented before and it just resulted in time.sleep().

README.md Outdated
`persistent_state` `present` does not directly result in a change in the
network configuration. That is, the profile is only created or modified, not
activated.
The `persistent_state` setting `present` does not directly result in a change
Copy link
Member

Choose a reason for hiding this comment

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

I would write The persistent_state value of present

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed it to

The value `present` for the `persistent_state` setting

prefix = "#%s, state:%s" % (idx, c["state"])
if c["state"] != "wait":
prefix = prefix + (", '%s'" % (c["name"]))
prefix = "#%s, state:%s persistent_satte:%s" % (
Copy link
Member

Choose a reason for hiding this comment

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

tyop

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

README.md Outdated
@@ -88,7 +88,6 @@ incomplete (lacks the `type` setting) and `persistent_state` is `present`,
the behavior is undefined. The value `absent` makes the role ensure
that the profile is not present on the target host.


Copy link
Member

Choose a reason for hiding this comment

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

Sorry that was a mistake. The commit should be dropped.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, removed it

@tyll tyll force-pushed the persistent_state branch 4 times, most recently from 1af1b3b to 51abe68 Compare August 14, 2018 18:36
Splitting the role in smaller parts helps to keep the overview and to
develop separate tests.
This allows to up profiles that are only available on disk.
This keeps the output more readable.
- persistent_state represents whether a profile is stored on disk
- persistent_state defaults to 'present'
- When there is no type specified for the profile, it is enough for a
profile with the same name to be stored on the target's systems file
system. Otherwise the role will fail
- state now represents the runtime state and can be up, down or
unspecified
- translate the state definitions into actions that will be performed.
The actions correspond to the previous states.
- add the possibility to write unit tests to only verify parts of the
resulting connection dictionary to only check for the expected changes
instead of the full connection that can also contain unrelated defaults
@pcahyna pcahyna merged commit 712ff3f into linux-system-roles:master Aug 21, 2018
@tyll tyll deleted the persistent_state branch January 11, 2019 16:36
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

3 participants