_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 31 13.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q245300 | SpacesType.create | train | async def create(
cls, *, name: str = None, description: str = None):
"""
Create a `Space` in MAAS.
:param name: The name of the `Space` (optional, will be given a
default value if not specified).
:type name: `str`
:param description: A description of the `Sp... | python | {
"resource": ""
} |
q245301 | SpaceType.get_default | train | async def get_default(cls):
"""Get the 'default' Space for the MAAS."""
| python | {
"resource": ""
} |
q245302 | Space.delete | train | async def delete(self):
"""Delete this Space."""
if self.id == self._origin.Space._default_space_id:
| python | {
"resource": ""
} |
q245303 | VlanType.read | train | async def read(cls, fabric: Union[Fabric, int], vid: int):
"""Get `Vlan` by `vid`.
:param fabric: Fabric to get the VLAN from.
:type fabric: `Fabric` or `int`
:param vid: VID of VLAN.
:type vid: `int`
"""
if isinstance(fabric, int):
fabric_id = fabric... | python | {
"resource": ""
} |
q245304 | Vlan.delete | train | async def delete(self):
"""Delete this VLAN."""
# Since the VID can be changed for the VLAN, we always use the vid
# from the original data. That way if the user changes the vid the
| python | {
"resource": ""
} |
q245305 | VlansType.read | train | async def read(cls, fabric: Union[Fabric, int]):
"""Get list of `Vlan`'s for `fabric`.
:param fabric: Fabric to get all VLAN's for.
:type fabric: `Fabric` or `int`
"""
if isinstance(fabric, int):
fabric_id = fabric
elif isinstance(fabric, Fabric):
... | python | {
"resource": ""
} |
q245306 | VlansType.create | train | async def create(
cls, fabric: Union[Fabric, int], vid: int, *,
name: str = None, description: str = None, mtu: int = None,
relay_vlan: Union[Vlan, int] = None, dhcp_on: bool = False,
primary_rack: Union[RackController, str] = None,
secondary_rack: Union[RackC... | python | {
"resource": ""
} |
q245307 | Vlans.get_default | train | def get_default(self):
"""Return the default VLAN from the set."""
length = len(self)
if length == 0:
return None
elif length == 1:
| python | {
"resource": ""
} |
q245308 | get_content_type | train | def get_content_type(*names):
"""Return the MIME content type for the file with the given name."""
for name in names:
if name is not None:
mimetype, encoding = mimetypes.guess_type(name)
if mimetype is not None:
if | python | {
"resource": ""
} |
q245309 | MAASType.set_http_proxy | train | async def set_http_proxy(cls, url: typing.Optional[str]):
"""See `get_http_proxy`."""
| python | {
"resource": ""
} |
q245310 | MAASType.get_kernel_options | train | async def get_kernel_options(cls) -> typing.Optional[str]:
"""Kernel options.
Boot parameters to pass to the kernel by default.
"""
| python | {
"resource": ""
} |
q245311 | MAASType.set_kernel_options | train | async def set_kernel_options(cls, options: typing.Optional[str]):
"""See `get_kernel_options`."""
| python | {
"resource": ""
} |
q245312 | MAASType.get_upstream_dns | train | async def get_upstream_dns(cls) -> list:
"""Upstream DNS server addresses.
Upstream DNS servers used to resolve domains not managed by this MAAS
(space-separated IP addresses). Only used when MAAS is running its own
DNS server. This value is used as the value of 'forwarders' in the DNS
... | python | {
"resource": ""
} |
q245313 | MAASType.set_upstream_dns | train | async def set_upstream_dns(
cls, addresses: typing.Optional[typing.Sequence[str]]):
"""See `get_upstream_dns`."""
await | python | {
"resource": ""
} |
q245314 | MAASType.get_dnssec_validation | train | async def get_dnssec_validation(cls) -> DNSSEC:
"""Enable DNSSEC validation of upstream zones.
Only used when MAAS is running its own DNS server. This value is used
as the value | python | {
"resource": ""
} |
q245315 | MAASType.get_windows_kms_host | train | async def get_windows_kms_host(cls) -> typing.Optional[str]:
"""Windows KMS activation host.
FQDN or IP address of the host that provides the KMS Windows
activation service. (Only needed for Windows deployments using KMS
activation.)
| python | {
"resource": ""
} |
q245316 | MAASType.set_windows_kms_host | train | async def set_windows_kms_host(cls, host: typing.Optional[str]):
"""See `get_windows_kms_host`."""
| python | {
"resource": ""
} |
q245317 | MAASType.get_default_storage_layout | train | async def get_default_storage_layout(cls) -> StorageLayout:
"""Default storage layout.
Storage layout that is applied to a node when it is deployed.
| python | {
"resource": ""
} |
q245318 | MAASType.get_default_min_hwe_kernel | train | async def get_default_min_hwe_kernel(cls) -> typing.Optional[str]:
"""Default minimum kernel version.
The minimum kernel version used on new and commissioned nodes.
"""
| python | {
"resource": ""
} |
q245319 | MAASType.set_default_min_hwe_kernel | train | async def set_default_min_hwe_kernel(cls, version: typing.Optional[str]):
"""See `get_default_min_hwe_kernel`."""
| python | {
"resource": ""
} |
q245320 | MAASType.set_config | train | async def set_config(cls, name: str, value):
"""Set a configuration value in MAAS.
Consult your MAAS server for recognised settings. Alternatively, use
the pre-canned functions also defined on | python | {
"resource": ""
} |
q245321 | VolumeGroupsType.create | train | async def create(
cls, node: Union[Node, str], name: str,
devices: Iterable[Union[BlockDevice, Partition]],
*, uuid: str = None):
"""
Create a volume group on a Node.
:param node: Node to create the interface on.
:type node: `Node` or `str`
:p... | python | {
"resource": ""
} |
q245322 | schema_create | train | def schema_create(conn):
"""Create the index for storing profiles.
This is idempotent; it can be called every time a database is opened to
make sure it's ready to use and up-to-date.
:param conn: A connection to an SQLite3 database.
"""
conn.execute(dedent("""\
CREATE TABLE IF NOT EXISTS p... | python | {
"resource": ""
} |
q245323 | schema_import | train | def schema_import(conn, dbpath):
"""Import profiles from another database.
This does not overwrite existing profiles in the target database. Profiles
in the source database that share names with those in the target database
are ignored.
:param conn: A connection to an SQLite3 database into which t... | python | {
"resource": ""
} |
q245324 | Profile.replace | train | def replace(self, **updates):
"""Return a new profile with the given updates.
Unspecified fields will be the same as | python | {
"resource": ""
} |
q245325 | Profile.dump | train | def dump(self):
"""Return a dict of fields that can be used to recreate this profile.
For example::
>>> profile = Profile(name="foobar", ...)
>>> profile == Profile(**profile.dump())
True
Use this value when persisting a profile.
| python | {
"resource": ""
} |
q245326 | ProfileStore.default | train | def default(self) -> typing.Optional[Profile]:
"""The name of the default profile to use, or `None`."""
found = self.database.execute(
"SELECT name, data FROM profiles WHERE selected"
" ORDER BY name LIMIT 1").fetchone()
if found is None:
| python | {
"resource": ""
} |
q245327 | ProfileStore.open | train | def open(cls, dbpath=Path("~/.maas.db").expanduser(),
migrate_from=Path("~/.maascli.db").expanduser()):
"""Load a profiles database.
Called without arguments this will open (and create) a database in the
user's home directory.
**Note** that this returns a context manager w... | python | {
"resource": ""
} |
q245328 | print_with_pager | train | def print_with_pager(output):
"""Print the output to `stdout` using less when in a tty."""
if sys.stdout.isatty():
try:
pager = subprocess.Popen(
['less', '-F', '-r', '-S', '-X', '-K'],
stdin=subprocess.PIPE, stdout=sys.stdout)
| python | {
"resource": ""
} |
q245329 | get_profile_names_and_default | train | def get_profile_names_and_default() -> (
typing.Tuple[typing.Sequence[str], typing.Optional[Profile]]):
"""Return the list of profile names and the default profile object.
The list of | python | {
"resource": ""
} |
q245330 | prepare_parser | train | def prepare_parser(program):
"""Create and populate an argument parser."""
parser = ArgumentParser(
description=PROG_DESCRIPTION, prog=program,
formatter_class=HelpFormatter,
add_help=False)
parser.add_argument(
"-h", "--help", action=MinimalHelpAction, help=argparse.SUPPRESS... | python | {
"resource": ""
} |
q245331 | post_mortem | train | def post_mortem(traceback):
"""Work with an exception in a post-mortem debugger.
Try to use `ipdb` first, falling back to `pdb`.
"""
try:
from ipdb import post_mortem
except ImportError:
| python | {
"resource": ""
} |
q245332 | ArgumentParser.subparsers | train | def subparsers(self):
"""Obtain the subparser's object."""
try:
return self.__subparsers
except AttributeError:
parent = super(ArgumentParser, self)
| python | {
"resource": ""
} |
q245333 | ArgumentParser.add_argument_group | train | def add_argument_group(self, title, description=None):
"""Add an argument group, or return a pre-existing one."""
try:
groups = self.__groups
except AttributeError:
groups = self.__groups = {}
| python | {
"resource": ""
} |
q245334 | ArgumentParser.print_minized_help | train | def print_minized_help(self, *, no_pager=False):
"""Return the formatted help text.
Override default ArgumentParser to just include the usage and the
description. The `help` action is used for provide more detail.
"""
formatter = self._get_formatter()
formatter.add_usage... | python | {
"resource": ""
} |
q245335 | Command.name | train | def name(cls):
"""Return the preferred name as which this command will be known."""
name = cls.__name__.replace("_", "-").lower()
| python | {
"resource": ""
} |
q245336 | Command.register | train | def register(cls, parser, name=None):
"""Register this command as a sub-parser of `parser`.
:type parser: An instance of `ArgumentParser`.
:return: The sub-parser created.
"""
help_title, help_body = utils.parse_docstring(cls)
command_parser = parser.subparsers.add_parse... | python | {
"resource": ""
} |
q245337 | cmd_help.print_all_commands | train | def print_all_commands(self, *, no_pager=False):
"""Print help for all commands.
Commands are sorted in alphabetical order and wrapping is done
based on the width of the terminal.
"""
formatter = self.parent_parser._get_formatter()
command_names = sorted(self.parent_pars... | python | {
"resource": ""
} |
q245338 | EventsType.query | train | async def query(
cls, *,
hostnames: typing.Iterable[str] = None,
domains: typing.Iterable[str] = None,
zones: typing.Iterable[str] = None,
macs: typing.Iterable[str] = None,
system_ids: typing.Iterable[str] = None,
agent_name: str = Non... | python | {
"resource": ""
} |
q245339 | SSHKeysType.create | train | async def create(cls, key: str):
"""
Create an SSH key in MAAS with the content in `key`.
:param key: The content | python | {
"resource": ""
} |
q245340 | BlockDevice.save | train | async def save(self):
"""Save this block device."""
old_tags = list(self._orig_data['tags'])
new_tags = list(self.tags)
self._changed_data.pop('tags', None)
await super(BlockDevice, self).save()
for tag_name in new_tags:
if tag_name not in old_tags:
... | python | {
"resource": ""
} |
q245341 | BlockDevice.set_as_boot_disk | train | async def set_as_boot_disk(self):
"""Set as boot disk for this node."""
| python | {
"resource": ""
} |
q245342 | BlockDevice.format | train | async def format(self, fstype, *, uuid=None):
"""Format this block device."""
self._data = await self._handler.format(
| python | {
"resource": ""
} |
q245343 | BlockDevice.unformat | train | async def unformat(self):
"""Unformat this block device."""
self._data = await | python | {
"resource": ""
} |
q245344 | BlockDevice.unmount | train | async def unmount(self):
"""Unmount this block device."""
self._data = await self._handler.unmount( | python | {
"resource": ""
} |
q245345 | BlockDevicesType.create | train | async def create(
cls, node: Union[Node, str], name: str,
*, model: str = None, serial: str = None,
id_path: str = None, size: int = None, block_size: int = 512,
tags: Iterable[str] = None):
"""
Create a physical block device on a Node.
Either mod... | python | {
"resource": ""
} |
q245346 | read | train | def read(filename):
"""Return the whitespace-stripped content of `filename`."""
path = join(here, filename)
| python | {
"resource": ""
} |
q245347 | VlansTable.get_subnets | train | def get_subnets(self, vlan):
"""Return the subnets for the `vlan`."""
return vlan._origin.Subnets([
subnet
| python | {
"resource": ""
} |
q245348 | BootSourcesType.create | train | async def create(cls, url, *, keyring_filename=None, keyring_data=None):
"""Create a new `BootSource`.
:param url: The URL for the boot source.
:param keyring_filename: The path to the keyring file on the server.
:param keyring_data: The GPG keyring data, | python | {
"resource": ""
} |
q245349 | fetch_api_description | train | async def fetch_api_description(
url: typing.Union[str, ParseResult, SplitResult],
insecure: bool = False):
"""Fetch the API description from the remote MAAS instance."""
url_describe = urljoin(_ensure_url_string(url), "describe/")
connector = aiohttp.TCPConnector(verify_ssl=(not insecure))
... | python | {
"resource": ""
} |
q245350 | _ensure_url_string | train | def _ensure_url_string(url):
"""Convert `url` to a string URL if it isn't one already."""
if isinstance(url, str):
return url
elif isinstance(url, (ParseResult, SplitResult)):
| python | {
"resource": ""
} |
q245351 | derive_resource_name | train | def derive_resource_name(name):
"""A stable, human-readable name and identifier for a resource."""
if name.startswith("Anon"):
name = name[4:]
if name.endswith("Handler"):
| python | {
"resource": ""
} |
q245352 | connect | train | async def connect(url, *, apikey=None, insecure=False):
"""Connect to a remote MAAS instance with `apikey`.
Returns a new :class:`Profile` which has NOT been saved. To connect AND
save a new profile::
profile = connect(url, apikey=apikey)
profile = profile.replace(name="mad-hatter")
... | python | {
"resource": ""
} |
q245353 | login | train | async def login(url, *, anonymous=False, username=None, password=None,
insecure=False):
"""Log-in to a remote MAAS instance.
Returns a new :class:`Profile` which has NOT been saved. To log-in AND
save a new profile::
profile = login(url, username="alice", password="wonderland")
... | python | {
"resource": ""
} |
q245354 | authenticate_with_macaroon | train | async def authenticate_with_macaroon(url, insecure=False):
"""Login via macaroons and generate and return new API keys."""
executor = futures.ThreadPoolExecutor(max_workers=1)
def get_token():
client = httpbakery.Client()
resp = client.request(
'POST', '{}/account/?op=create_aut... | python | {
"resource": ""
} |
q245355 | authenticate | train | async def authenticate(url, username, password, *, insecure=False):
"""Obtain a new API key by logging into MAAS.
:param url: URL for the MAAS API (i.e. ends with ``/api/x.y/``).
:param insecure: If true, don't verify SSL/TLS certificates.
:return: A `Credentials` instance.
:raise RemoteError: An ... | python | {
"resource": ""
} |
q245356 | PodsType.create | train | async def create(
cls, *, type: str,
power_address: str,
power_user: str = None,
power_pass: str = None,
name: str = None,
zone: typing.Union[str, Zone] = None,
tags: typing.Sequence[str] = None):
"""Create a `Pod` in MAAS.
... | python | {
"resource": ""
} |
q245357 | Pod.compose | train | async def compose(
self, *, cores: int = None, memory: int = None,
cpu_speed: int = None, architecture: str = None,
storage: typing.Sequence[str] = None, hostname: str = None,
domain: typing.Union[int, str] = None,
zone: typing.Union[int, str, Zone] = None,
... | python | {
"resource": ""
} |
q245358 | IPRangesType.create | train | async def create(
cls, start_ip: str, end_ip: str, *,
type: IPRangeType = IPRangeType.RESERVED,
comment: str = None, subnet: Union[Subnet, int] = None):
"""
Create a `IPRange` in MAAS.
:param start_ip: First IP address in the range (required).
:type s... | python | {
"resource": ""
} |
q245359 | gen_parents | train | def gen_parents(parents):
"""Generate the parents to send to the handler."""
for idx, parent in enumerate(parents):
if isinstance(parent, Interface):
| python | {
"resource": ""
} |
q245360 | get_parent | train | def get_parent(parent):
"""Get the parent to send to the handler."""
if isinstance(parent, Interface):
return parent.id
| python | {
"resource": ""
} |
q245361 | Interface.save | train | async def save(self):
"""Save this interface."""
if set(self.tags) != set(self._orig_data['tags']):
self._changed_data['tags'] = ','.join(self.tags)
elif 'tags' in self._changed_data:
del self._changed_data['tags']
orig_params = self._orig_data['params']
i... | python | {
"resource": ""
} |
q245362 | Interface.disconnect | train | async def disconnect(self):
"""Disconnect this interface."""
self._data = await | python | {
"resource": ""
} |
q245363 | InterfaceLink.delete | train | async def delete(self):
"""Delete this interface link."""
interface = self._data['interface']
data = await interface._handler.unlink_subnet(
system_id=interface.node.system_id, id=interface.id, _id=self.id)
| python | {
"resource": ""
} |
q245364 | InterfaceLink.set_as_default_gateway | train | async def set_as_default_gateway(self):
"""Set this link as the default gateway for the node."""
interface = | python | {
"resource": ""
} |
q245365 | InterfaceLinksType.create | train | async def create(
cls, interface: Interface, mode: LinkMode,
subnet: Union[Subnet, int] = None, ip_address: str = None,
force: bool = False, default_gateway: bool = False):
"""
Create a link on `Interface` in MAAS.
:param interface: Interface to create the li... | python | {
"resource": ""
} |
q245366 | BcacheCacheSetsType.create | train | async def create(
cls, node: Union[Node, str],
cache_device: Union[BlockDevice, Partition]):
"""
Create a BcacheCacheSet on a Node.
:param node: Node to create the interface on.
:type node: `Node` or `str`
:param cache_device: Block device or partition to... | python | {
"resource": ""
} |
q245367 | Table.render | train | def render(self, target, data):
"""Render the table."""
rows = self.get_rows(target, data)
rows = self._filter_rows(rows)
renderer = getattr(self, | python | {
"resource": ""
} |
q245368 | FabricType.get_default | train | async def get_default(cls):
"""
Get the 'default' Fabric for the MAAS.
"""
| python | {
"resource": ""
} |
q245369 | Fabric.delete | train | async def delete(self):
"""Delete this Fabric."""
if self.id == self._origin.Fabric._default_fabric_id:
| python | {
"resource": ""
} |
q245370 | dir_class | train | def dir_class(cls):
"""Return a list of names available on `cls`.
Eliminates names that bind to an `ObjectMethod` without a corresponding
class method; see `ObjectMethod`.
"""
# Class attributes (including methods).
for name, value in vars_class(cls).items():
if isinstance(value, Object... | python | {
"resource": ""
} |
q245371 | dir_instance | train | def dir_instance(inst):
"""Return a list of names available on `inst`.
Eliminates names that bind to an `ObjectMethod` without a corresponding
instance method; see `ObjectMethod`.
"""
# Skip instance attributes; __slots__ is automatically defined, and
# descriptors are used to define attributes... | python | {
"resource": ""
} |
q245372 | is_pk_descriptor | train | def is_pk_descriptor(descriptor, include_alt=False):
"""Return true if `descriptor` is a primary key."""
if descriptor.pk is True or type(descriptor.pk) is int:
return True
| python | {
"resource": ""
} |
q245373 | get_pk_descriptors | train | def get_pk_descriptors(cls):
"""Return tuple of tuples with attribute name and descriptor on the
`cls` that is defined as the primary keys."""
pk_fields = {
name: descriptor
for name, descriptor in vars_class(cls).items()
if isinstance(descriptor, ObjectField) and is_pk_descriptor(de... | python | {
"resource": ""
} |
q245374 | ManagedCreate | train | def ManagedCreate(super_cls):
"""Dynamically creates a `create` method for a `ObjectSet.Managed` class
that calls the `super_cls.create`.
The first positional argument that is passed to the `super_cls.create` is
the `_manager` that was set using `ObjectSet.Managed`. The created object
is added to t... | python | {
"resource": ""
} |
q245375 | mapping_of | train | def mapping_of(cls):
"""Expects a mapping from some key to data for `cls` instances."""
def mapper(data):
if not isinstance(data, Mapping):
raise TypeError(
"data must be a mapping, not | python | {
"resource": ""
} |
q245376 | find_objects | train | def find_objects(modules):
"""Find subclasses of `Object` and `ObjectSet` in the given modules.
:param modules: The full *names* of modules to include. These modules MUST
have been imported in advance.
"""
return {
subclass.__name__: subclass
| python | {
"resource": ""
} |
q245377 | ObjectType.bind | train | def bind(cls, origin, handler, *, name=None):
"""Bind this object to the given origin and handler.
:param origin: An instance of `Origin`.
:param handler: An instance of `bones.HandlerAPI`.
:return: A subclass of this class.
"""
name = cls.__name__ if name | python | {
"resource": ""
} |
q245378 | Object.refresh | train | async def refresh(self):
"""Refresh the object from MAAS."""
cls = type(self)
if hasattr(cls, 'read'):
descriptors, alt_descriptors = get_pk_descriptors(cls)
if len(descriptors) == 1:
try:
obj = await cls.read(getattr(self, descriptors[... | python | {
"resource": ""
} |
q245379 | Object.save | train | async def save(self):
"""Save the object in MAAS."""
if hasattr(self._handler, "update"):
if self._changed_data:
update_data = dict(self._changed_data)
update_data.update({
key: self._orig_data[key]
for key in self._hand... | python | {
"resource": ""
} |
q245380 | ObjectSet.Managed | train | def Managed(cls, manager, field, items):
"""Create a custom `ObjectSet` that is managed by a related `Object.`
:param manager: The manager of the `ObjectSet`. This is the `Object`
that manages this set of objects.
:param field: The field on the `manager` that created this managed
... | python | {
"resource": ""
} |
q245381 | ObjectField.Checked | train | def Checked(cls, name, datum_to_value=None, value_to_datum=None, **other):
"""Create a custom `ObjectField` that validates values and datums.
:param name: The name of the field. This is the name that's used to
store the datum in the MAAS-side data dictionary.
:param datum_to_value: ... | python | {
"resource": ""
} |
q245382 | ObjectFieldRelated.value_to_datum | train | def value_to_datum(self, instance, value):
"""Convert a given Python-side value to a MAAS-side datum.
:param instance: The `Object` instance on which this field is
currently operating. This method should treat it as read-only, for
example to perform validation with regards to ot... | python | {
"resource": ""
} |
q245383 | OriginType.fromURL | train | async def fromURL(cls, url, *, credentials=None, insecure=False):
"""Return an `Origin` for a given MAAS instance."""
session = await bones.SessionAPI.fromURL(
| python | {
"resource": ""
} |
q245384 | OriginType.fromProfile | train | def fromProfile(cls, profile):
"""Return an `Origin` from a given configuration profile.
:see: `ProfileStore`.
| python | {
"resource": ""
} |
q245385 | OriginType.fromProfileName | train | def fromProfileName(cls, name):
"""Return an `Origin` from a given configuration profile name.
:see: `ProfileStore`.
| python | {
"resource": ""
} |
q245386 | OriginType.login | train | async def login(
cls, url, *, username=None, password=None, insecure=False):
"""Make an `Origin` by logging-in with a username and password.
:return: A tuple of ``profile`` and ``origin``, where the former is an
unsaved `Profile` instance, and the latter is an `Origin` instance
... | python | {
"resource": ""
} |
q245387 | OriginType.connect | train | async def connect(
cls, url, *, apikey=None, insecure=False):
"""Make an `Origin` by connecting with an apikey.
:return: A tuple of ``profile`` and ``origin``, where the former is an
unsaved `Profile` instance, and the latter is an `Origin` instance
| python | {
"resource": ""
} |
q245388 | facade | train | def facade(factory):
"""Declare a method as a facade factory.""" | python | {
"resource": ""
} |
q245389 | Partition.delete | train | async def delete(self):
"""Delete this partition."""
await self._handler.delete(
| python | {
"resource": ""
} |
q245390 | Partition.unformat | train | async def unformat(self):
"""Unformat this partition."""
self._data = await self._handler.unformat(
| python | {
"resource": ""
} |
q245391 | Partition.mount | train | async def mount(self, mount_point, *, mount_options=None):
"""Mount this partition."""
self._data = await self._handler.mount(
system_id=self.block_device.node.system_id,
| python | {
"resource": ""
} |
q245392 | Partition.umount | train | async def umount(self):
"""Unmount this partition."""
self._data = await self._handler.unmount(
| python | {
"resource": ""
} |
q245393 | PartitionsType.read | train | async def read(cls, node, block_device):
"""Get list of `Partitions`'s for `node` and `block_device`."""
if isinstance(node, str):
system_id = node
elif isinstance(node, Node):
system_id = node.system_id
else:
raise TypeError(
"node mus... | python | {
"resource": ""
} |
q245394 | PartitionsType.create | train | async def create(cls, block_device: BlockDevice, size: int):
"""
Create a partition on a block device.
:param block_device: BlockDevice to create the paritition on.
:type block_device: `BlockDevice`
:param size: The size of the partition in bytes.
:type size: `int`
... | python | {
"resource": ""
} |
q245395 | asynchronous | train | def asynchronous(func):
"""Return `func` in a "smart" asynchronous-aware wrapper.
If `func` is called within the event-loop — i.e. when it is running — this
returns the result of `func` without alteration. However, when called from
outside of the event-loop, and the result is awaitable, the result will... | python | {
"resource": ""
} |
q245396 | _maybe_wrap | train | def _maybe_wrap(attribute):
"""Helper for `Asynchronous`."""
if iscoroutinefunction(attribute):
return asynchronous(attribute)
| python | {
"resource": ""
} |
q245397 | SubnetsType.create | train | async def create(
cls, cidr: str, vlan: Union[Vlan, int] = None, *,
name: str = None, description: str = None,
gateway_ip: str = None, rdns_mode: RDNSMode = None,
dns_servers: Union[Sequence[str], str] = None,
managed: bool = None):
"""
Create ... | python | {
"resource": ""
} |
q245398 | Subnet.save | train | async def save(self):
"""Save this subnet."""
if 'vlan' in self._changed_data and self._changed_data['vlan']:
# Update uses the ID of the VLAN, not the VLAN object.
self._changed_data['vlan'] = self._changed_data['vlan']['id']
if (self._orig_data['vlan'] and
... | python | {
"resource": ""
} |
q245399 | urlencode | train | def urlencode(data):
"""A version of `urllib.urlencode` that isn't insane.
This only cares that `data` is an iterable of iterables. Each sub-iterable
must be of overall length 2, i.e. a name/value pair.
Unicode strings will be encoded to UTF-8. This is what Django expects; see
`smart_text` in the ... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.