Assorted renaming and string changes

This commit is contained in:
Bill Nottingham
2021-04-30 14:14:38 -04:00
parent e0d6b138b0
commit c8cf28f266
97 changed files with 730 additions and 707 deletions

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash
# Enable Tower virtualenv
# Enable AWX virtualenv
for venv_path in /var/lib/awx/venv/awx; do
if [ -f $venv_path/bin/activate ]; then
. $venv_path/bin/activate

View File

@@ -14,12 +14,12 @@ for c in ';/?:@=&[]':
def _get_named_url_graph(url, auth):
"""Get the graph data structure Tower used to manage all named URLs.
"""Get the graph data structure AWX used to manage all named URLs.
Args:
url: String representing the URL of tower configuration endpoint where
to fetch graph information.
auth: Tuple of username + password to authenticate connection to Tower.
auth: Tuple of username + password to authenticate connection to AWX.
Return:
A dict of graph nodes that in ensembly represent the graph structure. Each
@@ -48,8 +48,7 @@ def _encode_uri(text):
for c in URL_PATH_RESERVED_CHARSET:
if c in text:
text = text.replace(c, URL_PATH_RESERVED_CHARSET[c])
text = text.replace(NAMED_URL_RES_INNER_DILIMITER,
'[%s]' % NAMED_URL_RES_INNER_DILIMITER)
text = text.replace(NAMED_URL_RES_INNER_DILIMITER, '[%s]' % NAMED_URL_RES_INNER_DILIMITER)
return text
@@ -81,8 +80,8 @@ def _get_named_url_identifier(url, named_url_graph, resource, tower_host, auth,
component from.
named_url_graph: The graph structure used to DFS against.
resource: Key name of the current graph node.
tower_host: String representing the host name of Tower backend.
auth: Tuple of username + password to authenticate connection to Tower.
tower_host: String representing the host name of AWX backend.
auth: Tuple of username + password to authenticate connection to AWX.
ret: list of strings storing components that would later be joined into
the final named URL identifier.
@@ -97,8 +96,7 @@ def _get_named_url_identifier(url, named_url_graph, resource, tower_host, auth,
for next_ in named_url_graph[resource]['adj_list']:
next_fk, next_res = tuple(next_)
if next_fk in r['related']:
_get_named_url_identifier(tower_host.strip('/') + r['related'][next_fk],
named_url_graph, next_res, tower_host, auth, ret)
_get_named_url_identifier(tower_host.strip('/') + r['related'][next_fk], named_url_graph, next_res, tower_host, auth, ret)
else:
ret.append('')
@@ -107,9 +105,9 @@ def main(username=None, password=None, tower_host=None, resource=None, pk=None):
"""Main function for generating and printing named URL of a resource object given its pk.
Args:
username: String representing the username needed to authenticating Tower.
password: String representing the password needed to authenticating Tower.
tower_host: String representing the host name of Tower backend.
username: String representing the username needed to authenticating AWX.
password: String representing the password needed to authenticating AWX.
tower_host: String representing the host name of AWX backend.
resource: REST API name of a specific resource, e.g. name for resource inventory
is 'inventories'.
pk: Primary key of the resource object whose named URL will be derived.
@@ -125,27 +123,15 @@ def main(username=None, password=None, tower_host=None, resource=None, pk=None):
auth = (username, password)
named_url_graph = _get_named_url_graph(conf_url, auth)
named_url_identifier = []
_get_named_url_identifier(start_url, named_url_graph, resource,
tower_host, auth, named_url_identifier)
print('%s/api/v2/%s/%s/' % (tower_host.strip('/'), resource.strip('/'),
NAMED_URL_RES_DILIMITER.join(named_url_identifier)))
_get_named_url_identifier(start_url, named_url_graph, resource, tower_host, auth, named_url_identifier)
print('%s/api/v2/%s/%s/' % (tower_host.strip('/'), resource.strip('/'), NAMED_URL_RES_DILIMITER.join(named_url_identifier)))
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--username', type=str, required=True,
help='Name of the Tower user for making requests',
dest='username', metavar='STR')
parser.add_argument('--password', type=str, required=True,
help='Password of the Tower user for making requests',
dest='password', metavar='STR')
parser.add_argument('--tower-host', type=str, required=True,
help='Tower host name, like "http://127.0.0.1"',
dest='tower_host', metavar='STR')
parser.add_argument('--resource', type=str, required=True,
help='Name of the resource in REST endpoints',
dest='resource', metavar='STR')
parser.add_argument('--pk', type=int, required=True,
help='Primary key of resource object whose named URL will be derived',
dest='pk', metavar='INT')
parser.add_argument('--username', type=str, required=True, help='Name of the user for making requests', dest='username', metavar='STR')
parser.add_argument('--password', type=str, required=True, help='Password of the user for making requests', dest='password', metavar='STR')
parser.add_argument('--tower-host', type=str, required=True, help='API host name, like "http://127.0.0.1"', dest='tower_host', metavar='STR')
parser.add_argument('--resource', type=str, required=True, help='Name of the resource in REST endpoints', dest='resource', metavar='STR')
parser.add_argument('--pk', type=int, required=True, help='Primary key of resource object whose named URL will be derived', dest='pk', metavar='INT')
main(**vars(parser.parse_args()))