-
Notifications
You must be signed in to change notification settings - Fork 104
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
Conversation
Pull Request Test Coverage Report for Build 172
💛 - Coveralls |
6ab9ea2
to
1be058b
Compare
3e986b4
to
0b7c0c0
Compare
@pcahyna I updated the README and tests, can you please review? |
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 |
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.
ITYM persistent_state
, not interface_state
.
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.
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, |
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.
ditto. (also should probably read "if persistent_state
is present
" or "if the persistent_state
setting is present
".)
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.
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`. |
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.
tyop
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.
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. |
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.
wait
different from zero is not yet implemented. - but the default is -1, is this not implemented?
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.
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.
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 filed #79 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 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?
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.
changed
README.md
Outdated
@@ -358,7 +363,7 @@ Device types like `bridge`, `bond`, `team` work similar: | |||
network_connections: | |||
- name: "br0" |
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 quotes were removed around eth0 above, they should be here as well for consistency.
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 removed the quotes from other appearances as well.
tests/tests_unit.yml
Outdated
@@ -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 |
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 would say "if necessary to get python2-mock", because that's the intent, right?
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, 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"] |
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.
Is it correct that "wait" has disappeared?
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 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 |
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 would write The persistent_state
value of present
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.
Changed it to
The value `present` for the `persistent_state` setting
library/network_connections.py
Outdated
prefix = "#%s, state:%s" % (idx, c["state"]) | ||
if c["state"] != "wait": | ||
prefix = prefix + (", '%s'" % (c["name"])) | ||
prefix = "#%s, state:%s persistent_satte:%s" % ( |
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.
tyop
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.
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. | |||
|
|||
|
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.
Sorry that was a mistake. The commit should be dropped.
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, removed it
1af1b3b
to
51abe68
Compare
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
This is still WIP, it still needs docs and example updates. Just want to use the CI to test the code.