id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
11,000 | Gandi/gandi.cli | gandi/cli/modules/datacenter.py | Datacenter.list_migration_choice | def list_migration_choice(cls, datacenter):
"""List available datacenters for migration from given datacenter."""
datacenter_id = cls.usable_id(datacenter)
dc_list = cls.list()
available_dcs = [dc for dc in dc_list
if dc['id'] == datacenter_id][0]['can_migrate_to... | python | def list_migration_choice(cls, datacenter):
"""List available datacenters for migration from given datacenter."""
datacenter_id = cls.usable_id(datacenter)
dc_list = cls.list()
available_dcs = [dc for dc in dc_list
if dc['id'] == datacenter_id][0]['can_migrate_to... | [
"def",
"list_migration_choice",
"(",
"cls",
",",
"datacenter",
")",
":",
"datacenter_id",
"=",
"cls",
".",
"usable_id",
"(",
"datacenter",
")",
"dc_list",
"=",
"cls",
".",
"list",
"(",
")",
"available_dcs",
"=",
"[",
"dc",
"for",
"dc",
"in",
"dc_list",
"... | List available datacenters for migration from given datacenter. | [
"List",
"available",
"datacenters",
"for",
"migration",
"from",
"given",
"datacenter",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/datacenter.py#L22-L30 |
11,001 | Gandi/gandi.cli | gandi/cli/modules/datacenter.py | Datacenter.is_opened | def is_opened(cls, dc_code, type_):
"""List opened datacenters for given type."""
options = {'dc_code': dc_code, '%s_opened' % type_: True}
datacenters = cls.safe_call('hosting.datacenter.list', options)
if not datacenters:
# try with ISO code
options = {'iso': dc... | python | def is_opened(cls, dc_code, type_):
"""List opened datacenters for given type."""
options = {'dc_code': dc_code, '%s_opened' % type_: True}
datacenters = cls.safe_call('hosting.datacenter.list', options)
if not datacenters:
# try with ISO code
options = {'iso': dc... | [
"def",
"is_opened",
"(",
"cls",
",",
"dc_code",
",",
"type_",
")",
":",
"options",
"=",
"{",
"'dc_code'",
":",
"dc_code",
",",
"'%s_opened'",
"%",
"type_",
":",
"True",
"}",
"datacenters",
"=",
"cls",
".",
"safe_call",
"(",
"'hosting.datacenter.list'",
","... | List opened datacenters for given type. | [
"List",
"opened",
"datacenters",
"for",
"given",
"type",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/datacenter.py#L33-L50 |
11,002 | Gandi/gandi.cli | gandi/cli/modules/datacenter.py | Datacenter.filtered_list | def filtered_list(cls, name=None, obj=None):
"""List datacenters matching name and compatible
with obj"""
options = {}
if name:
options['id'] = cls.usable_id(name)
def obj_ok(dc, obj):
if not obj or obj['datacenter_id'] == dc['id']:
return... | python | def filtered_list(cls, name=None, obj=None):
"""List datacenters matching name and compatible
with obj"""
options = {}
if name:
options['id'] = cls.usable_id(name)
def obj_ok(dc, obj):
if not obj or obj['datacenter_id'] == dc['id']:
return... | [
"def",
"filtered_list",
"(",
"cls",
",",
"name",
"=",
"None",
",",
"obj",
"=",
"None",
")",
":",
"options",
"=",
"{",
"}",
"if",
"name",
":",
"options",
"[",
"'id'",
"]",
"=",
"cls",
".",
"usable_id",
"(",
"name",
")",
"def",
"obj_ok",
"(",
"dc",... | List datacenters matching name and compatible
with obj | [
"List",
"datacenters",
"matching",
"name",
"and",
"compatible",
"with",
"obj"
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/datacenter.py#L53-L65 |
11,003 | Gandi/gandi.cli | gandi/cli/modules/datacenter.py | Datacenter.from_iso | def from_iso(cls, iso):
"""Retrieve the first datacenter id associated to an ISO."""
result = cls.list({'sort_by': 'id ASC'})
dc_isos = {}
for dc in result:
if dc['iso'] not in dc_isos:
dc_isos[dc['iso']] = dc['id']
return dc_isos.get(iso) | python | def from_iso(cls, iso):
"""Retrieve the first datacenter id associated to an ISO."""
result = cls.list({'sort_by': 'id ASC'})
dc_isos = {}
for dc in result:
if dc['iso'] not in dc_isos:
dc_isos[dc['iso']] = dc['id']
return dc_isos.get(iso) | [
"def",
"from_iso",
"(",
"cls",
",",
"iso",
")",
":",
"result",
"=",
"cls",
".",
"list",
"(",
"{",
"'sort_by'",
":",
"'id ASC'",
"}",
")",
"dc_isos",
"=",
"{",
"}",
"for",
"dc",
"in",
"result",
":",
"if",
"dc",
"[",
"'iso'",
"]",
"not",
"in",
"d... | Retrieve the first datacenter id associated to an ISO. | [
"Retrieve",
"the",
"first",
"datacenter",
"id",
"associated",
"to",
"an",
"ISO",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/datacenter.py#L68-L76 |
11,004 | Gandi/gandi.cli | gandi/cli/modules/datacenter.py | Datacenter.from_name | def from_name(cls, name):
"""Retrieve datacenter id associated to a name."""
result = cls.list()
dc_names = {}
for dc in result:
dc_names[dc['name']] = dc['id']
return dc_names.get(name) | python | def from_name(cls, name):
"""Retrieve datacenter id associated to a name."""
result = cls.list()
dc_names = {}
for dc in result:
dc_names[dc['name']] = dc['id']
return dc_names.get(name) | [
"def",
"from_name",
"(",
"cls",
",",
"name",
")",
":",
"result",
"=",
"cls",
".",
"list",
"(",
")",
"dc_names",
"=",
"{",
"}",
"for",
"dc",
"in",
"result",
":",
"dc_names",
"[",
"dc",
"[",
"'name'",
"]",
"]",
"=",
"dc",
"[",
"'id'",
"]",
"retur... | Retrieve datacenter id associated to a name. | [
"Retrieve",
"datacenter",
"id",
"associated",
"to",
"a",
"name",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/datacenter.py#L79-L86 |
11,005 | Gandi/gandi.cli | gandi/cli/modules/datacenter.py | Datacenter.from_country | def from_country(cls, country):
"""Retrieve the first datacenter id associated to a country."""
result = cls.list({'sort_by': 'id ASC'})
dc_countries = {}
for dc in result:
if dc['country'] not in dc_countries:
dc_countries[dc['country']] = dc['id']
r... | python | def from_country(cls, country):
"""Retrieve the first datacenter id associated to a country."""
result = cls.list({'sort_by': 'id ASC'})
dc_countries = {}
for dc in result:
if dc['country'] not in dc_countries:
dc_countries[dc['country']] = dc['id']
r... | [
"def",
"from_country",
"(",
"cls",
",",
"country",
")",
":",
"result",
"=",
"cls",
".",
"list",
"(",
"{",
"'sort_by'",
":",
"'id ASC'",
"}",
")",
"dc_countries",
"=",
"{",
"}",
"for",
"dc",
"in",
"result",
":",
"if",
"dc",
"[",
"'country'",
"]",
"n... | Retrieve the first datacenter id associated to a country. | [
"Retrieve",
"the",
"first",
"datacenter",
"id",
"associated",
"to",
"a",
"country",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/datacenter.py#L89-L97 |
11,006 | Gandi/gandi.cli | gandi/cli/modules/datacenter.py | Datacenter.from_dc_code | def from_dc_code(cls, dc_code):
"""Retrieve the datacenter id associated to a dc_code"""
result = cls.list()
dc_codes = {}
for dc in result:
if dc.get('dc_code'):
dc_codes[dc['dc_code']] = dc['id']
return dc_codes.get(dc_code) | python | def from_dc_code(cls, dc_code):
"""Retrieve the datacenter id associated to a dc_code"""
result = cls.list()
dc_codes = {}
for dc in result:
if dc.get('dc_code'):
dc_codes[dc['dc_code']] = dc['id']
return dc_codes.get(dc_code) | [
"def",
"from_dc_code",
"(",
"cls",
",",
"dc_code",
")",
":",
"result",
"=",
"cls",
".",
"list",
"(",
")",
"dc_codes",
"=",
"{",
"}",
"for",
"dc",
"in",
"result",
":",
"if",
"dc",
".",
"get",
"(",
"'dc_code'",
")",
":",
"dc_codes",
"[",
"dc",
"[",... | Retrieve the datacenter id associated to a dc_code | [
"Retrieve",
"the",
"datacenter",
"id",
"associated",
"to",
"a",
"dc_code"
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/datacenter.py#L100-L108 |
11,007 | Gandi/gandi.cli | gandi/cli/modules/datacenter.py | Datacenter.usable_id | def usable_id(cls, id):
""" Retrieve id from input which can be ISO, name, country, dc_code."""
try:
# id is maybe a dc_code
qry_id = cls.from_dc_code(id)
if not qry_id:
# id is maybe a ISO
qry_id = cls.from_iso(id)
if q... | python | def usable_id(cls, id):
""" Retrieve id from input which can be ISO, name, country, dc_code."""
try:
# id is maybe a dc_code
qry_id = cls.from_dc_code(id)
if not qry_id:
# id is maybe a ISO
qry_id = cls.from_iso(id)
if q... | [
"def",
"usable_id",
"(",
"cls",
",",
"id",
")",
":",
"try",
":",
"# id is maybe a dc_code",
"qry_id",
"=",
"cls",
".",
"from_dc_code",
"(",
"id",
")",
"if",
"not",
"qry_id",
":",
"# id is maybe a ISO",
"qry_id",
"=",
"cls",
".",
"from_iso",
"(",
"id",
")... | Retrieve id from input which can be ISO, name, country, dc_code. | [
"Retrieve",
"id",
"from",
"input",
"which",
"can",
"be",
"ISO",
"name",
"country",
"dc_code",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/datacenter.py#L111-L134 |
11,008 | Gandi/gandi.cli | gandi/cli/core/utils/unixpipe.py | find_port | def find_port(addr, user):
"""Find local port in existing tunnels"""
import pwd
home = pwd.getpwuid(os.getuid()).pw_dir
for name in os.listdir('%s/.ssh/' % home):
if name.startswith('unixpipe_%s@%s_' % (user, addr,)):
return int(name.split('_')[2]) | python | def find_port(addr, user):
"""Find local port in existing tunnels"""
import pwd
home = pwd.getpwuid(os.getuid()).pw_dir
for name in os.listdir('%s/.ssh/' % home):
if name.startswith('unixpipe_%s@%s_' % (user, addr,)):
return int(name.split('_')[2]) | [
"def",
"find_port",
"(",
"addr",
",",
"user",
")",
":",
"import",
"pwd",
"home",
"=",
"pwd",
".",
"getpwuid",
"(",
"os",
".",
"getuid",
"(",
")",
")",
".",
"pw_dir",
"for",
"name",
"in",
"os",
".",
"listdir",
"(",
"'%s/.ssh/'",
"%",
"home",
")",
... | Find local port in existing tunnels | [
"Find",
"local",
"port",
"in",
"existing",
"tunnels"
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/core/utils/unixpipe.py#L128-L134 |
11,009 | Gandi/gandi.cli | gandi/cli/core/utils/unixpipe.py | new_port | def new_port():
"""Find a free local port and allocate it"""
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_TCP)
for i in range(12042, 16042):
try:
s.bind(('127.0.0.1', i))
s.close()
return i
except socket.error:
pass
... | python | def new_port():
"""Find a free local port and allocate it"""
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_TCP)
for i in range(12042, 16042):
try:
s.bind(('127.0.0.1', i))
s.close()
return i
except socket.error:
pass
... | [
"def",
"new_port",
"(",
")",
":",
"s",
"=",
"socket",
".",
"socket",
"(",
"socket",
".",
"AF_INET",
",",
"socket",
".",
"SOCK_STREAM",
",",
"socket",
".",
"IPPROTO_TCP",
")",
"for",
"i",
"in",
"range",
"(",
"12042",
",",
"16042",
")",
":",
"try",
"... | Find a free local port and allocate it | [
"Find",
"a",
"free",
"local",
"port",
"and",
"allocate",
"it"
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/core/utils/unixpipe.py#L137-L147 |
11,010 | Gandi/gandi.cli | gandi/cli/core/utils/unixpipe.py | _ssh_master_cmd | def _ssh_master_cmd(addr, user, command, local_key=None):
"""Exit or check ssh mux"""
ssh_call = ['ssh', '-qNfL%d:127.0.0.1:12042' % find_port(addr, user),
'-o', 'ControlPath=~/.ssh/unixpipe_%%r@%%h_%d' %
find_port(addr, user),
'-O', command, '%s@%s' % (use... | python | def _ssh_master_cmd(addr, user, command, local_key=None):
"""Exit or check ssh mux"""
ssh_call = ['ssh', '-qNfL%d:127.0.0.1:12042' % find_port(addr, user),
'-o', 'ControlPath=~/.ssh/unixpipe_%%r@%%h_%d' %
find_port(addr, user),
'-O', command, '%s@%s' % (use... | [
"def",
"_ssh_master_cmd",
"(",
"addr",
",",
"user",
",",
"command",
",",
"local_key",
"=",
"None",
")",
":",
"ssh_call",
"=",
"[",
"'ssh'",
",",
"'-qNfL%d:127.0.0.1:12042'",
"%",
"find_port",
"(",
"addr",
",",
"user",
")",
",",
"'-o'",
",",
"'ControlPath=~... | Exit or check ssh mux | [
"Exit",
"or",
"check",
"ssh",
"mux"
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/core/utils/unixpipe.py#L150-L161 |
11,011 | Gandi/gandi.cli | gandi/cli/core/utils/unixpipe.py | setup | def setup(addr, user, remote_path, local_key=None):
"""Setup the tunnel"""
port = find_port(addr, user)
if not port or not is_alive(addr, user):
port = new_port()
scp(addr, user, __file__, '~/unixpipe', local_key)
ssh_call = ['ssh', '-fL%d:127.0.0.1:12042' % port,
... | python | def setup(addr, user, remote_path, local_key=None):
"""Setup the tunnel"""
port = find_port(addr, user)
if not port or not is_alive(addr, user):
port = new_port()
scp(addr, user, __file__, '~/unixpipe', local_key)
ssh_call = ['ssh', '-fL%d:127.0.0.1:12042' % port,
... | [
"def",
"setup",
"(",
"addr",
",",
"user",
",",
"remote_path",
",",
"local_key",
"=",
"None",
")",
":",
"port",
"=",
"find_port",
"(",
"addr",
",",
"user",
")",
"if",
"not",
"port",
"or",
"not",
"is_alive",
"(",
"addr",
",",
"user",
")",
":",
"port"... | Setup the tunnel | [
"Setup",
"the",
"tunnel"
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/core/utils/unixpipe.py#L169-L192 |
11,012 | Gandi/gandi.cli | gandi/cli/commands/oper.py | list | def list(gandi, limit, step):
"""List operations."""
output_keys = ['id', 'type', 'step']
options = {
'step': step,
'items_per_page': limit,
'sort_by': 'date_created DESC'
}
result = gandi.oper.list(options)
for num, oper in enumerate(reversed(result)):
if num:
... | python | def list(gandi, limit, step):
"""List operations."""
output_keys = ['id', 'type', 'step']
options = {
'step': step,
'items_per_page': limit,
'sort_by': 'date_created DESC'
}
result = gandi.oper.list(options)
for num, oper in enumerate(reversed(result)):
if num:
... | [
"def",
"list",
"(",
"gandi",
",",
"limit",
",",
"step",
")",
":",
"output_keys",
"=",
"[",
"'id'",
",",
"'type'",
",",
"'step'",
"]",
"options",
"=",
"{",
"'step'",
":",
"step",
",",
"'items_per_page'",
":",
"limit",
",",
"'sort_by'",
":",
"'date_creat... | List operations. | [
"List",
"operations",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/oper.py#L23-L39 |
11,013 | Gandi/gandi.cli | gandi/cli/commands/oper.py | info | def info(gandi, id):
"""Display information about an operation."""
output_keys = ['id', 'type', 'step', 'last_error']
oper = gandi.oper.info(id)
output_generic(gandi, oper, output_keys)
return oper | python | def info(gandi, id):
"""Display information about an operation."""
output_keys = ['id', 'type', 'step', 'last_error']
oper = gandi.oper.info(id)
output_generic(gandi, oper, output_keys)
return oper | [
"def",
"info",
"(",
"gandi",
",",
"id",
")",
":",
"output_keys",
"=",
"[",
"'id'",
",",
"'type'",
",",
"'step'",
",",
"'last_error'",
"]",
"oper",
"=",
"gandi",
".",
"oper",
".",
"info",
"(",
"id",
")",
"output_generic",
"(",
"gandi",
",",
"oper",
... | Display information about an operation. | [
"Display",
"information",
"about",
"an",
"operation",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/oper.py#L45-L52 |
11,014 | Gandi/gandi.cli | gandi/cli/commands/dnssec.py | create | def create(gandi, resource, flags, algorithm, public_key):
"""Create DNSSEC key."""
result = gandi.dnssec.create(resource, flags, algorithm, public_key)
return result | python | def create(gandi, resource, flags, algorithm, public_key):
"""Create DNSSEC key."""
result = gandi.dnssec.create(resource, flags, algorithm, public_key)
return result | [
"def",
"create",
"(",
"gandi",
",",
"resource",
",",
"flags",
",",
"algorithm",
",",
"public_key",
")",
":",
"result",
"=",
"gandi",
".",
"dnssec",
".",
"create",
"(",
"resource",
",",
"flags",
",",
"algorithm",
",",
"public_key",
")",
"return",
"result"... | Create DNSSEC key. | [
"Create",
"DNSSEC",
"key",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/dnssec.py#L23-L28 |
11,015 | Gandi/gandi.cli | gandi/cli/commands/dnssec.py | list | def list(gandi, resource):
"""List DNSSEC keys."""
keys = gandi.dnssec.list(resource)
gandi.pretty_echo(keys)
return keys | python | def list(gandi, resource):
"""List DNSSEC keys."""
keys = gandi.dnssec.list(resource)
gandi.pretty_echo(keys)
return keys | [
"def",
"list",
"(",
"gandi",
",",
"resource",
")",
":",
"keys",
"=",
"gandi",
".",
"dnssec",
".",
"list",
"(",
"resource",
")",
"gandi",
".",
"pretty_echo",
"(",
"keys",
")",
"return",
"keys"
] | List DNSSEC keys. | [
"List",
"DNSSEC",
"keys",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/dnssec.py#L34-L39 |
11,016 | Gandi/gandi.cli | gandi/cli/commands/dnssec.py | delete | def delete(gandi, resource):
"""Delete DNSSEC key.
"""
result = gandi.dnssec.delete(resource)
gandi.echo('Delete successful.')
return result | python | def delete(gandi, resource):
"""Delete DNSSEC key.
"""
result = gandi.dnssec.delete(resource)
gandi.echo('Delete successful.')
return result | [
"def",
"delete",
"(",
"gandi",
",",
"resource",
")",
":",
"result",
"=",
"gandi",
".",
"dnssec",
".",
"delete",
"(",
"resource",
")",
"gandi",
".",
"echo",
"(",
"'Delete successful.'",
")",
"return",
"result"
] | Delete DNSSEC key. | [
"Delete",
"DNSSEC",
"key",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/dnssec.py#L45-L52 |
11,017 | Gandi/gandi.cli | gandi/cli/core/conf.py | GandiConfig.load_config | def load_config(cls):
""" Load global and local configuration files and update if needed."""
config_file = os.path.expanduser(cls.home_config)
global_conf = cls.load(config_file, 'global')
cls.load(cls.local_config, 'local')
# update global configuration if needed
cls.upd... | python | def load_config(cls):
""" Load global and local configuration files and update if needed."""
config_file = os.path.expanduser(cls.home_config)
global_conf = cls.load(config_file, 'global')
cls.load(cls.local_config, 'local')
# update global configuration if needed
cls.upd... | [
"def",
"load_config",
"(",
"cls",
")",
":",
"config_file",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"cls",
".",
"home_config",
")",
"global_conf",
"=",
"cls",
".",
"load",
"(",
"config_file",
",",
"'global'",
")",
"cls",
".",
"load",
"(",
"cls",... | Load global and local configuration files and update if needed. | [
"Load",
"global",
"and",
"local",
"configuration",
"files",
"and",
"update",
"if",
"needed",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/core/conf.py#L40-L46 |
11,018 | Gandi/gandi.cli | gandi/cli/core/conf.py | GandiConfig.update_config | def update_config(cls, config_file, config):
""" Update configuration if needed. """
need_save = False
# delete old env key
if 'api' in config and 'env' in config['api']:
del config['api']['env']
need_save = True
# convert old ssh_key configuration entry
... | python | def update_config(cls, config_file, config):
""" Update configuration if needed. """
need_save = False
# delete old env key
if 'api' in config and 'env' in config['api']:
del config['api']['env']
need_save = True
# convert old ssh_key configuration entry
... | [
"def",
"update_config",
"(",
"cls",
",",
"config_file",
",",
"config",
")",
":",
"need_save",
"=",
"False",
"# delete old env key",
"if",
"'api'",
"in",
"config",
"and",
"'env'",
"in",
"config",
"[",
"'api'",
"]",
":",
"del",
"config",
"[",
"'api'",
"]",
... | Update configuration if needed. | [
"Update",
"configuration",
"if",
"needed",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/core/conf.py#L49-L72 |
11,019 | Gandi/gandi.cli | gandi/cli/core/conf.py | GandiConfig.load | def load(cls, filename, name=None):
""" Load yaml configuration from filename. """
if not os.path.exists(filename):
return {}
name = name or filename
if name not in cls._conffiles:
with open(filename) as fdesc:
content = yaml.load(fdesc, YAMLLoade... | python | def load(cls, filename, name=None):
""" Load yaml configuration from filename. """
if not os.path.exists(filename):
return {}
name = name or filename
if name not in cls._conffiles:
with open(filename) as fdesc:
content = yaml.load(fdesc, YAMLLoade... | [
"def",
"load",
"(",
"cls",
",",
"filename",
",",
"name",
"=",
"None",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"filename",
")",
":",
"return",
"{",
"}",
"name",
"=",
"name",
"or",
"filename",
"if",
"name",
"not",
"in",
"cls",... | Load yaml configuration from filename. | [
"Load",
"yaml",
"configuration",
"from",
"filename",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/core/conf.py#L75-L89 |
11,020 | Gandi/gandi.cli | gandi/cli/core/conf.py | GandiConfig.save | def save(cls, filename, config):
""" Save configuration to yaml file. """
mode = os.O_WRONLY | os.O_TRUNC | os.O_CREAT
with os.fdopen(os.open(filename, mode, 0o600), 'w') as fname:
yaml.safe_dump(config, fname, indent=4, default_flow_style=False) | python | def save(cls, filename, config):
""" Save configuration to yaml file. """
mode = os.O_WRONLY | os.O_TRUNC | os.O_CREAT
with os.fdopen(os.open(filename, mode, 0o600), 'w') as fname:
yaml.safe_dump(config, fname, indent=4, default_flow_style=False) | [
"def",
"save",
"(",
"cls",
",",
"filename",
",",
"config",
")",
":",
"mode",
"=",
"os",
".",
"O_WRONLY",
"|",
"os",
".",
"O_TRUNC",
"|",
"os",
".",
"O_CREAT",
"with",
"os",
".",
"fdopen",
"(",
"os",
".",
"open",
"(",
"filename",
",",
"mode",
",",... | Save configuration to yaml file. | [
"Save",
"configuration",
"to",
"yaml",
"file",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/core/conf.py#L92-L96 |
11,021 | Gandi/gandi.cli | gandi/cli/core/conf.py | GandiConfig.get | def get(cls, key, default=None, separator='.', global_=False):
""" Retrieve a key value from loaded configuration.
Order of search if global_=False:
1/ environnment variables
2/ local configuration
3/ global configuration
"""
# first check environnment variables
... | python | def get(cls, key, default=None, separator='.', global_=False):
""" Retrieve a key value from loaded configuration.
Order of search if global_=False:
1/ environnment variables
2/ local configuration
3/ global configuration
"""
# first check environnment variables
... | [
"def",
"get",
"(",
"cls",
",",
"key",
",",
"default",
"=",
"None",
",",
"separator",
"=",
"'.'",
",",
"global_",
"=",
"False",
")",
":",
"# first check environnment variables",
"# if we're not in global scope",
"if",
"not",
"global_",
":",
"ret",
"=",
"os",
... | Retrieve a key value from loaded configuration.
Order of search if global_=False:
1/ environnment variables
2/ local configuration
3/ global configuration | [
"Retrieve",
"a",
"key",
"value",
"from",
"loaded",
"configuration",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/core/conf.py#L165-L188 |
11,022 | Gandi/gandi.cli | gandi/cli/core/conf.py | GandiConfig.configure | def configure(cls, global_, key, val):
""" Update and save configuration value to file. """
# first retrieve current configuration
scope = 'global' if global_ else 'local'
if scope not in cls._conffiles:
cls._conffiles[scope] = {}
config = cls._conffiles.get(scope, {}... | python | def configure(cls, global_, key, val):
""" Update and save configuration value to file. """
# first retrieve current configuration
scope = 'global' if global_ else 'local'
if scope not in cls._conffiles:
cls._conffiles[scope] = {}
config = cls._conffiles.get(scope, {}... | [
"def",
"configure",
"(",
"cls",
",",
"global_",
",",
"key",
",",
"val",
")",
":",
"# first retrieve current configuration",
"scope",
"=",
"'global'",
"if",
"global_",
"else",
"'local'",
"if",
"scope",
"not",
"in",
"cls",
".",
"_conffiles",
":",
"cls",
".",
... | Update and save configuration value to file. | [
"Update",
"and",
"save",
"configuration",
"value",
"to",
"file",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/core/conf.py#L191-L202 |
11,023 | Gandi/gandi.cli | gandi/cli/commands/account.py | info | def info(gandi):
"""Display information about hosting account.
"""
output_keys = ['handle', 'credit', 'prepaid']
account = gandi.account.all()
account['prepaid_info'] = gandi.contact.balance().get('prepaid', {})
output_account(gandi, account, output_keys)
return account | python | def info(gandi):
"""Display information about hosting account.
"""
output_keys = ['handle', 'credit', 'prepaid']
account = gandi.account.all()
account['prepaid_info'] = gandi.contact.balance().get('prepaid', {})
output_account(gandi, account, output_keys)
return account | [
"def",
"info",
"(",
"gandi",
")",
":",
"output_keys",
"=",
"[",
"'handle'",
",",
"'credit'",
",",
"'prepaid'",
"]",
"account",
"=",
"gandi",
".",
"account",
".",
"all",
"(",
")",
"account",
"[",
"'prepaid_info'",
"]",
"=",
"gandi",
".",
"contact",
".",... | Display information about hosting account. | [
"Display",
"information",
"about",
"hosting",
"account",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/account.py#L16-L24 |
11,024 | Gandi/gandi.cli | gandi/cli/modules/network.py | Ip.create | def create(cls, ip_version, datacenter, bandwidth, vm=None, vlan=None,
ip=None, background=False):
""" Create a public ip and attach it if vm is given. """
return Iface.create(ip_version, datacenter, bandwidth, vlan, vm, ip,
background) | python | def create(cls, ip_version, datacenter, bandwidth, vm=None, vlan=None,
ip=None, background=False):
""" Create a public ip and attach it if vm is given. """
return Iface.create(ip_version, datacenter, bandwidth, vlan, vm, ip,
background) | [
"def",
"create",
"(",
"cls",
",",
"ip_version",
",",
"datacenter",
",",
"bandwidth",
",",
"vm",
"=",
"None",
",",
"vlan",
"=",
"None",
",",
"ip",
"=",
"None",
",",
"background",
"=",
"False",
")",
":",
"return",
"Iface",
".",
"create",
"(",
"ip_versi... | Create a public ip and attach it if vm is given. | [
"Create",
"a",
"public",
"ip",
"and",
"attach",
"it",
"if",
"vm",
"is",
"given",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/network.py#L39-L43 |
11,025 | Gandi/gandi.cli | gandi/cli/modules/network.py | Ip.update | def update(cls, resource, params, background=False):
""" Update this IP """
cls.echo('Updating your IP')
result = cls.call('hosting.ip.update', cls.usable_id(resource),
params)
if not background:
cls.display_progress(result)
return result | python | def update(cls, resource, params, background=False):
""" Update this IP """
cls.echo('Updating your IP')
result = cls.call('hosting.ip.update', cls.usable_id(resource),
params)
if not background:
cls.display_progress(result)
return result | [
"def",
"update",
"(",
"cls",
",",
"resource",
",",
"params",
",",
"background",
"=",
"False",
")",
":",
"cls",
".",
"echo",
"(",
"'Updating your IP'",
")",
"result",
"=",
"cls",
".",
"call",
"(",
"'hosting.ip.update'",
",",
"cls",
".",
"usable_id",
"(",
... | Update this IP | [
"Update",
"this",
"IP"
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/network.py#L46-L53 |
11,026 | Gandi/gandi.cli | gandi/cli/modules/network.py | Ip.delete | def delete(cls, resources, background=False, force=False):
"""Delete an ip by deleting the iface"""
if not isinstance(resources, (list, tuple)):
resources = [resources]
ifaces = []
for item in resources:
try:
ip_ = cls.info(item)
excep... | python | def delete(cls, resources, background=False, force=False):
"""Delete an ip by deleting the iface"""
if not isinstance(resources, (list, tuple)):
resources = [resources]
ifaces = []
for item in resources:
try:
ip_ = cls.info(item)
excep... | [
"def",
"delete",
"(",
"cls",
",",
"resources",
",",
"background",
"=",
"False",
",",
"force",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"resources",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"resources",
"=",
"[",
"resources",
"]",... | Delete an ip by deleting the iface | [
"Delete",
"an",
"ip",
"by",
"deleting",
"the",
"iface"
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/network.py#L113-L128 |
11,027 | Gandi/gandi.cli | gandi/cli/modules/network.py | Ip.from_ip | def from_ip(cls, ip):
"""Retrieve ip id associated to an ip."""
ips = dict([(ip_['ip'], ip_['id'])
for ip_ in cls.list({'items_per_page': 500})])
return ips.get(ip) | python | def from_ip(cls, ip):
"""Retrieve ip id associated to an ip."""
ips = dict([(ip_['ip'], ip_['id'])
for ip_ in cls.list({'items_per_page': 500})])
return ips.get(ip) | [
"def",
"from_ip",
"(",
"cls",
",",
"ip",
")",
":",
"ips",
"=",
"dict",
"(",
"[",
"(",
"ip_",
"[",
"'ip'",
"]",
",",
"ip_",
"[",
"'id'",
"]",
")",
"for",
"ip_",
"in",
"cls",
".",
"list",
"(",
"{",
"'items_per_page'",
":",
"500",
"}",
")",
"]",... | Retrieve ip id associated to an ip. | [
"Retrieve",
"ip",
"id",
"associated",
"to",
"an",
"ip",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/network.py#L131-L135 |
11,028 | Gandi/gandi.cli | gandi/cli/modules/network.py | Vlan.list | def list(cls, datacenter=None):
"""List virtual machine vlan
(in the future it should also handle PaaS vlan)."""
options = {}
if datacenter:
datacenter_id = int(Datacenter.usable_id(datacenter))
options['datacenter_id'] = datacenter_id
return cls.call('h... | python | def list(cls, datacenter=None):
"""List virtual machine vlan
(in the future it should also handle PaaS vlan)."""
options = {}
if datacenter:
datacenter_id = int(Datacenter.usable_id(datacenter))
options['datacenter_id'] = datacenter_id
return cls.call('h... | [
"def",
"list",
"(",
"cls",
",",
"datacenter",
"=",
"None",
")",
":",
"options",
"=",
"{",
"}",
"if",
"datacenter",
":",
"datacenter_id",
"=",
"int",
"(",
"Datacenter",
".",
"usable_id",
"(",
"datacenter",
")",
")",
"options",
"[",
"'datacenter_id'",
"]",... | List virtual machine vlan
(in the future it should also handle PaaS vlan). | [
"List",
"virtual",
"machine",
"vlan"
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/network.py#L168-L177 |
11,029 | Gandi/gandi.cli | gandi/cli/modules/network.py | Vlan.ifaces | def ifaces(cls, name):
""" Get vlan attached ifaces. """
ifaces = Iface.list({'vlan_id': cls.usable_id(name)})
ret = []
for iface in ifaces:
ret.append(Iface.info(iface['id']))
return ret | python | def ifaces(cls, name):
""" Get vlan attached ifaces. """
ifaces = Iface.list({'vlan_id': cls.usable_id(name)})
ret = []
for iface in ifaces:
ret.append(Iface.info(iface['id']))
return ret | [
"def",
"ifaces",
"(",
"cls",
",",
"name",
")",
":",
"ifaces",
"=",
"Iface",
".",
"list",
"(",
"{",
"'vlan_id'",
":",
"cls",
".",
"usable_id",
"(",
"name",
")",
"}",
")",
"ret",
"=",
"[",
"]",
"for",
"iface",
"in",
"ifaces",
":",
"ret",
".",
"ap... | Get vlan attached ifaces. | [
"Get",
"vlan",
"attached",
"ifaces",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/network.py#L188-L194 |
11,030 | Gandi/gandi.cli | gandi/cli/modules/network.py | Vlan.delete | def delete(cls, resources, background=False):
"""Delete a vlan."""
if not isinstance(resources, (list, tuple)):
resources = [resources]
opers = []
for item in resources:
oper = cls.call('hosting.vlan.delete', cls.usable_id(item))
if not oper:
... | python | def delete(cls, resources, background=False):
"""Delete a vlan."""
if not isinstance(resources, (list, tuple)):
resources = [resources]
opers = []
for item in resources:
oper = cls.call('hosting.vlan.delete', cls.usable_id(item))
if not oper:
... | [
"def",
"delete",
"(",
"cls",
",",
"resources",
",",
"background",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"resources",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"resources",
"=",
"[",
"resources",
"]",
"opers",
"=",
"[",
"]",
"... | Delete a vlan. | [
"Delete",
"a",
"vlan",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/network.py#L207-L229 |
11,031 | Gandi/gandi.cli | gandi/cli/modules/network.py | Vlan.create | def create(cls, name, datacenter, subnet=None, gateway=None,
background=False):
"""Create a new vlan."""
if not background and not cls.intty():
background = True
datacenter_id_ = int(Datacenter.usable_id(datacenter))
vlan_params = {
'name': name,
... | python | def create(cls, name, datacenter, subnet=None, gateway=None,
background=False):
"""Create a new vlan."""
if not background and not cls.intty():
background = True
datacenter_id_ = int(Datacenter.usable_id(datacenter))
vlan_params = {
'name': name,
... | [
"def",
"create",
"(",
"cls",
",",
"name",
",",
"datacenter",
",",
"subnet",
"=",
"None",
",",
"gateway",
"=",
"None",
",",
"background",
"=",
"False",
")",
":",
"if",
"not",
"background",
"and",
"not",
"cls",
".",
"intty",
"(",
")",
":",
"background"... | Create a new vlan. | [
"Create",
"a",
"new",
"vlan",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/network.py#L232-L258 |
11,032 | Gandi/gandi.cli | gandi/cli/modules/network.py | Vlan.update | def update(cls, id, params):
"""Update an existing vlan."""
cls.echo('Updating your vlan.')
result = cls.call('hosting.vlan.update', cls.usable_id(id), params)
return result | python | def update(cls, id, params):
"""Update an existing vlan."""
cls.echo('Updating your vlan.')
result = cls.call('hosting.vlan.update', cls.usable_id(id), params)
return result | [
"def",
"update",
"(",
"cls",
",",
"id",
",",
"params",
")",
":",
"cls",
".",
"echo",
"(",
"'Updating your vlan.'",
")",
"result",
"=",
"cls",
".",
"call",
"(",
"'hosting.vlan.update'",
",",
"cls",
".",
"usable_id",
"(",
"id",
")",
",",
"params",
")",
... | Update an existing vlan. | [
"Update",
"an",
"existing",
"vlan",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/network.py#L261-L265 |
11,033 | Gandi/gandi.cli | gandi/cli/modules/network.py | Vlan.from_name | def from_name(cls, name):
"""Retrieve vlan id associated to a name."""
result = cls.list()
vlans = {}
for vlan in result:
vlans[vlan['name']] = vlan['id']
return vlans.get(name) | python | def from_name(cls, name):
"""Retrieve vlan id associated to a name."""
result = cls.list()
vlans = {}
for vlan in result:
vlans[vlan['name']] = vlan['id']
return vlans.get(name) | [
"def",
"from_name",
"(",
"cls",
",",
"name",
")",
":",
"result",
"=",
"cls",
".",
"list",
"(",
")",
"vlans",
"=",
"{",
"}",
"for",
"vlan",
"in",
"result",
":",
"vlans",
"[",
"vlan",
"[",
"'name'",
"]",
"]",
"=",
"vlan",
"[",
"'id'",
"]",
"retur... | Retrieve vlan id associated to a name. | [
"Retrieve",
"vlan",
"id",
"associated",
"to",
"a",
"name",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/network.py#L268-L275 |
11,034 | Gandi/gandi.cli | gandi/cli/modules/network.py | Iface.usable_id | def usable_id(cls, id):
""" Retrieve id from input which can be num or id."""
try:
qry_id = int(id)
except Exception:
qry_id = None
if not qry_id:
msg = 'unknown identifier %s' % id
cls.error(msg)
return qry_id | python | def usable_id(cls, id):
""" Retrieve id from input which can be num or id."""
try:
qry_id = int(id)
except Exception:
qry_id = None
if not qry_id:
msg = 'unknown identifier %s' % id
cls.error(msg)
return qry_id | [
"def",
"usable_id",
"(",
"cls",
",",
"id",
")",
":",
"try",
":",
"qry_id",
"=",
"int",
"(",
"id",
")",
"except",
"Exception",
":",
"qry_id",
"=",
"None",
"if",
"not",
"qry_id",
":",
"msg",
"=",
"'unknown identifier %s'",
"%",
"id",
"cls",
".",
"error... | Retrieve id from input which can be num or id. | [
"Retrieve",
"id",
"from",
"input",
"which",
"can",
"be",
"num",
"or",
"id",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/network.py#L324-L335 |
11,035 | Gandi/gandi.cli | gandi/cli/modules/network.py | Iface._attach | def _attach(cls, iface_id, vm_id):
""" Attach an iface to a vm. """
oper = cls.call('hosting.vm.iface_attach', vm_id, iface_id)
return oper | python | def _attach(cls, iface_id, vm_id):
""" Attach an iface to a vm. """
oper = cls.call('hosting.vm.iface_attach', vm_id, iface_id)
return oper | [
"def",
"_attach",
"(",
"cls",
",",
"iface_id",
",",
"vm_id",
")",
":",
"oper",
"=",
"cls",
".",
"call",
"(",
"'hosting.vm.iface_attach'",
",",
"vm_id",
",",
"iface_id",
")",
"return",
"oper"
] | Attach an iface to a vm. | [
"Attach",
"an",
"iface",
"to",
"a",
"vm",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/network.py#L338-L341 |
11,036 | Gandi/gandi.cli | gandi/cli/modules/network.py | Iface.create | def create(cls, ip_version, datacenter, bandwidth, vlan, vm, ip,
background):
""" Create a new iface """
if not background and not cls.intty():
background = True
datacenter_id_ = int(Datacenter.usable_id(datacenter))
iface_params = {
'ip_version':... | python | def create(cls, ip_version, datacenter, bandwidth, vlan, vm, ip,
background):
""" Create a new iface """
if not background and not cls.intty():
background = True
datacenter_id_ = int(Datacenter.usable_id(datacenter))
iface_params = {
'ip_version':... | [
"def",
"create",
"(",
"cls",
",",
"ip_version",
",",
"datacenter",
",",
"bandwidth",
",",
"vlan",
",",
"vm",
",",
"ip",
",",
"background",
")",
":",
"if",
"not",
"background",
"and",
"not",
"cls",
".",
"intty",
"(",
")",
":",
"background",
"=",
"True... | Create a new iface | [
"Create",
"a",
"new",
"iface"
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/network.py#L344-L387 |
11,037 | Gandi/gandi.cli | gandi/cli/modules/network.py | Iface._detach | def _detach(cls, iface_id):
""" Detach an iface from a vm. """
iface = cls._info(iface_id)
opers = []
vm_id = iface.get('vm_id')
if vm_id:
cls.echo('The iface is still attached to the vm %s.' % vm_id)
cls.echo('Will detach it.')
opers.append(cl... | python | def _detach(cls, iface_id):
""" Detach an iface from a vm. """
iface = cls._info(iface_id)
opers = []
vm_id = iface.get('vm_id')
if vm_id:
cls.echo('The iface is still attached to the vm %s.' % vm_id)
cls.echo('Will detach it.')
opers.append(cl... | [
"def",
"_detach",
"(",
"cls",
",",
"iface_id",
")",
":",
"iface",
"=",
"cls",
".",
"_info",
"(",
"iface_id",
")",
"opers",
"=",
"[",
"]",
"vm_id",
"=",
"iface",
".",
"get",
"(",
"'vm_id'",
")",
"if",
"vm_id",
":",
"cls",
".",
"echo",
"(",
"'The i... | Detach an iface from a vm. | [
"Detach",
"an",
"iface",
"from",
"a",
"vm",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/network.py#L390-L399 |
11,038 | Gandi/gandi.cli | gandi/cli/modules/network.py | Iface.update | def update(cls, id, bandwidth, vm, background):
""" Update this iface. """
if not background and not cls.intty():
background = True
iface_params = {}
iface_id = cls.usable_id(id)
if bandwidth:
iface_params['bandwidth'] = bandwidth
if iface_param... | python | def update(cls, id, bandwidth, vm, background):
""" Update this iface. """
if not background and not cls.intty():
background = True
iface_params = {}
iface_id = cls.usable_id(id)
if bandwidth:
iface_params['bandwidth'] = bandwidth
if iface_param... | [
"def",
"update",
"(",
"cls",
",",
"id",
",",
"bandwidth",
",",
"vm",
",",
"background",
")",
":",
"if",
"not",
"background",
"and",
"not",
"cls",
".",
"intty",
"(",
")",
":",
"background",
"=",
"True",
"iface_params",
"=",
"{",
"}",
"iface_id",
"=",
... | Update this iface. | [
"Update",
"this",
"iface",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/network.py#L430-L466 |
11,039 | Gandi/gandi.cli | gandi/cli/modules/forward.py | Forward.get_destinations | def get_destinations(cls, domain, source):
"""Retrieve forward information."""
forwards = cls.list(domain, {'items_per_page': 500})
for fwd in forwards:
if fwd['source'] == source:
return fwd['destinations']
return [] | python | def get_destinations(cls, domain, source):
"""Retrieve forward information."""
forwards = cls.list(domain, {'items_per_page': 500})
for fwd in forwards:
if fwd['source'] == source:
return fwd['destinations']
return [] | [
"def",
"get_destinations",
"(",
"cls",
",",
"domain",
",",
"source",
")",
":",
"forwards",
"=",
"cls",
".",
"list",
"(",
"domain",
",",
"{",
"'items_per_page'",
":",
"500",
"}",
")",
"for",
"fwd",
"in",
"forwards",
":",
"if",
"fwd",
"[",
"'source'",
... | Retrieve forward information. | [
"Retrieve",
"forward",
"information",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/forward.py#L37-L44 |
11,040 | Gandi/gandi.cli | gandi/cli/modules/forward.py | Forward.update | def update(cls, domain, source, dest_add, dest_del):
"""Update a domain mail forward destinations."""
result = None
if dest_add or dest_del:
current_destinations = cls.get_destinations(domain, source)
fwds = current_destinations[:]
if dest_add:
... | python | def update(cls, domain, source, dest_add, dest_del):
"""Update a domain mail forward destinations."""
result = None
if dest_add or dest_del:
current_destinations = cls.get_destinations(domain, source)
fwds = current_destinations[:]
if dest_add:
... | [
"def",
"update",
"(",
"cls",
",",
"domain",
",",
"source",
",",
"dest_add",
",",
"dest_del",
")",
":",
"result",
"=",
"None",
"if",
"dest_add",
"or",
"dest_del",
":",
"current_destinations",
"=",
"cls",
".",
"get_destinations",
"(",
"domain",
",",
"source"... | Update a domain mail forward destinations. | [
"Update",
"a",
"domain",
"mail",
"forward",
"destinations",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/forward.py#L47-L70 |
11,041 | Gandi/gandi.cli | gandi/cli/commands/mail.py | list | def list(gandi, domain, limit):
"""List mailboxes created on a domain."""
options = {'items_per_page': limit}
mailboxes = gandi.mail.list(domain, options)
output_list(gandi, [mbox['login'] for mbox in mailboxes])
return mailboxes | python | def list(gandi, domain, limit):
"""List mailboxes created on a domain."""
options = {'items_per_page': limit}
mailboxes = gandi.mail.list(domain, options)
output_list(gandi, [mbox['login'] for mbox in mailboxes])
return mailboxes | [
"def",
"list",
"(",
"gandi",
",",
"domain",
",",
"limit",
")",
":",
"options",
"=",
"{",
"'items_per_page'",
":",
"limit",
"}",
"mailboxes",
"=",
"gandi",
".",
"mail",
".",
"list",
"(",
"domain",
",",
"options",
")",
"output_list",
"(",
"gandi",
",",
... | List mailboxes created on a domain. | [
"List",
"mailboxes",
"created",
"on",
"a",
"domain",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/mail.py#L21-L26 |
11,042 | Gandi/gandi.cli | gandi/cli/commands/mail.py | info | def info(gandi, email):
"""Display information about a mailbox."""
login, domain = email
output_keys = ['login', 'aliases', 'fallback', 'quota', 'responder']
mailbox = gandi.mail.info(domain, login)
output_mailbox(gandi, mailbox, output_keys)
return mailbox | python | def info(gandi, email):
"""Display information about a mailbox."""
login, domain = email
output_keys = ['login', 'aliases', 'fallback', 'quota', 'responder']
mailbox = gandi.mail.info(domain, login)
output_mailbox(gandi, mailbox, output_keys)
return mailbox | [
"def",
"info",
"(",
"gandi",
",",
"email",
")",
":",
"login",
",",
"domain",
"=",
"email",
"output_keys",
"=",
"[",
"'login'",
",",
"'aliases'",
",",
"'fallback'",
",",
"'quota'",
",",
"'responder'",
"]",
"mailbox",
"=",
"gandi",
".",
"mail",
".",
"inf... | Display information about a mailbox. | [
"Display",
"information",
"about",
"a",
"mailbox",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/mail.py#L32-L40 |
11,043 | Gandi/gandi.cli | gandi/cli/commands/mail.py | delete | def delete(gandi, email, force):
"""Delete a mailbox."""
login, domain = email
if not force:
proceed = click.confirm('Are you sure to delete the '
'mailbox %s@%s ?' % (login, domain))
if not proceed:
return
result = gandi.mail.delete(domain,... | python | def delete(gandi, email, force):
"""Delete a mailbox."""
login, domain = email
if not force:
proceed = click.confirm('Are you sure to delete the '
'mailbox %s@%s ?' % (login, domain))
if not proceed:
return
result = gandi.mail.delete(domain,... | [
"def",
"delete",
"(",
"gandi",
",",
"email",
",",
"force",
")",
":",
"login",
",",
"domain",
"=",
"email",
"if",
"not",
"force",
":",
"proceed",
"=",
"click",
".",
"confirm",
"(",
"'Are you sure to delete the '",
"'mailbox %s@%s ?'",
"%",
"(",
"login",
","... | Delete a mailbox. | [
"Delete",
"a",
"mailbox",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/mail.py#L79-L92 |
11,044 | Gandi/gandi.cli | gandi/cli/modules/disk.py | Disk.from_name | def from_name(cls, name):
""" Retrieve a disk id associated to a name. """
disks = cls.list({'name': name})
if len(disks) == 1:
return disks[0]['id']
elif not disks:
return
raise DuplicateResults('disk name %s is ambiguous.' % name) | python | def from_name(cls, name):
""" Retrieve a disk id associated to a name. """
disks = cls.list({'name': name})
if len(disks) == 1:
return disks[0]['id']
elif not disks:
return
raise DuplicateResults('disk name %s is ambiguous.' % name) | [
"def",
"from_name",
"(",
"cls",
",",
"name",
")",
":",
"disks",
"=",
"cls",
".",
"list",
"(",
"{",
"'name'",
":",
"name",
"}",
")",
"if",
"len",
"(",
"disks",
")",
"==",
"1",
":",
"return",
"disks",
"[",
"0",
"]",
"[",
"'id'",
"]",
"elif",
"n... | Retrieve a disk id associated to a name. | [
"Retrieve",
"a",
"disk",
"id",
"associated",
"to",
"a",
"name",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/disk.py#L26-L34 |
11,045 | Gandi/gandi.cli | gandi/cli/modules/disk.py | Disk.list_create | def list_create(cls, datacenter=None, label=None):
"""List available disks for vm creation."""
options = {
'items_per_page': DISK_MAXLIST
}
if datacenter:
datacenter_id = int(Datacenter.usable_id(datacenter))
options['datacenter_id'] = datacenter_id
... | python | def list_create(cls, datacenter=None, label=None):
"""List available disks for vm creation."""
options = {
'items_per_page': DISK_MAXLIST
}
if datacenter:
datacenter_id = int(Datacenter.usable_id(datacenter))
options['datacenter_id'] = datacenter_id
... | [
"def",
"list_create",
"(",
"cls",
",",
"datacenter",
"=",
"None",
",",
"label",
"=",
"None",
")",
":",
"options",
"=",
"{",
"'items_per_page'",
":",
"DISK_MAXLIST",
"}",
"if",
"datacenter",
":",
"datacenter_id",
"=",
"int",
"(",
"Datacenter",
".",
"usable_... | List available disks for vm creation. | [
"List",
"available",
"disks",
"for",
"vm",
"creation",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/disk.py#L61-L75 |
11,046 | Gandi/gandi.cli | gandi/cli/modules/disk.py | Disk.disk_param | def disk_param(name, size, snapshot_profile, cmdline=None, kernel=None):
""" Return disk parameter structure. """
disk_params = {}
if cmdline:
disk_params['cmdline'] = cmdline
if kernel:
disk_params['kernel'] = kernel
if name:
disk_params['n... | python | def disk_param(name, size, snapshot_profile, cmdline=None, kernel=None):
""" Return disk parameter structure. """
disk_params = {}
if cmdline:
disk_params['cmdline'] = cmdline
if kernel:
disk_params['kernel'] = kernel
if name:
disk_params['n... | [
"def",
"disk_param",
"(",
"name",
",",
"size",
",",
"snapshot_profile",
",",
"cmdline",
"=",
"None",
",",
"kernel",
"=",
"None",
")",
":",
"disk_params",
"=",
"{",
"}",
"if",
"cmdline",
":",
"disk_params",
"[",
"'cmdline'",
"]",
"=",
"cmdline",
"if",
"... | Return disk parameter structure. | [
"Return",
"disk",
"parameter",
"structure",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/disk.py#L88-L107 |
11,047 | Gandi/gandi.cli | gandi/cli/modules/disk.py | Disk.update | def update(cls, resource, name, size, snapshot_profile,
background, cmdline=None, kernel=None):
""" Update this disk. """
if isinstance(size, tuple):
prefix, size = size
if prefix == '+':
disk_info = cls.info(resource)
current_size =... | python | def update(cls, resource, name, size, snapshot_profile,
background, cmdline=None, kernel=None):
""" Update this disk. """
if isinstance(size, tuple):
prefix, size = size
if prefix == '+':
disk_info = cls.info(resource)
current_size =... | [
"def",
"update",
"(",
"cls",
",",
"resource",
",",
"name",
",",
"size",
",",
"snapshot_profile",
",",
"background",
",",
"cmdline",
"=",
"None",
",",
"kernel",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"size",
",",
"tuple",
")",
":",
"prefix",
... | Update this disk. | [
"Update",
"this",
"disk",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/disk.py#L110-L131 |
11,048 | Gandi/gandi.cli | gandi/cli/modules/disk.py | Disk._detach | def _detach(cls, disk_id):
""" Detach a disk from a vm. """
disk = cls._info(disk_id)
opers = []
if disk.get('vms_id'):
for vm_id in disk['vms_id']:
cls.echo('The disk is still attached to the vm %s.' % vm_id)
cls.echo('Will detach it.')
... | python | def _detach(cls, disk_id):
""" Detach a disk from a vm. """
disk = cls._info(disk_id)
opers = []
if disk.get('vms_id'):
for vm_id in disk['vms_id']:
cls.echo('The disk is still attached to the vm %s.' % vm_id)
cls.echo('Will detach it.')
... | [
"def",
"_detach",
"(",
"cls",
",",
"disk_id",
")",
":",
"disk",
"=",
"cls",
".",
"_info",
"(",
"disk_id",
")",
"opers",
"=",
"[",
"]",
"if",
"disk",
".",
"get",
"(",
"'vms_id'",
")",
":",
"for",
"vm_id",
"in",
"disk",
"[",
"'vms_id'",
"]",
":",
... | Detach a disk from a vm. | [
"Detach",
"a",
"disk",
"from",
"a",
"vm",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/disk.py#L134-L144 |
11,049 | Gandi/gandi.cli | gandi/cli/modules/disk.py | Disk.delete | def delete(cls, resources, background=False):
""" Delete this disk."""
if not isinstance(resources, (list, tuple)):
resources = [resources]
resources = [cls.usable_id(item) for item in resources]
opers = []
for disk_id in resources:
opers.extend(cls._det... | python | def delete(cls, resources, background=False):
""" Delete this disk."""
if not isinstance(resources, (list, tuple)):
resources = [resources]
resources = [cls.usable_id(item) for item in resources]
opers = []
for disk_id in resources:
opers.extend(cls._det... | [
"def",
"delete",
"(",
"cls",
",",
"resources",
",",
"background",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"resources",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"resources",
"=",
"[",
"resources",
"]",
"resources",
"=",
"[",
"cls... | Delete this disk. | [
"Delete",
"this",
"disk",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/disk.py#L164-L190 |
11,050 | Gandi/gandi.cli | gandi/cli/modules/disk.py | Disk._attach | def _attach(cls, disk_id, vm_id, options=None):
""" Attach a disk to a vm. """
options = options or {}
oper = cls.call('hosting.vm.disk_attach', vm_id, disk_id, options)
return oper | python | def _attach(cls, disk_id, vm_id, options=None):
""" Attach a disk to a vm. """
options = options or {}
oper = cls.call('hosting.vm.disk_attach', vm_id, disk_id, options)
return oper | [
"def",
"_attach",
"(",
"cls",
",",
"disk_id",
",",
"vm_id",
",",
"options",
"=",
"None",
")",
":",
"options",
"=",
"options",
"or",
"{",
"}",
"oper",
"=",
"cls",
".",
"call",
"(",
"'hosting.vm.disk_attach'",
",",
"vm_id",
",",
"disk_id",
",",
"options"... | Attach a disk to a vm. | [
"Attach",
"a",
"disk",
"to",
"a",
"vm",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/disk.py#L193-L197 |
11,051 | Gandi/gandi.cli | gandi/cli/modules/disk.py | Disk.create | def create(cls, name, vm, size, snapshotprofile, datacenter,
source, disk_type='data', background=False):
""" Create a disk and attach it to a vm. """
if isinstance(size, tuple):
prefix, size = size
if source:
size = None
disk_params = cls.disk_par... | python | def create(cls, name, vm, size, snapshotprofile, datacenter,
source, disk_type='data', background=False):
""" Create a disk and attach it to a vm. """
if isinstance(size, tuple):
prefix, size = size
if source:
size = None
disk_params = cls.disk_par... | [
"def",
"create",
"(",
"cls",
",",
"name",
",",
"vm",
",",
"size",
",",
"snapshotprofile",
",",
"datacenter",
",",
"source",
",",
"disk_type",
"=",
"'data'",
",",
"background",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"size",
",",
"tuple",
")",
... | Create a disk and attach it to a vm. | [
"Create",
"a",
"disk",
"and",
"attach",
"it",
"to",
"a",
"vm",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/disk.py#L236-L272 |
11,052 | Gandi/gandi.cli | gandi/cli/core/cli.py | compatcallback | def compatcallback(f):
""" Compatibility callback decorator for older click version.
Click 1.0 does not have a version string stored, so we need to
use getattr here to be safe.
"""
if getattr(click, '__version__', '0.0') >= '2.0':
return f
return update_wrapper(lambda ctx, value: f(ctx,... | python | def compatcallback(f):
""" Compatibility callback decorator for older click version.
Click 1.0 does not have a version string stored, so we need to
use getattr here to be safe.
"""
if getattr(click, '__version__', '0.0') >= '2.0':
return f
return update_wrapper(lambda ctx, value: f(ctx,... | [
"def",
"compatcallback",
"(",
"f",
")",
":",
"if",
"getattr",
"(",
"click",
",",
"'__version__'",
",",
"'0.0'",
")",
">=",
"'2.0'",
":",
"return",
"f",
"return",
"update_wrapper",
"(",
"lambda",
"ctx",
",",
"value",
":",
"f",
"(",
"ctx",
",",
"None",
... | Compatibility callback decorator for older click version.
Click 1.0 does not have a version string stored, so we need to
use getattr here to be safe. | [
"Compatibility",
"callback",
"decorator",
"for",
"older",
"click",
"version",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/core/cli.py#L40-L48 |
11,053 | Gandi/gandi.cli | gandi/cli/core/cli.py | GandiCLI.list_sub_commmands | def list_sub_commmands(self, cmd_name, cmd):
"""Return all commands for a group"""
ret = {}
if isinstance(cmd, click.core.Group):
for sub_cmd_name in cmd.commands:
sub_cmd = cmd.commands[sub_cmd_name]
sub = self.list_sub_commmands(sub_cmd_name, sub_cmd... | python | def list_sub_commmands(self, cmd_name, cmd):
"""Return all commands for a group"""
ret = {}
if isinstance(cmd, click.core.Group):
for sub_cmd_name in cmd.commands:
sub_cmd = cmd.commands[sub_cmd_name]
sub = self.list_sub_commmands(sub_cmd_name, sub_cmd... | [
"def",
"list_sub_commmands",
"(",
"self",
",",
"cmd_name",
",",
"cmd",
")",
":",
"ret",
"=",
"{",
"}",
"if",
"isinstance",
"(",
"cmd",
",",
"click",
".",
"core",
".",
"Group",
")",
":",
"for",
"sub_cmd_name",
"in",
"cmd",
".",
"commands",
":",
"sub_c... | Return all commands for a group | [
"Return",
"all",
"commands",
"for",
"a",
"group"
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/core/cli.py#L109-L124 |
11,054 | Gandi/gandi.cli | gandi/cli/core/cli.py | GandiCLI.load_commands | def load_commands(self):
""" Load cli commands from submodules. """
command_folder = os.path.join(os.path.dirname(__file__),
'..', 'commands')
command_dirs = {
'gandi.cli': command_folder
}
if 'GANDICLI_PATH' in os.environ:
... | python | def load_commands(self):
""" Load cli commands from submodules. """
command_folder = os.path.join(os.path.dirname(__file__),
'..', 'commands')
command_dirs = {
'gandi.cli': command_folder
}
if 'GANDICLI_PATH' in os.environ:
... | [
"def",
"load_commands",
"(",
"self",
")",
":",
"command_folder",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"'..'",
",",
"'commands'",
")",
"command_dirs",
"=",
"{",
"'gandi.cli'",
":",
"comm... | Load cli commands from submodules. | [
"Load",
"cli",
"commands",
"from",
"submodules",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/core/cli.py#L138-L158 |
11,055 | Gandi/gandi.cli | gandi/cli/core/cli.py | GandiCLI.invoke | def invoke(self, ctx):
""" Invoke command in context. """
ctx.obj = GandiContextHelper(verbose=ctx.obj['verbose'])
click.Group.invoke(self, ctx) | python | def invoke(self, ctx):
""" Invoke command in context. """
ctx.obj = GandiContextHelper(verbose=ctx.obj['verbose'])
click.Group.invoke(self, ctx) | [
"def",
"invoke",
"(",
"self",
",",
"ctx",
")",
":",
"ctx",
".",
"obj",
"=",
"GandiContextHelper",
"(",
"verbose",
"=",
"ctx",
".",
"obj",
"[",
"'verbose'",
"]",
")",
"click",
".",
"Group",
".",
"invoke",
"(",
"self",
",",
"ctx",
")"
] | Invoke command in context. | [
"Invoke",
"command",
"in",
"context",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/core/cli.py#L160-L163 |
11,056 | Gandi/gandi.cli | gandi/cli/modules/sshkey.py | Sshkey.from_name | def from_name(cls, name):
"""Retrieve a sshkey id associated to a name."""
sshkeys = cls.list({'name': name})
if len(sshkeys) == 1:
return sshkeys[0]['id']
elif not sshkeys:
return
raise DuplicateResults('sshkey name %s is ambiguous.' % name) | python | def from_name(cls, name):
"""Retrieve a sshkey id associated to a name."""
sshkeys = cls.list({'name': name})
if len(sshkeys) == 1:
return sshkeys[0]['id']
elif not sshkeys:
return
raise DuplicateResults('sshkey name %s is ambiguous.' % name) | [
"def",
"from_name",
"(",
"cls",
",",
"name",
")",
":",
"sshkeys",
"=",
"cls",
".",
"list",
"(",
"{",
"'name'",
":",
"name",
"}",
")",
"if",
"len",
"(",
"sshkeys",
")",
"==",
"1",
":",
"return",
"sshkeys",
"[",
"0",
"]",
"[",
"'id'",
"]",
"elif"... | Retrieve a sshkey id associated to a name. | [
"Retrieve",
"a",
"sshkey",
"id",
"associated",
"to",
"a",
"name",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/sshkey.py#L20-L28 |
11,057 | Gandi/gandi.cli | gandi/cli/modules/sshkey.py | Sshkey.usable_id | def usable_id(cls, id):
""" Retrieve id from input which can be name or id."""
try:
# id is maybe a sshkey name
qry_id = cls.from_name(id)
if not qry_id:
qry_id = int(id)
except DuplicateResults as exc:
cls.error(exc.errors)
... | python | def usable_id(cls, id):
""" Retrieve id from input which can be name or id."""
try:
# id is maybe a sshkey name
qry_id = cls.from_name(id)
if not qry_id:
qry_id = int(id)
except DuplicateResults as exc:
cls.error(exc.errors)
... | [
"def",
"usable_id",
"(",
"cls",
",",
"id",
")",
":",
"try",
":",
"# id is maybe a sshkey name",
"qry_id",
"=",
"cls",
".",
"from_name",
"(",
"id",
")",
"if",
"not",
"qry_id",
":",
"qry_id",
"=",
"int",
"(",
"id",
")",
"except",
"DuplicateResults",
"as",
... | Retrieve id from input which can be name or id. | [
"Retrieve",
"id",
"from",
"input",
"which",
"can",
"be",
"name",
"or",
"id",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/sshkey.py#L31-L47 |
11,058 | Gandi/gandi.cli | gandi/cli/modules/sshkey.py | Sshkey.create | def create(cls, name, value):
""" Create a new ssh key."""
sshkey_params = {
'name': name,
'value': value,
}
result = cls.call('hosting.ssh.create', sshkey_params)
return result | python | def create(cls, name, value):
""" Create a new ssh key."""
sshkey_params = {
'name': name,
'value': value,
}
result = cls.call('hosting.ssh.create', sshkey_params)
return result | [
"def",
"create",
"(",
"cls",
",",
"name",
",",
"value",
")",
":",
"sshkey_params",
"=",
"{",
"'name'",
":",
"name",
",",
"'value'",
":",
"value",
",",
"}",
"result",
"=",
"cls",
".",
"call",
"(",
"'hosting.ssh.create'",
",",
"sshkey_params",
")",
"retu... | Create a new ssh key. | [
"Create",
"a",
"new",
"ssh",
"key",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/sshkey.py#L61-L69 |
11,059 | Gandi/gandi.cli | gandi/cli/core/base.py | GandiModule.get_api_connector | def get_api_connector(cls):
""" Initialize an api connector for future use."""
if cls._api is None: # pragma: no cover
cls.load_config()
cls.debug('initialize connection to remote server')
apihost = cls.get('api.host')
if not apihost:
rais... | python | def get_api_connector(cls):
""" Initialize an api connector for future use."""
if cls._api is None: # pragma: no cover
cls.load_config()
cls.debug('initialize connection to remote server')
apihost = cls.get('api.host')
if not apihost:
rais... | [
"def",
"get_api_connector",
"(",
"cls",
")",
":",
"if",
"cls",
".",
"_api",
"is",
"None",
":",
"# pragma: no cover",
"cls",
".",
"load_config",
"(",
")",
"cls",
".",
"debug",
"(",
"'initialize connection to remote server'",
")",
"apihost",
"=",
"cls",
".",
"... | Initialize an api connector for future use. | [
"Initialize",
"an",
"api",
"connector",
"for",
"future",
"use",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/core/base.py#L45-L60 |
11,060 | Gandi/gandi.cli | gandi/cli/core/base.py | GandiModule.call | def call(cls, method, *args, **kwargs):
""" Call a remote api method and return the result."""
api = None
empty_key = kwargs.pop('empty_key', False)
try:
api = cls.get_api_connector()
apikey = cls.get('api.key')
if not apikey and not empty_key:
... | python | def call(cls, method, *args, **kwargs):
""" Call a remote api method and return the result."""
api = None
empty_key = kwargs.pop('empty_key', False)
try:
api = cls.get_api_connector()
apikey = cls.get('api.key')
if not apikey and not empty_key:
... | [
"def",
"call",
"(",
"cls",
",",
"method",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"api",
"=",
"None",
"empty_key",
"=",
"kwargs",
".",
"pop",
"(",
"'empty_key'",
",",
"False",
")",
"try",
":",
"api",
"=",
"cls",
".",
"get_api_connector... | Call a remote api method and return the result. | [
"Call",
"a",
"remote",
"api",
"method",
"and",
"return",
"the",
"result",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/core/base.py#L63-L118 |
11,061 | Gandi/gandi.cli | gandi/cli/core/base.py | GandiModule.safe_call | def safe_call(cls, method, *args):
""" Call a remote api method but don't raise if an error occurred."""
return cls.call(method, *args, safe=True) | python | def safe_call(cls, method, *args):
""" Call a remote api method but don't raise if an error occurred."""
return cls.call(method, *args, safe=True) | [
"def",
"safe_call",
"(",
"cls",
",",
"method",
",",
"*",
"args",
")",
":",
"return",
"cls",
".",
"call",
"(",
"method",
",",
"*",
"args",
",",
"safe",
"=",
"True",
")"
] | Call a remote api method but don't raise if an error occurred. | [
"Call",
"a",
"remote",
"api",
"method",
"but",
"don",
"t",
"raise",
"if",
"an",
"error",
"occurred",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/core/base.py#L121-L123 |
11,062 | Gandi/gandi.cli | gandi/cli/core/base.py | GandiModule.json_call | def json_call(cls, method, url, **kwargs):
""" Call a remote api using json format """
# retrieve api key if needed
empty_key = kwargs.pop('empty_key', False)
send_key = kwargs.pop('send_key', True)
return_header = kwargs.pop('return_header', False)
try:
apike... | python | def json_call(cls, method, url, **kwargs):
""" Call a remote api using json format """
# retrieve api key if needed
empty_key = kwargs.pop('empty_key', False)
send_key = kwargs.pop('send_key', True)
return_header = kwargs.pop('return_header', False)
try:
apike... | [
"def",
"json_call",
"(",
"cls",
",",
"method",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"# retrieve api key if needed",
"empty_key",
"=",
"kwargs",
".",
"pop",
"(",
"'empty_key'",
",",
"False",
")",
"send_key",
"=",
"kwargs",
".",
"pop",
"(",
"'sen... | Call a remote api using json format | [
"Call",
"a",
"remote",
"api",
"using",
"json",
"format"
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/core/base.py#L126-L157 |
11,063 | Gandi/gandi.cli | gandi/cli/core/base.py | GandiModule.intty | def intty(cls):
""" Check if we are in a tty. """
# XXX: temporary hack until we can detect if we are in a pipe or not
return True
if hasattr(sys.stdout, 'isatty') and sys.stdout.isatty():
return True
return False | python | def intty(cls):
""" Check if we are in a tty. """
# XXX: temporary hack until we can detect if we are in a pipe or not
return True
if hasattr(sys.stdout, 'isatty') and sys.stdout.isatty():
return True
return False | [
"def",
"intty",
"(",
"cls",
")",
":",
"# XXX: temporary hack until we can detect if we are in a pipe or not",
"return",
"True",
"if",
"hasattr",
"(",
"sys",
".",
"stdout",
",",
"'isatty'",
")",
"and",
"sys",
".",
"stdout",
".",
"isatty",
"(",
")",
":",
"return",... | Check if we are in a tty. | [
"Check",
"if",
"we",
"are",
"in",
"a",
"tty",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/core/base.py#L180-L188 |
11,064 | Gandi/gandi.cli | gandi/cli/core/base.py | GandiModule.pretty_echo | def pretty_echo(cls, message):
""" Display message using pretty print formatting. """
if cls.intty():
if message:
from pprint import pprint
pprint(message) | python | def pretty_echo(cls, message):
""" Display message using pretty print formatting. """
if cls.intty():
if message:
from pprint import pprint
pprint(message) | [
"def",
"pretty_echo",
"(",
"cls",
",",
"message",
")",
":",
"if",
"cls",
".",
"intty",
"(",
")",
":",
"if",
"message",
":",
"from",
"pprint",
"import",
"pprint",
"pprint",
"(",
"message",
")"
] | Display message using pretty print formatting. | [
"Display",
"message",
"using",
"pretty",
"print",
"formatting",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/core/base.py#L198-L203 |
11,065 | Gandi/gandi.cli | gandi/cli/core/base.py | GandiModule.dump | def dump(cls, message):
""" Display dump message if verbose level allows it. """
if cls.verbose > 2:
msg = '[DUMP] %s' % message
cls.echo(msg) | python | def dump(cls, message):
""" Display dump message if verbose level allows it. """
if cls.verbose > 2:
msg = '[DUMP] %s' % message
cls.echo(msg) | [
"def",
"dump",
"(",
"cls",
",",
"message",
")",
":",
"if",
"cls",
".",
"verbose",
">",
"2",
":",
"msg",
"=",
"'[DUMP] %s'",
"%",
"message",
"cls",
".",
"echo",
"(",
"msg",
")"
] | Display dump message if verbose level allows it. | [
"Display",
"dump",
"message",
"if",
"verbose",
"level",
"allows",
"it",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/core/base.py#L218-L222 |
11,066 | Gandi/gandi.cli | gandi/cli/core/base.py | GandiModule.debug | def debug(cls, message):
""" Display debug message if verbose level allows it. """
if cls.verbose > 1:
msg = '[DEBUG] %s' % message
cls.echo(msg) | python | def debug(cls, message):
""" Display debug message if verbose level allows it. """
if cls.verbose > 1:
msg = '[DEBUG] %s' % message
cls.echo(msg) | [
"def",
"debug",
"(",
"cls",
",",
"message",
")",
":",
"if",
"cls",
".",
"verbose",
">",
"1",
":",
"msg",
"=",
"'[DEBUG] %s'",
"%",
"message",
"cls",
".",
"echo",
"(",
"msg",
")"
] | Display debug message if verbose level allows it. | [
"Display",
"debug",
"message",
"if",
"verbose",
"level",
"allows",
"it",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/core/base.py#L225-L229 |
11,067 | Gandi/gandi.cli | gandi/cli/core/base.py | GandiModule.log | def log(cls, message):
""" Display info message if verbose level allows it. """
if cls.verbose > 0:
msg = '[INFO] %s' % message
cls.echo(msg) | python | def log(cls, message):
""" Display info message if verbose level allows it. """
if cls.verbose > 0:
msg = '[INFO] %s' % message
cls.echo(msg) | [
"def",
"log",
"(",
"cls",
",",
"message",
")",
":",
"if",
"cls",
".",
"verbose",
">",
"0",
":",
"msg",
"=",
"'[INFO] %s'",
"%",
"message",
"cls",
".",
"echo",
"(",
"msg",
")"
] | Display info message if verbose level allows it. | [
"Display",
"info",
"message",
"if",
"verbose",
"level",
"allows",
"it",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/core/base.py#L232-L236 |
11,068 | Gandi/gandi.cli | gandi/cli/core/base.py | GandiModule.exec_output | def exec_output(cls, command, shell=True, encoding='utf-8'):
""" Return execution output
:param encoding: charset used to decode the stdout
:type encoding: str
:return: the return of the command
:rtype: unicode string
"""
proc = Popen(command, shell=shell, stdou... | python | def exec_output(cls, command, shell=True, encoding='utf-8'):
""" Return execution output
:param encoding: charset used to decode the stdout
:type encoding: str
:return: the return of the command
:rtype: unicode string
"""
proc = Popen(command, shell=shell, stdou... | [
"def",
"exec_output",
"(",
"cls",
",",
"command",
",",
"shell",
"=",
"True",
",",
"encoding",
"=",
"'utf-8'",
")",
":",
"proc",
"=",
"Popen",
"(",
"command",
",",
"shell",
"=",
"shell",
",",
"stdout",
"=",
"PIPE",
")",
"stdout",
",",
"_stderr",
"=",
... | Return execution output
:param encoding: charset used to decode the stdout
:type encoding: str
:return: the return of the command
:rtype: unicode string | [
"Return",
"execution",
"output"
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/core/base.py#L258-L272 |
11,069 | Gandi/gandi.cli | gandi/cli/core/base.py | GandiModule.update_progress | def update_progress(cls, progress, starttime):
""" Display an ascii progress bar while processing operation. """
width, _height = click.get_terminal_size()
if not width:
return
duration = datetime.utcnow() - starttime
hours, remainder = divmod(duration.seconds, 3600)... | python | def update_progress(cls, progress, starttime):
""" Display an ascii progress bar while processing operation. """
width, _height = click.get_terminal_size()
if not width:
return
duration = datetime.utcnow() - starttime
hours, remainder = divmod(duration.seconds, 3600)... | [
"def",
"update_progress",
"(",
"cls",
",",
"progress",
",",
"starttime",
")",
":",
"width",
",",
"_height",
"=",
"click",
".",
"get_terminal_size",
"(",
")",
"if",
"not",
"width",
":",
"return",
"duration",
"=",
"datetime",
".",
"utcnow",
"(",
")",
"-",
... | Display an ascii progress bar while processing operation. | [
"Display",
"an",
"ascii",
"progress",
"bar",
"while",
"processing",
"operation",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/core/base.py#L275-L304 |
11,070 | Gandi/gandi.cli | gandi/cli/core/base.py | GandiModule.display_progress | def display_progress(cls, operations):
""" Display progress of Gandi operations.
polls API every 1 seconds to retrieve status.
"""
start_crea = datetime.utcnow()
# count number of operations, 3 steps per operation
if not isinstance(operations, (list, tuple)):
... | python | def display_progress(cls, operations):
""" Display progress of Gandi operations.
polls API every 1 seconds to retrieve status.
"""
start_crea = datetime.utcnow()
# count number of operations, 3 steps per operation
if not isinstance(operations, (list, tuple)):
... | [
"def",
"display_progress",
"(",
"cls",
",",
"operations",
")",
":",
"start_crea",
"=",
"datetime",
".",
"utcnow",
"(",
")",
"# count number of operations, 3 steps per operation",
"if",
"not",
"isinstance",
"(",
"operations",
",",
"(",
"list",
",",
"tuple",
")",
... | Display progress of Gandi operations.
polls API every 1 seconds to retrieve status. | [
"Display",
"progress",
"of",
"Gandi",
"operations",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/core/base.py#L307-L346 |
11,071 | Gandi/gandi.cli | gandi/cli/core/base.py | GandiContextHelper.load_modules | def load_modules(self):
""" Import CLI commands modules. """
module_folder = os.path.join(os.path.dirname(__file__),
'..', 'modules')
module_dirs = {
'gandi.cli': module_folder
}
if 'GANDICLI_PATH' in os.environ:
for _... | python | def load_modules(self):
""" Import CLI commands modules. """
module_folder = os.path.join(os.path.dirname(__file__),
'..', 'modules')
module_dirs = {
'gandi.cli': module_folder
}
if 'GANDICLI_PATH' in os.environ:
for _... | [
"def",
"load_modules",
"(",
"self",
")",
":",
"module_folder",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"'..'",
",",
"'modules'",
")",
"module_dirs",
"=",
"{",
"'gandi.cli'",
":",
"module_f... | Import CLI commands modules. | [
"Import",
"CLI",
"commands",
"modules",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/core/base.py#L372-L396 |
11,072 | Gandi/gandi.cli | gandi/cli/core/client.py | XMLRPCClient.request | def request(self, method, apikey, *args, **kwargs):
""" Make a xml-rpc call to remote API. """
dry_run = kwargs.get('dry_run', False)
return_dry_run = kwargs.get('return_dry_run', False)
if return_dry_run:
args[-1]['--dry-run'] = True
try:
func = getattr(... | python | def request(self, method, apikey, *args, **kwargs):
""" Make a xml-rpc call to remote API. """
dry_run = kwargs.get('dry_run', False)
return_dry_run = kwargs.get('return_dry_run', False)
if return_dry_run:
args[-1]['--dry-run'] = True
try:
func = getattr(... | [
"def",
"request",
"(",
"self",
",",
"method",
",",
"apikey",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"dry_run",
"=",
"kwargs",
".",
"get",
"(",
"'dry_run'",
",",
"False",
")",
"return_dry_run",
"=",
"kwargs",
".",
"get",
"(",
"'return_dr... | Make a xml-rpc call to remote API. | [
"Make",
"a",
"xml",
"-",
"rpc",
"call",
"to",
"remote",
"API",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/core/client.py#L61-L83 |
11,073 | Gandi/gandi.cli | gandi/cli/core/client.py | JsonClient.request | def request(cls, method, url, **kwargs):
"""Make a http call to a remote API and return a json response."""
user_agent = 'gandi.cli/%s' % __version__
headers = {'User-Agent': user_agent,
'Content-Type': 'application/json; charset=utf-8'}
if kwargs.get('headers'):
... | python | def request(cls, method, url, **kwargs):
"""Make a http call to a remote API and return a json response."""
user_agent = 'gandi.cli/%s' % __version__
headers = {'User-Agent': user_agent,
'Content-Type': 'application/json; charset=utf-8'}
if kwargs.get('headers'):
... | [
"def",
"request",
"(",
"cls",
",",
"method",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"user_agent",
"=",
"'gandi.cli/%s'",
"%",
"__version__",
"headers",
"=",
"{",
"'User-Agent'",
":",
"user_agent",
",",
"'Content-Type'",
":",
"'application/json; charset... | Make a http call to a remote API and return a json response. | [
"Make",
"a",
"http",
"call",
"to",
"a",
"remote",
"API",
"and",
"return",
"a",
"json",
"response",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/core/client.py#L95-L129 |
11,074 | Gandi/gandi.cli | gandi/cli/commands/docker.py | docker | def docker(gandi, vm, args):
"""
Manage docker instance
"""
if not [basedir for basedir in os.getenv('PATH', '.:/usr/bin').split(':')
if os.path.exists('%s/docker' % basedir)]:
gandi.echo("""'docker' not found in $PATH, required for this command \
to work
See https://docs.docker.com/... | python | def docker(gandi, vm, args):
"""
Manage docker instance
"""
if not [basedir for basedir in os.getenv('PATH', '.:/usr/bin').split(':')
if os.path.exists('%s/docker' % basedir)]:
gandi.echo("""'docker' not found in $PATH, required for this command \
to work
See https://docs.docker.com/... | [
"def",
"docker",
"(",
"gandi",
",",
"vm",
",",
"args",
")",
":",
"if",
"not",
"[",
"basedir",
"for",
"basedir",
"in",
"os",
".",
"getenv",
"(",
"'PATH'",
",",
"'.:/usr/bin'",
")",
".",
"split",
"(",
"':'",
")",
"if",
"os",
".",
"path",
".",
"exis... | Manage docker instance | [
"Manage",
"docker",
"instance"
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/docker.py#L15-L46 |
11,075 | Gandi/gandi.cli | gandi/cli/modules/metric.py | Metric.query | def query(cls, resources, time_range, query, resource_type, sampler):
"""Query statistics for given resources."""
if not isinstance(resources, (list, tuple)):
resources = [resources]
now = time.time()
start_utc = datetime.utcfromtimestamp(now - time_range)
end_utc = ... | python | def query(cls, resources, time_range, query, resource_type, sampler):
"""Query statistics for given resources."""
if not isinstance(resources, (list, tuple)):
resources = [resources]
now = time.time()
start_utc = datetime.utcfromtimestamp(now - time_range)
end_utc = ... | [
"def",
"query",
"(",
"cls",
",",
"resources",
",",
"time_range",
",",
"query",
",",
"resource_type",
",",
"sampler",
")",
":",
"if",
"not",
"isinstance",
"(",
"resources",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"resources",
"=",
"[",
"resources... | Query statistics for given resources. | [
"Query",
"statistics",
"for",
"given",
"resources",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/metric.py#L16-L33 |
11,076 | Gandi/gandi.cli | gandi/cli/modules/iaas.py | Iaas.required_max_memory | def required_max_memory(cls, id, memory):
"""
Recommend a max_memory setting for this vm given memory. If the
VM already has a nice setting, return None. The max_memory
param cannot be fixed too high, because page table allocation
would cost too much for small memory profile. Use... | python | def required_max_memory(cls, id, memory):
"""
Recommend a max_memory setting for this vm given memory. If the
VM already has a nice setting, return None. The max_memory
param cannot be fixed too high, because page table allocation
would cost too much for small memory profile. Use... | [
"def",
"required_max_memory",
"(",
"cls",
",",
"id",
",",
"memory",
")",
":",
"best",
"=",
"int",
"(",
"max",
"(",
"2",
"**",
"math",
".",
"ceil",
"(",
"math",
".",
"log",
"(",
"memory",
",",
"2",
")",
")",
",",
"2048",
")",
")",
"actual_vm",
"... | Recommend a max_memory setting for this vm given memory. If the
VM already has a nice setting, return None. The max_memory
param cannot be fixed too high, because page table allocation
would cost too much for small memory profile. Use a range as below. | [
"Recommend",
"a",
"max_memory",
"setting",
"for",
"this",
"vm",
"given",
"memory",
".",
"If",
"the",
"VM",
"already",
"has",
"a",
"nice",
"setting",
"return",
"None",
".",
"The",
"max_memory",
"param",
"cannot",
"be",
"fixed",
"too",
"high",
"because",
"pa... | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/iaas.py#L149-L162 |
11,077 | Gandi/gandi.cli | gandi/cli/modules/iaas.py | Iaas.need_finalize | def need_finalize(cls, resource):
"""Check if vm migration need to be finalized."""
vm_id = cls.usable_id(resource)
params = {'type': 'hosting_migration_vm',
'step': 'RUN',
'vm_id': vm_id}
result = cls.call('operation.list', params)
if not resu... | python | def need_finalize(cls, resource):
"""Check if vm migration need to be finalized."""
vm_id = cls.usable_id(resource)
params = {'type': 'hosting_migration_vm',
'step': 'RUN',
'vm_id': vm_id}
result = cls.call('operation.list', params)
if not resu... | [
"def",
"need_finalize",
"(",
"cls",
",",
"resource",
")",
":",
"vm_id",
"=",
"cls",
".",
"usable_id",
"(",
"resource",
")",
"params",
"=",
"{",
"'type'",
":",
"'hosting_migration_vm'",
",",
"'step'",
":",
"'RUN'",
",",
"'vm_id'",
":",
"vm_id",
"}",
"resu... | Check if vm migration need to be finalized. | [
"Check",
"if",
"vm",
"migration",
"need",
"to",
"be",
"finalized",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/iaas.py#L325-L339 |
11,078 | Gandi/gandi.cli | gandi/cli/modules/iaas.py | Iaas.check_can_migrate | def check_can_migrate(cls, resource):
"""Check if virtual machine can be migrated to another datacenter."""
vm_id = cls.usable_id(resource)
result = cls.call('hosting.vm.can_migrate', vm_id)
if not result['can_migrate']:
if result['matched']:
matched = result... | python | def check_can_migrate(cls, resource):
"""Check if virtual machine can be migrated to another datacenter."""
vm_id = cls.usable_id(resource)
result = cls.call('hosting.vm.can_migrate', vm_id)
if not result['can_migrate']:
if result['matched']:
matched = result... | [
"def",
"check_can_migrate",
"(",
"cls",
",",
"resource",
")",
":",
"vm_id",
"=",
"cls",
".",
"usable_id",
"(",
"resource",
")",
"result",
"=",
"cls",
".",
"call",
"(",
"'hosting.vm.can_migrate'",
",",
"vm_id",
")",
"if",
"not",
"result",
"[",
"'can_migrate... | Check if virtual machine can be migrated to another datacenter. | [
"Check",
"if",
"virtual",
"machine",
"can",
"be",
"migrated",
"to",
"another",
"datacenter",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/iaas.py#L342-L357 |
11,079 | Gandi/gandi.cli | gandi/cli/modules/iaas.py | Iaas.from_hostname | def from_hostname(cls, hostname):
"""Retrieve virtual machine id associated to a hostname."""
result = cls.list({'hostname': str(hostname)})
if result:
return result[0]['id'] | python | def from_hostname(cls, hostname):
"""Retrieve virtual machine id associated to a hostname."""
result = cls.list({'hostname': str(hostname)})
if result:
return result[0]['id'] | [
"def",
"from_hostname",
"(",
"cls",
",",
"hostname",
")",
":",
"result",
"=",
"cls",
".",
"list",
"(",
"{",
"'hostname'",
":",
"str",
"(",
"hostname",
")",
"}",
")",
"if",
"result",
":",
"return",
"result",
"[",
"0",
"]",
"[",
"'id'",
"]"
] | Retrieve virtual machine id associated to a hostname. | [
"Retrieve",
"virtual",
"machine",
"id",
"associated",
"to",
"a",
"hostname",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/iaas.py#L391-L395 |
11,080 | Gandi/gandi.cli | gandi/cli/modules/iaas.py | Iaas.wait_for_sshd | def wait_for_sshd(cls, vm_id):
"""Insist on having the vm booted and sshd
listening"""
cls.echo('Waiting for the vm to come online')
version, ip_addr = cls.vm_ip(vm_id)
give_up = time.time() + 300
last_error = None
while time.time() < give_up:
try:
... | python | def wait_for_sshd(cls, vm_id):
"""Insist on having the vm booted and sshd
listening"""
cls.echo('Waiting for the vm to come online')
version, ip_addr = cls.vm_ip(vm_id)
give_up = time.time() + 300
last_error = None
while time.time() < give_up:
try:
... | [
"def",
"wait_for_sshd",
"(",
"cls",
",",
"vm_id",
")",
":",
"cls",
".",
"echo",
"(",
"'Waiting for the vm to come online'",
")",
"version",
",",
"ip_addr",
"=",
"cls",
".",
"vm_ip",
"(",
"vm_id",
")",
"give_up",
"=",
"time",
".",
"time",
"(",
")",
"+",
... | Insist on having the vm booted and sshd
listening | [
"Insist",
"on",
"having",
"the",
"vm",
"booted",
"and",
"sshd",
"listening"
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/iaas.py#L427-L454 |
11,081 | Gandi/gandi.cli | gandi/cli/modules/iaas.py | Iaas.ssh_keyscan | def ssh_keyscan(cls, vm_id):
"""Wipe this old key and learn the new one from a freshly
created vm. This is a security risk for this VM, however
we dont have another way to learn the key yet, so do this
for the user."""
cls.echo('Wiping old key and learning the new one')
_... | python | def ssh_keyscan(cls, vm_id):
"""Wipe this old key and learn the new one from a freshly
created vm. This is a security risk for this VM, however
we dont have another way to learn the key yet, so do this
for the user."""
cls.echo('Wiping old key and learning the new one')
_... | [
"def",
"ssh_keyscan",
"(",
"cls",
",",
"vm_id",
")",
":",
"cls",
".",
"echo",
"(",
"'Wiping old key and learning the new one'",
")",
"_version",
",",
"ip_addr",
"=",
"cls",
".",
"vm_ip",
"(",
"vm_id",
")",
"cls",
".",
"execute",
"(",
"'ssh-keygen -R \"%s\"'",
... | Wipe this old key and learn the new one from a freshly
created vm. This is a security risk for this VM, however
we dont have another way to learn the key yet, so do this
for the user. | [
"Wipe",
"this",
"old",
"key",
"and",
"learn",
"the",
"new",
"one",
"from",
"a",
"freshly",
"created",
"vm",
".",
"This",
"is",
"a",
"security",
"risk",
"for",
"this",
"VM",
"however",
"we",
"dont",
"have",
"another",
"way",
"to",
"learn",
"the",
"key",... | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/iaas.py#L457-L472 |
11,082 | Gandi/gandi.cli | gandi/cli/modules/iaas.py | Iaas.scp | def scp(cls, vm_id, login, identity, local_file, remote_file):
"""Copy file to remote VM."""
cmd = ['scp']
if identity:
cmd.extend(('-i', identity,))
version, ip_addr = cls.vm_ip(vm_id)
if version == 6:
ip_addr = '[%s]' % ip_addr
cmd.extend((loca... | python | def scp(cls, vm_id, login, identity, local_file, remote_file):
"""Copy file to remote VM."""
cmd = ['scp']
if identity:
cmd.extend(('-i', identity,))
version, ip_addr = cls.vm_ip(vm_id)
if version == 6:
ip_addr = '[%s]' % ip_addr
cmd.extend((loca... | [
"def",
"scp",
"(",
"cls",
",",
"vm_id",
",",
"login",
",",
"identity",
",",
"local_file",
",",
"remote_file",
")",
":",
"cmd",
"=",
"[",
"'scp'",
"]",
"if",
"identity",
":",
"cmd",
".",
"extend",
"(",
"(",
"'-i'",
",",
"identity",
",",
")",
")",
... | Copy file to remote VM. | [
"Copy",
"file",
"to",
"remote",
"VM",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/iaas.py#L475-L493 |
11,083 | Gandi/gandi.cli | gandi/cli/modules/iaas.py | Iaas.ssh | def ssh(cls, vm_id, login, identity, args=None):
"""Spawn an ssh session to virtual machine."""
cmd = ['ssh']
if identity:
cmd.extend(('-i', identity,))
version, ip_addr = cls.vm_ip(vm_id)
if version == 6:
cmd.append('-6')
if not ip_addr:
... | python | def ssh(cls, vm_id, login, identity, args=None):
"""Spawn an ssh session to virtual machine."""
cmd = ['ssh']
if identity:
cmd.extend(('-i', identity,))
version, ip_addr = cls.vm_ip(vm_id)
if version == 6:
cmd.append('-6')
if not ip_addr:
... | [
"def",
"ssh",
"(",
"cls",
",",
"vm_id",
",",
"login",
",",
"identity",
",",
"args",
"=",
"None",
")",
":",
"cmd",
"=",
"[",
"'ssh'",
"]",
"if",
"identity",
":",
"cmd",
".",
"extend",
"(",
"(",
"'-i'",
",",
"identity",
",",
")",
")",
"version",
... | Spawn an ssh session to virtual machine. | [
"Spawn",
"an",
"ssh",
"session",
"to",
"virtual",
"machine",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/iaas.py#L496-L516 |
11,084 | Gandi/gandi.cli | gandi/cli/modules/iaas.py | Image.is_deprecated | def is_deprecated(cls, label, datacenter=None):
"""Check if image if flagged as deprecated."""
images = cls.list(datacenter, label)
images_visibility = dict([(image['label'], image['visibility'])
for image in images])
return images_visibility.get(label, ... | python | def is_deprecated(cls, label, datacenter=None):
"""Check if image if flagged as deprecated."""
images = cls.list(datacenter, label)
images_visibility = dict([(image['label'], image['visibility'])
for image in images])
return images_visibility.get(label, ... | [
"def",
"is_deprecated",
"(",
"cls",
",",
"label",
",",
"datacenter",
"=",
"None",
")",
":",
"images",
"=",
"cls",
".",
"list",
"(",
"datacenter",
",",
"label",
")",
"images_visibility",
"=",
"dict",
"(",
"[",
"(",
"image",
"[",
"'label'",
"]",
",",
"... | Check if image if flagged as deprecated. | [
"Check",
"if",
"image",
"if",
"flagged",
"as",
"deprecated",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/iaas.py#L560-L565 |
11,085 | Gandi/gandi.cli | gandi/cli/modules/iaas.py | Image.from_label | def from_label(cls, label, datacenter=None):
"""Retrieve disk image id associated to a label."""
result = cls.list(datacenter=datacenter)
image_labels = dict([(image['label'], image['disk_id'])
for image in result])
return image_labels.get(label) | python | def from_label(cls, label, datacenter=None):
"""Retrieve disk image id associated to a label."""
result = cls.list(datacenter=datacenter)
image_labels = dict([(image['label'], image['disk_id'])
for image in result])
return image_labels.get(label) | [
"def",
"from_label",
"(",
"cls",
",",
"label",
",",
"datacenter",
"=",
"None",
")",
":",
"result",
"=",
"cls",
".",
"list",
"(",
"datacenter",
"=",
"datacenter",
")",
"image_labels",
"=",
"dict",
"(",
"[",
"(",
"image",
"[",
"'label'",
"]",
",",
"ima... | Retrieve disk image id associated to a label. | [
"Retrieve",
"disk",
"image",
"id",
"associated",
"to",
"a",
"label",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/iaas.py#L568-L574 |
11,086 | Gandi/gandi.cli | gandi/cli/modules/iaas.py | Image.from_sysdisk | def from_sysdisk(cls, label):
"""Retrieve disk id from available system disks"""
disks = cls.safe_call('hosting.disk.list', {'name': label})
if len(disks):
return disks[0]['id'] | python | def from_sysdisk(cls, label):
"""Retrieve disk id from available system disks"""
disks = cls.safe_call('hosting.disk.list', {'name': label})
if len(disks):
return disks[0]['id'] | [
"def",
"from_sysdisk",
"(",
"cls",
",",
"label",
")",
":",
"disks",
"=",
"cls",
".",
"safe_call",
"(",
"'hosting.disk.list'",
",",
"{",
"'name'",
":",
"label",
"}",
")",
"if",
"len",
"(",
"disks",
")",
":",
"return",
"disks",
"[",
"0",
"]",
"[",
"'... | Retrieve disk id from available system disks | [
"Retrieve",
"disk",
"id",
"from",
"available",
"system",
"disks"
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/iaas.py#L577-L581 |
11,087 | Gandi/gandi.cli | gandi/cli/modules/iaas.py | Image.usable_id | def usable_id(cls, id, datacenter=None):
""" Retrieve id from input which can be label or id."""
try:
qry_id = int(id)
except Exception:
# if id is a string, prefer a system disk then a label
qry_id = cls.from_sysdisk(id) or cls.from_label(id, datacenter)
... | python | def usable_id(cls, id, datacenter=None):
""" Retrieve id from input which can be label or id."""
try:
qry_id = int(id)
except Exception:
# if id is a string, prefer a system disk then a label
qry_id = cls.from_sysdisk(id) or cls.from_label(id, datacenter)
... | [
"def",
"usable_id",
"(",
"cls",
",",
"id",
",",
"datacenter",
"=",
"None",
")",
":",
"try",
":",
"qry_id",
"=",
"int",
"(",
"id",
")",
"except",
"Exception",
":",
"# if id is a string, prefer a system disk then a label",
"qry_id",
"=",
"cls",
".",
"from_sysdis... | Retrieve id from input which can be label or id. | [
"Retrieve",
"id",
"from",
"input",
"which",
"can",
"be",
"label",
"or",
"id",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/iaas.py#L584-L596 |
11,088 | Gandi/gandi.cli | gandi/cli/modules/iaas.py | Kernel.list | def list(cls, datacenter=None, flavor=None, match='', exact_match=False):
""" List available kernels for datacenter."""
if not datacenter:
dc_ids = [dc['id'] for dc in Datacenter.filtered_list()]
kmap = {}
for dc_id in dc_ids:
vals = cls.safe_call('hos... | python | def list(cls, datacenter=None, flavor=None, match='', exact_match=False):
""" List available kernels for datacenter."""
if not datacenter:
dc_ids = [dc['id'] for dc in Datacenter.filtered_list()]
kmap = {}
for dc_id in dc_ids:
vals = cls.safe_call('hos... | [
"def",
"list",
"(",
"cls",
",",
"datacenter",
"=",
"None",
",",
"flavor",
"=",
"None",
",",
"match",
"=",
"''",
",",
"exact_match",
"=",
"False",
")",
":",
"if",
"not",
"datacenter",
":",
"dc_ids",
"=",
"[",
"dc",
"[",
"'id'",
"]",
"for",
"dc",
"... | List available kernels for datacenter. | [
"List",
"available",
"kernels",
"for",
"datacenter",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/iaas.py#L604-L631 |
11,089 | Gandi/gandi.cli | gandi/cli/modules/iaas.py | Kernel.is_available | def is_available(cls, disk, kernel):
""" Check if kernel is available for disk."""
kmap = cls.list(disk['datacenter_id'], None, kernel, True)
for flavor in kmap:
if kernel in kmap[flavor]:
return True
return False | python | def is_available(cls, disk, kernel):
""" Check if kernel is available for disk."""
kmap = cls.list(disk['datacenter_id'], None, kernel, True)
for flavor in kmap:
if kernel in kmap[flavor]:
return True
return False | [
"def",
"is_available",
"(",
"cls",
",",
"disk",
",",
"kernel",
")",
":",
"kmap",
"=",
"cls",
".",
"list",
"(",
"disk",
"[",
"'datacenter_id'",
"]",
",",
"None",
",",
"kernel",
",",
"True",
")",
"for",
"flavor",
"in",
"kmap",
":",
"if",
"kernel",
"i... | Check if kernel is available for disk. | [
"Check",
"if",
"kernel",
"is",
"available",
"for",
"disk",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/iaas.py#L634-L640 |
11,090 | Gandi/gandi.cli | gandi/cli/modules/paas.py | Paas.clone | def clone(cls, name, vhost, directory, origin):
"""Clone a PaaS instance's vhost into a local git repository."""
paas_info = cls.info(name)
if 'php' in paas_info['type'] and not vhost:
cls.error('PHP instances require indicating the VHOST to clone '
'with --vho... | python | def clone(cls, name, vhost, directory, origin):
"""Clone a PaaS instance's vhost into a local git repository."""
paas_info = cls.info(name)
if 'php' in paas_info['type'] and not vhost:
cls.error('PHP instances require indicating the VHOST to clone '
'with --vho... | [
"def",
"clone",
"(",
"cls",
",",
"name",
",",
"vhost",
",",
"directory",
",",
"origin",
")",
":",
"paas_info",
"=",
"cls",
".",
"info",
"(",
"name",
")",
"if",
"'php'",
"in",
"paas_info",
"[",
"'type'",
"]",
"and",
"not",
"vhost",
":",
"cls",
".",
... | Clone a PaaS instance's vhost into a local git repository. | [
"Clone",
"a",
"PaaS",
"instance",
"s",
"vhost",
"into",
"a",
"local",
"git",
"repository",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/paas.py#L36-L55 |
11,091 | Gandi/gandi.cli | gandi/cli/modules/paas.py | Paas.attach | def attach(cls, name, vhost, remote_name):
"""Attach an instance's vhost to a remote from the local repository."""
paas_access = cls.get('paas_access')
if not paas_access:
paas_info = cls.info(name)
paas_access = '%s@%s' \
% (paas_info['user'], ... | python | def attach(cls, name, vhost, remote_name):
"""Attach an instance's vhost to a remote from the local repository."""
paas_access = cls.get('paas_access')
if not paas_access:
paas_info = cls.info(name)
paas_access = '%s@%s' \
% (paas_info['user'], ... | [
"def",
"attach",
"(",
"cls",
",",
"name",
",",
"vhost",
",",
"remote_name",
")",
":",
"paas_access",
"=",
"cls",
".",
"get",
"(",
"'paas_access'",
")",
"if",
"not",
"paas_access",
":",
"paas_info",
"=",
"cls",
".",
"info",
"(",
"name",
")",
"paas_acces... | Attach an instance's vhost to a remote from the local repository. | [
"Attach",
"an",
"instance",
"s",
"vhost",
"to",
"a",
"remote",
"from",
"the",
"local",
"repository",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/paas.py#L58-L77 |
11,092 | Gandi/gandi.cli | gandi/cli/modules/paas.py | Paas.cache | def cache(cls, id):
"""return the number of query cache for the last 24H"""
sampler = {'unit': 'days', 'value': 1, 'function': 'sum'}
query = 'webacc.requests.cache.all'
metrics = Metric.query(id, 60 * 60 * 24, query, 'paas', sampler)
cache = {'hit': 0, 'miss': 0, 'not': 0, 'pas... | python | def cache(cls, id):
"""return the number of query cache for the last 24H"""
sampler = {'unit': 'days', 'value': 1, 'function': 'sum'}
query = 'webacc.requests.cache.all'
metrics = Metric.query(id, 60 * 60 * 24, query, 'paas', sampler)
cache = {'hit': 0, 'miss': 0, 'not': 0, 'pas... | [
"def",
"cache",
"(",
"cls",
",",
"id",
")",
":",
"sampler",
"=",
"{",
"'unit'",
":",
"'days'",
",",
"'value'",
":",
"1",
",",
"'function'",
":",
"'sum'",
"}",
"query",
"=",
"'webacc.requests.cache.all'",
"metrics",
"=",
"Metric",
".",
"query",
"(",
"id... | return the number of query cache for the last 24H | [
"return",
"the",
"number",
"of",
"query",
"cache",
"for",
"the",
"last",
"24H"
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/paas.py#L157-L169 |
11,093 | Gandi/gandi.cli | gandi/cli/modules/paas.py | Paas.create | def create(cls, name, size, type, quantity, duration, datacenter, vhosts,
password, snapshot_profile, background, sshkey):
"""Create a new PaaS instance."""
if not background and not cls.intty():
background = True
datacenter_id_ = int(Datacenter.usable_id(datacenter))... | python | def create(cls, name, size, type, quantity, duration, datacenter, vhosts,
password, snapshot_profile, background, sshkey):
"""Create a new PaaS instance."""
if not background and not cls.intty():
background = True
datacenter_id_ = int(Datacenter.usable_id(datacenter))... | [
"def",
"create",
"(",
"cls",
",",
"name",
",",
"size",
",",
"type",
",",
"quantity",
",",
"duration",
",",
"datacenter",
",",
"vhosts",
",",
"password",
",",
"snapshot_profile",
",",
"background",
",",
"sshkey",
")",
":",
"if",
"not",
"background",
"and"... | Create a new PaaS instance. | [
"Create",
"a",
"new",
"PaaS",
"instance",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/paas.py#L237-L276 |
11,094 | Gandi/gandi.cli | gandi/cli/modules/paas.py | Paas.console | def console(cls, id):
"""Open a console to a PaaS instance."""
oper = cls.call('paas.update', cls.usable_id(id), {'console': 1})
cls.echo('Activation of the console on your PaaS instance')
cls.display_progress(oper)
console_url = Paas.info(cls.usable_id(id))['console']
ac... | python | def console(cls, id):
"""Open a console to a PaaS instance."""
oper = cls.call('paas.update', cls.usable_id(id), {'console': 1})
cls.echo('Activation of the console on your PaaS instance')
cls.display_progress(oper)
console_url = Paas.info(cls.usable_id(id))['console']
ac... | [
"def",
"console",
"(",
"cls",
",",
"id",
")",
":",
"oper",
"=",
"cls",
".",
"call",
"(",
"'paas.update'",
",",
"cls",
".",
"usable_id",
"(",
"id",
")",
",",
"{",
"'console'",
":",
"1",
"}",
")",
"cls",
".",
"echo",
"(",
"'Activation of the console on... | Open a console to a PaaS instance. | [
"Open",
"a",
"console",
"to",
"a",
"PaaS",
"instance",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/paas.py#L312-L319 |
11,095 | Gandi/gandi.cli | gandi/cli/modules/paas.py | Paas.from_vhost | def from_vhost(cls, vhost):
"""Retrieve paas instance id associated to a vhost."""
result = Vhost().list()
paas_hosts = {}
for host in result:
paas_hosts[host['name']] = host['paas_id']
return paas_hosts.get(vhost) | python | def from_vhost(cls, vhost):
"""Retrieve paas instance id associated to a vhost."""
result = Vhost().list()
paas_hosts = {}
for host in result:
paas_hosts[host['name']] = host['paas_id']
return paas_hosts.get(vhost) | [
"def",
"from_vhost",
"(",
"cls",
",",
"vhost",
")",
":",
"result",
"=",
"Vhost",
"(",
")",
".",
"list",
"(",
")",
"paas_hosts",
"=",
"{",
"}",
"for",
"host",
"in",
"result",
":",
"paas_hosts",
"[",
"host",
"[",
"'name'",
"]",
"]",
"=",
"host",
"[... | Retrieve paas instance id associated to a vhost. | [
"Retrieve",
"paas",
"instance",
"id",
"associated",
"to",
"a",
"vhost",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/paas.py#L342-L349 |
11,096 | Gandi/gandi.cli | gandi/cli/modules/paas.py | Paas.from_hostname | def from_hostname(cls, hostname):
"""Retrieve paas instance id associated to a host."""
result = cls.list({'items_per_page': 500})
paas_hosts = {}
for host in result:
paas_hosts[host['name']] = host['id']
return paas_hosts.get(hostname) | python | def from_hostname(cls, hostname):
"""Retrieve paas instance id associated to a host."""
result = cls.list({'items_per_page': 500})
paas_hosts = {}
for host in result:
paas_hosts[host['name']] = host['id']
return paas_hosts.get(hostname) | [
"def",
"from_hostname",
"(",
"cls",
",",
"hostname",
")",
":",
"result",
"=",
"cls",
".",
"list",
"(",
"{",
"'items_per_page'",
":",
"500",
"}",
")",
"paas_hosts",
"=",
"{",
"}",
"for",
"host",
"in",
"result",
":",
"paas_hosts",
"[",
"host",
"[",
"'n... | Retrieve paas instance id associated to a host. | [
"Retrieve",
"paas",
"instance",
"id",
"associated",
"to",
"a",
"host",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/paas.py#L352-L359 |
11,097 | Gandi/gandi.cli | gandi/cli/modules/paas.py | Paas.list_names | def list_names(cls):
"""Retrieve paas id and names."""
ret = dict([(item['id'], item['name'])
for item in cls.list({'items_per_page': 500})])
return ret | python | def list_names(cls):
"""Retrieve paas id and names."""
ret = dict([(item['id'], item['name'])
for item in cls.list({'items_per_page': 500})])
return ret | [
"def",
"list_names",
"(",
"cls",
")",
":",
"ret",
"=",
"dict",
"(",
"[",
"(",
"item",
"[",
"'id'",
"]",
",",
"item",
"[",
"'name'",
"]",
")",
"for",
"item",
"in",
"cls",
".",
"list",
"(",
"{",
"'items_per_page'",
":",
"500",
"}",
")",
"]",
")",... | Retrieve paas id and names. | [
"Retrieve",
"paas",
"id",
"and",
"names",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/paas.py#L362-L366 |
11,098 | Gandi/gandi.cli | gandi/cli/modules/cert.py | Certificate.from_cn | def from_cn(cls, common_name):
""" Retrieve a certificate by its common name. """
# search with cn
result_cn = [(cert['id'], [cert['cn']] + cert['altnames'])
for cert in cls.list({'status': ['pending', 'valid'],
'items_per_page': 50... | python | def from_cn(cls, common_name):
""" Retrieve a certificate by its common name. """
# search with cn
result_cn = [(cert['id'], [cert['cn']] + cert['altnames'])
for cert in cls.list({'status': ['pending', 'valid'],
'items_per_page': 50... | [
"def",
"from_cn",
"(",
"cls",
",",
"common_name",
")",
":",
"# search with cn",
"result_cn",
"=",
"[",
"(",
"cert",
"[",
"'id'",
"]",
",",
"[",
"cert",
"[",
"'cn'",
"]",
"]",
"+",
"cert",
"[",
"'altnames'",
"]",
")",
"for",
"cert",
"in",
"cls",
"."... | Retrieve a certificate by its common name. | [
"Retrieve",
"a",
"certificate",
"by",
"its",
"common",
"name",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/cert.py#L121-L144 |
11,099 | Gandi/gandi.cli | gandi/cli/modules/cert.py | Certificate.usable_ids | def usable_ids(cls, id, accept_multi=True):
""" Retrieve id from input which can be an id or a cn."""
try:
qry_id = [int(id)]
except ValueError:
try:
qry_id = cls.from_cn(id)
except Exception:
qry_id = None
if not qry_i... | python | def usable_ids(cls, id, accept_multi=True):
""" Retrieve id from input which can be an id or a cn."""
try:
qry_id = [int(id)]
except ValueError:
try:
qry_id = cls.from_cn(id)
except Exception:
qry_id = None
if not qry_i... | [
"def",
"usable_ids",
"(",
"cls",
",",
"id",
",",
"accept_multi",
"=",
"True",
")",
":",
"try",
":",
"qry_id",
"=",
"[",
"int",
"(",
"id",
")",
"]",
"except",
"ValueError",
":",
"try",
":",
"qry_id",
"=",
"cls",
".",
"from_cn",
"(",
"id",
")",
"ex... | Retrieve id from input which can be an id or a cn. | [
"Retrieve",
"id",
"from",
"input",
"which",
"can",
"be",
"an",
"id",
"or",
"a",
"cn",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/cert.py#L147-L161 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.