Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
allclients
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Anders Blomdell
allclients
Commits
f4c24e96
Commit
f4c24e96
authored
3 years ago
by
Anders Blomdell
Browse files
Options
Downloads
Patches
Plain Diff
Add possibilty to specify machines
parent
3c390154
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/allclients.py
+25
-13
25 additions, 13 deletions
src/allclients.py
with
25 additions
and
13 deletions
src/allclients.py
+
25
−
13
View file @
f4c24e96
...
...
@@ -38,7 +38,11 @@ if __name__ == '__main__':
optParser
.
add_option
(
"
-g
"
,
"
--group
"
,
action
=
"
append
"
,
default
=
[],
metavar
=
"
GROUP
"
,
help
=
"
apply actions only to GROUP
"
)
help
=
"
apply actions to GROUP
"
)
optParser
.
add_option
(
"
-m
"
,
"
--machine
"
,
action
=
"
append
"
,
default
=
[],
metavar
=
"
MACHINE
"
,
help
=
"
apply actions to MACHINE
"
)
optParser
.
add_option
(
"
-o
"
,
"
--ordered
"
,
action
=
"
store_true
"
,
default
=
False
,
help
=
"
order result by hostname
"
)
...
...
@@ -65,7 +69,7 @@ if __name__ == '__main__':
if
options
.
ipv4
and
options
.
ipv6
:
raise
Exception
(
'
Only one --ipv4 or --ipv6 may be specified
'
)
if
not
options
.
group
:
if
not
options
.
group
and
not
options
.
machine
:
options
.
group
=
[
'
__all__
'
]
pass
exclude
=
set
()
...
...
@@ -73,21 +77,29 @@ if __name__ == '__main__':
exclude
.
update
(
local_interfaces
())
pass
hosts
=
set
()
for
n
in
map
(
netgroup
.
getgroup
,
options
.
group
):
for
h
,
_
,
_
in
n
:
def
add_host
(
name
):
try
:
for
_
,
_
,
_
,
_
,
a
in
socket
.
getaddrinfo
(
h
,
0
,
for
_
,
_
,
_
,
_
,
a
in
socket
.
getaddrinfo
(
name
,
0
,
socket
.
AF_UNSPEC
,
socket
.
SOCK_STREAM
):
if
not
a
[
0
]
in
exclude
:
hosts
.
add
(
h
)
hosts
.
add
(
name
)
pass
pass
pass
except
socket
.
gaierror
:
# Silently skip non-existing machines
if
not
options
.
quiet
:
print
(
'
%s has no address
'
%
name
)
pass
pass
return
for
n
in
map
(
netgroup
.
getgroup
,
options
.
group
):
for
h
,
_
,
_
in
n
:
add_host
(
h
)
pass
pass
for
h
in
options
.
machine
:
add_host
(
h
)
pass
if
hosts
:
def
status
(
msg
,
done
,
failed
,
total
):
...
...
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