repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
thecynic/pylutron | pylutron/__init__.py | Keypad.add_led | def add_led(self, led):
"""Add an LED that's part of this keypad."""
self._leds.append(led)
self._components[led.component_number] = led | python | def add_led(self, led):
"""Add an LED that's part of this keypad."""
self._leds.append(led)
self._components[led.component_number] = led | [
"def",
"add_led",
"(",
"self",
",",
"led",
")",
":",
"self",
".",
"_leds",
".",
"append",
"(",
"led",
")",
"self",
".",
"_components",
"[",
"led",
".",
"component_number",
"]",
"=",
"led"
] | Add an LED that's part of this keypad. | [
"Add",
"an",
"LED",
"that",
"s",
"part",
"of",
"this",
"keypad",
"."
] | train | https://github.com/thecynic/pylutron/blob/4d9222c96ef7ac7ac458031c058ad93ec31cebbf/pylutron/__init__.py#L808-L811 |
thecynic/pylutron | pylutron/__init__.py | Keypad.handle_update | def handle_update(self, args):
"""The callback invoked by the main event loop if there's an event from this keypad."""
component = int(args[0])
action = int(args[1])
params = [int(x) for x in args[2:]]
_LOGGER.debug("Updating %d(%s): c=%d a=%d params=%s" % (
self._integration_id, self._name,... | python | def handle_update(self, args):
"""The callback invoked by the main event loop if there's an event from this keypad."""
component = int(args[0])
action = int(args[1])
params = [int(x) for x in args[2:]]
_LOGGER.debug("Updating %d(%s): c=%d a=%d params=%s" % (
self._integration_id, self._name,... | [
"def",
"handle_update",
"(",
"self",
",",
"args",
")",
":",
"component",
"=",
"int",
"(",
"args",
"[",
"0",
"]",
")",
"action",
"=",
"int",
"(",
"args",
"[",
"1",
"]",
")",
"params",
"=",
"[",
"int",
"(",
"x",
")",
"for",
"x",
"in",
"args",
"... | The callback invoked by the main event loop if there's an event from this keypad. | [
"The",
"callback",
"invoked",
"by",
"the",
"main",
"event",
"loop",
"if",
"there",
"s",
"an",
"event",
"from",
"this",
"keypad",
"."
] | train | https://github.com/thecynic/pylutron/blob/4d9222c96ef7ac7ac458031c058ad93ec31cebbf/pylutron/__init__.py#L833-L842 |
oasis-open/cti-pattern-validator | stix2patterns/validator.py | run_validator | def run_validator(pattern):
"""
Validates a pattern against the STIX Pattern grammar. Error messages are
returned in a list. The test passed if the returned list is empty.
"""
start = ''
if isinstance(pattern, six.string_types):
start = pattern[:2]
pattern = InputStream(patter... | python | def run_validator(pattern):
"""
Validates a pattern against the STIX Pattern grammar. Error messages are
returned in a list. The test passed if the returned list is empty.
"""
start = ''
if isinstance(pattern, six.string_types):
start = pattern[:2]
pattern = InputStream(patter... | [
"def",
"run_validator",
"(",
"pattern",
")",
":",
"start",
"=",
"''",
"if",
"isinstance",
"(",
"pattern",
",",
"six",
".",
"string_types",
")",
":",
"start",
"=",
"pattern",
"[",
":",
"2",
"]",
"pattern",
"=",
"InputStream",
"(",
"pattern",
")",
"if",
... | Validates a pattern against the STIX Pattern grammar. Error messages are
returned in a list. The test passed if the returned list is empty. | [
"Validates",
"a",
"pattern",
"against",
"the",
"STIX",
"Pattern",
"grammar",
".",
"Error",
"messages",
"are",
"returned",
"in",
"a",
"list",
".",
"The",
"test",
"passed",
"if",
"the",
"returned",
"list",
"is",
"empty",
"."
] | train | https://github.com/oasis-open/cti-pattern-validator/blob/753a6901120db25f0c8550607de1eab4440d59df/stix2patterns/validator.py#L31-L74 |
oasis-open/cti-pattern-validator | stix2patterns/validator.py | validate | def validate(user_input, ret_errs=False, print_errs=False):
"""
Wrapper for run_validator function that returns True if the user_input
contains a valid STIX pattern or False otherwise. The error messages may
also be returned or printed based upon the ret_errs and print_errs arg
values.
"""
... | python | def validate(user_input, ret_errs=False, print_errs=False):
"""
Wrapper for run_validator function that returns True if the user_input
contains a valid STIX pattern or False otherwise. The error messages may
also be returned or printed based upon the ret_errs and print_errs arg
values.
"""
... | [
"def",
"validate",
"(",
"user_input",
",",
"ret_errs",
"=",
"False",
",",
"print_errs",
"=",
"False",
")",
":",
"errs",
"=",
"run_validator",
"(",
"user_input",
")",
"passed",
"=",
"len",
"(",
"errs",
")",
"==",
"0",
"if",
"print_errs",
":",
"for",
"er... | Wrapper for run_validator function that returns True if the user_input
contains a valid STIX pattern or False otherwise. The error messages may
also be returned or printed based upon the ret_errs and print_errs arg
values. | [
"Wrapper",
"for",
"run_validator",
"function",
"that",
"returns",
"True",
"if",
"the",
"user_input",
"contains",
"a",
"valid",
"STIX",
"pattern",
"or",
"False",
"otherwise",
".",
"The",
"error",
"messages",
"may",
"also",
"be",
"returned",
"or",
"printed",
"ba... | train | https://github.com/oasis-open/cti-pattern-validator/blob/753a6901120db25f0c8550607de1eab4440d59df/stix2patterns/validator.py#L77-L95 |
oasis-open/cti-pattern-validator | stix2patterns/validator.py | main | def main():
"""
Continues to validate patterns until it encounters EOF within a pattern
file or Ctrl-C is pressed by the user.
"""
parser = argparse.ArgumentParser(description='Validate STIX Patterns.')
parser.add_argument('-f', '--file',
help="Specify this arg to read pa... | python | def main():
"""
Continues to validate patterns until it encounters EOF within a pattern
file or Ctrl-C is pressed by the user.
"""
parser = argparse.ArgumentParser(description='Validate STIX Patterns.')
parser.add_argument('-f', '--file',
help="Specify this arg to read pa... | [
"def",
"main",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'Validate STIX Patterns.'",
")",
"parser",
".",
"add_argument",
"(",
"'-f'",
",",
"'--file'",
",",
"help",
"=",
"\"Specify this arg to read patterns from a file... | Continues to validate patterns until it encounters EOF within a pattern
file or Ctrl-C is pressed by the user. | [
"Continues",
"to",
"validate",
"patterns",
"until",
"it",
"encounters",
"EOF",
"within",
"a",
"pattern",
"file",
"or",
"Ctrl",
"-",
"C",
"is",
"pressed",
"by",
"the",
"user",
"."
] | train | https://github.com/oasis-open/cti-pattern-validator/blob/753a6901120db25f0c8550607de1eab4440d59df/stix2patterns/validator.py#L98-L143 |
oasis-open/cti-pattern-validator | stix2patterns/inspector.py | _string_literal_to_string | def _string_literal_to_string(string_literal_token):
"""Converts the StringLiteral token to a plain string: get text content,
removes quote characters, and unescapes it.
:param string_literal_token: The string literal
:return:
"""
token_text = string_literal_token.getText()
return token_tex... | python | def _string_literal_to_string(string_literal_token):
"""Converts the StringLiteral token to a plain string: get text content,
removes quote characters, and unescapes it.
:param string_literal_token: The string literal
:return:
"""
token_text = string_literal_token.getText()
return token_tex... | [
"def",
"_string_literal_to_string",
"(",
"string_literal_token",
")",
":",
"token_text",
"=",
"string_literal_token",
".",
"getText",
"(",
")",
"return",
"token_text",
"[",
"1",
":",
"-",
"1",
"]",
".",
"replace",
"(",
"u\"\\\\'\"",
",",
"u\"'\"",
")",
".",
... | Converts the StringLiteral token to a plain string: get text content,
removes quote characters, and unescapes it.
:param string_literal_token: The string literal
:return: | [
"Converts",
"the",
"StringLiteral",
"token",
"to",
"a",
"plain",
"string",
":",
"get",
"text",
"content",
"removes",
"quote",
"characters",
"and",
"unescapes",
"it",
"."
] | train | https://github.com/oasis-open/cti-pattern-validator/blob/753a6901120db25f0c8550607de1eab4440d59df/stix2patterns/inspector.py#L19-L28 |
alexhayes/django-pdfkit | django_pdfkit/views.py | PDFView.get | def get(self, request, *args, **kwargs):
"""
Return a HTTPResponse either of a PDF file or HTML.
:rtype: HttpResponse
"""
if 'html' in request.GET:
# Output HTML
content = self.render_html(*args, **kwargs)
return HttpResponse(content)
... | python | def get(self, request, *args, **kwargs):
"""
Return a HTTPResponse either of a PDF file or HTML.
:rtype: HttpResponse
"""
if 'html' in request.GET:
# Output HTML
content = self.render_html(*args, **kwargs)
return HttpResponse(content)
... | [
"def",
"get",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'html'",
"in",
"request",
".",
"GET",
":",
"# Output HTML",
"content",
"=",
"self",
".",
"render_html",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs"... | Return a HTTPResponse either of a PDF file or HTML.
:rtype: HttpResponse | [
"Return",
"a",
"HTTPResponse",
"either",
"of",
"a",
"PDF",
"file",
"or",
"HTML",
"."
] | train | https://github.com/alexhayes/django-pdfkit/blob/02774ae2cb67d05dd5e4cb50661c56464ebb2413/django_pdfkit/views.py#L31-L53 |
alexhayes/django-pdfkit | django_pdfkit/views.py | PDFView.render_pdf | def render_pdf(self, *args, **kwargs):
"""
Render the PDF and returns as bytes.
:rtype: bytes
"""
html = self.render_html(*args, **kwargs)
options = self.get_pdfkit_options()
if 'debug' in self.request.GET and settings.DEBUG:
options['debug-javascrip... | python | def render_pdf(self, *args, **kwargs):
"""
Render the PDF and returns as bytes.
:rtype: bytes
"""
html = self.render_html(*args, **kwargs)
options = self.get_pdfkit_options()
if 'debug' in self.request.GET and settings.DEBUG:
options['debug-javascrip... | [
"def",
"render_pdf",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"html",
"=",
"self",
".",
"render_html",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"options",
"=",
"self",
".",
"get_pdfkit_options",
"(",
")",
"if",
"'deb... | Render the PDF and returns as bytes.
:rtype: bytes | [
"Render",
"the",
"PDF",
"and",
"returns",
"as",
"bytes",
"."
] | train | https://github.com/alexhayes/django-pdfkit/blob/02774ae2cb67d05dd5e4cb50661c56464ebb2413/django_pdfkit/views.py#L55-L74 |
alexhayes/django-pdfkit | django_pdfkit/views.py | PDFView.get_filename | def get_filename(self):
"""
Return ``self.filename`` if set otherwise return the template basename with a ``.pdf`` extension.
:rtype: str
"""
if self.filename is None:
name = splitext(basename(self.template_name))[0]
return '{}.pdf'.format(name)
... | python | def get_filename(self):
"""
Return ``self.filename`` if set otherwise return the template basename with a ``.pdf`` extension.
:rtype: str
"""
if self.filename is None:
name = splitext(basename(self.template_name))[0]
return '{}.pdf'.format(name)
... | [
"def",
"get_filename",
"(",
"self",
")",
":",
"if",
"self",
".",
"filename",
"is",
"None",
":",
"name",
"=",
"splitext",
"(",
"basename",
"(",
"self",
".",
"template_name",
")",
")",
"[",
"0",
"]",
"return",
"'{}.pdf'",
".",
"format",
"(",
"name",
")... | Return ``self.filename`` if set otherwise return the template basename with a ``.pdf`` extension.
:rtype: str | [
"Return",
"self",
".",
"filename",
"if",
"set",
"otherwise",
"return",
"the",
"template",
"basename",
"with",
"a",
".",
"pdf",
"extension",
"."
] | train | https://github.com/alexhayes/django-pdfkit/blob/02774ae2cb67d05dd5e4cb50661c56464ebb2413/django_pdfkit/views.py#L90-L100 |
alexhayes/django-pdfkit | django_pdfkit/views.py | PDFView.render_html | def render_html(self, *args, **kwargs):
"""
Renders the template.
:rtype: str
"""
static_url = '%s://%s%s' % (self.request.scheme, self.request.get_host(), settings.STATIC_URL)
media_url = '%s://%s%s' % (self.request.scheme, self.request.get_host(), settings.MEDIA_URL)
... | python | def render_html(self, *args, **kwargs):
"""
Renders the template.
:rtype: str
"""
static_url = '%s://%s%s' % (self.request.scheme, self.request.get_host(), settings.STATIC_URL)
media_url = '%s://%s%s' % (self.request.scheme, self.request.get_host(), settings.MEDIA_URL)
... | [
"def",
"render_html",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"static_url",
"=",
"'%s://%s%s'",
"%",
"(",
"self",
".",
"request",
".",
"scheme",
",",
"self",
".",
"request",
".",
"get_host",
"(",
")",
",",
"settings",
".",
... | Renders the template.
:rtype: str | [
"Renders",
"the",
"template",
"."
] | train | https://github.com/alexhayes/django-pdfkit/blob/02774ae2cb67d05dd5e4cb50661c56464ebb2413/django_pdfkit/views.py#L102-L115 |
oasis-open/cti-pattern-validator | stix2patterns/pattern.py | Pattern.inspect | def inspect(self):
"""
Inspect a pattern. This gives information regarding the sorts of
operations, content, etc in use in the pattern.
:return: Pattern information
"""
inspector = stix2patterns.inspector.InspectionListener()
self.walk(inspector)
retur... | python | def inspect(self):
"""
Inspect a pattern. This gives information regarding the sorts of
operations, content, etc in use in the pattern.
:return: Pattern information
"""
inspector = stix2patterns.inspector.InspectionListener()
self.walk(inspector)
retur... | [
"def",
"inspect",
"(",
"self",
")",
":",
"inspector",
"=",
"stix2patterns",
".",
"inspector",
".",
"InspectionListener",
"(",
")",
"self",
".",
"walk",
"(",
"inspector",
")",
"return",
"inspector",
".",
"pattern_data",
"(",
")"
] | Inspect a pattern. This gives information regarding the sorts of
operations, content, etc in use in the pattern.
:return: Pattern information | [
"Inspect",
"a",
"pattern",
".",
"This",
"gives",
"information",
"regarding",
"the",
"sorts",
"of",
"operations",
"content",
"etc",
"in",
"use",
"in",
"the",
"pattern",
"."
] | train | https://github.com/oasis-open/cti-pattern-validator/blob/753a6901120db25f0c8550607de1eab4440d59df/stix2patterns/pattern.py#L36-L47 |
oasis-open/cti-pattern-validator | stix2patterns/pattern.py | Pattern.walk | def walk(self, listener):
"""Walk the parse tree, using the given listener. The listener
should be a
stix2patterns.grammars.STIXPatternListener.STIXPatternListener (or
subclass) instance."""
antlr4.ParseTreeWalker.DEFAULT.walk(listener, self.__parse_tree) | python | def walk(self, listener):
"""Walk the parse tree, using the given listener. The listener
should be a
stix2patterns.grammars.STIXPatternListener.STIXPatternListener (or
subclass) instance."""
antlr4.ParseTreeWalker.DEFAULT.walk(listener, self.__parse_tree) | [
"def",
"walk",
"(",
"self",
",",
"listener",
")",
":",
"antlr4",
".",
"ParseTreeWalker",
".",
"DEFAULT",
".",
"walk",
"(",
"listener",
",",
"self",
".",
"__parse_tree",
")"
] | Walk the parse tree, using the given listener. The listener
should be a
stix2patterns.grammars.STIXPatternListener.STIXPatternListener (or
subclass) instance. | [
"Walk",
"the",
"parse",
"tree",
"using",
"the",
"given",
"listener",
".",
"The",
"listener",
"should",
"be",
"a",
"stix2patterns",
".",
"grammars",
".",
"STIXPatternListener",
".",
"STIXPatternListener",
"(",
"or",
"subclass",
")",
"instance",
"."
] | train | https://github.com/oasis-open/cti-pattern-validator/blob/753a6901120db25f0c8550607de1eab4440d59df/stix2patterns/pattern.py#L49-L54 |
oasis-open/cti-pattern-validator | stix2patterns/pattern.py | Pattern.__do_parse | def __do_parse(self, pattern_str):
"""
Parses the given pattern and returns the antlr parse tree.
:param pattern_str: The STIX pattern
:return: The parse tree
:raises ParseException: If there is a parse error
"""
in_ = antlr4.InputStream(pattern_str)
lexe... | python | def __do_parse(self, pattern_str):
"""
Parses the given pattern and returns the antlr parse tree.
:param pattern_str: The STIX pattern
:return: The parse tree
:raises ParseException: If there is a parse error
"""
in_ = antlr4.InputStream(pattern_str)
lexe... | [
"def",
"__do_parse",
"(",
"self",
",",
"pattern_str",
")",
":",
"in_",
"=",
"antlr4",
".",
"InputStream",
"(",
"pattern_str",
")",
"lexer",
"=",
"STIXPatternLexer",
"(",
"in_",
")",
"lexer",
".",
"removeErrorListeners",
"(",
")",
"# remove the default \"console\... | Parses the given pattern and returns the antlr parse tree.
:param pattern_str: The STIX pattern
:return: The parse tree
:raises ParseException: If there is a parse error | [
"Parses",
"the",
"given",
"pattern",
"and",
"returns",
"the",
"antlr",
"parse",
"tree",
"."
] | train | https://github.com/oasis-open/cti-pattern-validator/blob/753a6901120db25f0c8550607de1eab4440d59df/stix2patterns/pattern.py#L56-L117 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | Return.stdout | def stdout(self):
"""
The job stdout
:return: string or None
"""
streams = self._payload.get('streams', None)
return streams[0] if streams is not None and len(streams) >= 1 else '' | python | def stdout(self):
"""
The job stdout
:return: string or None
"""
streams = self._payload.get('streams', None)
return streams[0] if streams is not None and len(streams) >= 1 else '' | [
"def",
"stdout",
"(",
"self",
")",
":",
"streams",
"=",
"self",
".",
"_payload",
".",
"get",
"(",
"'streams'",
",",
"None",
")",
"return",
"streams",
"[",
"0",
"]",
"if",
"streams",
"is",
"not",
"None",
"and",
"len",
"(",
"streams",
")",
">=",
"1",... | The job stdout
:return: string or None | [
"The",
"job",
"stdout",
":",
"return",
":",
"string",
"or",
"None"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L102-L108 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | Return.stderr | def stderr(self):
"""
The job stderr
:return: string or None
"""
streams = self._payload.get('streams', None)
return streams[1] if streams is not None and len(streams) >= 2 else '' | python | def stderr(self):
"""
The job stderr
:return: string or None
"""
streams = self._payload.get('streams', None)
return streams[1] if streams is not None and len(streams) >= 2 else '' | [
"def",
"stderr",
"(",
"self",
")",
":",
"streams",
"=",
"self",
".",
"_payload",
".",
"get",
"(",
"'streams'",
",",
"None",
")",
"return",
"streams",
"[",
"1",
"]",
"if",
"streams",
"is",
"not",
"None",
"and",
"len",
"(",
"streams",
")",
">=",
"2",... | The job stderr
:return: string or None | [
"The",
"job",
"stderr",
":",
"return",
":",
"string",
"or",
"None"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L111-L117 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | Response.exists | def exists(self):
"""
Returns true if the job is still running or zero-os still knows about this job ID
After a job is finished, a job remains on zero-os for max of 5min where you still can read the job result
after the 5 min is gone, the job result is no more fetchable
:return:... | python | def exists(self):
"""
Returns true if the job is still running or zero-os still knows about this job ID
After a job is finished, a job remains on zero-os for max of 5min where you still can read the job result
after the 5 min is gone, the job result is no more fetchable
:return:... | [
"def",
"exists",
"(",
"self",
")",
":",
"r",
"=",
"self",
".",
"_client",
".",
"_redis",
"flag",
"=",
"'{}:flag'",
".",
"format",
"(",
"self",
".",
"_queue",
")",
"return",
"bool",
"(",
"r",
".",
"exists",
"(",
"flag",
")",
")"
] | Returns true if the job is still running or zero-os still knows about this job ID
After a job is finished, a job remains on zero-os for max of 5min where you still can read the job result
after the 5 min is gone, the job result is no more fetchable
:return: bool | [
"Returns",
"true",
"if",
"the",
"job",
"is",
"still",
"running",
"or",
"zero",
"-",
"os",
"still",
"knows",
"about",
"this",
"job",
"ID"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L162-L172 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | Response.running | def running(self):
"""
Returns true if job still in running state
:return:
"""
r = self._client._redis
flag = '{}:flag'.format(self._queue)
if bool(r.exists(flag)):
return r.ttl(flag) is None
return False | python | def running(self):
"""
Returns true if job still in running state
:return:
"""
r = self._client._redis
flag = '{}:flag'.format(self._queue)
if bool(r.exists(flag)):
return r.ttl(flag) is None
return False | [
"def",
"running",
"(",
"self",
")",
":",
"r",
"=",
"self",
".",
"_client",
".",
"_redis",
"flag",
"=",
"'{}:flag'",
".",
"format",
"(",
"self",
".",
"_queue",
")",
"if",
"bool",
"(",
"r",
".",
"exists",
"(",
"flag",
")",
")",
":",
"return",
"r",
... | Returns true if job still in running state
:return: | [
"Returns",
"true",
"if",
"job",
"still",
"in",
"running",
"state",
":",
"return",
":"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L175-L185 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | Response.stream | def stream(self, callback=None):
"""
Runtime copy of job messages. This required the 'stream` flag to be set to True otherwise it will
not be able to copy any output, while it will block until the process exits.
:note: This function will block until it reaches end of stream or the proce... | python | def stream(self, callback=None):
"""
Runtime copy of job messages. This required the 'stream` flag to be set to True otherwise it will
not be able to copy any output, while it will block until the process exits.
:note: This function will block until it reaches end of stream or the proce... | [
"def",
"stream",
"(",
"self",
",",
"callback",
"=",
"None",
")",
":",
"if",
"callback",
"is",
"None",
":",
"callback",
"=",
"Response",
".",
"__default",
"if",
"not",
"callable",
"(",
"callback",
")",
":",
"raise",
"Exception",
"(",
"'callback must be call... | Runtime copy of job messages. This required the 'stream` flag to be set to True otherwise it will
not be able to copy any output, while it will block until the process exits.
:note: This function will block until it reaches end of stream or the process is no longer running.
:param callback: ca... | [
"Runtime",
"copy",
"of",
"job",
"messages",
".",
"This",
"required",
"the",
"stream",
"flag",
"to",
"be",
"set",
"to",
"True",
"otherwise",
"it",
"will",
"not",
"be",
"able",
"to",
"copy",
"any",
"output",
"while",
"it",
"will",
"block",
"until",
"the",
... | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L187-L237 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | Response.get | def get(self, timeout=None):
"""
Waits for a job to finish (max of given timeout seconds) and return job results. When a job exits get() will
keep returning the same result until zero-os doesn't remember the job anymore (self.exists == False)
:notes: the timeout here is a client side ti... | python | def get(self, timeout=None):
"""
Waits for a job to finish (max of given timeout seconds) and return job results. When a job exits get() will
keep returning the same result until zero-os doesn't remember the job anymore (self.exists == False)
:notes: the timeout here is a client side ti... | [
"def",
"get",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"if",
"timeout",
"is",
"None",
":",
"timeout",
"=",
"self",
".",
"_client",
".",
"timeout",
"r",
"=",
"self",
".",
"_client",
".",
"_redis",
"start",
"=",
"time",
".",
"time",
"(",
... | Waits for a job to finish (max of given timeout seconds) and return job results. When a job exits get() will
keep returning the same result until zero-os doesn't remember the job anymore (self.exists == False)
:notes: the timeout here is a client side timeout, it's different than the timeout given to t... | [
"Waits",
"for",
"a",
"job",
"to",
"finish",
"(",
"max",
"of",
"given",
"timeout",
"seconds",
")",
"and",
"return",
"job",
"results",
".",
"When",
"a",
"job",
"exits",
"get",
"()",
"will",
"keep",
"returning",
"the",
"same",
"result",
"until",
"zero",
"... | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L245-L273 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | JSONResponse.get | def get(self, timeout=None):
"""
Get response as json, will fail if the job doesn't return a valid json response
:param timeout: client side timeout in seconds
:return: int
"""
result = super().get(timeout)
if result.state != 'SUCCESS':
raise ResultEr... | python | def get(self, timeout=None):
"""
Get response as json, will fail if the job doesn't return a valid json response
:param timeout: client side timeout in seconds
:return: int
"""
result = super().get(timeout)
if result.state != 'SUCCESS':
raise ResultEr... | [
"def",
"get",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"result",
"=",
"super",
"(",
")",
".",
"get",
"(",
"timeout",
")",
"if",
"result",
".",
"state",
"!=",
"'SUCCESS'",
":",
"raise",
"ResultError",
"(",
"result",
".",
"data",
",",
"res... | Get response as json, will fail if the job doesn't return a valid json response
:param timeout: client side timeout in seconds
:return: int | [
"Get",
"response",
"as",
"json",
"will",
"fail",
"if",
"the",
"job",
"doesn",
"t",
"return",
"a",
"valid",
"json",
"response"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L280-L293 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | JobManager.list | def list(self, id=None):
"""
List all running jobs
:param id: optional ID for the job to list
"""
args = {'id': id}
self._job_chk.check(args)
return self._client.json('job.list', args) | python | def list(self, id=None):
"""
List all running jobs
:param id: optional ID for the job to list
"""
args = {'id': id}
self._job_chk.check(args)
return self._client.json('job.list', args) | [
"def",
"list",
"(",
"self",
",",
"id",
"=",
"None",
")",
":",
"args",
"=",
"{",
"'id'",
":",
"id",
"}",
"self",
".",
"_job_chk",
".",
"check",
"(",
"args",
")",
"return",
"self",
".",
"_client",
".",
"json",
"(",
"'job.list'",
",",
"args",
")"
] | List all running jobs
:param id: optional ID for the job to list | [
"List",
"all",
"running",
"jobs"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L372-L380 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | JobManager.kill | def kill(self, id, signal=signal.SIGTERM):
"""
Kill a job with given id
:WARNING: beware of what u kill, if u killed redis for example core0 or coreX won't be reachable
:param id: job id to kill
"""
args = {
'id': id,
'signal': int(signal),
... | python | def kill(self, id, signal=signal.SIGTERM):
"""
Kill a job with given id
:WARNING: beware of what u kill, if u killed redis for example core0 or coreX won't be reachable
:param id: job id to kill
"""
args = {
'id': id,
'signal': int(signal),
... | [
"def",
"kill",
"(",
"self",
",",
"id",
",",
"signal",
"=",
"signal",
".",
"SIGTERM",
")",
":",
"args",
"=",
"{",
"'id'",
":",
"id",
",",
"'signal'",
":",
"int",
"(",
"signal",
")",
",",
"}",
"self",
".",
"_kill_chk",
".",
"check",
"(",
"args",
... | Kill a job with given id
:WARNING: beware of what u kill, if u killed redis for example core0 or coreX won't be reachable
:param id: job id to kill | [
"Kill",
"a",
"job",
"with",
"given",
"id"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L382-L395 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | ProcessManager.list | def list(self, id=None):
"""
List all running processes
:param id: optional PID for the process to list
"""
args = {'pid': id}
self._process_chk.check(args)
return self._client.json('process.list', args) | python | def list(self, id=None):
"""
List all running processes
:param id: optional PID for the process to list
"""
args = {'pid': id}
self._process_chk.check(args)
return self._client.json('process.list', args) | [
"def",
"list",
"(",
"self",
",",
"id",
"=",
"None",
")",
":",
"args",
"=",
"{",
"'pid'",
":",
"id",
"}",
"self",
".",
"_process_chk",
".",
"check",
"(",
"args",
")",
"return",
"self",
".",
"_client",
".",
"json",
"(",
"'process.list'",
",",
"args",... | List all running processes
:param id: optional PID for the process to list | [
"List",
"all",
"running",
"processes"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L411-L419 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | FilesystemManager.open | def open(self, file, mode='r', perm=0o0644):
"""
Opens a file on the node
:param file: file path to open
:param mode: open mode
:param perm: file permission in octet form
mode:
'r' read only
'w' write only (truncate)
'+' read/write
... | python | def open(self, file, mode='r', perm=0o0644):
"""
Opens a file on the node
:param file: file path to open
:param mode: open mode
:param perm: file permission in octet form
mode:
'r' read only
'w' write only (truncate)
'+' read/write
... | [
"def",
"open",
"(",
"self",
",",
"file",
",",
"mode",
"=",
"'r'",
",",
"perm",
"=",
"0o0644",
")",
":",
"args",
"=",
"{",
"'file'",
":",
"file",
",",
"'mode'",
":",
"mode",
",",
"'perm'",
":",
"perm",
",",
"}",
"return",
"self",
".",
"_client",
... | Opens a file on the node
:param file: file path to open
:param mode: open mode
:param perm: file permission in octet form
mode:
'r' read only
'w' write only (truncate)
'+' read/write
'x' create if not exist
'a' append
:return: a... | [
"Opens",
"a",
"file",
"on",
"the",
"node"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L442-L464 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | FilesystemManager.move | def move(self, path, destination):
"""
Move a path to destination
:param path: source
:param destination: destination
:return:
"""
args = {
'path': path,
'destination': destination,
}
return self._client.json('filesystem.m... | python | def move(self, path, destination):
"""
Move a path to destination
:param path: source
:param destination: destination
:return:
"""
args = {
'path': path,
'destination': destination,
}
return self._client.json('filesystem.m... | [
"def",
"move",
"(",
"self",
",",
"path",
",",
"destination",
")",
":",
"args",
"=",
"{",
"'path'",
":",
"path",
",",
"'destination'",
":",
"destination",
",",
"}",
"return",
"self",
".",
"_client",
".",
"json",
"(",
"'filesystem.move'",
",",
"args",
")... | Move a path to destination
:param path: source
:param destination: destination
:return: | [
"Move",
"a",
"path",
"to",
"destination"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L516-L529 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | FilesystemManager.chmod | def chmod(self, path, mode, recursive=False):
"""
Change file/dir permission
:param path: path of file/dir to change
:param mode: octet mode
:param recursive: apply chmod recursively
:return:
"""
args = {
'path': path,
'mode': mode... | python | def chmod(self, path, mode, recursive=False):
"""
Change file/dir permission
:param path: path of file/dir to change
:param mode: octet mode
:param recursive: apply chmod recursively
:return:
"""
args = {
'path': path,
'mode': mode... | [
"def",
"chmod",
"(",
"self",
",",
"path",
",",
"mode",
",",
"recursive",
"=",
"False",
")",
":",
"args",
"=",
"{",
"'path'",
":",
"path",
",",
"'mode'",
":",
"mode",
",",
"'recursive'",
":",
"recursive",
",",
"}",
"return",
"self",
".",
"_client",
... | Change file/dir permission
:param path: path of file/dir to change
:param mode: octet mode
:param recursive: apply chmod recursively
:return: | [
"Change",
"file",
"/",
"dir",
"permission"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L531-L546 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | FilesystemManager.chown | def chown(self, path, user, group, recursive=False):
"""
Change file/dir owner
:param path: path of file/dir
:param user: user name
:param group: group name
:param recursive: apply chown recursively
:return:
"""
args = {
'path': path,
... | python | def chown(self, path, user, group, recursive=False):
"""
Change file/dir owner
:param path: path of file/dir
:param user: user name
:param group: group name
:param recursive: apply chown recursively
:return:
"""
args = {
'path': path,
... | [
"def",
"chown",
"(",
"self",
",",
"path",
",",
"user",
",",
"group",
",",
"recursive",
"=",
"False",
")",
":",
"args",
"=",
"{",
"'path'",
":",
"path",
",",
"'user'",
":",
"user",
",",
"'group'",
":",
"group",
",",
"'recursive'",
":",
"recursive",
... | Change file/dir owner
:param path: path of file/dir
:param user: user name
:param group: group name
:param recursive: apply chown recursively
:return: | [
"Change",
"file",
"/",
"dir",
"owner"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L548-L565 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | FilesystemManager.read | def read(self, fd):
"""
Read a block from the given file descriptor
:param fd: file descriptor
:return: bytes
"""
args = {
'fd': fd,
}
data = self._client.json('filesystem.read', args)
return base64.decodebytes(data.encode()) | python | def read(self, fd):
"""
Read a block from the given file descriptor
:param fd: file descriptor
:return: bytes
"""
args = {
'fd': fd,
}
data = self._client.json('filesystem.read', args)
return base64.decodebytes(data.encode()) | [
"def",
"read",
"(",
"self",
",",
"fd",
")",
":",
"args",
"=",
"{",
"'fd'",
":",
"fd",
",",
"}",
"data",
"=",
"self",
".",
"_client",
".",
"json",
"(",
"'filesystem.read'",
",",
"args",
")",
"return",
"base64",
".",
"decodebytes",
"(",
"data",
".",
... | Read a block from the given file descriptor
:param fd: file descriptor
:return: bytes | [
"Read",
"a",
"block",
"from",
"the",
"given",
"file",
"descriptor"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L567-L579 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | FilesystemManager.write | def write(self, fd, bytes):
"""
Write a block of bytes to an open file descriptor (that is open with one of the writing modes
:param fd: file descriptor
:param bytes: bytes block to write
:return:
:note: don't overkill the node with large byte chunks, also for large fil... | python | def write(self, fd, bytes):
"""
Write a block of bytes to an open file descriptor (that is open with one of the writing modes
:param fd: file descriptor
:param bytes: bytes block to write
:return:
:note: don't overkill the node with large byte chunks, also for large fil... | [
"def",
"write",
"(",
"self",
",",
"fd",
",",
"bytes",
")",
":",
"args",
"=",
"{",
"'fd'",
":",
"fd",
",",
"'block'",
":",
"base64",
".",
"encodebytes",
"(",
"bytes",
")",
".",
"decode",
"(",
")",
",",
"}",
"return",
"self",
".",
"_client",
".",
... | Write a block of bytes to an open file descriptor (that is open with one of the writing modes
:param fd: file descriptor
:param bytes: bytes block to write
:return:
:note: don't overkill the node with large byte chunks, also for large file upload check the upload method. | [
"Write",
"a",
"block",
"of",
"bytes",
"to",
"an",
"open",
"file",
"descriptor",
"(",
"that",
"is",
"open",
"with",
"one",
"of",
"the",
"writing",
"modes"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L581-L596 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | FilesystemManager.upload | def upload(self, remote, reader):
"""
Uploads a file
:param remote: remote file name
:param reader: an object that implements the read(size) method (typically a file descriptor)
:return:
"""
fd = self.open(remote, 'w')
while True:
chunk = read... | python | def upload(self, remote, reader):
"""
Uploads a file
:param remote: remote file name
:param reader: an object that implements the read(size) method (typically a file descriptor)
:return:
"""
fd = self.open(remote, 'w')
while True:
chunk = read... | [
"def",
"upload",
"(",
"self",
",",
"remote",
",",
"reader",
")",
":",
"fd",
"=",
"self",
".",
"open",
"(",
"remote",
",",
"'w'",
")",
"while",
"True",
":",
"chunk",
"=",
"reader",
".",
"read",
"(",
"512",
"*",
"1024",
")",
"if",
"chunk",
"==",
... | Uploads a file
:param remote: remote file name
:param reader: an object that implements the read(size) method (typically a file descriptor)
:return: | [
"Uploads",
"a",
"file",
":",
"param",
"remote",
":",
"remote",
"file",
"name",
":",
"param",
"reader",
":",
"an",
"object",
"that",
"implements",
"the",
"read",
"(",
"size",
")",
"method",
"(",
"typically",
"a",
"file",
"descriptor",
")",
":",
"return",
... | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L610-L624 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | FilesystemManager.download | def download(self, remote, writer):
"""
Downloads a file
:param remote: remote file name
:param writer: an object the implements the write(bytes) interface (typical a file descriptor)
:return:
"""
fd = self.open(remote)
while True:
chunk = sel... | python | def download(self, remote, writer):
"""
Downloads a file
:param remote: remote file name
:param writer: an object the implements the write(bytes) interface (typical a file descriptor)
:return:
"""
fd = self.open(remote)
while True:
chunk = sel... | [
"def",
"download",
"(",
"self",
",",
"remote",
",",
"writer",
")",
":",
"fd",
"=",
"self",
".",
"open",
"(",
"remote",
")",
"while",
"True",
":",
"chunk",
"=",
"self",
".",
"read",
"(",
"fd",
")",
"if",
"chunk",
"==",
"b''",
":",
"break",
"writer... | Downloads a file
:param remote: remote file name
:param writer: an object the implements the write(bytes) interface (typical a file descriptor)
:return: | [
"Downloads",
"a",
"file",
":",
"param",
"remote",
":",
"remote",
"file",
"name",
":",
"param",
"writer",
":",
"an",
"object",
"the",
"implements",
"the",
"write",
"(",
"bytes",
")",
"interface",
"(",
"typical",
"a",
"file",
"descriptor",
")",
":",
"retur... | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L626-L640 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | FilesystemManager.upload_file | def upload_file(self, remote, local):
"""
Uploads a file
:param remote: remote file name
:param local: local file name
:return:
"""
file = open(local, 'rb')
try:
self.upload(remote, file)
finally:
file.close() | python | def upload_file(self, remote, local):
"""
Uploads a file
:param remote: remote file name
:param local: local file name
:return:
"""
file = open(local, 'rb')
try:
self.upload(remote, file)
finally:
file.close() | [
"def",
"upload_file",
"(",
"self",
",",
"remote",
",",
"local",
")",
":",
"file",
"=",
"open",
"(",
"local",
",",
"'rb'",
")",
"try",
":",
"self",
".",
"upload",
"(",
"remote",
",",
"file",
")",
"finally",
":",
"file",
".",
"close",
"(",
")"
] | Uploads a file
:param remote: remote file name
:param local: local file name
:return: | [
"Uploads",
"a",
"file",
":",
"param",
"remote",
":",
"remote",
"file",
"name",
":",
"param",
"local",
":",
"local",
"file",
"name",
":",
"return",
":"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L642-L653 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | FilesystemManager.download_file | def download_file(self, remote, local):
"""
Downloads a file
:param remote: remote file name
:param local: local file name
:return:
"""
file = open(local, 'wb')
try:
self.download(remote, file)
finally:
file.close() | python | def download_file(self, remote, local):
"""
Downloads a file
:param remote: remote file name
:param local: local file name
:return:
"""
file = open(local, 'wb')
try:
self.download(remote, file)
finally:
file.close() | [
"def",
"download_file",
"(",
"self",
",",
"remote",
",",
"local",
")",
":",
"file",
"=",
"open",
"(",
"local",
",",
"'wb'",
")",
"try",
":",
"self",
".",
"download",
"(",
"remote",
",",
"file",
")",
"finally",
":",
"file",
".",
"close",
"(",
")"
] | Downloads a file
:param remote: remote file name
:param local: local file name
:return: | [
"Downloads",
"a",
"file",
":",
"param",
"remote",
":",
"remote",
"file",
"name",
":",
"param",
"local",
":",
"local",
"file",
"name",
":",
"return",
":"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L655-L666 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | BaseClient.raw | def raw(self, command, arguments, queue=None, max_time=None, stream=False, tags=None, id=None):
"""
Implements the low level command call, this needs to build the command structure
and push it on the correct queue.
:param command: Command name to execute supported by the node (ex: core.... | python | def raw(self, command, arguments, queue=None, max_time=None, stream=False, tags=None, id=None):
"""
Implements the low level command call, this needs to build the command structure
and push it on the correct queue.
:param command: Command name to execute supported by the node (ex: core.... | [
"def",
"raw",
"(",
"self",
",",
"command",
",",
"arguments",
",",
"queue",
"=",
"None",
",",
"max_time",
"=",
"None",
",",
"stream",
"=",
"False",
",",
"tags",
"=",
"None",
",",
"id",
"=",
"None",
")",
":",
"raise",
"NotImplemented",
"(",
")"
] | Implements the low level command call, this needs to build the command structure
and push it on the correct queue.
:param command: Command name to execute supported by the node (ex: core.system, info.cpu, etc...)
check documentation for list of built in commands
:param a... | [
"Implements",
"the",
"low",
"level",
"command",
"call",
"this",
"needs",
"to",
"build",
"the",
"command",
"structure",
"and",
"push",
"it",
"on",
"the",
"correct",
"queue",
"."
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L734-L750 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | BaseClient.sync | def sync(self, command, arguments, tags=None, id=None):
"""
Same as self.raw except it do a response.get() waiting for the command execution to finish and reads the result
:param command: Command name to execute supported by the node (ex: core.system, info.cpu, etc...)
ch... | python | def sync(self, command, arguments, tags=None, id=None):
"""
Same as self.raw except it do a response.get() waiting for the command execution to finish and reads the result
:param command: Command name to execute supported by the node (ex: core.system, info.cpu, etc...)
ch... | [
"def",
"sync",
"(",
"self",
",",
"command",
",",
"arguments",
",",
"tags",
"=",
"None",
",",
"id",
"=",
"None",
")",
":",
"response",
"=",
"self",
".",
"raw",
"(",
"command",
",",
"arguments",
",",
"tags",
"=",
"tags",
",",
"id",
"=",
"id",
")",
... | Same as self.raw except it do a response.get() waiting for the command execution to finish and reads the result
:param command: Command name to execute supported by the node (ex: core.system, info.cpu, etc...)
check documentation for list of built in commands
:param arguments: A ... | [
"Same",
"as",
"self",
".",
"raw",
"except",
"it",
"do",
"a",
"response",
".",
"get",
"()",
"waiting",
"for",
"the",
"command",
"execution",
"to",
"finish",
"and",
"reads",
"the",
"result",
":",
"param",
"command",
":",
"Command",
"name",
"to",
"execute",... | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L752-L769 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | BaseClient.json | def json(self, command, arguments, tags=None, id=None):
"""
Same as self.sync except it assumes the returned result is json, and loads the payload of the return object
if the returned (data) is not of level (20) an error is raised.
:Return: Data
"""
result = self.sync(com... | python | def json(self, command, arguments, tags=None, id=None):
"""
Same as self.sync except it assumes the returned result is json, and loads the payload of the return object
if the returned (data) is not of level (20) an error is raised.
:Return: Data
"""
result = self.sync(com... | [
"def",
"json",
"(",
"self",
",",
"command",
",",
"arguments",
",",
"tags",
"=",
"None",
",",
"id",
"=",
"None",
")",
":",
"result",
"=",
"self",
".",
"sync",
"(",
"command",
",",
"arguments",
",",
"tags",
"=",
"tags",
",",
"id",
"=",
"id",
")",
... | Same as self.sync except it assumes the returned result is json, and loads the payload of the return object
if the returned (data) is not of level (20) an error is raised.
:Return: Data | [
"Same",
"as",
"self",
".",
"sync",
"except",
"it",
"assumes",
"the",
"returned",
"result",
"is",
"json",
"and",
"loads",
"the",
"payload",
"of",
"the",
"return",
"object",
"if",
"the",
"returned",
"(",
"data",
")",
"is",
"not",
"of",
"level",
"(",
"20"... | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L771-L781 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | BaseClient.system | def system(self, command, dir='', stdin='', env=None, queue=None, max_time=None, stream=False, tags=None, id=None):
"""
Execute a command
:param command: command to execute (with its arguments) ex: `ls -l /root`
:param dir: CWD of command
:param stdin: Stdin data to feed to the... | python | def system(self, command, dir='', stdin='', env=None, queue=None, max_time=None, stream=False, tags=None, id=None):
"""
Execute a command
:param command: command to execute (with its arguments) ex: `ls -l /root`
:param dir: CWD of command
:param stdin: Stdin data to feed to the... | [
"def",
"system",
"(",
"self",
",",
"command",
",",
"dir",
"=",
"''",
",",
"stdin",
"=",
"''",
",",
"env",
"=",
"None",
",",
"queue",
"=",
"None",
",",
"max_time",
"=",
"None",
",",
"stream",
"=",
"False",
",",
"tags",
"=",
"None",
",",
"id",
"=... | Execute a command
:param command: command to execute (with its arguments) ex: `ls -l /root`
:param dir: CWD of command
:param stdin: Stdin data to feed to the command stdin
:param env: dict with ENV variables that will be exported to the command
:param id: job id. Auto generate... | [
"Execute",
"a",
"command"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L791-L818 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | BaseClient.bash | def bash(self, script, stdin='', queue=None, max_time=None, stream=False, tags=None, id=None):
"""
Execute a bash script, or run a process inside a bash shell.
:param script: Script to execute (can be multiline script)
:param stdin: Stdin data to feed to the script
:param id: jo... | python | def bash(self, script, stdin='', queue=None, max_time=None, stream=False, tags=None, id=None):
"""
Execute a bash script, or run a process inside a bash shell.
:param script: Script to execute (can be multiline script)
:param stdin: Stdin data to feed to the script
:param id: jo... | [
"def",
"bash",
"(",
"self",
",",
"script",
",",
"stdin",
"=",
"''",
",",
"queue",
"=",
"None",
",",
"max_time",
"=",
"None",
",",
"stream",
"=",
"False",
",",
"tags",
"=",
"None",
",",
"id",
"=",
"None",
")",
":",
"args",
"=",
"{",
"'script'",
... | Execute a bash script, or run a process inside a bash shell.
:param script: Script to execute (can be multiline script)
:param stdin: Stdin data to feed to the script
:param id: job id. Auto generated if not defined.
:return: | [
"Execute",
"a",
"bash",
"script",
"or",
"run",
"a",
"process",
"inside",
"a",
"bash",
"shell",
"."
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L820-L837 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | BaseClient.subscribe | def subscribe(self, job, id=None):
"""
Subscribes to job logs. It return the subscribe Response object which you will need to call .stream() on
to read the output stream of this job.
Calling subscribe multiple times will cause different subscriptions on the same job, each subscription w... | python | def subscribe(self, job, id=None):
"""
Subscribes to job logs. It return the subscribe Response object which you will need to call .stream() on
to read the output stream of this job.
Calling subscribe multiple times will cause different subscriptions on the same job, each subscription w... | [
"def",
"subscribe",
"(",
"self",
",",
"job",
",",
"id",
"=",
"None",
")",
":",
"return",
"self",
".",
"raw",
"(",
"'core.subscribe'",
",",
"{",
"'id'",
":",
"job",
"}",
",",
"stream",
"=",
"True",
",",
"id",
"=",
"id",
")"
] | Subscribes to job logs. It return the subscribe Response object which you will need to call .stream() on
to read the output stream of this job.
Calling subscribe multiple times will cause different subscriptions on the same job, each subscription will
have a copy of this job streams.
N... | [
"Subscribes",
"to",
"job",
"logs",
".",
"It",
"return",
"the",
"subscribe",
"Response",
"object",
"which",
"you",
"will",
"need",
"to",
"call",
".",
"stream",
"()",
"on",
"to",
"read",
"the",
"output",
"stream",
"of",
"this",
"job",
"."
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L839-L876 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | ContainerClient.raw | def raw(self, command, arguments, queue=None, max_time=None, stream=False, tags=None, id=None):
"""
Implements the low level command call, this needs to build the command structure
and push it on the correct queue.
:param command: Command name to execute supported by the node (ex: core.... | python | def raw(self, command, arguments, queue=None, max_time=None, stream=False, tags=None, id=None):
"""
Implements the low level command call, this needs to build the command structure
and push it on the correct queue.
:param command: Command name to execute supported by the node (ex: core.... | [
"def",
"raw",
"(",
"self",
",",
"command",
",",
"arguments",
",",
"queue",
"=",
"None",
",",
"max_time",
"=",
"None",
",",
"stream",
"=",
"False",
",",
"tags",
"=",
"None",
",",
"id",
"=",
"None",
")",
":",
"args",
"=",
"{",
"'container'",
":",
"... | Implements the low level command call, this needs to build the command structure
and push it on the correct queue.
:param command: Command name to execute supported by the node (ex: core.system, info.cpu, etc...)
check documentation for list of built in commands
:param a... | [
"Implements",
"the",
"low",
"level",
"command",
"call",
"this",
"needs",
"to",
"build",
"the",
"command",
"structure",
"and",
"push",
"it",
"on",
"the",
"correct",
"queue",
"."
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L927-L966 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | ContainerManager.create | def create(self, root_url, mount=None, host_network=False, nics=DefaultNetworking, port=None,
hostname=None, privileged=False, storage=None, name=None, tags=None, identity=None, env=None,
cgroups=None):
"""
Creater a new container with the given root flist, mount points and
zerot... | python | def create(self, root_url, mount=None, host_network=False, nics=DefaultNetworking, port=None,
hostname=None, privileged=False, storage=None, name=None, tags=None, identity=None, env=None,
cgroups=None):
"""
Creater a new container with the given root flist, mount points and
zerot... | [
"def",
"create",
"(",
"self",
",",
"root_url",
",",
"mount",
"=",
"None",
",",
"host_network",
"=",
"False",
",",
"nics",
"=",
"DefaultNetworking",
",",
"port",
"=",
"None",
",",
"hostname",
"=",
"None",
",",
"privileged",
"=",
"False",
",",
"storage",
... | Creater a new container with the given root flist, mount points and
zerotier id, and connected to the given bridges
:param root_url: The root filesystem flist
:param mount: a dict with {host_source: container_target} mount points.
where host_source directory must exists.
... | [
"Creater",
"a",
"new",
"container",
"with",
"the",
"given",
"root",
"flist",
"mount",
"points",
"and",
"zerotier",
"id",
"and",
"connected",
"to",
"the",
"given",
"bridges",
":",
"param",
"root_url",
":",
"The",
"root",
"filesystem",
"flist",
":",
"param",
... | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L1034-L1108 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | ContainerManager.find | def find(self, *tags):
"""
Find containers that matches set of tags
:param tags:
:return:
"""
tags = list(map(str, tags))
return self._client.json('corex.find', {'tags': tags}) | python | def find(self, *tags):
"""
Find containers that matches set of tags
:param tags:
:return:
"""
tags = list(map(str, tags))
return self._client.json('corex.find', {'tags': tags}) | [
"def",
"find",
"(",
"self",
",",
"*",
"tags",
")",
":",
"tags",
"=",
"list",
"(",
"map",
"(",
"str",
",",
"tags",
")",
")",
"return",
"self",
".",
"_client",
".",
"json",
"(",
"'corex.find'",
",",
"{",
"'tags'",
":",
"tags",
"}",
")"
] | Find containers that matches set of tags
:param tags:
:return: | [
"Find",
"containers",
"that",
"matches",
"set",
"of",
"tags",
":",
"param",
"tags",
":",
":",
"return",
":"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L1117-L1124 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | ContainerManager.terminate | def terminate(self, container):
"""
Terminate a container given it's id
:param container: container id
:return:
"""
self._client_chk.check(container)
args = {
'container': int(container),
}
response = self._client.raw('corex.terminate'... | python | def terminate(self, container):
"""
Terminate a container given it's id
:param container: container id
:return:
"""
self._client_chk.check(container)
args = {
'container': int(container),
}
response = self._client.raw('corex.terminate'... | [
"def",
"terminate",
"(",
"self",
",",
"container",
")",
":",
"self",
".",
"_client_chk",
".",
"check",
"(",
"container",
")",
"args",
"=",
"{",
"'container'",
":",
"int",
"(",
"container",
")",
",",
"}",
"response",
"=",
"self",
".",
"_client",
".",
... | Terminate a container given it's id
:param container: container id
:return: | [
"Terminate",
"a",
"container",
"given",
"it",
"s",
"id"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L1126-L1141 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | ContainerManager.nic_add | def nic_add(self, container, nic):
"""
Hot plug a nic into a container
:param container: container ID
:param nic: {
'type': nic_type # one of default, bridge, zerotier, macvlan, passthrough, vlan, or vxlan (note, vlan and vxlan only supported by ovs)
... | python | def nic_add(self, container, nic):
"""
Hot plug a nic into a container
:param container: container ID
:param nic: {
'type': nic_type # one of default, bridge, zerotier, macvlan, passthrough, vlan, or vxlan (note, vlan and vxlan only supported by ovs)
... | [
"def",
"nic_add",
"(",
"self",
",",
"container",
",",
"nic",
")",
":",
"args",
"=",
"{",
"'container'",
":",
"container",
",",
"'nic'",
":",
"nic",
"}",
"self",
".",
"_nic_add",
".",
"check",
"(",
"args",
")",
"return",
"self",
".",
"_client",
".",
... | Hot plug a nic into a container
:param container: container ID
:param nic: {
'type': nic_type # one of default, bridge, zerotier, macvlan, passthrough, vlan, or vxlan (note, vlan and vxlan only supported by ovs)
'id': id # depends on the type
... | [
"Hot",
"plug",
"a",
"nic",
"into",
"a",
"container"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L1143-L1174 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | ContainerManager.nic_remove | def nic_remove(self, container, index):
"""
Hot unplug of nic from a container
Note: removing a nic, doesn't remove the nic from the container info object, instead it sets it's state
to `destroyed`.
:param container: container ID
:param index: index of the nic as return... | python | def nic_remove(self, container, index):
"""
Hot unplug of nic from a container
Note: removing a nic, doesn't remove the nic from the container info object, instead it sets it's state
to `destroyed`.
:param container: container ID
:param index: index of the nic as return... | [
"def",
"nic_remove",
"(",
"self",
",",
"container",
",",
"index",
")",
":",
"args",
"=",
"{",
"'container'",
":",
"container",
",",
"'index'",
":",
"index",
"}",
"self",
".",
"_nic_remove",
".",
"check",
"(",
"args",
")",
"return",
"self",
".",
"_clien... | Hot unplug of nic from a container
Note: removing a nic, doesn't remove the nic from the container info object, instead it sets it's state
to `destroyed`.
:param container: container ID
:param index: index of the nic as returned in the container object info (as shown by container.list(... | [
"Hot",
"unplug",
"of",
"nic",
"from",
"a",
"container"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L1176-L1193 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | ContainerManager.client | def client(self, container):
"""
Return a client instance that is bound to that container.
:param container: container id
:return: Client object bound to the specified container id
Return a ContainerResponse from container.create
"""
self._client_chk.check(conta... | python | def client(self, container):
"""
Return a client instance that is bound to that container.
:param container: container id
:return: Client object bound to the specified container id
Return a ContainerResponse from container.create
"""
self._client_chk.check(conta... | [
"def",
"client",
"(",
"self",
",",
"container",
")",
":",
"self",
".",
"_client_chk",
".",
"check",
"(",
"container",
")",
"return",
"ContainerClient",
"(",
"self",
".",
"_client",
",",
"int",
"(",
"container",
")",
")"
] | Return a client instance that is bound to that container.
:param container: container id
:return: Client object bound to the specified container id
Return a ContainerResponse from container.create | [
"Return",
"a",
"client",
"instance",
"that",
"is",
"bound",
"to",
"that",
"container",
"."
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L1195-L1205 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | ContainerManager.backup | def backup(self, container, url):
"""
Backup a container to the given restic url
all restic urls are supported
:param container:
:param url: Url to restic repo
examples
(file:///path/to/restic/?password=<password>)
:return: Json response ... | python | def backup(self, container, url):
"""
Backup a container to the given restic url
all restic urls are supported
:param container:
:param url: Url to restic repo
examples
(file:///path/to/restic/?password=<password>)
:return: Json response ... | [
"def",
"backup",
"(",
"self",
",",
"container",
",",
"url",
")",
":",
"args",
"=",
"{",
"'container'",
":",
"container",
",",
"'url'",
":",
"url",
",",
"}",
"return",
"JSONResponse",
"(",
"self",
".",
"_client",
".",
"raw",
"(",
"'corex.backup'",
",",
... | Backup a container to the given restic url
all restic urls are supported
:param container:
:param url: Url to restic repo
examples
(file:///path/to/restic/?password=<password>)
:return: Json response to the backup job (do .get() to get the snapshot ID | [
"Backup",
"a",
"container",
"to",
"the",
"given",
"restic",
"url",
"all",
"restic",
"urls",
"are",
"supported"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L1207-L1225 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | ContainerManager.restore | def restore(self, url, tags=None):
"""
Full restore of a container backup. This restore method will recreate
an exact copy of the backedup container (including same network setup, and other
configurations as defined by the `create` method.
To just restore the container data, and... | python | def restore(self, url, tags=None):
"""
Full restore of a container backup. This restore method will recreate
an exact copy of the backedup container (including same network setup, and other
configurations as defined by the `create` method.
To just restore the container data, and... | [
"def",
"restore",
"(",
"self",
",",
"url",
",",
"tags",
"=",
"None",
")",
":",
"args",
"=",
"{",
"'url'",
":",
"url",
",",
"}",
"return",
"JSONResponse",
"(",
"self",
".",
"_client",
".",
"raw",
"(",
"'corex.restore'",
",",
"args",
",",
"tags",
"="... | Full restore of a container backup. This restore method will recreate
an exact copy of the backedup container (including same network setup, and other
configurations as defined by the `create` method.
To just restore the container data, and use new configuration, use the create method instead
... | [
"Full",
"restore",
"of",
"a",
"container",
"backup",
".",
"This",
"restore",
"method",
"will",
"recreate",
"an",
"exact",
"copy",
"of",
"the",
"backedup",
"container",
"(",
"including",
"same",
"network",
"setup",
"and",
"other",
"configurations",
"as",
"defin... | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L1227-L1246 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | BridgeManager.create | def create(self, name, hwaddr=None, network=None, nat=False, settings={}):
"""
Create a bridge with the given name, hwaddr and networking setup
:param name: name of the bridge (must be unique), 15 characters or less, and not equal to "default".
:param hwaddr: MAC address of the bridge. I... | python | def create(self, name, hwaddr=None, network=None, nat=False, settings={}):
"""
Create a bridge with the given name, hwaddr and networking setup
:param name: name of the bridge (must be unique), 15 characters or less, and not equal to "default".
:param hwaddr: MAC address of the bridge. I... | [
"def",
"create",
"(",
"self",
",",
"name",
",",
"hwaddr",
"=",
"None",
",",
"network",
"=",
"None",
",",
"nat",
"=",
"False",
",",
"settings",
"=",
"{",
"}",
")",
":",
"args",
"=",
"{",
"'name'",
":",
"name",
",",
"'hwaddr'",
":",
"hwaddr",
",",
... | Create a bridge with the given name, hwaddr and networking setup
:param name: name of the bridge (must be unique), 15 characters or less, and not equal to "default".
:param hwaddr: MAC address of the bridge. If none, a one will be created for u
:param network: Networking mode, options are none, ... | [
"Create",
"a",
"bridge",
"with",
"the",
"given",
"name",
"hwaddr",
"and",
"networking",
"setup",
":",
"param",
"name",
":",
"name",
"of",
"the",
"bridge",
"(",
"must",
"be",
"unique",
")",
"15",
"characters",
"or",
"less",
"and",
"not",
"equal",
"to",
... | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L1520-L1554 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | BridgeManager.delete | def delete(self, bridge):
"""
Delete a bridge by name
:param bridge: bridge name
:return:
"""
args = {
'name': bridge,
}
self._bridge_chk.check(args)
return self._client.json('bridge.delete', args) | python | def delete(self, bridge):
"""
Delete a bridge by name
:param bridge: bridge name
:return:
"""
args = {
'name': bridge,
}
self._bridge_chk.check(args)
return self._client.json('bridge.delete', args) | [
"def",
"delete",
"(",
"self",
",",
"bridge",
")",
":",
"args",
"=",
"{",
"'name'",
":",
"bridge",
",",
"}",
"self",
".",
"_bridge_chk",
".",
"check",
"(",
"args",
")",
"return",
"self",
".",
"_client",
".",
"json",
"(",
"'bridge.delete'",
",",
"args"... | Delete a bridge by name
:param bridge: bridge name
:return: | [
"Delete",
"a",
"bridge",
"by",
"name"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L1563-L1576 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | BridgeManager.nic_add | def nic_add(self, bridge, nic):
"""
Attach a nic to a bridge
:param bridge: bridge name
:param nic: nic name
"""
args = {
'name': bridge,
'nic': nic,
}
self._nic_add_chk.check(args)
return self._client.json('bridge.nic-a... | python | def nic_add(self, bridge, nic):
"""
Attach a nic to a bridge
:param bridge: bridge name
:param nic: nic name
"""
args = {
'name': bridge,
'nic': nic,
}
self._nic_add_chk.check(args)
return self._client.json('bridge.nic-a... | [
"def",
"nic_add",
"(",
"self",
",",
"bridge",
",",
"nic",
")",
":",
"args",
"=",
"{",
"'name'",
":",
"bridge",
",",
"'nic'",
":",
"nic",
",",
"}",
"self",
".",
"_nic_add_chk",
".",
"check",
"(",
"args",
")",
"return",
"self",
".",
"_client",
".",
... | Attach a nic to a bridge
:param bridge: bridge name
:param nic: nic name | [
"Attach",
"a",
"nic",
"to",
"a",
"bridge"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L1578-L1593 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | BridgeManager.nic_remove | def nic_remove(self, nic):
"""
Detach a nic from a bridge
:param nic: nic name to detach
"""
args = {
'nic': nic,
}
self._nic_remove_chk.check(args)
return self._client.json('bridge.nic-remove', args) | python | def nic_remove(self, nic):
"""
Detach a nic from a bridge
:param nic: nic name to detach
"""
args = {
'nic': nic,
}
self._nic_remove_chk.check(args)
return self._client.json('bridge.nic-remove', args) | [
"def",
"nic_remove",
"(",
"self",
",",
"nic",
")",
":",
"args",
"=",
"{",
"'nic'",
":",
"nic",
",",
"}",
"self",
".",
"_nic_remove_chk",
".",
"check",
"(",
"args",
")",
"return",
"self",
".",
"_client",
".",
"json",
"(",
"'bridge.nic-remove'",
",",
"... | Detach a nic from a bridge
:param nic: nic name to detach | [
"Detach",
"a",
"nic",
"from",
"a",
"bridge"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L1595-L1608 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | BridgeManager.nic_list | def nic_list(self, bridge):
"""
List nics attached to bridge
:param bridge: bridge name
"""
args = {
'name': bridge,
}
self._bridge_chk.check(args)
return self._client.json('bridge.nic-list', args) | python | def nic_list(self, bridge):
"""
List nics attached to bridge
:param bridge: bridge name
"""
args = {
'name': bridge,
}
self._bridge_chk.check(args)
return self._client.json('bridge.nic-list', args) | [
"def",
"nic_list",
"(",
"self",
",",
"bridge",
")",
":",
"args",
"=",
"{",
"'name'",
":",
"bridge",
",",
"}",
"self",
".",
"_bridge_chk",
".",
"check",
"(",
"args",
")",
"return",
"self",
".",
"_client",
".",
"json",
"(",
"'bridge.nic-list'",
",",
"a... | List nics attached to bridge
:param bridge: bridge name | [
"List",
"nics",
"attached",
"to",
"bridge"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L1610-L1623 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | DiskManager.list | def list(self):
"""
List available block devices
"""
response = self._client.raw('disk.list', {})
result = response.get()
if result.state != 'SUCCESS':
raise RuntimeError('failed to list disks: %s' % result.stderr)
if result.level != 20: # 20 is JS... | python | def list(self):
"""
List available block devices
"""
response = self._client.raw('disk.list', {})
result = response.get()
if result.state != 'SUCCESS':
raise RuntimeError('failed to list disks: %s' % result.stderr)
if result.level != 20: # 20 is JS... | [
"def",
"list",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"_client",
".",
"raw",
"(",
"'disk.list'",
",",
"{",
"}",
")",
"result",
"=",
"response",
".",
"get",
"(",
")",
"if",
"result",
".",
"state",
"!=",
"'SUCCESS'",
":",
"raise",
"Runt... | List available block devices | [
"List",
"available",
"block",
"devices"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L1670-L1688 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | DiskManager.mktable | def mktable(self, disk, table_type='gpt'):
"""
Make partition table on block device.
:param disk: device path (/dev/sda, /dev/disk/by-id/ata-Samsung..., etc...)
:param table_type: Partition table type as accepted by parted
"""
args = {
'disk': disk,
... | python | def mktable(self, disk, table_type='gpt'):
"""
Make partition table on block device.
:param disk: device path (/dev/sda, /dev/disk/by-id/ata-Samsung..., etc...)
:param table_type: Partition table type as accepted by parted
"""
args = {
'disk': disk,
... | [
"def",
"mktable",
"(",
"self",
",",
"disk",
",",
"table_type",
"=",
"'gpt'",
")",
":",
"args",
"=",
"{",
"'disk'",
":",
"disk",
",",
"'table_type'",
":",
"table_type",
",",
"}",
"self",
".",
"_mktable_chk",
".",
"check",
"(",
"args",
")",
"response",
... | Make partition table on block device.
:param disk: device path (/dev/sda, /dev/disk/by-id/ata-Samsung..., etc...)
:param table_type: Partition table type as accepted by parted | [
"Make",
"partition",
"table",
"on",
"block",
"device",
".",
":",
"param",
"disk",
":",
"device",
"path",
"(",
"/",
"dev",
"/",
"sda",
"/",
"dev",
"/",
"disk",
"/",
"by",
"-",
"id",
"/",
"ata",
"-",
"Samsung",
"...",
"etc",
"...",
")",
":",
"param... | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L1690-L1708 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | DiskManager.getinfo | def getinfo(self, disk, part=''):
"""
Get more info about a disk or a disk partition
:param disk: (/dev/sda, /dev/sdb, etc..)
:param part: (/dev/sda1, /dev/sdb2, etc...)
:return: a dict with {"blocksize", "start", "size", and "free" sections}
"""
args = {
... | python | def getinfo(self, disk, part=''):
"""
Get more info about a disk or a disk partition
:param disk: (/dev/sda, /dev/sdb, etc..)
:param part: (/dev/sda1, /dev/sdb2, etc...)
:return: a dict with {"blocksize", "start", "size", and "free" sections}
"""
args = {
... | [
"def",
"getinfo",
"(",
"self",
",",
"disk",
",",
"part",
"=",
"''",
")",
":",
"args",
"=",
"{",
"\"disk\"",
":",
"disk",
",",
"\"part\"",
":",
"part",
",",
"}",
"self",
".",
"_getpart_chk",
".",
"check",
"(",
"args",
")",
"response",
"=",
"self",
... | Get more info about a disk or a disk partition
:param disk: (/dev/sda, /dev/sdb, etc..)
:param part: (/dev/sda1, /dev/sdb2, etc...)
:return: a dict with {"blocksize", "start", "size", and "free" sections} | [
"Get",
"more",
"info",
"about",
"a",
"disk",
"or",
"a",
"disk",
"partition"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L1710-L1739 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | DiskManager.mkpart | def mkpart(self, disk, start, end, part_type='primary'):
"""
Make partition on disk
:param disk: device path (/dev/sda, /dev/sdb, etc...)
:param start: partition start as accepted by parted mkpart
:param end: partition end as accepted by parted mkpart
:param part_type: pa... | python | def mkpart(self, disk, start, end, part_type='primary'):
"""
Make partition on disk
:param disk: device path (/dev/sda, /dev/sdb, etc...)
:param start: partition start as accepted by parted mkpart
:param end: partition end as accepted by parted mkpart
:param part_type: pa... | [
"def",
"mkpart",
"(",
"self",
",",
"disk",
",",
"start",
",",
"end",
",",
"part_type",
"=",
"'primary'",
")",
":",
"args",
"=",
"{",
"'disk'",
":",
"disk",
",",
"'start'",
":",
"start",
",",
"'end'",
":",
"end",
",",
"'part_type'",
":",
"part_type",
... | Make partition on disk
:param disk: device path (/dev/sda, /dev/sdb, etc...)
:param start: partition start as accepted by parted mkpart
:param end: partition end as accepted by parted mkpart
:param part_type: partition type as accepted by parted mkpart | [
"Make",
"partition",
"on",
"disk",
":",
"param",
"disk",
":",
"device",
"path",
"(",
"/",
"dev",
"/",
"sda",
"/",
"dev",
"/",
"sdb",
"etc",
"...",
")",
":",
"param",
"start",
":",
"partition",
"start",
"as",
"accepted",
"by",
"parted",
"mkpart",
":",... | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L1741-L1763 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | DiskManager.rmpart | def rmpart(self, disk, number):
"""
Remove partion from disk
:param disk: device path (/dev/sda, /dev/sdb, etc...)
:param number: Partition number (starting from 1)
"""
args = {
'disk': disk,
'number': number,
}
self._rmpart_chk.ch... | python | def rmpart(self, disk, number):
"""
Remove partion from disk
:param disk: device path (/dev/sda, /dev/sdb, etc...)
:param number: Partition number (starting from 1)
"""
args = {
'disk': disk,
'number': number,
}
self._rmpart_chk.ch... | [
"def",
"rmpart",
"(",
"self",
",",
"disk",
",",
"number",
")",
":",
"args",
"=",
"{",
"'disk'",
":",
"disk",
",",
"'number'",
":",
"number",
",",
"}",
"self",
".",
"_rmpart_chk",
".",
"check",
"(",
"args",
")",
"response",
"=",
"self",
".",
"_clien... | Remove partion from disk
:param disk: device path (/dev/sda, /dev/sdb, etc...)
:param number: Partition number (starting from 1) | [
"Remove",
"partion",
"from",
"disk",
":",
"param",
"disk",
":",
"device",
"path",
"(",
"/",
"dev",
"/",
"sda",
"/",
"dev",
"/",
"sdb",
"etc",
"...",
")",
":",
"param",
"number",
":",
"Partition",
"number",
"(",
"starting",
"from",
"1",
")"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L1765-L1783 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | DiskManager.mount | def mount(self, source, target, options=[]):
"""
Mount partion on target
:param source: Full partition path like /dev/sda1
:param target: Mount point
:param options: Optional mount options
"""
if len(options) == 0:
options = ['']
args = {
... | python | def mount(self, source, target, options=[]):
"""
Mount partion on target
:param source: Full partition path like /dev/sda1
:param target: Mount point
:param options: Optional mount options
"""
if len(options) == 0:
options = ['']
args = {
... | [
"def",
"mount",
"(",
"self",
",",
"source",
",",
"target",
",",
"options",
"=",
"[",
"]",
")",
":",
"if",
"len",
"(",
"options",
")",
"==",
"0",
":",
"options",
"=",
"[",
"''",
"]",
"args",
"=",
"{",
"'options'",
":",
"','",
".",
"join",
"(",
... | Mount partion on target
:param source: Full partition path like /dev/sda1
:param target: Mount point
:param options: Optional mount options | [
"Mount",
"partion",
"on",
"target",
":",
"param",
"source",
":",
"Full",
"partition",
"path",
"like",
"/",
"dev",
"/",
"sda1",
":",
"param",
"target",
":",
"Mount",
"point",
":",
"param",
"options",
":",
"Optional",
"mount",
"options"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L1785-L1808 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | DiskManager.umount | def umount(self, source):
"""
Unmount partion
:param source: Full partition path like /dev/sda1
"""
args = {
'source': source,
}
self._umount_chk.check(args)
response = self._client.raw('disk.umount', args)
result = response.get()
... | python | def umount(self, source):
"""
Unmount partion
:param source: Full partition path like /dev/sda1
"""
args = {
'source': source,
}
self._umount_chk.check(args)
response = self._client.raw('disk.umount', args)
result = response.get()
... | [
"def",
"umount",
"(",
"self",
",",
"source",
")",
":",
"args",
"=",
"{",
"'source'",
":",
"source",
",",
"}",
"self",
".",
"_umount_chk",
".",
"check",
"(",
"args",
")",
"response",
"=",
"self",
".",
"_client",
".",
"raw",
"(",
"'disk.umount'",
",",
... | Unmount partion
:param source: Full partition path like /dev/sda1 | [
"Unmount",
"partion",
":",
"param",
"source",
":",
"Full",
"partition",
"path",
"like",
"/",
"dev",
"/",
"sda1"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L1810-L1826 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | DiskManager.spindown | def spindown(self, disk, spindown=1):
"""
Spindown a disk
:param disk str: Full path to a disk like /dev/sda
:param spindown int: spindown value should be in [1, 240]
"""
args = {
"disk": disk,
"spindown": spindown
}
self._spindown_... | python | def spindown(self, disk, spindown=1):
"""
Spindown a disk
:param disk str: Full path to a disk like /dev/sda
:param spindown int: spindown value should be in [1, 240]
"""
args = {
"disk": disk,
"spindown": spindown
}
self._spindown_... | [
"def",
"spindown",
"(",
"self",
",",
"disk",
",",
"spindown",
"=",
"1",
")",
":",
"args",
"=",
"{",
"\"disk\"",
":",
"disk",
",",
"\"spindown\"",
":",
"spindown",
"}",
"self",
".",
"_spindown_chk",
".",
"check",
"(",
"args",
")",
"response",
"=",
"se... | Spindown a disk
:param disk str: Full path to a disk like /dev/sda
:param spindown int: spindown value should be in [1, 240] | [
"Spindown",
"a",
"disk",
":",
"param",
"disk",
"str",
":",
"Full",
"path",
"to",
"a",
"disk",
"like",
"/",
"dev",
"/",
"sda",
":",
"param",
"spindown",
"int",
":",
"spindown",
"value",
"should",
"be",
"in",
"[",
"1",
"240",
"]"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L1828-L1843 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | DiskManager.seektime | def seektime(self, disk):
"""
Gives seek latency on disk which is a very good indication to the `type` of the disk.
it's a very good way to verify if the underlying disk type is SSD or HDD
:param disk: disk path or name (/dev/sda, or sda)
:return: a dict as follows {'device': '<... | python | def seektime(self, disk):
"""
Gives seek latency on disk which is a very good indication to the `type` of the disk.
it's a very good way to verify if the underlying disk type is SSD or HDD
:param disk: disk path or name (/dev/sda, or sda)
:return: a dict as follows {'device': '<... | [
"def",
"seektime",
"(",
"self",
",",
"disk",
")",
":",
"args",
"=",
"{",
"'disk'",
":",
"disk",
",",
"}",
"self",
".",
"_seektime_chk",
".",
"check",
"(",
"args",
")",
"return",
"self",
".",
"_client",
".",
"json",
"(",
"\"disk.seektime\"",
",",
"arg... | Gives seek latency on disk which is a very good indication to the `type` of the disk.
it's a very good way to verify if the underlying disk type is SSD or HDD
:param disk: disk path or name (/dev/sda, or sda)
:return: a dict as follows {'device': '<device-path>', 'elapsed': <seek-time in us', '... | [
"Gives",
"seek",
"latency",
"on",
"disk",
"which",
"is",
"a",
"very",
"good",
"indication",
"to",
"the",
"type",
"of",
"the",
"disk",
".",
"it",
"s",
"a",
"very",
"good",
"way",
"to",
"verify",
"if",
"the",
"underlying",
"disk",
"type",
"is",
"SSD",
... | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L1845-L1859 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | BtrfsManager.create | def create(self, label, devices, metadata_profile="", data_profile="", overwrite=False):
"""
Create a btrfs filesystem with the given label, devices, and profiles
:param label: name/label
:param devices : array of devices (/dev/sda1, etc...)
:metadata_profile: raid0, raid1, raid5... | python | def create(self, label, devices, metadata_profile="", data_profile="", overwrite=False):
"""
Create a btrfs filesystem with the given label, devices, and profiles
:param label: name/label
:param devices : array of devices (/dev/sda1, etc...)
:metadata_profile: raid0, raid1, raid5... | [
"def",
"create",
"(",
"self",
",",
"label",
",",
"devices",
",",
"metadata_profile",
"=",
"\"\"",
",",
"data_profile",
"=",
"\"\"",
",",
"overwrite",
"=",
"False",
")",
":",
"args",
"=",
"{",
"'label'",
":",
"label",
",",
"'metadata'",
":",
"metadata_pro... | Create a btrfs filesystem with the given label, devices, and profiles
:param label: name/label
:param devices : array of devices (/dev/sda1, etc...)
:metadata_profile: raid0, raid1, raid5, raid6, raid10, dup or single
:data_profile: same as metadata profile
:overwrite: force crea... | [
"Create",
"a",
"btrfs",
"filesystem",
"with",
"the",
"given",
"label",
"devices",
"and",
"profiles",
":",
"param",
"label",
":",
"name",
"/",
"label",
":",
"param",
"devices",
":",
"array",
"of",
"devices",
"(",
"/",
"dev",
"/",
"sda1",
"etc",
"...",
"... | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L1906-L1925 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | BtrfsManager.device_add | def device_add(self, mountpoint, *device):
"""
Add one or more devices to btrfs filesystem mounted under `mountpoint`
:param mountpoint: mount point of the btrfs system
:param devices: one ore more devices to add
:return:
"""
if len(device) == 0:
retu... | python | def device_add(self, mountpoint, *device):
"""
Add one or more devices to btrfs filesystem mounted under `mountpoint`
:param mountpoint: mount point of the btrfs system
:param devices: one ore more devices to add
:return:
"""
if len(device) == 0:
retu... | [
"def",
"device_add",
"(",
"self",
",",
"mountpoint",
",",
"*",
"device",
")",
":",
"if",
"len",
"(",
"device",
")",
"==",
"0",
":",
"return",
"args",
"=",
"{",
"'mountpoint'",
":",
"mountpoint",
",",
"'devices'",
":",
"device",
",",
"}",
"self",
".",... | Add one or more devices to btrfs filesystem mounted under `mountpoint`
:param mountpoint: mount point of the btrfs system
:param devices: one ore more devices to add
:return: | [
"Add",
"one",
"or",
"more",
"devices",
"to",
"btrfs",
"filesystem",
"mounted",
"under",
"mountpoint"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L1927-L1945 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | BtrfsManager.subvol_create | def subvol_create(self, path):
"""
Create a btrfs subvolume in the specified path
:param path: path to create
"""
args = {
'path': path
}
self._subvol_chk.check(args)
self._client.sync('btrfs.subvol_create', args) | python | def subvol_create(self, path):
"""
Create a btrfs subvolume in the specified path
:param path: path to create
"""
args = {
'path': path
}
self._subvol_chk.check(args)
self._client.sync('btrfs.subvol_create', args) | [
"def",
"subvol_create",
"(",
"self",
",",
"path",
")",
":",
"args",
"=",
"{",
"'path'",
":",
"path",
"}",
"self",
".",
"_subvol_chk",
".",
"check",
"(",
"args",
")",
"self",
".",
"_client",
".",
"sync",
"(",
"'btrfs.subvol_create'",
",",
"args",
")"
] | Create a btrfs subvolume in the specified path
:param path: path to create | [
"Create",
"a",
"btrfs",
"subvolume",
"in",
"the",
"specified",
"path",
":",
"param",
"path",
":",
"path",
"to",
"create"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L1967-L1976 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | BtrfsManager.subvol_delete | def subvol_delete(self, path):
"""
Delete a btrfs subvolume in the specified path
:param path: path to delete
"""
args = {
'path': path
}
self._subvol_chk.check(args)
self._client.sync('btrfs.subvol_delete', args) | python | def subvol_delete(self, path):
"""
Delete a btrfs subvolume in the specified path
:param path: path to delete
"""
args = {
'path': path
}
self._subvol_chk.check(args)
self._client.sync('btrfs.subvol_delete', args) | [
"def",
"subvol_delete",
"(",
"self",
",",
"path",
")",
":",
"args",
"=",
"{",
"'path'",
":",
"path",
"}",
"self",
".",
"_subvol_chk",
".",
"check",
"(",
"args",
")",
"self",
".",
"_client",
".",
"sync",
"(",
"'btrfs.subvol_delete'",
",",
"args",
")"
] | Delete a btrfs subvolume in the specified path
:param path: path to delete | [
"Delete",
"a",
"btrfs",
"subvolume",
"in",
"the",
"specified",
"path",
":",
"param",
"path",
":",
"path",
"to",
"delete"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L1987-L1998 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | BtrfsManager.subvol_quota | def subvol_quota(self, path, limit):
"""
Apply a quota to a btrfs subvolume in the specified path
:param path: path to apply the quota for (it has to be the path of the subvol)
:param limit: the limit to Apply
"""
args = {
'path': path,
'limit': l... | python | def subvol_quota(self, path, limit):
"""
Apply a quota to a btrfs subvolume in the specified path
:param path: path to apply the quota for (it has to be the path of the subvol)
:param limit: the limit to Apply
"""
args = {
'path': path,
'limit': l... | [
"def",
"subvol_quota",
"(",
"self",
",",
"path",
",",
"limit",
")",
":",
"args",
"=",
"{",
"'path'",
":",
"path",
",",
"'limit'",
":",
"limit",
",",
"}",
"self",
".",
"_subvol_quota_chk",
".",
"check",
"(",
"args",
")",
"self",
".",
"_client",
".",
... | Apply a quota to a btrfs subvolume in the specified path
:param path: path to apply the quota for (it has to be the path of the subvol)
:param limit: the limit to Apply | [
"Apply",
"a",
"quota",
"to",
"a",
"btrfs",
"subvolume",
"in",
"the",
"specified",
"path",
":",
"param",
"path",
":",
"path",
"to",
"apply",
"the",
"quota",
"for",
"(",
"it",
"has",
"to",
"be",
"the",
"path",
"of",
"the",
"subvol",
")",
":",
"param",
... | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L2000-L2013 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | BtrfsManager.subvol_snapshot | def subvol_snapshot(self, source, destination, read_only=False):
"""
Take a snapshot
:param source: source path of subvol
:param destination: destination path of snapshot
:param read_only: Set read-only on the snapshot
:return:
"""
args = {
"... | python | def subvol_snapshot(self, source, destination, read_only=False):
"""
Take a snapshot
:param source: source path of subvol
:param destination: destination path of snapshot
:param read_only: Set read-only on the snapshot
:return:
"""
args = {
"... | [
"def",
"subvol_snapshot",
"(",
"self",
",",
"source",
",",
"destination",
",",
"read_only",
"=",
"False",
")",
":",
"args",
"=",
"{",
"\"source\"",
":",
"source",
",",
"\"destination\"",
":",
"destination",
",",
"\"read_only\"",
":",
"read_only",
",",
"}",
... | Take a snapshot
:param source: source path of subvol
:param destination: destination path of snapshot
:param read_only: Set read-only on the snapshot
:return: | [
"Take",
"a",
"snapshot"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L2015-L2032 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | ZerotierManager.join | def join(self, network):
"""
Join a zerotier network
:param network: network id to join
:return:
"""
args = {'network': network}
self._network_chk.check(args)
response = self._client.raw('zerotier.join', args)
result = response.get()
if r... | python | def join(self, network):
"""
Join a zerotier network
:param network: network id to join
:return:
"""
args = {'network': network}
self._network_chk.check(args)
response = self._client.raw('zerotier.join', args)
result = response.get()
if r... | [
"def",
"join",
"(",
"self",
",",
"network",
")",
":",
"args",
"=",
"{",
"'network'",
":",
"network",
"}",
"self",
".",
"_network_chk",
".",
"check",
"(",
"args",
")",
"response",
"=",
"self",
".",
"_client",
".",
"raw",
"(",
"'zerotier.join'",
",",
"... | Join a zerotier network
:param network: network id to join
:return: | [
"Join",
"a",
"zerotier",
"network"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L2043-L2056 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | KvmManager.create | def create(self, name, media=None, flist=None, cpu=2, memory=512,
nics=None, port=None, mount=None, tags=None, config=None):
"""
:param name: Name of the kvm domain
:param media: (optional) array of media objects to attach to the machine, where the first object is the boot device
... | python | def create(self, name, media=None, flist=None, cpu=2, memory=512,
nics=None, port=None, mount=None, tags=None, config=None):
"""
:param name: Name of the kvm domain
:param media: (optional) array of media objects to attach to the machine, where the first object is the boot device
... | [
"def",
"create",
"(",
"self",
",",
"name",
",",
"media",
"=",
"None",
",",
"flist",
"=",
"None",
",",
"cpu",
"=",
"2",
",",
"memory",
"=",
"512",
",",
"nics",
"=",
"None",
",",
"port",
"=",
"None",
",",
"mount",
"=",
"None",
",",
"tags",
"=",
... | :param name: Name of the kvm domain
:param media: (optional) array of media objects to attach to the machine, where the first object is the boot device
each media object is a dict of {url, type} where type can be one of 'disk', or 'cdrom', or empty (default to disk)
e... | [
":",
"param",
"name",
":",
"Name",
"of",
"the",
"kvm",
"domain",
":",
"param",
"media",
":",
"(",
"optional",
")",
"array",
"of",
"media",
"objects",
"to",
"attach",
"to",
"the",
"machine",
"where",
"the",
"first",
"object",
"is",
"the",
"boot",
"devic... | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L2224-L2282 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | KvmManager.prepare_migration_target | def prepare_migration_target(self, uuid, nics=None, port=None, tags=None):
"""
:param name: Name of the kvm domain that will be migrated
:param port: A dict of host_port: container_port pairs
Example:
`port={8080: 80, 7000:7000}`
... | python | def prepare_migration_target(self, uuid, nics=None, port=None, tags=None):
"""
:param name: Name of the kvm domain that will be migrated
:param port: A dict of host_port: container_port pairs
Example:
`port={8080: 80, 7000:7000}`
... | [
"def",
"prepare_migration_target",
"(",
"self",
",",
"uuid",
",",
"nics",
"=",
"None",
",",
"port",
"=",
"None",
",",
"tags",
"=",
"None",
")",
":",
"if",
"nics",
"is",
"None",
":",
"nics",
"=",
"[",
"]",
"args",
"=",
"{",
"'nics'",
":",
"nics",
... | :param name: Name of the kvm domain that will be migrated
:param port: A dict of host_port: container_port pairs
Example:
`port={8080: 80, 7000:7000}`
Only supported if default network is used
:param nics: Configure the attached nics to... | [
":",
"param",
"name",
":",
"Name",
"of",
"the",
"kvm",
"domain",
"that",
"will",
"be",
"migrated",
":",
"param",
"port",
":",
"A",
"dict",
"of",
"host_port",
":",
"container_port",
"pairs",
"Example",
":",
"port",
"=",
"{",
"8080",
":",
"80",
"7000",
... | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L2284-L2311 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | KvmManager.destroy | def destroy(self, uuid):
"""
Destroy a kvm domain by uuid
:param uuid: uuid of the kvm container (same as the used in create)
:return:
"""
args = {
'uuid': uuid,
}
self._domain_action_chk.check(args)
self._client.sync('kvm.destroy', ar... | python | def destroy(self, uuid):
"""
Destroy a kvm domain by uuid
:param uuid: uuid of the kvm container (same as the used in create)
:return:
"""
args = {
'uuid': uuid,
}
self._domain_action_chk.check(args)
self._client.sync('kvm.destroy', ar... | [
"def",
"destroy",
"(",
"self",
",",
"uuid",
")",
":",
"args",
"=",
"{",
"'uuid'",
":",
"uuid",
",",
"}",
"self",
".",
"_domain_action_chk",
".",
"check",
"(",
"args",
")",
"self",
".",
"_client",
".",
"sync",
"(",
"'kvm.destroy'",
",",
"args",
")"
] | Destroy a kvm domain by uuid
:param uuid: uuid of the kvm container (same as the used in create)
:return: | [
"Destroy",
"a",
"kvm",
"domain",
"by",
"uuid",
":",
"param",
"uuid",
":",
"uuid",
"of",
"the",
"kvm",
"container",
"(",
"same",
"as",
"the",
"used",
"in",
"create",
")",
":",
"return",
":"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L2313-L2324 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | KvmManager.shutdown | def shutdown(self, uuid):
"""
Shutdown a kvm domain by uuid
:param uuid: uuid of the kvm container (same as the used in create)
:return:
"""
args = {
'uuid': uuid,
}
self._domain_action_chk.check(args)
self._client.sync('kvm.shutdown',... | python | def shutdown(self, uuid):
"""
Shutdown a kvm domain by uuid
:param uuid: uuid of the kvm container (same as the used in create)
:return:
"""
args = {
'uuid': uuid,
}
self._domain_action_chk.check(args)
self._client.sync('kvm.shutdown',... | [
"def",
"shutdown",
"(",
"self",
",",
"uuid",
")",
":",
"args",
"=",
"{",
"'uuid'",
":",
"uuid",
",",
"}",
"self",
".",
"_domain_action_chk",
".",
"check",
"(",
"args",
")",
"self",
".",
"_client",
".",
"sync",
"(",
"'kvm.shutdown'",
",",
"args",
")"
... | Shutdown a kvm domain by uuid
:param uuid: uuid of the kvm container (same as the used in create)
:return: | [
"Shutdown",
"a",
"kvm",
"domain",
"by",
"uuid",
":",
"param",
"uuid",
":",
"uuid",
"of",
"the",
"kvm",
"container",
"(",
"same",
"as",
"the",
"used",
"in",
"create",
")",
":",
"return",
":"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L2326-L2337 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | KvmManager.reboot | def reboot(self, uuid):
"""
Reboot a kvm domain by uuid
:param uuid: uuid of the kvm container (same as the used in create)
:return:
"""
args = {
'uuid': uuid,
}
self._domain_action_chk.check(args)
self._client.sync('kvm.reboot', args) | python | def reboot(self, uuid):
"""
Reboot a kvm domain by uuid
:param uuid: uuid of the kvm container (same as the used in create)
:return:
"""
args = {
'uuid': uuid,
}
self._domain_action_chk.check(args)
self._client.sync('kvm.reboot', args) | [
"def",
"reboot",
"(",
"self",
",",
"uuid",
")",
":",
"args",
"=",
"{",
"'uuid'",
":",
"uuid",
",",
"}",
"self",
".",
"_domain_action_chk",
".",
"check",
"(",
"args",
")",
"self",
".",
"_client",
".",
"sync",
"(",
"'kvm.reboot'",
",",
"args",
")"
] | Reboot a kvm domain by uuid
:param uuid: uuid of the kvm container (same as the used in create)
:return: | [
"Reboot",
"a",
"kvm",
"domain",
"by",
"uuid",
":",
"param",
"uuid",
":",
"uuid",
"of",
"the",
"kvm",
"container",
"(",
"same",
"as",
"the",
"used",
"in",
"create",
")",
":",
"return",
":"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L2339-L2350 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | KvmManager.reset | def reset(self, uuid):
"""
Reset (Force reboot) a kvm domain by uuid
:param uuid: uuid of the kvm container (same as the used in create)
:return:
"""
args = {
'uuid': uuid,
}
self._domain_action_chk.check(args)
self._client.sync('kvm.r... | python | def reset(self, uuid):
"""
Reset (Force reboot) a kvm domain by uuid
:param uuid: uuid of the kvm container (same as the used in create)
:return:
"""
args = {
'uuid': uuid,
}
self._domain_action_chk.check(args)
self._client.sync('kvm.r... | [
"def",
"reset",
"(",
"self",
",",
"uuid",
")",
":",
"args",
"=",
"{",
"'uuid'",
":",
"uuid",
",",
"}",
"self",
".",
"_domain_action_chk",
".",
"check",
"(",
"args",
")",
"self",
".",
"_client",
".",
"sync",
"(",
"'kvm.reset'",
",",
"args",
")"
] | Reset (Force reboot) a kvm domain by uuid
:param uuid: uuid of the kvm container (same as the used in create)
:return: | [
"Reset",
"(",
"Force",
"reboot",
")",
"a",
"kvm",
"domain",
"by",
"uuid",
":",
"param",
"uuid",
":",
"uuid",
"of",
"the",
"kvm",
"container",
"(",
"same",
"as",
"the",
"used",
"in",
"create",
")",
":",
"return",
":"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L2352-L2363 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | KvmManager.pause | def pause(self, uuid):
"""
Pause a kvm domain by uuid
:param uuid: uuid of the kvm container (same as the used in create)
:return:
"""
args = {
'uuid': uuid,
}
self._domain_action_chk.check(args)
self._client.sync('kvm.pause', args) | python | def pause(self, uuid):
"""
Pause a kvm domain by uuid
:param uuid: uuid of the kvm container (same as the used in create)
:return:
"""
args = {
'uuid': uuid,
}
self._domain_action_chk.check(args)
self._client.sync('kvm.pause', args) | [
"def",
"pause",
"(",
"self",
",",
"uuid",
")",
":",
"args",
"=",
"{",
"'uuid'",
":",
"uuid",
",",
"}",
"self",
".",
"_domain_action_chk",
".",
"check",
"(",
"args",
")",
"self",
".",
"_client",
".",
"sync",
"(",
"'kvm.pause'",
",",
"args",
")"
] | Pause a kvm domain by uuid
:param uuid: uuid of the kvm container (same as the used in create)
:return: | [
"Pause",
"a",
"kvm",
"domain",
"by",
"uuid",
":",
"param",
"uuid",
":",
"uuid",
"of",
"the",
"kvm",
"container",
"(",
"same",
"as",
"the",
"used",
"in",
"create",
")",
":",
"return",
":"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L2365-L2376 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | KvmManager.resume | def resume(self, uuid):
"""
Resume a kvm domain by uuid
:param uuid: uuid of the kvm container (same as the used in create)
:return:
"""
args = {
'uuid': uuid,
}
self._domain_action_chk.check(args)
self._client.sync('kvm.resume', args) | python | def resume(self, uuid):
"""
Resume a kvm domain by uuid
:param uuid: uuid of the kvm container (same as the used in create)
:return:
"""
args = {
'uuid': uuid,
}
self._domain_action_chk.check(args)
self._client.sync('kvm.resume', args) | [
"def",
"resume",
"(",
"self",
",",
"uuid",
")",
":",
"args",
"=",
"{",
"'uuid'",
":",
"uuid",
",",
"}",
"self",
".",
"_domain_action_chk",
".",
"check",
"(",
"args",
")",
"self",
".",
"_client",
".",
"sync",
"(",
"'kvm.resume'",
",",
"args",
")"
] | Resume a kvm domain by uuid
:param uuid: uuid of the kvm container (same as the used in create)
:return: | [
"Resume",
"a",
"kvm",
"domain",
"by",
"uuid",
":",
"param",
"uuid",
":",
"uuid",
"of",
"the",
"kvm",
"container",
"(",
"same",
"as",
"the",
"used",
"in",
"create",
")",
":",
"return",
":"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L2378-L2389 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | KvmManager.info | def info(self, uuid):
"""
Get info about a kvm domain by uuid
:param uuid: uuid of the kvm container (same as the used in create)
:return:
"""
args = {
'uuid': uuid,
}
self._domain_action_chk.check(args)
return self._client.json('kvm.i... | python | def info(self, uuid):
"""
Get info about a kvm domain by uuid
:param uuid: uuid of the kvm container (same as the used in create)
:return:
"""
args = {
'uuid': uuid,
}
self._domain_action_chk.check(args)
return self._client.json('kvm.i... | [
"def",
"info",
"(",
"self",
",",
"uuid",
")",
":",
"args",
"=",
"{",
"'uuid'",
":",
"uuid",
",",
"}",
"self",
".",
"_domain_action_chk",
".",
"check",
"(",
"args",
")",
"return",
"self",
".",
"_client",
".",
"json",
"(",
"'kvm.info'",
",",
"args",
... | Get info about a kvm domain by uuid
:param uuid: uuid of the kvm container (same as the used in create)
:return: | [
"Get",
"info",
"about",
"a",
"kvm",
"domain",
"by",
"uuid",
":",
"param",
"uuid",
":",
"uuid",
"of",
"the",
"kvm",
"container",
"(",
"same",
"as",
"the",
"used",
"in",
"create",
")",
":",
"return",
":"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L2391-L2402 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | KvmManager.infops | def infops(self, uuid):
"""
Get info per second about a kvm domain by uuid
:param uuid: uuid of the kvm container (same as the used in create)
:return:
"""
args = {
'uuid': uuid,
}
self._domain_action_chk.check(args)
return self._clien... | python | def infops(self, uuid):
"""
Get info per second about a kvm domain by uuid
:param uuid: uuid of the kvm container (same as the used in create)
:return:
"""
args = {
'uuid': uuid,
}
self._domain_action_chk.check(args)
return self._clien... | [
"def",
"infops",
"(",
"self",
",",
"uuid",
")",
":",
"args",
"=",
"{",
"'uuid'",
":",
"uuid",
",",
"}",
"self",
".",
"_domain_action_chk",
".",
"check",
"(",
"args",
")",
"return",
"self",
".",
"_client",
".",
"json",
"(",
"'kvm.infops'",
",",
"args"... | Get info per second about a kvm domain by uuid
:param uuid: uuid of the kvm container (same as the used in create)
:return: | [
"Get",
"info",
"per",
"second",
"about",
"a",
"kvm",
"domain",
"by",
"uuid",
":",
"param",
"uuid",
":",
"uuid",
"of",
"the",
"kvm",
"container",
"(",
"same",
"as",
"the",
"used",
"in",
"create",
")",
":",
"return",
":"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L2404-L2415 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | KvmManager.attach_disk | def attach_disk(self, uuid, media):
"""
Attach a disk to a machine
:param uuid: uuid of the kvm container (same as the used in create)
:param media: the media object to attach to the machine
media object is a dict of {url, and type} where type can be one of 'disk', ... | python | def attach_disk(self, uuid, media):
"""
Attach a disk to a machine
:param uuid: uuid of the kvm container (same as the used in create)
:param media: the media object to attach to the machine
media object is a dict of {url, and type} where type can be one of 'disk', ... | [
"def",
"attach_disk",
"(",
"self",
",",
"uuid",
",",
"media",
")",
":",
"args",
"=",
"{",
"'uuid'",
":",
"uuid",
",",
"'media'",
":",
"media",
",",
"}",
"self",
".",
"_man_disk_action_chk",
".",
"check",
"(",
"args",
")",
"self",
".",
"_client",
".",... | Attach a disk to a machine
:param uuid: uuid of the kvm container (same as the used in create)
:param media: the media object to attach to the machine
media object is a dict of {url, and type} where type can be one of 'disk', or 'cdrom', or empty (default to disk)
... | [
"Attach",
"a",
"disk",
"to",
"a",
"machine",
":",
"param",
"uuid",
":",
"uuid",
"of",
"the",
"kvm",
"container",
"(",
"same",
"as",
"the",
"used",
"in",
"create",
")",
":",
"param",
"media",
":",
"the",
"media",
"object",
"to",
"attach",
"to",
"the",... | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L2417-L2432 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | KvmManager.add_nic | def add_nic(self, uuid, type, id=None, hwaddr=None):
"""
Add a nic to a machine
:param uuid: uuid of the kvm container (same as the used in create)
:param type: nic_type # default, bridge, vlan, or vxlan (note, vlan and vxlan only supported by ovs)
param id: id # depends on the ... | python | def add_nic(self, uuid, type, id=None, hwaddr=None):
"""
Add a nic to a machine
:param uuid: uuid of the kvm container (same as the used in create)
:param type: nic_type # default, bridge, vlan, or vxlan (note, vlan and vxlan only supported by ovs)
param id: id # depends on the ... | [
"def",
"add_nic",
"(",
"self",
",",
"uuid",
",",
"type",
",",
"id",
"=",
"None",
",",
"hwaddr",
"=",
"None",
")",
":",
"args",
"=",
"{",
"'uuid'",
":",
"uuid",
",",
"'type'",
":",
"type",
",",
"'id'",
":",
"id",
",",
"'hwaddr'",
":",
"hwaddr",
... | Add a nic to a machine
:param uuid: uuid of the kvm container (same as the used in create)
:param type: nic_type # default, bridge, vlan, or vxlan (note, vlan and vxlan only supported by ovs)
param id: id # depends on the type, bridge name (bridge type) zerotier network id (zertier type), the v... | [
"Add",
"a",
"nic",
"to",
"a",
"machine",
":",
"param",
"uuid",
":",
"uuid",
"of",
"the",
"kvm",
"container",
"(",
"same",
"as",
"the",
"used",
"in",
"create",
")",
":",
"param",
"type",
":",
"nic_type",
"#",
"default",
"bridge",
"vlan",
"or",
"vxlan"... | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L2451-L2468 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | KvmManager.limit_disk_io | def limit_disk_io(self, uuid, media, totalbytessecset=False, totalbytessec=0, readbytessecset=False, readbytessec=0, writebytessecset=False,
writebytessec=0, totaliopssecset=False, totaliopssec=0, readiopssecset=False, readiopssec=0, writeiopssecset=False, writeiopssec=0,
tot... | python | def limit_disk_io(self, uuid, media, totalbytessecset=False, totalbytessec=0, readbytessecset=False, readbytessec=0, writebytessecset=False,
writebytessec=0, totaliopssecset=False, totaliopssec=0, readiopssecset=False, readiopssec=0, writeiopssecset=False, writeiopssec=0,
tot... | [
"def",
"limit_disk_io",
"(",
"self",
",",
"uuid",
",",
"media",
",",
"totalbytessecset",
"=",
"False",
",",
"totalbytessec",
"=",
"0",
",",
"readbytessecset",
"=",
"False",
",",
"readbytessec",
"=",
"0",
",",
"writebytessecset",
"=",
"False",
",",
"writebyte... | Remove a nic from a machine
:param uuid: uuid of the kvm container (same as the used in create)
:param media: the media to limit the diskio
:return: | [
"Remove",
"a",
"nic",
"from",
"a",
"machine",
":",
"param",
"uuid",
":",
"uuid",
"of",
"the",
"kvm",
"container",
"(",
"same",
"as",
"the",
"used",
"in",
"create",
")",
":",
"param",
"media",
":",
"the",
"media",
"to",
"limit",
"the",
"diskio",
":",
... | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L2489-L2549 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | KvmManager.migrate | def migrate(self, uuid, desturi):
"""
Migrate a vm to another node
:param uuid: uuid of the kvm container (same as the used in create)
:param desturi: the uri of the destination node
:return:
"""
args = {
'uuid': uuid,
'desturi': desturi,
... | python | def migrate(self, uuid, desturi):
"""
Migrate a vm to another node
:param uuid: uuid of the kvm container (same as the used in create)
:param desturi: the uri of the destination node
:return:
"""
args = {
'uuid': uuid,
'desturi': desturi,
... | [
"def",
"migrate",
"(",
"self",
",",
"uuid",
",",
"desturi",
")",
":",
"args",
"=",
"{",
"'uuid'",
":",
"uuid",
",",
"'desturi'",
":",
"desturi",
",",
"}",
"self",
".",
"_migrate_action_chk",
".",
"check",
"(",
"args",
")",
"self",
".",
"_client",
"."... | Migrate a vm to another node
:param uuid: uuid of the kvm container (same as the used in create)
:param desturi: the uri of the destination node
:return: | [
"Migrate",
"a",
"vm",
"to",
"another",
"node",
":",
"param",
"uuid",
":",
"uuid",
"of",
"the",
"kvm",
"container",
"(",
"same",
"as",
"the",
"used",
"in",
"create",
")",
":",
"param",
"desturi",
":",
"the",
"uri",
"of",
"the",
"destination",
"node",
... | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L2551-L2564 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | KvmManager.get | def get(self, uuid):
"""
Get machine info
:param uuid str: domain uuid
:return: machine info
"""
args = {'uuid':uuid}
self._get_chk.check(args)
return self._client.json('kvm.get', args) | python | def get(self, uuid):
"""
Get machine info
:param uuid str: domain uuid
:return: machine info
"""
args = {'uuid':uuid}
self._get_chk.check(args)
return self._client.json('kvm.get', args) | [
"def",
"get",
"(",
"self",
",",
"uuid",
")",
":",
"args",
"=",
"{",
"'uuid'",
":",
"uuid",
"}",
"self",
".",
"_get_chk",
".",
"check",
"(",
"args",
")",
"return",
"self",
".",
"_client",
".",
"json",
"(",
"'kvm.get'",
",",
"args",
")"
] | Get machine info
:param uuid str: domain uuid
:return: machine info | [
"Get",
"machine",
"info",
":",
"param",
"uuid",
"str",
":",
"domain",
"uuid"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L2574-L2583 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | Logger.set_level | def set_level(self, level):
"""
Set the log level of the g8os
Note: this level is for messages that ends up on screen or on log file
:param level: the level to be set can be one of ("CRITICAL", "ERROR", "WARNING", "NOTICE", "INFO", "DEBUG")
"""
args = {
'leve... | python | def set_level(self, level):
"""
Set the log level of the g8os
Note: this level is for messages that ends up on screen or on log file
:param level: the level to be set can be one of ("CRITICAL", "ERROR", "WARNING", "NOTICE", "INFO", "DEBUG")
"""
args = {
'leve... | [
"def",
"set_level",
"(",
"self",
",",
"level",
")",
":",
"args",
"=",
"{",
"'level'",
":",
"level",
",",
"}",
"self",
".",
"_level_chk",
".",
"check",
"(",
"args",
")",
"return",
"self",
".",
"_client",
".",
"json",
"(",
"'logger.set_level'",
",",
"a... | Set the log level of the g8os
Note: this level is for messages that ends up on screen or on log file
:param level: the level to be set can be one of ("CRITICAL", "ERROR", "WARNING", "NOTICE", "INFO", "DEBUG") | [
"Set",
"the",
"log",
"level",
"of",
"the",
"g8os",
"Note",
":",
"this",
"level",
"is",
"for",
"messages",
"that",
"ends",
"up",
"on",
"screen",
"or",
"on",
"log",
"file"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L2598-L2610 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | Logger.subscribe | def subscribe(self, queue=None, *levels):
"""
Subscribe to the aggregated log stream. On subscribe a ledis queue will be fed with all running processes
logs. Always use the returned queue name from this method, even if u specified the queue name to use
Note: it is legal to subscribe to ... | python | def subscribe(self, queue=None, *levels):
"""
Subscribe to the aggregated log stream. On subscribe a ledis queue will be fed with all running processes
logs. Always use the returned queue name from this method, even if u specified the queue name to use
Note: it is legal to subscribe to ... | [
"def",
"subscribe",
"(",
"self",
",",
"queue",
"=",
"None",
",",
"*",
"levels",
")",
":",
"args",
"=",
"{",
"'queue'",
":",
"queue",
",",
"'levels'",
":",
"list",
"(",
"levels",
")",
",",
"}",
"self",
".",
"_subscribe_chk",
".",
"check",
"(",
"args... | Subscribe to the aggregated log stream. On subscribe a ledis queue will be fed with all running processes
logs. Always use the returned queue name from this method, even if u specified the queue name to use
Note: it is legal to subscribe to the same queue, but would be a bad logic if two processes are ... | [
"Subscribe",
"to",
"the",
"aggregated",
"log",
"stream",
".",
"On",
"subscribe",
"a",
"ledis",
"queue",
"will",
"be",
"fed",
"with",
"all",
"running",
"processes",
"logs",
".",
"Always",
"use",
"the",
"returned",
"queue",
"name",
"from",
"this",
"method",
... | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L2618-L2637 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | Nft.drop_port | def drop_port(self, port, interface=None, subnet=None):
"""
close an opened port (takes the same parameters passed in open)
:param port: then port number
:param interface: an optional interface to close the port for
:param subnet: an optional subnet to close the port for
... | python | def drop_port(self, port, interface=None, subnet=None):
"""
close an opened port (takes the same parameters passed in open)
:param port: then port number
:param interface: an optional interface to close the port for
:param subnet: an optional subnet to close the port for
... | [
"def",
"drop_port",
"(",
"self",
",",
"port",
",",
"interface",
"=",
"None",
",",
"subnet",
"=",
"None",
")",
":",
"args",
"=",
"{",
"'port'",
":",
"port",
",",
"'interface'",
":",
"interface",
",",
"'subnet'",
":",
"subnet",
",",
"}",
"self",
".",
... | close an opened port (takes the same parameters passed in open)
:param port: then port number
:param interface: an optional interface to close the port for
:param subnet: an optional subnet to close the port for | [
"close",
"an",
"opened",
"port",
"(",
"takes",
"the",
"same",
"parameters",
"passed",
"in",
"open",
")",
":",
"param",
"port",
":",
"then",
"port",
"number",
":",
"param",
"interface",
":",
"an",
"optional",
"interface",
"to",
"close",
"the",
"port",
"fo... | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L2677-L2691 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | AggregatorManager.query | def query(self, key=None, **tags):
"""
Query zero-os aggregator for current state object of monitored metrics.
Note: ID is returned as part of the key (if set) to avoid conflict with similar metrics that
has same key. For example, a cpu core nr can be the id associated with 'machine.CPU... | python | def query(self, key=None, **tags):
"""
Query zero-os aggregator for current state object of monitored metrics.
Note: ID is returned as part of the key (if set) to avoid conflict with similar metrics that
has same key. For example, a cpu core nr can be the id associated with 'machine.CPU... | [
"def",
"query",
"(",
"self",
",",
"key",
"=",
"None",
",",
"*",
"*",
"tags",
")",
":",
"args",
"=",
"{",
"'key'",
":",
"key",
",",
"'tags'",
":",
"tags",
",",
"}",
"self",
".",
"_query_chk",
".",
"check",
"(",
"args",
")",
"return",
"self",
"."... | Query zero-os aggregator for current state object of monitored metrics.
Note: ID is returned as part of the key (if set) to avoid conflict with similar metrics that
has same key. For example, a cpu core nr can be the id associated with 'machine.CPU.percent'
so we can return all values for all t... | [
"Query",
"zero",
"-",
"os",
"aggregator",
"for",
"current",
"state",
"object",
"of",
"monitored",
"metrics",
"."
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L2737-L2761 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | RTInfoManager.start | def start(self, host="localhost", port=8999, disks=None):
"""
Start rtinfo-client
:param host: str rtinfod host address
:param port: int rtinfod client port
:param disks: list of prefixes of wathable disks (e.g ["sd"])
"""
disks = [] if disks is None else disks
... | python | def start(self, host="localhost", port=8999, disks=None):
"""
Start rtinfo-client
:param host: str rtinfod host address
:param port: int rtinfod client port
:param disks: list of prefixes of wathable disks (e.g ["sd"])
"""
disks = [] if disks is None else disks
... | [
"def",
"start",
"(",
"self",
",",
"host",
"=",
"\"localhost\"",
",",
"port",
"=",
"8999",
",",
"disks",
"=",
"None",
")",
":",
"disks",
"=",
"[",
"]",
"if",
"disks",
"is",
"None",
"else",
"disks",
"args",
"=",
"{",
"\"host\"",
":",
"host",
",",
"... | Start rtinfo-client
:param host: str rtinfod host address
:param port: int rtinfod client port
:param disks: list of prefixes of wathable disks (e.g ["sd"]) | [
"Start",
"rtinfo",
"-",
"client",
":",
"param",
"host",
":",
"str",
"rtinfod",
"host",
"address",
":",
"param",
"port",
":",
"int",
"rtinfod",
"client",
"port",
":",
"param",
"disks",
":",
"list",
"of",
"prefixes",
"of",
"wathable",
"disks",
"(",
"e",
... | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L2778-L2795 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | RTInfoManager.stop | def stop(self, host, port):
"""
Stop rtinfo-client
:param host: str rtinfod host address
:param port: int rtinfod client port
"""
args = {
"host": host,
"port": port,
}
self._rtinfo_stop_params_chk.check(args)
return self.... | python | def stop(self, host, port):
"""
Stop rtinfo-client
:param host: str rtinfod host address
:param port: int rtinfod client port
"""
args = {
"host": host,
"port": port,
}
self._rtinfo_stop_params_chk.check(args)
return self.... | [
"def",
"stop",
"(",
"self",
",",
"host",
",",
"port",
")",
":",
"args",
"=",
"{",
"\"host\"",
":",
"host",
",",
"\"port\"",
":",
"port",
",",
"}",
"self",
".",
"_rtinfo_stop_params_chk",
".",
"check",
"(",
"args",
")",
"return",
"self",
".",
"_client... | Stop rtinfo-client
:param host: str rtinfod host address
:param port: int rtinfod client port | [
"Stop",
"rtinfo",
"-",
"client",
":",
"param",
"host",
":",
"str",
"rtinfod",
"host",
"address",
":",
"param",
"port",
":",
"int",
"rtinfod",
"client",
"port"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L2797-L2810 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | CGroupManager.ensure | def ensure(self, subsystem, name):
"""
Creates a cgroup if it doesn't exist under the specified subsystem
and the given name
:param subsystem: the cgroup subsystem (currently support 'memory', and 'cpuset')
:param name: name of the cgroup to delete
"""
args = {
... | python | def ensure(self, subsystem, name):
"""
Creates a cgroup if it doesn't exist under the specified subsystem
and the given name
:param subsystem: the cgroup subsystem (currently support 'memory', and 'cpuset')
:param name: name of the cgroup to delete
"""
args = {
... | [
"def",
"ensure",
"(",
"self",
",",
"subsystem",
",",
"name",
")",
":",
"args",
"=",
"{",
"'subsystem'",
":",
"subsystem",
",",
"'name'",
":",
"name",
",",
"}",
"self",
".",
"_cgroup_chk",
".",
"check",
"(",
"args",
")",
"return",
"self",
".",
"_clien... | Creates a cgroup if it doesn't exist under the specified subsystem
and the given name
:param subsystem: the cgroup subsystem (currently support 'memory', and 'cpuset')
:param name: name of the cgroup to delete | [
"Creates",
"a",
"cgroup",
"if",
"it",
"doesn",
"t",
"exist",
"under",
"the",
"specified",
"subsystem",
"and",
"the",
"given",
"name"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L2854-L2868 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | CGroupManager.task_add | def task_add(self, subsystem, name, pid):
"""
Add process (with pid) to a cgroup
:param subsystem: the cgroup subsystem (currently support 'memory', and 'cpuset')
:param name: name of the cgroup
:param pid: PID to add
"""
args = {
'subsystem': subsys... | python | def task_add(self, subsystem, name, pid):
"""
Add process (with pid) to a cgroup
:param subsystem: the cgroup subsystem (currently support 'memory', and 'cpuset')
:param name: name of the cgroup
:param pid: PID to add
"""
args = {
'subsystem': subsys... | [
"def",
"task_add",
"(",
"self",
",",
"subsystem",
",",
"name",
",",
"pid",
")",
":",
"args",
"=",
"{",
"'subsystem'",
":",
"subsystem",
",",
"'name'",
":",
"name",
",",
"'pid'",
":",
"pid",
",",
"}",
"self",
".",
"_task_chk",
".",
"check",
"(",
"ar... | Add process (with pid) to a cgroup
:param subsystem: the cgroup subsystem (currently support 'memory', and 'cpuset')
:param name: name of the cgroup
:param pid: PID to add | [
"Add",
"process",
"(",
"with",
"pid",
")",
"to",
"a",
"cgroup"
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L2902-L2918 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | CGroupManager.memory | def memory(self, name, mem=0, swap=0):
"""
Set/Get memory cgroup specification/limitation
the call to this method will always GET the current set values for both mem and swap.
If mem is not zero, the memory will set the memory limit to the given value, and swap to the given value (even 0... | python | def memory(self, name, mem=0, swap=0):
"""
Set/Get memory cgroup specification/limitation
the call to this method will always GET the current set values for both mem and swap.
If mem is not zero, the memory will set the memory limit to the given value, and swap to the given value (even 0... | [
"def",
"memory",
"(",
"self",
",",
"name",
",",
"mem",
"=",
"0",
",",
"swap",
"=",
"0",
")",
":",
"args",
"=",
"{",
"'name'",
":",
"name",
",",
"'mem'",
":",
"mem",
",",
"'swap'",
":",
"swap",
",",
"}",
"self",
".",
"_memory_spec",
".",
"check"... | Set/Get memory cgroup specification/limitation
the call to this method will always GET the current set values for both mem and swap.
If mem is not zero, the memory will set the memory limit to the given value, and swap to the given value (even 0)
:param mem: Set memory limit to the given value ... | [
"Set",
"/",
"Get",
"memory",
"cgroup",
"specification",
"/",
"limitation",
"the",
"call",
"to",
"this",
"method",
"will",
"always",
"GET",
"the",
"current",
"set",
"values",
"for",
"both",
"mem",
"and",
"swap",
".",
"If",
"mem",
"is",
"not",
"zero",
"the... | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L2954-L2973 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | CGroupManager.cpuset | def cpuset(self, name, cpus=None, mems=None):
"""
Set/Get cpuset cgroup specification/limitation
the call to this method will always GET the current set values for both cpus and mems
If cpus, or mems is NOT NONE value it will be set as the spec for that attribute
:param cpus: Se... | python | def cpuset(self, name, cpus=None, mems=None):
"""
Set/Get cpuset cgroup specification/limitation
the call to this method will always GET the current set values for both cpus and mems
If cpus, or mems is NOT NONE value it will be set as the spec for that attribute
:param cpus: Se... | [
"def",
"cpuset",
"(",
"self",
",",
"name",
",",
"cpus",
"=",
"None",
",",
"mems",
"=",
"None",
")",
":",
"args",
"=",
"{",
"'name'",
":",
"name",
",",
"'cpus'",
":",
"cpus",
",",
"'mems'",
":",
"mems",
",",
"}",
"self",
".",
"_cpuset_spec",
".",
... | Set/Get cpuset cgroup specification/limitation
the call to this method will always GET the current set values for both cpus and mems
If cpus, or mems is NOT NONE value it will be set as the spec for that attribute
:param cpus: Set cpus affinity limit to the given value (0, 1, 0-10, etc...)
... | [
"Set",
"/",
"Get",
"cpuset",
"cgroup",
"specification",
"/",
"limitation",
"the",
"call",
"to",
"this",
"method",
"will",
"always",
"GET",
"the",
"current",
"set",
"values",
"for",
"both",
"cpus",
"and",
"mems",
"If",
"cpus",
"or",
"mems",
"is",
"NOT",
"... | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L2975-L2994 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | Client.raw | def raw(self, command, arguments, queue=None, max_time=None, stream=False, tags=None, id=None):
"""
Implements the low level command call, this needs to build the command structure
and push it on the correct queue.
:param command: Command name to execute supported by the node (ex: core.... | python | def raw(self, command, arguments, queue=None, max_time=None, stream=False, tags=None, id=None):
"""
Implements the low level command call, this needs to build the command structure
and push it on the correct queue.
:param command: Command name to execute supported by the node (ex: core.... | [
"def",
"raw",
"(",
"self",
",",
"command",
",",
"arguments",
",",
"queue",
"=",
"None",
",",
"max_time",
"=",
"None",
",",
"stream",
"=",
"False",
",",
"tags",
"=",
"None",
",",
"id",
"=",
"None",
")",
":",
"if",
"not",
"id",
":",
"id",
"=",
"s... | Implements the low level command call, this needs to build the command structure
and push it on the correct queue.
:param command: Command name to execute supported by the node (ex: core.system, info.cpu, etc...)
check documentation for list of built in commands
:param a... | [
"Implements",
"the",
"low",
"level",
"command",
"call",
"this",
"needs",
"to",
"build",
"the",
"command",
"structure",
"and",
"push",
"it",
"on",
"the",
"correct",
"queue",
"."
] | train | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L3139-L3175 |
vallis/libstempo | libstempo/spharmORFbasis.py | calczeta | def calczeta(phi1, phi2, theta1, theta2):
"""
Calculate the angular separation between position (phi1, theta1) and
(phi2, theta2)
"""
zeta = 0.0
if phi1 == phi2 and theta1 == theta2:
zeta = 0.0
else:
argument = sin(theta1)*sin(theta2)*cos(phi1-phi2) + \
... | python | def calczeta(phi1, phi2, theta1, theta2):
"""
Calculate the angular separation between position (phi1, theta1) and
(phi2, theta2)
"""
zeta = 0.0
if phi1 == phi2 and theta1 == theta2:
zeta = 0.0
else:
argument = sin(theta1)*sin(theta2)*cos(phi1-phi2) + \
... | [
"def",
"calczeta",
"(",
"phi1",
",",
"phi2",
",",
"theta1",
",",
"theta2",
")",
":",
"zeta",
"=",
"0.0",
"if",
"phi1",
"==",
"phi2",
"and",
"theta1",
"==",
"theta2",
":",
"zeta",
"=",
"0.0",
"else",
":",
"argument",
"=",
"sin",
"(",
"theta1",
")",
... | Calculate the angular separation between position (phi1, theta1) and
(phi2, theta2) | [
"Calculate",
"the",
"angular",
"separation",
"between",
"position",
"(",
"phi1",
"theta1",
")",
"and",
"(",
"phi2",
"theta2",
")"
] | train | https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/spharmORFbasis.py#L23-L45 |
vallis/libstempo | libstempo/spharmORFbasis.py | dlmk | def dlmk(l,m,k,theta1):
"""
returns value of d^l_mk as defined in allen, ottewill 97.
Called by Dlmk
"""
if m >= k:
factor = sqrt(factorial(l-k)*factorial(l+m)/factorial(l+k)/factorial(l-m))
part2 = (cos(theta1/2))**(2*l+k-m)*(-sin(theta1/2))**(m-k)/factorial(m-k)
... | python | def dlmk(l,m,k,theta1):
"""
returns value of d^l_mk as defined in allen, ottewill 97.
Called by Dlmk
"""
if m >= k:
factor = sqrt(factorial(l-k)*factorial(l+m)/factorial(l+k)/factorial(l-m))
part2 = (cos(theta1/2))**(2*l+k-m)*(-sin(theta1/2))**(m-k)/factorial(m-k)
... | [
"def",
"dlmk",
"(",
"l",
",",
"m",
",",
"k",
",",
"theta1",
")",
":",
"if",
"m",
">=",
"k",
":",
"factor",
"=",
"sqrt",
"(",
"factorial",
"(",
"l",
"-",
"k",
")",
"*",
"factorial",
"(",
"l",
"+",
"m",
")",
"/",
"factorial",
"(",
"l",
"+",
... | returns value of d^l_mk as defined in allen, ottewill 97.
Called by Dlmk | [
"returns",
"value",
"of",
"d^l_mk",
"as",
"defined",
"in",
"allen",
"ottewill",
"97",
".",
"Called",
"by",
"Dlmk"
] | train | https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/spharmORFbasis.py#L173-L190 |
vallis/libstempo | libstempo/spharmORFbasis.py | Dlmk | def Dlmk(l,m,k,phi1,phi2,theta1,theta2):
"""
returns value of D^l_mk as defined in allen, ottewill 97.
"""
return exp(complex(0.,-m*phi1)) * dlmk(l,m,k,theta1) * \
exp(complex(0.,-k*gamma(phi1,phi2,theta1,theta2))) | python | def Dlmk(l,m,k,phi1,phi2,theta1,theta2):
"""
returns value of D^l_mk as defined in allen, ottewill 97.
"""
return exp(complex(0.,-m*phi1)) * dlmk(l,m,k,theta1) * \
exp(complex(0.,-k*gamma(phi1,phi2,theta1,theta2))) | [
"def",
"Dlmk",
"(",
"l",
",",
"m",
",",
"k",
",",
"phi1",
",",
"phi2",
",",
"theta1",
",",
"theta2",
")",
":",
"return",
"exp",
"(",
"complex",
"(",
"0.",
",",
"-",
"m",
"*",
"phi1",
")",
")",
"*",
"dlmk",
"(",
"l",
",",
"m",
",",
"k",
",... | returns value of D^l_mk as defined in allen, ottewill 97. | [
"returns",
"value",
"of",
"D^l_mk",
"as",
"defined",
"in",
"allen",
"ottewill",
"97",
"."
] | train | https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/spharmORFbasis.py#L193-L200 |
vallis/libstempo | libstempo/spharmORFbasis.py | gamma | def gamma(phi1,phi2,theta1,theta2):
"""
calculate third rotation angle
inputs are angles from 2 pulsars
returns the angle.
"""
if phi1 == phi2 and theta1 == theta2:
gamma = 0
else:
gamma = atan( sin(theta2)*sin(phi2-phi1) / \
(cos(theta1)*sin(t... | python | def gamma(phi1,phi2,theta1,theta2):
"""
calculate third rotation angle
inputs are angles from 2 pulsars
returns the angle.
"""
if phi1 == phi2 and theta1 == theta2:
gamma = 0
else:
gamma = atan( sin(theta2)*sin(phi2-phi1) / \
(cos(theta1)*sin(t... | [
"def",
"gamma",
"(",
"phi1",
",",
"phi2",
",",
"theta1",
",",
"theta2",
")",
":",
"if",
"phi1",
"==",
"phi2",
"and",
"theta1",
"==",
"theta2",
":",
"gamma",
"=",
"0",
"else",
":",
"gamma",
"=",
"atan",
"(",
"sin",
"(",
"theta2",
")",
"*",
"sin",
... | calculate third rotation angle
inputs are angles from 2 pulsars
returns the angle. | [
"calculate",
"third",
"rotation",
"angle",
"inputs",
"are",
"angles",
"from",
"2",
"pulsars",
"returns",
"the",
"angle",
"."
] | train | https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/spharmORFbasis.py#L203-L225 |
vallis/libstempo | libstempo/spharmORFbasis.py | rotated_Gamma_ml | def rotated_Gamma_ml(m,l,phi1,phi2,theta1,theta2,gamma_ml):
"""
This function takes any gamma in the computational frame and rotates it to the
cosmic frame.
"""
rotated_gamma = 0
for ii in range(2*l+1):
rotated_gamma += Dlmk(l,m,ii-l,phi1,phi2,theta1,theta2).conjugate()*g... | python | def rotated_Gamma_ml(m,l,phi1,phi2,theta1,theta2,gamma_ml):
"""
This function takes any gamma in the computational frame and rotates it to the
cosmic frame.
"""
rotated_gamma = 0
for ii in range(2*l+1):
rotated_gamma += Dlmk(l,m,ii-l,phi1,phi2,theta1,theta2).conjugate()*g... | [
"def",
"rotated_Gamma_ml",
"(",
"m",
",",
"l",
",",
"phi1",
",",
"phi2",
",",
"theta1",
",",
"theta2",
",",
"gamma_ml",
")",
":",
"rotated_gamma",
"=",
"0",
"for",
"ii",
"in",
"range",
"(",
"2",
"*",
"l",
"+",
"1",
")",
":",
"rotated_gamma",
"+=",
... | This function takes any gamma in the computational frame and rotates it to the
cosmic frame. | [
"This",
"function",
"takes",
"any",
"gamma",
"in",
"the",
"computational",
"frame",
"and",
"rotates",
"it",
"to",
"the",
"cosmic",
"frame",
"."
] | train | https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/spharmORFbasis.py#L266-L278 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.