Note: The default ITS GitLab runner is a shared resource and is subject to slowdowns during heavy usage.
You can run your own GitLab runner that is dedicated just to your group if you need to avoid processing delays.

Commit 968f6225 authored by Rob Carleski's avatar Rob Carleski 🇮🇸
Browse files

Add prompting optionto create_shared

parent 0291e395
......@@ -22,6 +22,15 @@ from time import sleep
devnull = open(os.devnull, 'w')
def arg_prompt(text, **kwargs):
while True:
r = input(text)
if r:
return r
elif 'default' in kwargs.keys():
return kwargs['default']
class SharedAccount:
def __init__(self, args, config):
......@@ -284,7 +293,8 @@ https://documentation.its.umich.edu/node/339/
self.mcomm_group.memberGroups.remove(self.control_group)
self.mcomm_group.update_membership()
except mcommunity.core.MCommError as e:
self.logger.warning(e, extra={'entity': self.account})
self.logger.error(e, extra={'entity': self.account})
exit(2)
try:
self.logger.info(
......@@ -301,7 +311,8 @@ https://documentation.its.umich.edu/node/339/
except AssertionError as e:
self.logger.warning(e, extra={'entity': self.account})
except mcommunity.core.MCommError as e:
self.logger.warning(e, extra={'entity': self.account})
self.logger.error(e, extra={'entity': self.account})
exit(2)
def take_group_ownership(self):
input('Add api controller as group owner, then press enter.')
......@@ -472,7 +483,6 @@ def main():
'--account',
'-a',
help='The account name to use.',
required=True
)
parser.add_argument(
'--password',
......@@ -484,7 +494,7 @@ def main():
'-o',
help='Uniqname(s) of shared account owner(s)',
nargs='+',
default={}
default=[]
)
parser.add_argument(
'--service',
......@@ -510,7 +520,8 @@ def main():
parser.add_argument(
'--secure',
help='Secure the account for sensitive data',
action='store_true'
action='store_true',
default=False
)
parser.add_argument(
'--config',
......@@ -520,6 +531,44 @@ def main():
)
args = parser.parse_args()
# Interactive mode
if not args.account:
args.account = arg_prompt(
'Please enter the account name: '
)
_owners = arg_prompt(
'(for new accounts) Please specify owners separated by spaces: ',
default=[]
)
if isinstance(_owners, str):
args.owners = _owners.split(' ')
elif isinstance(_owners, list):
args.owners = _owners
args.first_name = arg_prompt(
'(for new accounts) Please enter a first name to use: ',
default=''
)
args.last_name = arg_prompt(
'(for new accounts) Please enter a last name to use: ',
default=''
)
args.service = arg_prompt(
'Which service should accounts be created for? '
'(google/box/both) [both]: ',
default='both'
).lower()
print(args.service)
if args.service == 'box' or args.service == 'both':
_secure = arg_prompt(
'Apply security settings to Box account: [y/N] ',
default='n'
).lower()
args.secure = True if _secure == 'y' else False
args.password = arg_prompt(
'(for new accounts) Please enter a password to use: ',
default=None
)
# Open the CAK Config
with open(args.config) as stream:
config = yaml.load(stream, Loader=yaml.BaseLoader)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment