kalavai-client 0.5.0__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- kalavai_client/__init__.py +2 -0
- kalavai_client/__main__.py +5 -0
- kalavai_client/assets/apps.yaml +201 -0
- kalavai_client/assets/apps_values.yaml +83 -0
- kalavai_client/assets/docker-compose-template.yaml +55 -0
- kalavai_client/assets/pool_config_template.yaml +19 -0
- kalavai_client/assets/pool_config_values.yaml +12 -0
- kalavai_client/assets/user_workspace.yaml +19 -0
- kalavai_client/assets/user_workspace_values.yaml +29 -0
- kalavai_client/assets/vpn-template.yaml +13 -0
- kalavai_client/auth.py +68 -0
- kalavai_client/cli.py +1989 -0
- kalavai_client/cluster.py +308 -0
- kalavai_client/utils.py +456 -0
- kalavai_client-0.5.0.dist-info/LICENSE +201 -0
- kalavai_client-0.5.0.dist-info/METADATA +279 -0
- kalavai_client-0.5.0.dist-info/RECORD +19 -0
- kalavai_client-0.5.0.dist-info/WHEEL +4 -0
- kalavai_client-0.5.0.dist-info/entry_points.txt +3 -0
kalavai_client/utils.py
ADDED
@@ -0,0 +1,456 @@
|
|
1
|
+
import json, base64
|
2
|
+
import os
|
3
|
+
import requests
|
4
|
+
from pathlib import Path
|
5
|
+
from urllib.parse import urljoin
|
6
|
+
import shutil
|
7
|
+
import subprocess
|
8
|
+
import re
|
9
|
+
|
10
|
+
import importlib
|
11
|
+
from jinja2 import Template
|
12
|
+
|
13
|
+
from rich.table import Table
|
14
|
+
import yaml
|
15
|
+
import platform
|
16
|
+
import psutil
|
17
|
+
|
18
|
+
import GPUtil
|
19
|
+
|
20
|
+
from kalavai_client.auth import KalavaiAuthClient
|
21
|
+
|
22
|
+
|
23
|
+
GITHUB_ORG = "kalavai-net"
|
24
|
+
GITHUB_REPO = "kalavai-client"
|
25
|
+
GITHUB_TEMPLATE_PATH = "templates"
|
26
|
+
USER_NODE_LABEL_KEY = "user_node_label"
|
27
|
+
CLUSTER_IP_KEY = "cluster_ip"
|
28
|
+
CLUSTER_TOKEN_KEY = "cluster_token"
|
29
|
+
SERVER_IP_KEY = "server_ip"
|
30
|
+
NODE_NAME_KEY = "node_name"
|
31
|
+
PUBLIC_LOCATION_KEY = "public_location"
|
32
|
+
CLUSTER_NAME_KEY = "cluster_name"
|
33
|
+
AUTH_KEY = "watcher_admin_key"
|
34
|
+
WRITE_AUTH_KEY = "watcher_write_key"
|
35
|
+
ALLOW_UNREGISTERED_USER_KEY = "watcher_allow_unregistered_user"
|
36
|
+
USER_API_KEY = "user_api_key"
|
37
|
+
READONLY_AUTH_KEY = "watcher_readonly_key"
|
38
|
+
WATCHER_SERVICE_KEY = "watcher_service"
|
39
|
+
WATCHER_PORT_KEY = "watcher_port"
|
40
|
+
ENDPOINT_PORTS_KEY = "endpoint_ports"
|
41
|
+
TEMPLATE_ID_FIELD = "id_field"
|
42
|
+
TEMPLATE_ID_KEY = "deployment_id"
|
43
|
+
MANDATORY_TOKEN_FIELDS = [
|
44
|
+
CLUSTER_IP_KEY,
|
45
|
+
CLUSTER_TOKEN_KEY,
|
46
|
+
CLUSTER_NAME_KEY,
|
47
|
+
AUTH_KEY,
|
48
|
+
WATCHER_SERVICE_KEY,
|
49
|
+
PUBLIC_LOCATION_KEY
|
50
|
+
]
|
51
|
+
MANDATORY_POOLCONFIG_FIELDS = [
|
52
|
+
SERVER_IP_KEY,
|
53
|
+
AUTH_KEY,
|
54
|
+
WATCHER_SERVICE_KEY,
|
55
|
+
NODE_NAME_KEY,
|
56
|
+
CLUSTER_NAME_KEY,
|
57
|
+
PUBLIC_LOCATION_KEY
|
58
|
+
]
|
59
|
+
|
60
|
+
|
61
|
+
####### Methods to check OS compatibility ########
|
62
|
+
def check_gpu_drivers():
|
63
|
+
value = run_cmd("command -v nvidia-smi")
|
64
|
+
if len(value.decode("utf-8")) == 0:
|
65
|
+
# no nvidia installed, no need to check nvidia any further
|
66
|
+
return False
|
67
|
+
else:
|
68
|
+
# check drivers are set correctly
|
69
|
+
try:
|
70
|
+
value = run_cmd("nvidia-smi")
|
71
|
+
return True
|
72
|
+
except:
|
73
|
+
raise ("Nvidia not configured properly. Please check your drivers are installed and configured")
|
74
|
+
|
75
|
+
def is_storage_compatible():
|
76
|
+
"""
|
77
|
+
Raw method to determine if running node is compatible with PVC (longhorn)
|
78
|
+
|
79
|
+
Exclude: WSL
|
80
|
+
"""
|
81
|
+
try:
|
82
|
+
flagged = any([
|
83
|
+
"microsoft" in run_cmd("cat /proc/version").decode().lower()
|
84
|
+
])
|
85
|
+
return not flagged
|
86
|
+
except:
|
87
|
+
return False
|
88
|
+
################
|
89
|
+
|
90
|
+
def is_watcher_alive(server_creds, user_cookie):
|
91
|
+
try:
|
92
|
+
request_to_server(
|
93
|
+
method="get",
|
94
|
+
endpoint="/v1/health",
|
95
|
+
data=None,
|
96
|
+
server_creds=server_creds,
|
97
|
+
user_cookie=user_cookie
|
98
|
+
)
|
99
|
+
except Exception as e:
|
100
|
+
print(str(e))
|
101
|
+
return False
|
102
|
+
return True
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
def load_server_info(data_key, file):
|
107
|
+
try:
|
108
|
+
with open(file, "r") as f:
|
109
|
+
return json.load(f)[data_key]
|
110
|
+
except:
|
111
|
+
return None
|
112
|
+
|
113
|
+
def user_login(user_cookie, username=None, password=None):
|
114
|
+
auth = KalavaiAuthClient(
|
115
|
+
user_cookie_file=user_cookie
|
116
|
+
)
|
117
|
+
user = auth.load_user_session()
|
118
|
+
if user is None:
|
119
|
+
user = auth.login(username=username, password=password)
|
120
|
+
return user
|
121
|
+
|
122
|
+
def user_logout(user_cookie):
|
123
|
+
auth = KalavaiAuthClient(
|
124
|
+
user_cookie_file=user_cookie
|
125
|
+
)
|
126
|
+
auth.logout()
|
127
|
+
|
128
|
+
def load_user_session(user_cookie):
|
129
|
+
auth = KalavaiAuthClient(
|
130
|
+
user_cookie_file=user_cookie
|
131
|
+
)
|
132
|
+
if not auth.is_logged_in():
|
133
|
+
return None
|
134
|
+
return auth.load_user_session()
|
135
|
+
|
136
|
+
def get_public_vpns(user_cookie):
|
137
|
+
auth = KalavaiAuthClient(
|
138
|
+
user_cookie_file=user_cookie
|
139
|
+
)
|
140
|
+
if not auth.is_logged_in():
|
141
|
+
raise ValueError("Cannot access vpns, user is not authenticated")
|
142
|
+
seeds = auth.call_function(
|
143
|
+
"get_public_vpns"
|
144
|
+
)
|
145
|
+
return seeds
|
146
|
+
|
147
|
+
def get_public_seeds(user_only, user_cookie):
|
148
|
+
auth = KalavaiAuthClient(
|
149
|
+
user_cookie_file=user_cookie
|
150
|
+
)
|
151
|
+
if not auth.is_logged_in():
|
152
|
+
raise ValueError("Cannot access vpns, user is not authenticated")
|
153
|
+
user = auth.load_user_session() if user_only else None
|
154
|
+
seeds = auth.call_function(
|
155
|
+
"get_available_seeds",
|
156
|
+
user
|
157
|
+
)
|
158
|
+
return seeds
|
159
|
+
|
160
|
+
def get_vpn_details(location, user_cookie):
|
161
|
+
auth = KalavaiAuthClient(
|
162
|
+
user_cookie_file=user_cookie
|
163
|
+
)
|
164
|
+
if not auth.is_logged_in():
|
165
|
+
raise ValueError("Cannot access vpns, user is not authenticated")
|
166
|
+
vpn = auth.call_function(
|
167
|
+
"get_vpn_details",
|
168
|
+
location
|
169
|
+
)
|
170
|
+
return vpn
|
171
|
+
|
172
|
+
def register_cluster(name, token, description, user_cookie):
|
173
|
+
auth = KalavaiAuthClient(
|
174
|
+
user_cookie_file=user_cookie
|
175
|
+
)
|
176
|
+
if not auth.is_logged_in():
|
177
|
+
raise ValueError("Cannot register cluster, user is not authenticated")
|
178
|
+
user = auth.load_user_session()
|
179
|
+
seed = auth.call_function(
|
180
|
+
"register_seed",
|
181
|
+
name,
|
182
|
+
user,
|
183
|
+
description,
|
184
|
+
token
|
185
|
+
)
|
186
|
+
return seed
|
187
|
+
|
188
|
+
def unregister_cluster(name, user_cookie):
|
189
|
+
auth = KalavaiAuthClient(
|
190
|
+
user_cookie_file=user_cookie
|
191
|
+
)
|
192
|
+
if not auth.is_logged_in():
|
193
|
+
raise ValueError("Cannot unregister cluster, user is not authenticated")
|
194
|
+
user = auth.load_user_session()
|
195
|
+
seed = auth.call_function(
|
196
|
+
"unregister_seed",
|
197
|
+
name,
|
198
|
+
user,
|
199
|
+
)
|
200
|
+
return seed
|
201
|
+
|
202
|
+
def validate_join_public_seed(cluster_name, join_key, user_cookie):
|
203
|
+
auth = KalavaiAuthClient(
|
204
|
+
user_cookie_file=user_cookie
|
205
|
+
)
|
206
|
+
if not auth.is_logged_in():
|
207
|
+
raise ValueError("Cannot notify join cluster, user is not authenticated")
|
208
|
+
user = auth.load_user_session()
|
209
|
+
seed = auth.call_function(
|
210
|
+
"validate_join_public_seed",
|
211
|
+
cluster_name,
|
212
|
+
join_key,
|
213
|
+
user,
|
214
|
+
)
|
215
|
+
return seed
|
216
|
+
|
217
|
+
def validate_poolconfig(poolconfig_file):
|
218
|
+
if not Path(poolconfig_file).is_file():
|
219
|
+
return False
|
220
|
+
with open(poolconfig_file, "r") as f:
|
221
|
+
data = json.load(f)
|
222
|
+
for field in MANDATORY_POOLCONFIG_FIELDS:
|
223
|
+
if field not in data:
|
224
|
+
return False
|
225
|
+
return True
|
226
|
+
|
227
|
+
def run_cmd(command):
|
228
|
+
try:
|
229
|
+
return_value = subprocess.check_output(command, shell=True, executable="/bin/bash")
|
230
|
+
return return_value
|
231
|
+
except OSError as error:
|
232
|
+
return error # for exit code
|
233
|
+
|
234
|
+
def join_vpn(location, user_cookie):
|
235
|
+
vpn = get_vpn_details(location=location, user_cookie=user_cookie)
|
236
|
+
token = vpn["key"]
|
237
|
+
if token is None:
|
238
|
+
raise ValueError(f"VPN location {location} not found or is private")
|
239
|
+
try:
|
240
|
+
data = decode_dict(token)
|
241
|
+
for field in ["server", "value"]:
|
242
|
+
assert field in data
|
243
|
+
except:
|
244
|
+
raise ValueError("Invalid net token")
|
245
|
+
run_cmd(f"sudo netclient join -t {token} >/dev/null 2>&1")
|
246
|
+
return vpn
|
247
|
+
|
248
|
+
def leave_vpn():
|
249
|
+
try:
|
250
|
+
vpns = json.loads(run_cmd("sudo netclient list").decode())
|
251
|
+
left_vpns = [vpn['network'] for vpn in vpns]
|
252
|
+
for vpn in left_vpns:
|
253
|
+
run_cmd(f"sudo netclient leave {vpn}")
|
254
|
+
return left_vpns
|
255
|
+
except:
|
256
|
+
return None
|
257
|
+
|
258
|
+
def request_to_server(
|
259
|
+
method,
|
260
|
+
endpoint,
|
261
|
+
data,
|
262
|
+
server_creds,
|
263
|
+
force_url=None,
|
264
|
+
force_key=None,
|
265
|
+
user_cookie=None
|
266
|
+
):
|
267
|
+
if force_url is None:
|
268
|
+
service_url = load_server_info(data_key=WATCHER_SERVICE_KEY, file=server_creds)
|
269
|
+
else:
|
270
|
+
service_url = force_url
|
271
|
+
|
272
|
+
if force_key is None:
|
273
|
+
auth_key = load_server_info(data_key=AUTH_KEY, file=server_creds)
|
274
|
+
else:
|
275
|
+
auth_key = force_key
|
276
|
+
|
277
|
+
headers = {
|
278
|
+
"X-API-KEY": auth_key
|
279
|
+
}
|
280
|
+
|
281
|
+
user = load_user_session(user_cookie=user_cookie)
|
282
|
+
headers["USER-KEY"] = load_server_info(data_key=USER_API_KEY, file=server_creds)
|
283
|
+
headers["USER"] = user["username"] if user is not None else None
|
284
|
+
|
285
|
+
response = requests.request(
|
286
|
+
method=method,
|
287
|
+
url=f"http://{service_url}{endpoint}",
|
288
|
+
json=data,
|
289
|
+
headers=headers
|
290
|
+
)
|
291
|
+
result = response.json()
|
292
|
+
return result
|
293
|
+
|
294
|
+
|
295
|
+
def generate_table(columns, rows, end_sections=None):
|
296
|
+
|
297
|
+
table = Table(show_header=True, header_style="bold white")
|
298
|
+
[table.add_column(col, overflow="fold") for col in columns]
|
299
|
+
for idx, row in enumerate(rows):
|
300
|
+
table.add_row(*row, end_section=end_sections and idx in end_sections)
|
301
|
+
|
302
|
+
return table
|
303
|
+
|
304
|
+
def store_server_info(server_ip, auth_key, watcher_service, file, node_name, cluster_name, readonly_auth_key=None, write_auth_key=None, public_location=None, user_api_key=None):
|
305
|
+
with open(file, "w") as f:
|
306
|
+
json.dump({
|
307
|
+
SERVER_IP_KEY: server_ip,
|
308
|
+
AUTH_KEY: auth_key,
|
309
|
+
READONLY_AUTH_KEY: readonly_auth_key,
|
310
|
+
WRITE_AUTH_KEY: write_auth_key,
|
311
|
+
WATCHER_SERVICE_KEY: watcher_service,
|
312
|
+
NODE_NAME_KEY: node_name,
|
313
|
+
CLUSTER_NAME_KEY: cluster_name,
|
314
|
+
PUBLIC_LOCATION_KEY: public_location,
|
315
|
+
USER_API_KEY: user_api_key
|
316
|
+
}, f)
|
317
|
+
return True
|
318
|
+
|
319
|
+
def populate_template(template_str, values_dict):
|
320
|
+
return Template(template_str).render(values_dict)
|
321
|
+
|
322
|
+
def escape_field(text):
|
323
|
+
return re.sub('[^0-9a-z]+', '-', text.lower())
|
324
|
+
|
325
|
+
def load_template(template_path, values, default_values_path=None, force_defaults=False):
|
326
|
+
|
327
|
+
if not Path(template_path).exists():
|
328
|
+
raise FileNotFoundError(f"{template_path} does not exist")
|
329
|
+
with open(template_path, 'r') as f:
|
330
|
+
yaml_template = "".join(f.readlines())
|
331
|
+
|
332
|
+
# substitute missing values with defaults
|
333
|
+
if default_values_path is not None:
|
334
|
+
with open(default_values_path, 'r') as f:
|
335
|
+
default_values = yaml.safe_load(f)
|
336
|
+
for default in default_values:
|
337
|
+
if default["name"] == TEMPLATE_ID_FIELD:
|
338
|
+
if default["default"] not in values:
|
339
|
+
raise ValueError(f"Key value '{default['default']}' missing from values")
|
340
|
+
values[TEMPLATE_ID_KEY] = escape_field(values[default["default"]])
|
341
|
+
continue
|
342
|
+
if force_defaults or default["name"] not in values:
|
343
|
+
values[default['name']] = default['default']
|
344
|
+
|
345
|
+
return populate_template(template_str=yaml_template, values_dict=values)
|
346
|
+
|
347
|
+
|
348
|
+
def user_confirm(question: str, options: list, multiple: bool=False) -> int:
|
349
|
+
try:
|
350
|
+
print(question)
|
351
|
+
[print(f"{idx}) {option}") for idx, option in enumerate(options)]
|
352
|
+
reply = str(input())
|
353
|
+
if multiple:
|
354
|
+
if "," in reply:
|
355
|
+
selection = reply.split(",")
|
356
|
+
cast_selection = [int(s) for s in selection]
|
357
|
+
if all([s >= 0 and s < len(options) for s in cast_selection]):
|
358
|
+
return cast_selection
|
359
|
+
else:
|
360
|
+
reply = int(reply)
|
361
|
+
if reply >= 0 and reply <= len(options):
|
362
|
+
return [reply]
|
363
|
+
else:
|
364
|
+
reply = int(reply)
|
365
|
+
if reply >= 0 and reply <= len(options):
|
366
|
+
return reply
|
367
|
+
|
368
|
+
except:
|
369
|
+
return None
|
370
|
+
return None
|
371
|
+
|
372
|
+
def generate_join_token(cluster_ip, cluster_token, cluster_name, auth_key, watcher_service, public_location):
|
373
|
+
data = {
|
374
|
+
CLUSTER_IP_KEY: cluster_ip,
|
375
|
+
CLUSTER_NAME_KEY: cluster_name,
|
376
|
+
CLUSTER_TOKEN_KEY: cluster_token,
|
377
|
+
AUTH_KEY: auth_key,
|
378
|
+
WATCHER_SERVICE_KEY: watcher_service,
|
379
|
+
PUBLIC_LOCATION_KEY: public_location
|
380
|
+
}
|
381
|
+
return encode_dict(data=data)
|
382
|
+
|
383
|
+
def encode_dict(data: dict):
|
384
|
+
base64_str = base64.b64encode(json.dumps(data).encode())
|
385
|
+
return base64_str.decode()
|
386
|
+
|
387
|
+
def decode_dict(str_data: str):
|
388
|
+
return json.loads(base64.b64decode(str_data.encode()))
|
389
|
+
|
390
|
+
def get_gpus():
|
391
|
+
GPUs = GPUtil.getGPUs()
|
392
|
+
gpus = []
|
393
|
+
for gpu in GPUs:
|
394
|
+
name = "nvidia" if "nvidia" in gpu.name.lower() else None
|
395
|
+
if name is None:
|
396
|
+
continue
|
397
|
+
mem = int(gpu.memoryTotal / 1000) # in GBs
|
398
|
+
gpus.append(f"{name}-{mem}GB")
|
399
|
+
return ",".join(gpus)
|
400
|
+
|
401
|
+
def system_uptick_request(username, node_name, backend_endpoint, backend_api_key, local_version=0):
|
402
|
+
gpus = get_gpus()
|
403
|
+
data = {
|
404
|
+
"username": username,
|
405
|
+
"system_info": {
|
406
|
+
"os": platform.system(),
|
407
|
+
"cpu_count": os.cpu_count(),
|
408
|
+
"cpu": platform.processor(),
|
409
|
+
"platform": platform.platform(),
|
410
|
+
"ram": round(psutil.virtual_memory().total / (1024.0 **3)),
|
411
|
+
"hostname": node_name,
|
412
|
+
"gpus": gpus
|
413
|
+
},
|
414
|
+
"version": local_version
|
415
|
+
}
|
416
|
+
|
417
|
+
response = requests.post(
|
418
|
+
url=urljoin(backend_endpoint, "/uptick"),
|
419
|
+
json=data,
|
420
|
+
headers={'X-API-KEY': backend_api_key}
|
421
|
+
)
|
422
|
+
response.raise_for_status()
|
423
|
+
return response.json()
|
424
|
+
|
425
|
+
def resource_path(relative_path: str):
|
426
|
+
""" Get absolute path to resource """
|
427
|
+
try:
|
428
|
+
last_slash = relative_path.rfind("/")
|
429
|
+
path = relative_path[:last_slash].replace("/", ".")
|
430
|
+
filename = relative_path[last_slash+1:]
|
431
|
+
resource = importlib.resources.path(path, filename)
|
432
|
+
except:
|
433
|
+
return None
|
434
|
+
return resource
|
435
|
+
|
436
|
+
def user_path(relative_path, create_path=False):
|
437
|
+
"""Transform a relative path into the user's cache folder path"""
|
438
|
+
base = os.path.expanduser("~")
|
439
|
+
kalavai_user_path = os.path.join(base, ".cache/kalavai")
|
440
|
+
full_path = os.path.join(kalavai_user_path, relative_path)
|
441
|
+
if create_path:
|
442
|
+
Path(full_path).mkdir(parents=True, exist_ok=True)
|
443
|
+
|
444
|
+
return full_path
|
445
|
+
|
446
|
+
def safe_remove(filepath, force=True):
|
447
|
+
if not os.path.exists(filepath):
|
448
|
+
return
|
449
|
+
try:
|
450
|
+
if os.path.isfile(filepath):
|
451
|
+
os.remove(filepath)
|
452
|
+
if os.path.isdir(filepath):
|
453
|
+
shutil.rmtree(filepath)
|
454
|
+
except:
|
455
|
+
if force:
|
456
|
+
run_cmd(f"sudo rm -rf {filepath}")
|
@@ -0,0 +1,201 @@
|
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
177
|
+
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
179
|
+
|
180
|
+
To apply the Apache License to your work, attach the following
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
182
|
+
replaced with your own identifying information. (Don't include
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
184
|
+
comment syntax for the file format. We also recommend that a
|
185
|
+
file or class name and description of purpose be included on the
|
186
|
+
same "printed page" as the copyright notice for easier
|
187
|
+
identification within third-party archives.
|
188
|
+
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
190
|
+
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192
|
+
you may not use this file except in compliance with the License.
|
193
|
+
You may obtain a copy of the License at
|
194
|
+
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
196
|
+
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200
|
+
See the License for the specific language governing permissions and
|
201
|
+
limitations under the License.
|