Skip to content

Commit

Permalink
Use app_name instead of app
Browse files Browse the repository at this point in the history
  • Loading branch information
sonicaj committed Aug 11, 2024
1 parent 67c45b9 commit 522a319
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/middlewared/middlewared/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ def __init__(self, middleware, ws, input_queue, loop, username, as_root, options
super(ShellWorkerThread, self).__init__(daemon=True)

def get_command(self, username, as_root, options):
allowed_options = ('vm_id', 'app')
allowed_options = ('vm_id', 'app_name')
if all(options.get(k) for k in allowed_options):
raise CallError(f'Only one option is supported from {", ".join(allowed_options)}')

Expand All @@ -635,7 +635,7 @@ def get_command(self, username, as_root, options):
command = ['/usr/bin/sudo', '-H', '-u', username] + command

return command, not as_root
elif options.get('app'):
elif options.get('app_name'):
command = [
'/usr/bin/docker', 'exec', '-it', options['container_id'], options.get('command', '/bin/bash'),
]
Expand Down Expand Up @@ -825,10 +825,12 @@ async def run(self, ws, request, conndata):
options = data.get('options', {})
if options.get('vm_id'):
options['vm_data'] = await self.middleware.call('vm.get_instance', options['vm_id'])
if options.get('app'):
if options.get('app_name'):
if not options.get('container_id'):
raise CallError('Container id must be specified')
if options['container_id'] not in await self.middleware.call('app.container_ids', options['app']):
if options['container_id'] not in await self.middleware.call(
'app.container_ids', options['app_name']
):
raise CallError('Provided container id is not valid')

# By default we want to run virsh with user's privileges and assume all "permission denied"
Expand Down

0 comments on commit 522a319

Please sign in to comment.