Ejemplo n.º 1
0
def do_exec(cs, args):
    """Execute command in a running container."""
    opts = {}
    opts['command'] = zun_utils.parse_command(args.command)
    if args.interactive:
        opts['interactive'] = True
        opts['run'] = False
    response = cs.containers.execute(args.container, **opts)
    if args.interactive:
        exec_id = response['exec_id']
        url = response['proxy_url']
        websocketclient.do_exec(cs, url, args.container, exec_id, "~", 0.5)
    else:
        output = response['output']
        exit_code = response['exit_code']
        print(output)
        return exit_code
Ejemplo n.º 2
0
 def _process_command(self, kwargs):
     cmd_microversion = api_versions.APIVersion("1.20")
     if self.api_version < cmd_microversion:
         command = kwargs.pop('command', None)
         if command:
             kwargs['command'] = utils.parse_command(command)
Ejemplo n.º 3
0
 def test_no_command(self):
     command = []
     result = utils.parse_command(command)
     self.assertEqual('', result)
Ejemplo n.º 4
0
 def _process_command(self, kwargs):
     cmd_microversion = api_versions.APIVersion("1.20")
     if self.api_version < cmd_microversion:
         command = kwargs.pop('command', None)
         if command:
             kwargs['command'] = utils.parse_command(command)
Ejemplo n.º 5
0
 def test_command_echo_hello(self):
     command = ['sh', '-c', 'echo hello']
     result = utils.parse_command(command)
     self.assertEqual('"sh" "-c" "echo hello"', result)
Ejemplo n.º 6
0
 def test_command_ls(self):
     command = ['ls', '-al']
     result = utils.parse_command(command)
     self.assertEqual('"ls" "-al"', result)
Ejemplo n.º 7
0
 def test_command_echo_hello(self):
     command = ['sh', '-c', 'echo hello']
     result = utils.parse_command(command)
     self.assertEqual('"sh" "-c" "echo hello"', result)
Ejemplo n.º 8
0
 def test_command_ls(self):
     command = ['ls', '-al']
     result = utils.parse_command(command)
     self.assertEqual('"ls" "-al"', result)
Ejemplo n.º 9
0
 def test_no_command(self):
     command = []
     result = utils.parse_command(command)
     self.assertEqual('', result)