Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F12420513
zr.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
zr.py
View Options
# -*- coding: utf-8 -*-
# -------------------------------------------------------------
# Salt — Zemke-Rhyne module
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Project: Nasqueron
# Created: 2018-09-11
# Description: Fetch Zemke-Rhyne credentials
# License: BSD-2-Clause
# -------------------------------------------------------------
from
salt.utils.path
import
which
as
path_which
def
__virtual__
():
'''
Only load if zr exists on the system
'''
return
path_which
(
'zr'
)
is
not
None
,
'The Zemke-Rhyne execution module cannot be loaded: zr not installed.'
def
_assert_stricly_positive_integer
(
value
):
try
:
number
=
int
(
value
)
if
number
<
1
:
raise
ValueError
(
value
,
"A strictly positive integer was expected."
)
except
ValueError
:
raise
def
get_password
(
credential_id
):
"""
A function to fetch credential through Zemke-Rhyne
CLI Example:
salt equatower zr.get_password 124
:param credential_id: The credential number (K...) in Phabricator
:return: The secret value
"""
_assert_stricly_positive_integer
(
credential_id
)
zr_command
=
"zr getcredentials {0}"
.
format
(
credential_id
)
return
__salt__
[
'cmd.shell'
](
zr_command
)
def
get_username
(
credential_id
):
"""
A function to fetch the username associated to a credential
through Zemke-Rhyne
CLI Example:
salt equatower zr.get_username 124
:param credential_id: The credential number (K...) in Phabricator
:return: The username
"""
_assert_stricly_positive_integer
(
credential_id
)
zr_command
=
"zr getcredentials {0} username"
.
format
(
credential_id
)
return
__salt__
[
'cmd.shell'
](
zr_command
)
File Metadata
Details
Attached
Mime Type
text/x-python
Expires
Thu, Nov 6, 11:18 (1 d, 13 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3136702
Default Alt Text
zr.py (1 KB)
Attached To
Mode
rOPS Nasqueron Operations
Attached
Detach File
Event Timeline
Log In to Comment