Page Menu
Home
ClusterLabs Projects
Search
Configure Global Search
Log In
Files
F4623625
utils.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
504 B
Referenced Files
None
Subscribers
None
utils.py
View Options
#!/usr/bin/python
import
subprocess
import
re
def
run_cmd
(
cmd
):
p
=
subprocess
.
Popen
(
cmd
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
(
stdout
,
stderr
)
=
p
.
communicate
()
return
(
stdout
,
stderr
,
p
.
returncode
)
def
get_IP
():
(
stdout
,
stderr
,
returncode
)
=
run_cmd
([
'hostname'
,
'-i'
])
if
returncode
!=
0
:
raise
RuntimeError
,
"Failed to run hostname -i:
\n
"
+
stderr
# in case multiple IP addresses are returned, use only the first.
return
re
.
sub
(
r'\s.*'
,
''
,
stdout
)
File Metadata
Details
Attached
Mime Type
text/x-script.python
Expires
Tue, Jul 8, 4:35 PM (1 d, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1995534
Default Alt Text
utils.py (504 B)
Attached To
Mode
rB Booth
Attached
Detach File
Event Timeline
Log In to Comment