Search is not available for this dataset
text
stringlengths
75
104k
def wait_for_ready(self, instance_id, limit=14400, delay=10, pending=False): """Determine if a Server is ready. A server is ready when no transactions are running on it. :param int instance_id: The instance ID with the pending transaction :param int limit: The maximum amount of seconds...
def cli(env, identifier, immediate, comment, reason): """Cancel a dedicated server.""" mgr = SoftLayer.HardwareManager(env.client) hw_id = helpers.resolve_id(mgr.resolve_ids, identifier, 'hardware') if not (env.skip_confirmations or formatting.no_going_back(hw_id)): raise exceptions.CLIAbort('...
def cli(env, identifier, postinstall, key, image): """Reload operating system on a virtual server.""" vsi = SoftLayer.VSManager(env.client) vs_id = helpers.resolve_id(vsi.resolve_ids, identifier, 'VS') keys = [] if key: for single_key in key: resolver = SoftLayer.SshKeyManager(e...
def cli(env, identifier, columns): """Reserved Capacity Group details. Will show which guests are assigned to a reservation.""" manager = CapacityManager(env.client) mask = """mask[instances[id,createDate,guestId,billingItem[id, description, recurringFee, category[name]], guest[modifyDate,id,...
def get_client_settings_args(**kwargs): """Retrieve client settings from user-supplied arguments. :param \\*\\*kwargs: Arguments that are passed into the client instance """ timeout = kwargs.get('timeout') if timeout is not None: timeout = float(timeout) return { 'endpoint_...
def get_client_settings_env(**_): """Retrieve client settings from environment settings. :param \\*\\*kwargs: Arguments that are passed into the client instance """ return { 'proxy': os.environ.get('https_proxy'), 'username': os.environ.get('SL_USERNAME'), 'api_key': os.env...
def get_client_settings_config_file(**kwargs): # pylint: disable=inconsistent-return-statements """Retrieve client settings from the possible config file locations. :param \\*\\*kwargs: Arguments that are passed into the client instance """ config_files = ['/etc/softlayer.conf', '~/.softlayer'] ...
def get_client_settings(**kwargs): """Parse client settings. Parses settings from various input methods, preferring earlier values to later ones. The settings currently come from explicit user arguments, environmental variables and config files. :param \\*\\*kwargs: Arguments that are passed i...
def cli(env, package_keyname, required): """List the categories of a package. :: # List the categories of Bare Metal servers slcli order category-list BARE_METAL_SERVER # List the required categories for Bare Metal servers slcli order category-list BARE_METAL_SERVER --required...
def list_certs(self, method='all'): """List all certificates. :param string method: The type of certificates to list. Options are 'all', 'expired', and 'valid'. :returns: A list of dictionaries representing the requested SSL certs. Example:: #...
def cli(env): """List all zones.""" manager = SoftLayer.DNSManager(env.client) zones = manager.list_zones() table = formatting.Table(['id', 'zone', 'serial', 'updated']) table.align['serial'] = 'c' table.align['updated'] = 'c' for zone in zones: table.add_row([ zone['id...
def cli(env, columns, sortby, volume_id): """List ACLs.""" file_manager = SoftLayer.FileStorageManager(env.client) access_list = file_manager.get_file_volume_access_list( volume_id=volume_id) table = formatting.Table(columns.columns) table.sortby = sortby for key, type_name in [('allowe...
def cli(env, start, end, sortby): """Bandwidth report for every pool/server. This reports on the total data transfered for each virtual sever, hardware server and bandwidth pool. """ env.err('Generating bandwidth report for %s to %s' % (start, end)) table = formatting.Table([ 'type', ...
def list_file_volumes(self, datacenter=None, username=None, storage_type=None, **kwargs): """Returns a list of file volumes. :param datacenter: Datacenter short name (e.g.: dal09) :param username: Name of volume. :param storage_type: Type of volume: Endurance o...
def get_file_volume_details(self, volume_id, **kwargs): """Returns details about the specified volume. :param volume_id: ID of volume. :param kwargs: :return: Returns details about the specified volume. """ if 'mask' not in kwargs: items = [ ...
def order_replicant_volume(self, volume_id, snapshot_schedule, location, tier=None): """Places an order for a replicant file volume. :param volume_id: The ID of the primary volume to be replicated :param snapshot_schedule: The primary volume's snapshot ...
def order_duplicate_volume(self, origin_volume_id, origin_snapshot_id=None, duplicate_size=None, duplicate_iops=None, duplicate_tier_level=None, duplicate_snapshot_size=None, hourly_billing_flag=F...
def order_modified_volume(self, volume_id, new_size=None, new_iops=None, new_tier_level=None): """Places an order for modifying an existing file volume. :param volume_id: The ID of the volume to be modified :param new_size: The new size/capacity for the volume :param new_iops: The new I...
def order_snapshot_space(self, volume_id, capacity, tier, upgrade, **kwargs): """Orders snapshot space for the given file volume. :param integer volume_id: The ID of the volume :param integer capacity: The capacity to order, in GB :param float tier: The tier level of the file volume, in...
def cli(env, zone): """Print zone in BIND format.""" manager = SoftLayer.DNSManager(env.client) zone_id = helpers.resolve_id(manager.resolve_ids, zone, name='zone') env.fout(manager.dump_zone(zone_id))
def rescue(env, identifier): """Reboot into a rescue image.""" vsi = SoftLayer.VSManager(env.client) vs_id = helpers.resolve_id(vsi.resolve_ids, identifier, 'VS') if not (env.skip_confirmations or formatting.confirm("This action will reboot this VSI. Continue?")): raise exceptions.C...
def reboot(env, identifier, hard): """Reboot an active virtual server.""" virtual_guest = env.client['Virtual_Guest'] mgr = SoftLayer.HardwareManager(env.client) vs_id = helpers.resolve_id(mgr.resolve_ids, identifier, 'VS') if not (env.skip_confirmations or formatting.confirm('This will...
def power_off(env, identifier, hard): """Power off an active virtual server.""" virtual_guest = env.client['Virtual_Guest'] vsi = SoftLayer.VSManager(env.client) vs_id = helpers.resolve_id(vsi.resolve_ids, identifier, 'VS') if not (env.skip_confirmations or formatting.confirm('This will...
def power_on(env, identifier): """Power on a virtual server.""" vsi = SoftLayer.VSManager(env.client) vs_id = helpers.resolve_id(vsi.resolve_ids, identifier, 'VS') env.client['Virtual_Guest'].powerOn(id=vs_id)
def pause(env, identifier): """Pauses an active virtual server.""" vsi = SoftLayer.VSManager(env.client) vs_id = helpers.resolve_id(vsi.resolve_ids, identifier, 'VS') if not (env.skip_confirmations or formatting.confirm('This will pause the VS with id %s. Continue?' ...
def resume(env, identifier): """Resumes a paused virtual server.""" vsi = SoftLayer.VSManager(env.client) vs_id = helpers.resolve_id(vsi.resolve_ids, identifier, 'VS') env.client['Virtual_Guest'].resume(id=vs_id)
def cli(env): """Prints some various bits of information about an account""" manager = AccountManager(env.client) summary = manager.get_summary() env.fout(get_snapshot_table(summary))
def get_snapshot_table(account): """Generates a table for printing account summary data""" table = formatting.KeyValueTable(["Name", "Value"], title="Account Snapshot") table.align['Name'] = 'r' table.align['Value'] = 'l' table.add_row(['Company Name', account.get('companyName', '-')]) table.add...
def cli(env, prop): """Find details about this machine.""" try: if prop == 'network': env.fout(get_network()) return meta_prop = META_MAPPING.get(prop) or prop env.fout(SoftLayer.MetadataManager().get(meta_prop)) except SoftLayer.TransportError: rais...
def get_network(): """Returns a list of tables with public and private network details.""" meta = SoftLayer.MetadataManager() network_tables = [] for network_func in [meta.public_network, meta.private_network]: network = network_func() table = formatting.KeyValueTable(['name', 'value'])...
def get_formatter(columns): """This function returns a callback to use with click options. The returned function parses a comma-separated value and returns a new ColumnFormatter. :param columns: a list of Column instances """ column_map = dict((column.name, column) for column in columns) ...
def add_column(self, column): """Add a new column along with a formatting function.""" self.columns.append(column.name) self.column_funcs.append(column.path) if column.mask is not None: self.mask_parts.add(column.mask)
def row(self, data): """Return a formatted row for the given data.""" for column in self.column_funcs: if callable(column): yield column(data) else: yield utils.lookup(data, *column)
def cli(env, account_id, origin_id): """Remove an origin pull mapping.""" manager = SoftLayer.CDNManager(env.client) manager.remove_origin(account_id, origin_id)
def cli(env, sortby): """List all CDN accounts.""" manager = SoftLayer.CDNManager(env.client) accounts = manager.list_accounts() table = formatting.Table(['id', 'account_name', 'type', 'created', ...
def cli(env, volume_id, sortby, columns): """List file storage snapshots.""" file_manager = SoftLayer.FileStorageManager(env.client) snapshots = file_manager.get_file_volume_snapshot_list( volume_id, mask=columns.mask() ) table = formatting.Table(columns.columns) table.sortby = ...
def list_instances(self, hourly=True, monthly=True, tags=None, cpus=None, memory=None, hostname=None, domain=None, local_disk=None, datacenter=None, nic_speed=None, public_ip=None, private_ip=None, **kwargs): """Retrieve a list of all virtual ...
def get_instance(self, instance_id, **kwargs): """Get details about a virtual server instance. :param integer instance_id: the instance ID :returns: A dictionary containing a large amount of information about the specified instance. Example:: # Print out ...
def reload_instance(self, instance_id, post_uri=None, ssh_keys=None, image_id=None): """Perform an OS reload of an instance. :param integer instance_id: the instance ID to reload :param string post_url: The URI of the post-...
def _generate_create_dict( self, cpus=None, memory=None, hourly=True, hostname=None, domain=None, local_disk=True, datacenter=None, os_code=None, image_id=None, dedicated=False, public_vlan=None, private_vlan=None, private_subnet=None, public_subnet=None, ...
def wait_for_transaction(self, instance_id, limit, delay=10): """Waits on a VS transaction for the specified amount of time. This is really just a wrapper for wait_for_ready(pending=True). Provided for backwards compatibility. :param int instance_id: The instance ID with the pending tr...
def verify_create_instance(self, **kwargs): """Verifies an instance creation command. Without actually placing an order. See :func:`create_instance` for a list of available options. Example:: new_vsi = { 'domain': u'test01.labs.sftlyr.ws', '...
def create_instance(self, **kwargs): """Creates a new virtual server instance. .. warning:: This will add charges to your account Example:: new_vsi = { 'domain': u'test01.labs.sftlyr.ws', 'hostname': u'minion05', 'datace...
def set_tags(self, tags, guest_id): """Sets tags on a guest with a retry decorator Just calls guest.setTags, but if it fails from an APIError will retry """ self.guest.setTags(tags, id=guest_id)
def create_instances(self, config_list): """Creates multiple virtual server instances. This takes a list of dictionaries using the same arguments as create_instance(). .. warning:: This will add charges to your account Example:: # Define the instance ...
def change_port_speed(self, instance_id, public, speed): """Allows you to change the port speed of a virtual server's NICs. Example:: #change the Public interface to 10Mbps on instance 12345 result = mgr.change_port_speed(instance_id=12345, ...
def _get_ids_from_hostname(self, hostname): """List VS ids which match the given hostname.""" results = self.list_instances(hostname=hostname, mask="id") return [result['id'] for result in results]
def _get_ids_from_ip(self, ip_address): # pylint: disable=inconsistent-return-statements """List VS ids which match the given ip address.""" try: # Does it look like an ip address? socket.inet_aton(ip_address) except socket.error: return [] # Find th...
def edit(self, instance_id, userdata=None, hostname=None, domain=None, notes=None, tags=None): """Edit hostname, domain name, notes, and/or the user data of a VS. Parameters set to None will be ignored and not attempted to be updated. :param integer instance_id: the instance ID to...
def capture(self, instance_id, name, additional_disks=False, notes=None): """Capture one or all disks from a VS to a SoftLayer image. Parameters set to None will be ignored and not attempted to be updated. :param integer instance_id: the instance ID to edit :param string name: name ass...
def upgrade(self, instance_id, cpus=None, memory=None, nic_speed=None, public=True, preset=None): """Upgrades a VS instance. Example:: # Upgrade instance 12345 to 4 CPUs and 4 GB of memory import SoftLayer client = SoftLayer.create_client_from_env() mgr = So...
def order_guest(self, guest_object, test=False): """Uses Product_Order::placeOrder to create a virtual guest. Useful when creating a virtual guest with options not supported by Virtual_Guest::createObject specifically ipv6 support. :param dictionary guest_object: See SoftLayer.CLI.virt...
def _get_package_items(self): """Following Method gets all the item ids related to VS. Deprecated in favor of _get_upgrade_prices() """ warnings.warn("use _get_upgrade_prices() instead", DeprecationWarning) mask = [ 'description', 'c...
def _get_upgrade_prices(self, instance_id, include_downgrade_options=True): """Following Method gets all the price ids related to upgrading a VS. :param int instance_id: Instance id of the VS to be upgraded :returns: list """ mask = [ 'id', 'locationGrou...
def _get_price_id_for_upgrade_option(self, upgrade_prices, option, value, public=True): """Find the price id for the option and value to upgrade. This :param list upgrade_prices: Contains all the prices related to a VS upgrade :param string option: Describes type of parameter to be upgraded ...
def _get_price_id_for_upgrade(self, package_items, option, value, public=True): """Find the price id for the option and value to upgrade. Deprecated in favor of _get_price_id_for_upgrade_option() :param list package_items: Contains all the items related to an VS :param string option: D...
def interface_list(env, securitygroup_id, sortby): """List interfaces associated with security groups.""" mgr = SoftLayer.NetworkManager(env.client) table = formatting.Table(COLUMNS) table.sortby = sortby mask = ( '''networkComponentBindings[ networkComponentId, net...
def add(env, securitygroup_id, network_component, server, interface): """Attach an interface to a security group.""" _validate_args(network_component, server, interface) mgr = SoftLayer.NetworkManager(env.client) component_id = _get_component_id(env, network_component, server, interface) ret = mgr...
def default_select(identifier, all_entry_points): # pylint: disable=inconsistent-return-statements """ Raise an exception when we have ambiguous entry points. """ if len(all_entry_points) == 0: raise PluginMissingError(identifier) elif len(all_entry_points) == 1: return all_entry_...
def _load_class_entry_point(cls, entry_point): """ Load `entry_point`, and set the `entry_point.name` as the attribute `plugin_name` on the loaded object """ class_ = entry_point.load() setattr(class_, 'plugin_name', entry_point.name) return class_
def load_class(cls, identifier, default=None, select=None): """Load a single class specified by identifier. If `identifier` specifies more than a single class, and `select` is not None, then call `select` on the list of entry_points. Otherwise, choose the first one and log a warning. ...
def load_classes(cls, fail_silently=True): """Load all the classes for a plugin. Produces a sequence containing the identifiers and their corresponding classes for all of the available instances of this plugin. fail_silently causes the code to simply log warnings if a plugin ca...
def register_temp_plugin(cls, class_, identifier=None, dist='xblock'): """Decorate a function to run with a temporary plugin available. Use it like this in tests:: @register_temp_plugin(MyXBlockClass): def test_the_thing(): # Here I can load MyXBlockClass by nam...
def webob_to_django_response(webob_response): """Returns a django response to the `webob_response`""" from django.http import HttpResponse django_response = HttpResponse( webob_response.app_iter, content_type=webob_response.content_type, status=webob_response.status_code, ) f...
def querydict_to_multidict(query_dict, wrap=None): """ Returns a new `webob.MultiDict` from a `django.http.QueryDict`. If `wrap` is provided, it's used to wrap the values. """ wrap = wrap or (lambda val: val) return MultiDict(chain.from_iterable( six.moves.zip(repeat(key), (wrap(v) for...
def _meta_name(self, name): """ Translate HTTP header names to the format used by Django request objects. See https://docs.djangoproject.com/en/1.4/ref/request-response/#django.http.HttpRequest.META """ name = name.upper().replace('-', '_') if name not in self.UNPREFIXED...
def _un_meta_name(self, name): """ Reverse of _meta_name """ if name.startswith('HTTP_'): name = name[5:] return name.replace('_', '-').title()
def environ(self): """ Add path_info to the request's META dictionary. """ environ = dict(self._request.META) environ['PATH_INFO'] = self._request.path_info return environ
def _getfield(self, block, name): """ Return the field with the given `name` from `block`. If no field with `name` exists in any namespace, raises a KeyError. :param block: xblock to retrieve the field from :type block: :class:`~xblock.core.XBlock` :param name: name of t...
def _key(self, block, name): """ Resolves `name` to a key, in the following form: KeyValueStore.Key( scope=field.scope, user_id=student_id, block_scope_id=block_id, field_name=name, block_family=block.entry_point, ) """...
def get(self, block, name): """ Retrieve the value for the field named `name`. If a value is provided for `default`, then it will be returned if no value is set """ return self._kvs.get(self._key(block, name))
def set(self, block, name, value): """ Set the value of the field named `name` """ self._kvs.set(self._key(block, name), value)
def delete(self, block, name): """ Reset the value of the field named `name` to the default """ self._kvs.delete(self._key(block, name))
def has(self, block, name): """ Return whether or not the field named `name` has a non-default value """ try: return self._kvs.has(self._key(block, name)) except KeyError: return False
def set_many(self, block, update_dict): """Update the underlying model with the correct values.""" updated_dict = {} # Generate a new dict with the correct mappings. for (key, value) in six.iteritems(update_dict): updated_dict[self._key(block, key)] = value self._kv...
def default(self, block, name): """ Ask the kvs for the default (default implementation which other classes may override). :param block: block containing field to default :type block: :class:`~xblock.core.XBlock` :param name: name of the field to default """ retu...
def create_aside(self, definition_id, usage_id, aside_type): """Create the aside.""" return ( self.ASIDE_DEFINITION_ID(definition_id, aside_type), self.ASIDE_USAGE_ID(usage_id, aside_type), )
def create_usage(self, def_id): """Make a usage, storing its definition id.""" usage_id = self._next_id("u") self._usages[usage_id] = def_id return usage_id
def get_definition_id(self, usage_id): """Get a definition_id by its usage id.""" try: return self._usages[usage_id] except KeyError: raise NoSuchUsage(repr(usage_id))
def create_definition(self, block_type, slug=None): """Make a definition, storing its block type.""" prefix = "d" if slug: prefix += "_" + slug def_id = self._next_id(prefix) self._definitions[def_id] = block_type return def_id
def get_block_type(self, def_id): """Get a block_type by its definition id.""" try: return self._definitions[def_id] except KeyError: try: return def_id.aside_type except AttributeError: raise NoSuchDefinition(repr(def_id))
def field_data(self, field_data): """ Set field_data. Deprecated in favor of a 'field-data' service. """ warnings.warn("Runtime.field_data is deprecated", FieldDataDeprecationWarning, stacklevel=2) self._deprecated_per_instance_field_data = field_data
def load_block_type(self, block_type): """ Returns a subclass of :class:`.XBlock` that corresponds to the specified `block_type`. """ return XBlock.load_class(block_type, self.default_class, self.select)
def construct_xblock(self, block_type, scope_ids, field_data=None, *args, **kwargs): r""" Construct a new xblock of the type identified by block_type, passing \*args and \*\*kwargs into `__init__`. """ return self.construct_xblock_from_class( cls=self.load_block_type(...
def construct_xblock_from_class(self, cls, scope_ids, field_data=None, *args, **kwargs): """ Construct a new xblock of type cls, mixing in the mixins defined for this application. """ return self.mixologist.mix(cls)( runtime=self, field_data=field_data, ...
def get_block(self, usage_id, for_parent=None): """ Create an XBlock instance in this runtime. The `usage_id` is used to find the XBlock class and data. """ def_id = self.id_reader.get_definition_id(usage_id) try: block_type = self.id_reader.get_block_type(de...
def get_aside(self, aside_usage_id): """ Create an XBlockAside in this runtime. The `aside_usage_id` is used to find the Aside class and data. """ aside_type = self.id_reader.get_aside_type_from_usage(aside_usage_id) xblock_usage = self.id_reader.get_usage_id_from_aside(...
def parse_xml_string(self, xml, id_generator=None): """Parse a string of XML, returning a usage id.""" if id_generator is not None: warnings.warn( "Passing an id_generator directly is deprecated " "in favor of constructing the Runtime with the id_generator", ...
def parse_xml_file(self, fileobj, id_generator=None): """Parse an open XML file, returning a usage id.""" root = etree.parse(fileobj).getroot() usage_id = self._usage_id_from_node(root, None, id_generator) return usage_id
def _usage_id_from_node(self, node, parent_id, id_generator=None): """Create a new usage id from an XML dom node. Args: node (lxml.etree.Element): The DOM node to interpret. parent_id: The usage ID of the parent block id_generator (IdGenerator): The :class:`.IdGenera...
def _aside_from_xml(self, node, block_def_id, block_usage_id, id_generator): """ Create an aside from the xml and attach it to the given block """ id_generator = id_generator or self.id_generator aside_type = node.tag aside_class = self.load_aside_type(aside_type) ...
def add_node_as_child(self, block, node, id_generator=None): """ Called by XBlock.parse_xml to treat a child node as a child block. """ usage_id = self._usage_id_from_node(node, block.scope_ids.usage_id, id_generator) block.children.append(usage_id)
def export_to_xml(self, block, xmlfile): """ Export the block to XML, writing the XML to `xmlfile`. """ root = etree.Element("unknown_root", nsmap=XML_NAMESPACES) tree = etree.ElementTree(root) block.add_xml_to_node(root) # write asides as children for asi...
def add_block_as_child_node(self, block, node): """ Export `block` as a child node of `node`. """ child = etree.SubElement(node, "unknown") block.add_xml_to_node(child)
def render(self, block, view_name, context=None): """ Render a block by invoking its view. Finds the view named `view_name` on `block`. The default view will be used if a specific view hasn't be registered. If there is no default view, an exception will be raised. The...
def render_child(self, child, view_name=None, context=None): """A shortcut to render a child block. Use this method to render your children from your own view function. If `view_name` is not provided, it will default to the view name you're being rendered with. Returns the sam...
def render_children(self, block, view_name=None, context=None): """Render a block's children, returning a list of results. Each child of `block` will be rendered, just as :func:`render_child` does. Returns a list of values, each as provided by :func:`render`. """ results = [] ...
def wrap_xblock(self, block, view, frag, context): # pylint: disable=W0613 """ Creates a div which identifies the xblock and writes out the json_init_args into a script tag. If there's a `wrap_child` method, it calls that with a deprecation warning. The default implementation creates ...
def wrap_aside(self, block, aside, view, frag, context): # pylint: disable=unused-argument """ Creates a div which identifies the aside, points to the original block, and writes out the json_init_args into a script tag. The default implementation creates a frag to wraps frag w/ a div i...
def _wrap_ele(self, block, view, frag, extra_data=None): """ Does the guts of the wrapping the same way for both xblocks and asides. Their wrappers provide other info in extra_data which gets put into the dom data- attrs. """ wrapped = Fragment() data = { 'usa...