Search is not available for this dataset
text
stringlengths
75
104k
def roles_table(user): """Creates a table for a users roles""" table = formatting.Table(['id', 'Role Name', 'Description']) for role in user['roles']: table.add_row([role['id'], role['name'], role['description']]) return table
def _update_with_like_args(ctx, _, value): """Update arguments with options taken from a currently running VS.""" if value is None: return env = ctx.ensure_object(environment.Environment) vsi = SoftLayer.VSManager(env.client) vs_id = helpers.resolve_id(vsi.resolve_ids, value, 'VS') like...
def _parse_create_args(client, args): """Converts CLI arguments to args for VSManager.create_instance. :param dict args: CLI arguments """ data = { "hourly": args.get('billing', 'hourly') == 'hourly', "cpus": args.get('cpu', None), "ipv6": args.get('ipv6', None), "disks"...
def cli(env, **args): """Order/create virtual servers.""" vsi = SoftLayer.VSManager(env.client) _validate_args(env, args) create_args = _parse_create_args(env.client, args) test = args.get('test', False) do_create = not (args.get('export') or test) if do_create: if not (env.skip_co...
def _build_receipt_table(result, billing="hourly", test=False): """Retrieve the total recurring fee of the items prices""" title = "OrderId: %s" % (result.get('orderId', 'No order placed')) table = formatting.Table(['Cost', 'Description'], title=title) table.align['Cost'] = 'r' table.align['Descript...
def _validate_args(env, args): """Raises an ArgumentError if the given arguments are not valid.""" if all([args['cpu'], args['flavor']]): raise exceptions.ArgumentError( '[-c | --cpu] not allowed with [-f | --flavor]') if all([args['memory'], args['flavor']]): raise exceptions....
def cli(env, identifier, cpu, private, memory, network, flavor): """Upgrade a virtual server.""" vsi = SoftLayer.VSManager(env.client) if not any([cpu, memory, network, flavor]): raise exceptions.ArgumentError("Must provide [--cpu], [--memory], [--network], or [--flavor] to upgrade") if priva...
def reboot(env, identifier, hard): """Reboot an active server.""" hardware_server = env.client['Hardware_Server'] mgr = SoftLayer.HardwareManager(env.client) hw_id = helpers.resolve_id(mgr.resolve_ids, identifier, 'hardware') if not (env.skip_confirmations or formatting.confirm('This wi...
def power_on(env, identifier): """Power on a server.""" mgr = SoftLayer.HardwareManager(env.client) hw_id = helpers.resolve_id(mgr.resolve_ids, identifier, 'hardware') env.client['Hardware_Server'].powerOn(id=hw_id)
def power_cycle(env, identifier): """Power cycle a server.""" mgr = SoftLayer.HardwareManager(env.client) hw_id = helpers.resolve_id(mgr.resolve_ids, identifier, 'hardware') if not (env.skip_confirmations or formatting.confirm('This will power off the server with id %s. ' ...
def cli(env, group_id, name, description): """Edit details of a security group.""" mgr = SoftLayer.NetworkManager(env.client) data = {} if name: data['name'] = name if description: data['description'] = description if not mgr.edit_securitygroup(group_id, **data): raise e...
def cli(env, sortby): """List SSH keys.""" mgr = SoftLayer.SshKeyManager(env.client) keys = mgr.list_keys() table = formatting.Table(['id', 'label', 'fingerprint', 'notes']) table.sortby = sortby for key in keys: table.add_row([key['id'], key.get('label'), ...
def cli(env, date_min, date_max, obj_event, obj_id, obj_type, utc_offset, metadata, limit): """Get Event Logs Example: slcli event-log get -d 01/01/2019 -D 02/01/2019 -t User -l 10 """ columns = ['Event', 'Object', 'Type', 'Date', 'Username'] event_mgr = SoftLayer.EventLogManager(env.clien...
def cli(env, volume_id, new_size, new_iops, new_tier): """Modify an existing file storage volume.""" file_manager = SoftLayer.FileStorageManager(env.client) if new_tier is not None: new_tier = float(new_tier) try: order = file_manager.order_modified_volume( volume_id, ...
def list_users(self, objectmask=None, objectfilter=None): """Lists all users on an account :param string objectmask: Used to overwrite the default objectmask. :param dictionary objectfilter: If you want to use an objectfilter. :returns: A list of dictionaries that describe each user ...
def get_user(self, user_id, objectmask=None): """Calls SoftLayer_User_Customer::getObject :param int user_id: Id of the user :param string objectmask: default is 'mask[userStatus[name], parent[id, username]]' :returns: A user object. """ if objectmask is None: ...
def get_current_user(self, objectmask=None): """Calls SoftLayer_Account::getCurrentUser""" if objectmask is None: objectmask = "mask[userStatus[name], parent[id, username]]" return self.account_service.getCurrentUser(mask=objectmask)
def get_all_permissions(self): """Calls SoftLayer_User_CustomerPermissions_Permission::getAllObjects Stores the result in self.all_permissions :returns: A list of dictionaries that contains all valid permissions """ if self.all_permissions is None: permissions = self...
def add_permissions(self, user_id, permissions): """Enables a list of permissions for a user :param int id: user id to set :param list permissions: List of permissions keynames to enable :returns: True on success, Exception otherwise Example:: add_permissions(123, [...
def remove_permissions(self, user_id, permissions): """Disables a list of permissions for a user :param int id: user id to set :param list permissions: List of permissions keynames to disable :returns: True on success, Exception otherwise Example:: remove_permission...
def permissions_from_user(self, user_id, from_user_id): """Sets user_id's permission to be the same as from_user_id's Any permissions from_user_id has will be added to user_id. Any permissions from_user_id doesn't have will be removed from user_id. :param int user_id: The user to chang...
def get_user_permissions(self, user_id): """Returns a sorted list of a users permissions""" permissions = self.user_service.getPermissions(id=user_id) return sorted(permissions, key=itemgetter('keyName'))
def get_logins(self, user_id, start_date=None): """Gets the login history for a user, default start_date is 30 days ago :param int id: User id to get :param string start_date: "%m/%d/%Y %H:%M:%s" formatted string. :returns: list https://softlayer.github.io/reference/datatypes/SoftLayer_...
def get_events(self, user_id, start_date=None): """Gets the event log for a specific user, default start_date is 30 days ago :param int id: User id to view :param string start_date: "%Y-%m-%dT%H:%M:%s.0000-06:00" is the full formatted string. The Timezone part ...
def _get_id_from_username(self, username): """Looks up a username's id :param string username: Username to lookup :returns: The id that matches username. """ _mask = "mask[id, username]" _filter = {'users': {'username': utils.query_filter(username)}} user = self....
def format_permission_object(self, permissions): """Formats a list of permission key names into something the SLAPI will respect. :param list permissions: A list of SLAPI permissions keyNames. keyName of ALL will return all permissions. :returns: list of diction...
def create_user(self, user_object, password): """Blindly sends user_object to SoftLayer_User_Customer::createObject :param dictionary user_object: https://softlayer.github.io/reference/datatypes/SoftLayer_User_Customer/ """ LOGGER.warning("Creating User %s", user_object['username']) ...
def edit_user(self, user_id, user_object): """Blindly sends user_object to SoftLayer_User_Customer::editObject :param int user_id: User to edit :param dictionary user_object: https://softlayer.github.io/reference/datatypes/SoftLayer_User_Customer/ """ return self.user_service.ed...
def cli(env, identifier): """Unassigns a global IP from a target.""" mgr = SoftLayer.NetworkManager(env.client) global_ip_id = helpers.resolve_id(mgr.resolve_global_ip_ids, identifier, name='global ip') mgr.unassign_global_ip(global_ip_id)
def cli(env, context_id): """Request configuration of a tunnel context. This action will update the advancedConfigurationFlag on the context instance and further modifications against the context will be prevented until all changes can be propgated to network devices. """ manager = SoftLayer.IP...
def _get_zone_id_from_name(self, name): """Return zone ID based on a zone.""" results = self.client['Account'].getDomains( filter={"domains": {"name": utils.query_filter(name)}}) return [x['id'] for x in results]
def get_zone(self, zone_id, records=True): """Get a zone and its records. :param zone: the zone name :returns: A dictionary containing a large amount of information about the specified zone. """ mask = None if records: mask = 'resourceRecor...
def create_zone(self, zone, serial=None): """Create a zone for the specified zone. :param zone: the zone name to create :param serial: serial value on the zone (default: strftime(%Y%m%d01)) """ return self.service.createObject({ 'name': zone, 'serial': s...
def create_record(self, zone_id, record, record_type, data, ttl=60): """Create a resource record on a domain. :param integer id: the zone's ID :param record: the name of the record to add :param record_type: the type of record (A, AAAA, CNAME, TXT, etc.) :param data: the record'...
def create_record_mx(self, zone_id, record, data, ttl=60, priority=10): """Create a mx resource record on a domain. :param integer id: the zone's ID :param record: the name of the record to add :param data: the record's value :param integer ttl: the TTL or time-to-live value (de...
def create_record_srv(self, zone_id, record, data, protocol, port, service, ttl=60, priority=20, weight=10): """Create a resource record on a domain. :param integer id: the zone's ID :param record: the name of the record to add :param data: the record's value ...
def create_record_ptr(self, record, data, ttl=60): """Create a reverse record. :param record: the public ip address of device for which you would like to manage reverse DNS. :param data: the record's value :param integer ttl: the TTL or time-to-live value (default: 60) """ ...
def _generate_create_dict(record, record_type, data, ttl, **kwargs): """Returns a dict appropriate to pass into Dns_Domain_ResourceRecord::createObject""" # Basic dns record structure resource_record = { 'host': record, 'data': data, 'ttl': ttl, '...
def get_records(self, zone_id, ttl=None, data=None, host=None, record_type=None): """List, and optionally filter, records within a zone. :param zone: the zone name in which to search. :param int ttl: time in seconds :param str data: the records data :param st...
def cancel_guests(self, host_id): """Cancel all guests into the dedicated host immediately. To cancel an specified guest use the method VSManager.cancel_instance() :param host_id: The ID of the dedicated host. :return: The id, fqdn and status of all guests into a dictionary. The status...
def list_guests(self, host_id, tags=None, cpus=None, memory=None, hostname=None, domain=None, local_disk=None, nic_speed=None, public_ip=None, private_ip=None, **kwargs): """Retrieve a list of all virtual servers on the dedicated host. Example:: # Pr...
def list_instances(self, tags=None, cpus=None, memory=None, hostname=None, disk=None, datacenter=None, **kwargs): """Retrieve a list of all dedicated hosts on the account :param list tags: filter based on list of tags :param integer cpus: filter based on number of CPUS ...
def get_host(self, host_id, **kwargs): """Get details about a dedicated host. :param integer : the host ID :returns: A dictionary containing host information. Example:: # Print out host ID 12345. dh = mgr.get_host(12345) print dh # Prin...
def place_order(self, hostname, domain, location, flavor, hourly, router=None): """Places an order for a dedicated host. See get_create_options() for valid arguments. :param string hostname: server hostname :param string domain: server domain name :param string location: locati...
def verify_order(self, hostname, domain, location, hourly, flavor, router=None): """Verifies an order for a dedicated host. See :func:`place_order` for a list of available options. """ create_options = self._generate_create_dict(hostname=hostname, ...
def _generate_create_dict(self, hostname=None, domain=None, flavor=None, router=None, datacenter=None, hourly=True): """Translates a...
def _get_location(self, regions, datacenter): """Get the longer key with a short location(datacenter) name.""" for region in regions: # list of locations if region['location']['location']['name'] == datacenter: return region raise SoftLayer.SoftLayerError...
def get_create_options(self): """Returns valid options for ordering a dedicated host.""" package = self._get_package() # Locations locations = [] for region in package['regions']: locations.append({ 'name': region['location']['location']['longName'], ...
def _get_price(self, package): """Returns valid price for ordering a dedicated host.""" for price in package['prices']: if not price.get('locationGroupId'): return price['id'] raise SoftLayer.SoftLayerError("Could not find valid price")
def _get_item(self, package, flavor): """Returns the item for ordering a dedicated host.""" for item in package['items']: if item['keyName'] == flavor: return item raise SoftLayer.SoftLayerError("Could not find valid item for: '%s'" % flavor)
def _get_backend_router(self, locations, item): """Returns valid router options for ordering a dedicated host.""" mask = ''' id, hostname ''' cpu_count = item['capacity'] for capacity in item['bundleItems']: for category in capacity['categorie...
def _get_default_router(self, routers, router_name=None): """Returns the default router for ordering a dedicated host.""" if router_name is None: for router in routers: if router['id'] is not None: return router['id'] else: for router i...
def get_router_options(self, datacenter=None, flavor=None): """Returns available backend routers for the dedicated host.""" package = self._get_package() location = self._get_location(package['regions'], datacenter) item = self._get_item(package, flavor) return self._get_backen...
def _delete_guest(self, guest_id): """Deletes a guest and returns 'Cancelled' or and Exception message""" msg = 'Cancelled' try: self.guest.deleteObject(id=guest_id) except SoftLayer.SoftLayerAPIError as e: msg = 'Exception: ' + e.faultString return msg
def _click_autocomplete(root, text): """Completer generator for click applications.""" try: parts = shlex.split(text) except ValueError: raise StopIteration location, incomplete = _click_resolve_command(root, parts) if not text.endswith(' ') and not incomplete and text: rai...
def _click_resolve_command(root, parts): """Return the click command and the left over text given some vargs.""" location = root incomplete = '' for part in parts: incomplete = part if not part[0:2].isalnum(): continue try: next_location = location.get_c...
def cli(env, identifier, enable, permission, from_user): """Enable or Disable specific permissions.""" mgr = SoftLayer.UserManager(env.client) user_id = helpers.resolve_id(mgr.resolve_ids, identifier, 'username') result = False if from_user: from_user_id = helpers.resolve_id(mgr.resolve_ids,...
def list_accounts(self): """Lists CDN accounts for the active user.""" account = self.client['Account'] mask = 'cdnAccounts[%s]' % ', '.join(['id', 'createDate', 'cdnAccountName', ...
def get_account(self, account_id, **kwargs): """Retrieves a CDN account with the specified account ID. :param account_id int: the numeric ID associated with the CDN account. :param dict \\*\\*kwargs: additional arguments to include in the object mask. """...
def get_origins(self, account_id, **kwargs): """Retrieves list of origin pull mappings for a specified CDN account. :param account_id int: the numeric ID associated with the CDN account. :param dict \\*\\*kwargs: additional arguments to include in the object mask...
def add_origin(self, account_id, media_type, origin_url, cname=None, secure=False): """Adds an original pull mapping to an origin-pull. :param int account_id: the numeric ID associated with the CDN account. :param string media_type: the media type/protocol associated with thi...
def remove_origin(self, account_id, origin_id): """Removes an origin pull mapping with the given origin pull ID. :param int account_id: the CDN account ID from which the mapping should be deleted. :param int origin_id: the origin pull mapping ID to delete. ...
def load_content(self, account_id, urls): """Prefetches one or more URLs to the CDN edge nodes. :param int account_id: the CDN account ID into which content should be preloaded. :param urls: a string or a list of strings representing the CDN URLs ...
def purge_content(self, account_id, urls): """Purges one or more URLs from the CDN edge nodes. :param int account_id: the CDN account ID from which content should be purged. :param urls: a string or a list of strings representing the CDN URLs ...
def get_lb_pkgs(self): """Retrieves the local load balancer packages. :returns: A dictionary containing the load balancer packages """ _filter = {'items': {'description': utils.query_filter('*Load Balancer*')}} packages = self.prod_pkg.getItems(id=...
def _get_location(self, datacenter_name): """Returns the location of the specified datacenter. :param string datacenter_name: The datacenter to create the loadbalancer in :returns: the location id of the given datacenter """ datacenters =...
def cancel_lb(self, loadbal_id): """Cancels the specified load balancer. :param int loadbal_id: Load Balancer ID to be cancelled. """ lb_billing = self.lb_svc.getBillingItem(id=loadbal_id) billing_id = lb_billing['id'] billing_item = self.client['Billing_Item'] ...
def add_local_lb(self, price_item_id, datacenter): """Creates a local load balancer in the specified data center. :param int price_item_id: The price item ID for the load balancer :param string datacenter: The datacenter to create the loadbalancer in :returns: A dictionary containing th...
def get_local_lb(self, loadbal_id, **kwargs): """Returns a specified local load balancer given the id. :param int loadbal_id: The id of the load balancer to retrieve :returns: A dictionary containing the details of the load balancer """ if 'mask' not in kwargs: kwar...
def delete_service(self, service_id): """Deletes a service from the loadbal_id. :param int service_id: The id of the service to delete """ svc = self.client['Network_Application_Delivery_Controller_' 'LoadBalancer_Service'] return svc.deleteObject(id=...
def delete_service_group(self, group_id): """Deletes a service group from the loadbal_id. :param int group_id: The id of the service group to delete """ svc = self.client['Network_Application_Delivery_Controller_' 'LoadBalancer_VirtualServer'] return ...
def toggle_service_status(self, service_id): """Toggles the service status. :param int service_id: The id of the service to delete """ svc = self.client['Network_Application_Delivery_Controller_' 'LoadBalancer_Service'] return svc.toggleStatus(id=servi...
def edit_service(self, loadbal_id, service_id, ip_address_id=None, port=None, enabled=None, hc_type=None, weight=None): """Edits an existing service properties. :param int loadbal_id: The id of the loadbal where the service resides :param int service_id: The id of the servi...
def add_service(self, loadbal_id, service_group_id, ip_address_id, port=80, enabled=True, hc_type=21, weight=1): """Adds a new service to the service group. :param int loadbal_id: The id of the loadbal where the service resides :param int service_group_id: The group to add t...
def add_service_group(self, lb_id, allocation=100, port=80, routing_type=2, routing_method=10): """Adds a new service group to the load balancer. :param int loadbal_id: The id of the loadbal where the service resides :param int allocation: percent of connections to all...
def edit_service_group(self, loadbal_id, group_id, allocation=None, port=None, routing_type=None, routing_method=None): """Edit an existing service group. :param int loadbal_id: The id of the loadbal where the service resides :param int group_id: The id of the service...
def reset_service_group(self, loadbal_id, group_id): """Resets all the connections on the service group. :param int loadbal_id: The id of the loadbal :param int group_id: The id of the service group to reset """ _filter = {'virtualServers': {'id': utils.query_filter(group_id)}}...
def cli(env, identifier): """Get details for an image.""" image_mgr = SoftLayer.ImageManager(env.client) image_id = helpers.resolve_id(image_mgr.resolve_ids, identifier, 'image') image = image_mgr.get_image(image_id, mask=image_mod.DETAIL_MASK) disk_space = 0 datacenters = [] for child in ...
def cli(env, volume_id, schedule_type, retention_count, minute, hour, day_of_week): """Enables snapshots for a given volume on the specified schedule""" file_manager = SoftLayer.FileStorageManager(env.client) valid_schedule_types = {'INTERVAL', 'HOURLY', 'DAILY', 'WEEKLY'} valid_days = {'SUNDAY...
def get_upcoming_events(self): """Retreives a list of Notification_Occurrence_Events that have not ended yet :return: SoftLayer_Notification_Occurrence_Event """ mask = "mask[id, subject, startDate, endDate, statusCode, acknowledgedFlag, impactedResourceCount, updateCount]" _fil...
def get_event(self, event_id): """Gets details about a maintenance event :param int event_id: Notification_Occurrence_Event ID :return: Notification_Occurrence_Event """ mask = """mask[ acknowledgedFlag, attachments, impactedResources, ...
def get_invoices(self, limit=50, closed=False, get_all=False): """Gets an accounts invoices. :param int limit: Number of invoices to get back in a single call. :param bool closed: If True, will also get CLOSED invoices :param bool get_all: If True, will paginate through invoices until a...
def get_billing_items(self, identifier): """Gets all topLevelBillingItems from a specific invoice :param int identifier: Invoice Id :return: Billing_Invoice_Item """ mask = """mask[ id, description, hostName, domainName, oneTimeAfterTaxAmount, recurringAfterTaxAmoun...
def cli(env): """Get price options to create a load balancer with.""" mgr = SoftLayer.LoadBalancerManager(env.client) table = formatting.Table(['price_id', 'capacity', 'description', 'price']) table.sortby = 'price' table.align['price'] = 'r' table.align['capacity'] = 'r' table.align['id'...
def cli(env, identifier): """List virtual server credentials.""" vsi = SoftLayer.VSManager(env.client) vs_id = helpers.resolve_id(vsi.resolve_ids, identifier, 'VS') instance = vsi.get_instance(vs_id) table = formatting.Table(['username', 'password']) for item in instance['operatingSystem']['pa...
def list_commands(self, ctx): """List all sub-commands.""" commands = [] for filename in os.listdir(self.path): if filename == '__init__.py': continue if filename.endswith('.py'): commands.append(filename[:-3].replace("_", "-")) com...
def get_command(self, ctx, cmd_name): """Get command for click.""" path = "%s.%s" % (__name__, cmd_name) path = path.replace("-", "_") module = importlib.import_module(path) return getattr(module, 'cli')
def cli(env, zone_id, by_record, by_id, data, ttl): """Update DNS record.""" manager = SoftLayer.DNSManager(env.client) zone_id = helpers.resolve_id(manager.resolve_ids, zone_id, name='zone') results = manager.get_records(zone_id, host=by_record) for result in results: if by_id and str(res...
def cli(env, identifier, wait): """Check if a server is ready.""" compute = SoftLayer.HardwareManager(env.client) compute_id = helpers.resolve_id(compute.resolve_ids, identifier, 'hardware') ready = compute.wait_for_ready(compute_id, wait) if ready: env.f...
def cli(env): """Summary info about tickets.""" mask = ('openTicketCount, closedTicketCount, ' 'openBillingTicketCount, openOtherTicketCount, ' 'openSalesTicketCount, openSupportTicketCount, ' 'openAccountingTicketCount') account = env.client['Account'].getObject(mask=ma...
def cli(env, ip_version): """List all global IPs.""" mgr = SoftLayer.NetworkManager(env.client) table = formatting.Table(['id', 'ip', 'assigned', 'target']) version = None if ip_version == 'v4': version = 4 elif ip_version == 'v6': version = 6 ips = mgr.list_global_ips(ve...
def cli(env, identifier): """Cancel global IP.""" mgr = SoftLayer.NetworkManager(env.client) global_ip_id = helpers.resolve_id(mgr.resolve_global_ip_ids, identifier, name='global ip') if not (env.skip_confirmations or formatting.no_going_back(global_ip_id)): ...
def create_client_from_env(username=None, api_key=None, endpoint_url=None, timeout=None, auth=None, config_file=None, proxy=None, u...
def authenticate_with_password(self, username, password, security_question_id=None, security_question_answer=None): """Performs Username/Password Authentication :param string username: your SoftLayer username :param string pa...
def call(self, service, method, *args, **kwargs): """Make a SoftLayer API call. :param method: the method to call on the service :param \\*args: (optional) arguments for the remote call :param id: (optional) id for the resource :param mask: (optional) object mask :param ...
def iter_call(self, service, method, *args, **kwargs): """A generator that deals with paginating through results. :param service: the name of the SoftLayer API service :param method: the method to call on the service :param integer limit: result size for each API call (defaults to 100) ...
def call(self, name, *args, **kwargs): """Make a SoftLayer API call :param service: the name of the SoftLayer API service :param method: the method to call on the service :param \\*args: same optional arguments that ``BaseClient.call`` takes :param \\*\\*kwargs: same optional ke...
def iter_call(self, name, *args, **kwargs): """A generator that deals with paginating through results. :param method: the method to call on the service :param integer chunk: result size for each API call :param \\*args: same optional arguments that ``Service.call`` takes :param ...
def cli(env, identifier): """Retrieve credentials used for generating an AWS signature. Max of 2.""" mgr = SoftLayer.ObjectStorageManager(env.client) credential_list = mgr.list_credential(identifier) table = formatting.Table(['id', 'password', 'username', 'type_name']) for credential in credential...
def cli(env, sortby, cpu, columns, datacenter, name, memory, disk, tag): """List dedicated host.""" mgr = SoftLayer.DedicatedHostManager(env.client) hosts = mgr.list_instances(cpus=cpu, datacenter=datacenter, hostname=name, ...