Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
serverdensity
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ansible
Plugins
serverdensity
Commits
d413d220
Commit
d413d220
authored
10 years ago
by
jurgenhaas
Browse files
Options
Downloads
Patches
Plain Diff
Improve the update process of existing hosts
parent
cc606023
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
action_plugins/serverdensity.py
+14
-3
14 additions, 3 deletions
action_plugins/serverdensity.py
with
14 additions
and
3 deletions
action_plugins/serverdensity.py
+
14
−
3
View file @
d413d220
...
...
@@ -208,6 +208,12 @@ class ActionModule(object):
raise
ae
(
'
%s
'
%
msg
)
return
content
def
_get_device
(
self
,
hostname
):
for
host
in
self
.
devices
:
if
host
.
get
(
'
hostname
'
)
==
hostname
:
return
host
return
False
def
_get_device_id
(
self
,
hostname
):
for
host
in
self
.
devices
:
if
host
.
get
(
'
hostname
'
)
==
hostname
:
...
...
@@ -362,6 +368,7 @@ class ActionModule(object):
'
swapSpace
'
:
swapSpace
,
'
location
'
:
location
,
'
provider
'
:
provider
,
'
agentKey
'
:
None
,
}
deviceId
=
self
.
_get_device_id
(
hostname
)
if
not
deviceId
:
...
...
@@ -371,13 +378,17 @@ class ActionModule(object):
if
not
self
.
force_update
:
return
path
=
'
inventory/devices/
'
+
deviceId
device
=
self
.
_get_device
(
hostname
)
for
key
in
data
:
value
=
data
.
get
(
key
)
or
device
.
get
(
key
)
data
.
__setitem__
(
key
,
value
)
device
=
self
.
_request
(
path
,
data
)
if
deviceId
:
for
old_device
in
self
.
device
s
:
if
old_device
.
get
(
'
hostname
'
)
==
hostname
:
self
.
devices
.
remove
(
old_device
)
old_device
=
self
.
_get_
device
(
hostname
)
if
old_device
:
self
.
devices
.
remove
(
old_device
)
self
.
devices
.
append
(
device
)
self
.
cache_update
(
False
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment