forked from qiniu/python-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsandbox_connect.py
More file actions
37 lines (31 loc) · 914 Bytes
/
Copy pathsandbox_connect.py
File metadata and controls
37 lines (31 loc) · 914 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# -*- coding: utf-8 -*-
from __future__ import print_function
from qiniu.services.sandbox import Sandbox
from sandbox_common import (
cleanup_sandbox,
create_sandbox,
run_example,
sandbox_client,
)
def main():
client = sandbox_client()
sandbox = create_sandbox(
client=client,
timeout=300,
metadata={'example': 'sandbox_connect'},
)
try:
items = Sandbox.list(client=client, limit=10).next_items()
print('list:', [item.sandbox_id for item in items])
connected = Sandbox.connect(
sandbox.sandbox_id,
client=client,
timeout=300,
)
print('connected:', connected.sandbox_id)
print('envd:', connected.envd_url())
print('uptime:', connected.commands.run('uptime').stdout)
finally:
cleanup_sandbox(sandbox)
if __name__ == '__main__':
run_example(main)