13
13
14
14
Minimum python version 3.7, asyncio.run
15
15
16
- Script to create a session for a named bastion services , and
16
+ Script to create a session for a named bastion service , and
17
17
generates the ssh command for connection to the session
18
18
19
19
The Session have two formats:
33
33
34
34
35
35
If File location is missing, the default config will be used.
36
- If profile_name is missing DEFAULt fill be used
36
+ If profile_name is missing DEFAULT fill be used
37
37
If the OCIconfigname parameter is missing in the session section,
38
38
DEFAULT from DEFAULT location will be used.
39
39
76
76
# GenericError
77
77
#
78
78
# Extension of Exception class, thrown when any Exception is raised
79
- # and caught or any API error/Exception occurs
79
+ # and caught, or any API error/Exception occurs
80
80
#
81
81
class GenericError (Exception ):
82
82
"""
@@ -116,14 +116,14 @@ def __init__(self, message="Value missing in configuration"):
116
116
# get_validated_config_entry
117
117
#
118
118
# Iterate over JSON array (list) and return first JSON object (dict)
119
- # where JSON element with name search_key_name matches search_key_value
119
+ # where JSON element with name search_key_name match search_key_value
120
120
#
121
121
# If a matching dict is found, iterate over it and verify existence of
122
122
# all mandator values
123
- # Finally iterate over it and add any missing non mandatory values
123
+ # Finally iterate over it and add any missing non- mandatory values
124
124
#
125
125
# Returns a complete dict with valid entry with all default values for
126
- # non mandatory values
126
+ # non- mandatory values
127
127
#
128
128
# Raises MissingConfigError if no entry with search_key_value is found,
129
129
# or mandatory field is missing
@@ -197,7 +197,7 @@ def get_validated_config_entry(
197
197
+ " confguration"
198
198
)
199
199
#
200
- # Iterate and populate all non mandatory values with defaults
200
+ # Iterate and populate all non- mandatory values with defaults
201
201
if non_manadatory_key_values is not None :
202
202
for key in non_manadatory_key_values :
203
203
if key not in config_entry :
@@ -226,7 +226,7 @@ def get_validated_config_entry(
226
226
# False if an error occurs
227
227
# Exception:
228
228
# GenericError, if sessionType is not legal or if bastion
229
- # public key can't be retreived
229
+ # public key can't be retrieved
230
230
#
231
231
def valdate_config (config , config_type , int_list ):
232
232
"""Function sanity checks and validates some key config entries, converts
@@ -302,7 +302,7 @@ def valdate_config(config, config_type, int_list):
302
302
#
303
303
# creates a bastion session with the SDK (API)
304
304
# Bastion session will normally take some time. If initial call is
305
- # successful the bastion state is "CREATING"
305
+ # successful, the bastion state is "CREATING"
306
306
# and when the creation is complete and successful,
307
307
# it changes state to "ACTIVE"
308
308
# The code loops and sleeps until max iterations is reached or
@@ -361,7 +361,7 @@ def create_single_session(session_config, bastion_client):
361
361
#
362
362
# Loop until max time and wait for session to be migrated
363
363
# from CREATING to ACTIVE
364
- # The loops iterates maxWaitCount times and sleep waitRefresh
364
+ # The loops iterate maxWaitCount times and sleep waitRefresh
365
365
# seconds between each iteration
366
366
#
367
367
active_session = False
@@ -436,7 +436,7 @@ def get_command(bastion_session, session_config):
436
436
print ("Port managed start cmd" )
437
437
#
438
438
# The bastion service might add a note to the end of the command.
439
- # Supress the note
439
+ # Suppress the note
440
440
#
441
441
if session_cmd .find (" # " ) > - 1 :
442
442
session_cmd = session_cmd .split (" # " )[0 ]
@@ -453,7 +453,7 @@ def get_command(bastion_session, session_config):
453
453
tunnel_cmd = tunnel_cmd .replace ("<localPort>" ,
454
454
str (session_config [const .LOCALPORT ]))
455
455
#
456
- # Setup the correct client comamnd for ssh or putty
456
+ # Setup the correct client command for ssh or putty
457
457
if session_config [const .SSHCOMMAND ] == const .SSH :
458
458
client_cmd = (
459
459
"ssh -i "
@@ -482,7 +482,7 @@ def get_command(bastion_session, session_config):
482
482
)
483
483
cmd [const .CLIENTSIDE ] = client_cmd
484
484
#
485
- # Build serverside command
485
+ # Build server-side command
486
486
#
487
487
if session_config [const .SSHCOMMAND ] == const .SSH :
488
488
cmd [const .SERVERSIDE ] = tunnel_cmd
@@ -492,7 +492,7 @@ def get_command(bastion_session, session_config):
492
492
return cmd
493
493
else :
494
494
#
495
- # Adjust serverside cmd for putty.exe
495
+ # Adjust server-side command for putty.exe
496
496
#
497
497
cmd [const .SERVERSIDE ] = (
498
498
(tunnel_cmd .replace ("ssh" , "putty" , 1 ))
@@ -657,7 +657,7 @@ def process_bastion_config(config, session_name):
657
657
const .OCIREGION ,
658
658
]
659
659
660
- # dict of non mandatory keys,in the sessions object from JSON,
660
+ # dict of non- mandatory keys, in the sessions object from JSON,
661
661
# with default values
662
662
non_mandatory_session_keys = {
663
663
const .BASTIONPRIVATEKEYFILE : "<bastion private key file>" ,
@@ -709,7 +709,7 @@ def process_bastion_config(config, session_name):
709
709
raise MissingConfigError ("Ociconfigurations key is missing in configuration" )
710
710
#
711
711
# Verify configurations, verify all mandatory elements and add defaults
712
- # for non mandatory elements
712
+ # for non- mandatory elements
713
713
#
714
714
# Verify Session
715
715
#
@@ -883,9 +883,9 @@ def wait_for_session_deletion(session_id,
883
883
#
884
884
# create_sessions
885
885
#
886
- # Creates one or more consecuive bastion sessions
886
+ # Creates one or more consecutive bastion sessions
887
887
# Create Bastion Session
888
- # if exec_ssh is true, A new session is created when the past expires
888
+ # if exec_ssh is true, a new session is created when the past expires
889
889
# Iterate until maxSessions is reached or session creation fail
890
890
#
891
891
# Input Parameters:
@@ -1010,7 +1010,7 @@ def create_sessions(config, exec_ssh):
1010
1010
# parse error. Underlying exceptions are passed on to caller
1011
1011
#
1012
1012
def main ():
1013
- """Main entry point, orkestrates all functions"""
1013
+ """Main entry point, orchestrates all functions"""
1014
1014
print ("Bastion session manager " + __version__ + "\n " )
1015
1015
#
1016
1016
# Get bastion config
0 commit comments