From 14b7f4dc68193dbfbc3c671d29781888a74639b1 Mon Sep 17 00:00:00 2001 From: allmightyspiff Date: Wed, 11 Mar 2015 16:58:06 -0500 Subject: [PATCH 1/7] Adding some examples for the vs manager --- SoftLayer/managers/vs.py | 197 ++++++++++++++++++++++++++++++--------- 1 file changed, 154 insertions(+), 43 deletions(-) diff --git a/SoftLayer/managers/vs.py b/SoftLayer/managers/vs.py index 64ae95770..6cfd0257e 100644 --- a/SoftLayer/managers/vs.py +++ b/SoftLayer/managers/vs.py @@ -23,6 +23,17 @@ class VSManager(utils.IdentifierMixin, object): manager to handle ordering. If none is provided, one will be auto initialized. + + Example:: + # Initialize the VSManager. + # env variables. These can also be specified in ~/.softlayer, + # or passed directly to SoftLayer.Client() + # SL_USERNAME = YOUR_USERNAME + # SL_API_KEY = YOUR_API_KEY + import SoftLayer + client = SoftLayer.Client() + mgr = SoftLayer.VSManager(client) + """ def __init__(self, client, ordering_manager=None): @@ -57,18 +68,17 @@ def list_instances(self, hourly=True, monthly=True, tags=None, cpus=None, :returns: Returns a list of dictionaries representing the matching virtual servers - :: + Example:: - # Print out a list of all hourly instances in the DAL05 data center. - # env variables - # SL_USERNAME = YOUR_USERNAME - # SL_API_KEY = YOUR_API_KEY - import SoftLayer - client = SoftLayer.Client() + # Print out a list of all hourly instances in the DAL05 data center. - mgr = SoftLayer.VSManager(client) - for vsi in mgr.list_instances(hourly=True, datacenter='dal05'): - print vsi['fullyQualifiedDomainName'], vs['primaryIpAddress'] + for vsi in mgr.list_instances(hourly=True, datacenter='dal05'): + print vsi['fullyQualifiedDomainName'], vsi['primaryIpAddress'] + + # Using a custom object-mask. Will get ONLY what is specified + object_mask = "mask[hostname,monitoringRobot[robotStatus]]" + for vsi in mgr.list_instances(mask=object_mask,hourly=True): + print vsi """ if 'mask' not in kwargs: @@ -147,18 +157,16 @@ def get_instance(self, instance_id, **kwargs): :returns: A dictionary containing a large amount of information about the specified instance. - :: + Example:: - # Print out the FQDN and IP address for instance ID 12345. - # env variables - # SL_USERNAME = YOUR_USERNAME - # SL_API_KEY = YOUR_API_KEY - import SoftLayer - client = SoftLayer.Client() + # Print out instance ID 12345. + vsi = mgr.get_instance(12345) + print vsi - mgr = SoftLayer.VSManager(client) - vsi = mgr.get_instance(12345) - print vsi['fullyQualifiedDomainName'], vs['primaryIpAddress'] + # Print out only FQDN and primaryIP for instance 12345 + object_mask = "mask[fullyQualifiedDomainName,primaryIpAddress]" + vsi = mgr.get_instance(12345, mask=mask) + print vsi """ @@ -211,6 +219,11 @@ def get_create_options(self): :returns: A dictionary of creation options. + Example:: + + # Prints out the create option dictionary + options = mgr.get_create_options() + print(options) """ return self.guest.getCreateObjectOptions() @@ -219,17 +232,10 @@ def cancel_instance(self, instance_id): :param integer instance_id: the instance ID to cancel - :: + Example:: - # Cancel for instance ID 12345. - # env variables - # SL_USERNAME = YOUR_USERNAME - # SL_API_KEY = YOUR_API_KEY - import SoftLayer - client = SoftLayer.Client() - - mgr = SoftLayer.VSManager(client) - mgr.cancel_instance(12345) + # Cancels instance 12345 + mgr.cancel_instance(12345) """ return self.guest.deleteObject(id=instance_id) @@ -242,17 +248,15 @@ def reload_instance(self, instance_id, post_uri=None, ssh_keys=None): after reload :param list ssh_keys: The SSH keys to add to the root user - :: + .. warning:: + Post-provision script MUST be HTTPS for it to be executed. + This will reformat the primary drive. - # Reload instance ID 12345 then run a custom post-provision script. - # env variables - # SL_USERNAME = YOUR_USERNAME - # SL_API_KEY = YOUR_API_KEY - import SoftLayer - client = SoftLayer.Client() + Example:: + # Reload instance ID 12345 then run a custom post-provision script. + # Post-provision script MUST be HTTPS for it to be executed. post_uri = 'https://somehost.com/bootstrap.sh' - mgr = SoftLayer.VSManager(client) vsi = mgr.reload_instance(12345, post_uri=post_url) """ @@ -384,6 +388,10 @@ def wait_for_ready(self, instance_id, limit, delay=1, pending=False): Defaults to 1. :param bool pending: Wait for pending transactions not related to provisioning or reloads such as monitoring. + + Example:: + # Will return once vsi 12345 is ready, or after 10 checks + ready = mgr.wait_for_ready(12345, 10) """ for count, new_instance in enumerate(itertools.repeat(instance_id), start=1): @@ -423,6 +431,27 @@ def verify_create_instance(self, **kwargs): Without actually placing an order. See :func:`create_instance` for a list of available options. + + Example:: + new_vsi = { + 'domain': u'test01.labs.sftlyr.ws', + 'hostname': u'minion05', + 'datacenter': u'hkg02', + 'dedicated': False, + 'private': False, + 'cpus': 1, + 'os_code' : u'UBUNTU_LATEST', + 'hourly': True, + 'ssh_keys': [1234], + 'disks': ('100','25'), + 'local_disk': True, + 'memory': 1024 + } + + vsi = mgr.verify_create_instance(**new_vsi) + # vsi will be a SoftLayer_Container_Product_Order_Virtual_Guest + # if your order is correct. Otherwise you will get an exception + print vsi """ create_options = self._generate_create_dict(**kwargs) return self.guest.generateOrderTemplate(create_options) @@ -459,6 +488,30 @@ def create_instance(self, **kwargs): :param list ssh_keys: The SSH keys to add to the root user :param int nic_speed: The port speed to set :param string tags: tags to set on the VS as a comma separated list + + .. warning:: + This will add charges to your account + + Example:: + new_vsi = { + 'domain': u'test01.labs.sftlyr.ws', + 'hostname': u'minion05', + 'datacenter': u'hkg02', + 'dedicated': False, + 'private': False, + 'cpus': 1, + 'os_code' : u'UBUNTU_LATEST', + 'hourly': True, + 'ssh_keys': [1234], + 'disks': ('100','25'), + 'local_disk': True, + 'memory': 1024, + 'tags': 'test, pleaseCancel' + } + + vsi = mgr.create_instance(**new_vsi) + # vsi will have the newly created vsi details if done properly. + print vsi """ tags = kwargs.pop('tags', None) inst = self.guest.createObject(self._generate_create_dict(**kwargs)) @@ -471,6 +524,39 @@ def create_instances(self, config_list): 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 we want to create. + new_vsi = { + 'domain': u'test01.labs.sftlyr.ws', + 'hostname': u'multi-test', + 'datacenter': u'hkg02', + 'dedicated': False, + 'private': False, + 'cpus': 1, + 'os_code' : u'UBUNTU_LATEST', + 'hourly': True, + 'ssh_keys': [87634], + 'disks': ('100','25'), + 'local_disk': True, + 'memory': 1024, + 'tags': 'test, pleaseCancel' + } + + # using .copy() so we can make changes to individual nodes + instances = [new_vsi.copy(), new_vsi.copy(), new_vsi.copy()] + + # give each its own hostname, not required. + instances[0]['hostname'] = "multi-test01" + instances[1]['hostname'] = "multi-test02" + instances[2]['hostname'] = "multi-test03" + + vsi = mgr.create_instances(config_list=instances) + #vsi will be a dictionary of all the new virtual servers + print vsi """ tags = [conf.pop('tags', None) for conf in config_list] @@ -491,6 +577,16 @@ def change_port_speed(self, instance_id, public, speed): True (default) means the public interface. False indicates the private interface. :param int speed: The port speed to set. + + .. warning:: + A port speed of 0 will disable the interface. + + Example:: + #change the Public interface to 10Mbps on instance 12345 + result = mgr.change_port_speed(instance_id=12345, + public=True, speed=10) + # result will be True or an Exception + print result """ if public: func = self.guest.setPublicNetworkInterfaceSpeed @@ -535,7 +631,13 @@ def edit(self, instance_id, userdata=None, hostname=None, domain=None, :param string notes: notes about this particular VS :param string tags: tags to set on the VS as a comma separated list. Use the empty string to remove all tags. + :returns: bool -- True or an Exception + Example:: + # Change the hostname on instance 12345 to 'something' + result = mgr.edit(instance_id=12345 , hostname="something") + #result will be True or an Exception + print vsi """ obj = {} @@ -563,6 +665,11 @@ def rescue(self, instance_id): """Reboot a VSI into the Xen recsue kernel. :param integer instance_id: the instance ID to rescue + :returns: bool -- True or an Exception + + Example:: + # Puts instance 12345 into rescue mode + result = mgr.rescue(instance_id=12345) """ return self.guest.executeRescueLayer(id=instance_id) @@ -577,6 +684,13 @@ def capture(self, instance_id, name, additional_disks=False, notes=None): attached storage devices :param string notes: notes about this particular image + :returns: dictionary -- information about the capture transaction. + + Example:: + name = "Testing Images" + notes = "Some notes about this image" + result = mgr.capture(instance_id=12345, name=name, notes=notes) + print result """ vsi = self.get_instance(instance_id) @@ -602,11 +716,8 @@ def upgrade(self, instance_id, cpus=None, memory=None, :param int memory: RAM of the VS to be upgraded to. :param int nic_speed: The port speed to set - :: - - # Upgrade instance 12345 to 4 CPUs and 4 GB of memory - import SoftLayer - client = SoftLayer.Client(config="~/.softlayer") + :returns: bool + Example:: mgr = SoftLayer.VSManager(client) mgr.upgrade(12345, cpus=4, memory=4) From e2fbcd9dd2307d424c8e2ee5b46941b49350d888 Mon Sep 17 00:00:00 2001 From: allmightyspiff Date: Fri, 13 Mar 2015 19:53:57 -0500 Subject: [PATCH 2/7] Added examples to hardware, ssl --- SoftLayer/managers/hardware.py | 119 ++++++++++++++++++++++++++++++--- SoftLayer/managers/ssl.py | 40 +++++++++++ SoftLayer/managers/vs.py | 2 +- 3 files changed, 150 insertions(+), 11 deletions(-) diff --git a/SoftLayer/managers/hardware.py b/SoftLayer/managers/hardware.py index 434890e22..c2178a303 100644 --- a/SoftLayer/managers/hardware.py +++ b/SoftLayer/managers/hardware.py @@ -21,6 +21,16 @@ class HardwareManager(utils.IdentifierMixin, object): manager to handle ordering. If none is provided, one will be auto initialized. + Example:: + # Initialize the Manager. + # env variables. These can also be specified in ~/.softlayer, + # or passed directly to SoftLayer.Client() + # SL_USERNAME = YOUR_USERNAME + # SL_API_KEY = YOUR_API_KEY + import SoftLayer + client = SoftLayer.Client() + mgr = SoftLayer.HardwareManager(client) + """ def __init__(self, client, ordering_manager=None): self.client = client @@ -41,6 +51,14 @@ def cancel_hardware(self, hardware_id, reason='unneeded', comment='', come from :func:`get_cancellation_reasons`. :param string comment: An optional comment to include with the cancellation. + :param immediate bool: False = Cancel at end of billing cycle. + True = Cancel now, only for bareMetalInstances + + Example:: + + # Cancels hardware id 1234 + result = mrg.cancel_hardware(hardware_id=1234) + print result """ # Check to see if this is actually a pre-configured server (BMC). They # require a different cancellation call. @@ -75,6 +93,11 @@ def cancel_metal(self, hardware_id, immediate=False): :param bool immediate: If true, the bare metal instance will be cancelled immediately. Otherwise, it will be scheduled to cancel on the anniversary date. + + Example:: + + result = mgr.cancel_metal(hardware_id=1234) + print result """ hw_billing = self.get_hardware(hardware_id, mask='mask[id, billingItem.id]') @@ -107,6 +130,14 @@ def list_hardware(self, tags=None, cpus=None, memory=None, hostname=None, hardware. This list will contain both dedicated servers and bare metal computing instances + Example:: + + # Using a custom object-mask. Will get ONLY what is specified + # These will stem from the SoftLayer_Hardware_Server datatype + object_mask = "mask[hostname,monitoringRobot[robotStatus]]" + result = mgr.list_hardware(mask=object_mask) + print result + """ if 'mask' not in kwargs: hw_items = [ @@ -183,6 +214,11 @@ def get_bare_metal_create_options(self): function will make those calls and reformat the results into a dictionary that's easier to manage. It's recommended that you cache these results with a reasonable lifetime for performance reasons. + + Example:: + + result = mgr.get_bare_metal_create_options() + print result """ hw_id = self.get_bare_metal_package_id() @@ -192,7 +228,15 @@ def get_bare_metal_create_options(self): return self._parse_package_data(hw_id) def get_bare_metal_package_id(self): - """Return the bare metal package id.""" + """Return the bare metal package id. + + :resturns: the id of the BARE_METAL_CORE package + + Example:: + + result = mgr.get_bare_metal_package_id + + """ ordering_manager = self.ordering_manager mask = "mask[id,name,description,type[keyName]]" package = ordering_manager.get_package_by_type('BARE_METAL_CORE', mask) @@ -204,6 +248,11 @@ def get_available_dedicated_server_packages(self): :returns: A list of tuples of available dedicated server packages in the form (id, name, description) + + Example:: + + result = mgr.get_available_dedicated_server_packages() + print result """ available_packages = [] ordering_manager = self.ordering_manager @@ -246,6 +295,14 @@ def get_dedicated_server_create_options(self, package_id): make those calls and reformat the results into a dictionary that's easier to manage. It's recommended that you cache these results with a reasonable lifetime for performance reasons. + + Example:: + + package_ids = mgr.get_available_dedicated_server_packages() + #pick which package you want the create options for + package_id = ?? + result = mgr.get_dedicated_server_create_options(package_id) + print result """ return self._parse_package_data(package_id) @@ -256,6 +313,12 @@ def get_hardware(self, hardware_id, **kwargs): :returns: A dictionary containing a large amount of information about the specified server. + Example:: + + object_mask = "mask[id,networkVlans[vlanNumber]]" + # Object masks are optional + result = mrg.get_hardware(hardware_id=1234,mask=object_mask) + print result """ if 'mask' not in kwargs: @@ -323,6 +386,11 @@ def rescue(self, hardware_id): """Reboot a server into the a recsue kernel. :param integer instance_id: the server ID to rescue + + Example:: + + result = mgr.rescue(1234) + print result """ return self.hardware.bootToRescueLayer(id=hardware_id) @@ -334,6 +402,16 @@ def change_port_speed(self, hardware_id, public, speed): True (default) means the public interface. False indicates the private interface. :param int speed: The port speed to set. + + .. warning:: + A port speed of 0 will disable the interface. + + Example:: + #change the Public interface to 10Mbps on instance 12345 + result = mgr.change_port_speed(hardware_id=12345, + public=True, speed=10) + # result will be True or an Exception + print result """ if public: func = self.hardware.setPublicNetworkInterfaceSpeed @@ -390,7 +468,7 @@ def place_order(self, **kwargs): following sample for an example of using HardwareManager functions for ordering a basic server. - :: + Example:: # client is assumed to be an initialized SoftLayer.API.Client object mgr = HardwareManager(client) @@ -449,8 +527,17 @@ def place_order(self, **kwargs): def verify_order(self, **kwargs): """Verifies an order for a piece of hardware. + Behaves exactly like place_order, except it doesnt actually + add a server to your account. Will let you know if the ordering + system likes your order or not. See :func:`place_order` for a list of available options. + + Example:: + + # Use the place_order example for the content of args + result = mgr.verify_order(**args) + print result """ create_options = self._generate_create_dict(**kwargs) return self.client['Product_Order'].verifyOrder(create_options) @@ -460,6 +547,11 @@ def get_cancellation_reasons(self): These can be used when cancelling a dedicated server via :func:`cancel_hardware`. + + Example:: + + result = mgr.get_cancellation_reasons() + print result """ return { 'unneeded': 'No longer needed', @@ -726,6 +818,11 @@ def edit(self, hardware_id, userdata=None, hostname=None, domain=None, :param string domain: valid domain name :param string notes: notes about this particular hardware + Example:: + # Change the hostname on instance 12345 to 'something' + result = mgr.edit(hardware_id=12345 , hostname="something") + #result will be True or an Exception + print result """ obj = {} @@ -746,12 +843,8 @@ def edit(self, hardware_id, userdata=None, hostname=None, domain=None, return self.hardware.editObject(obj, id=hardware_id) - def update_firmware(self, - hardware_id, - ipmi=True, - raid_controller=True, - bios=True, - hard_drive=True): + def update_firmware(self, hardware_id, ipmi=True, raid_controller=True, + bios=True, hard_drive=True): """Update hardware firmware. This will cause the server to be unavailable for ~20 minutes. @@ -762,6 +855,12 @@ def update_firmware(self, :param bool raid_controller: Update the raid controller firmware. :param bool bios: Update the bios firmware. :param bool hard_drive: Update the hard drive firmware. + + Example:: + + # Check the servers active transactions to see progress + result = mgr.update_firmware(hardware_id=1234) + print result """ return self.hardware.createFirmwareUpdateTransaction( @@ -780,9 +879,9 @@ def get_default_value(package_options, category, hourly=False): If the category has multiple items with no fee, this will return the first it finds and then short circuit. This may not match the default value presented on the SoftLayer ordering portal. Additionally, this - method will return None if there are no free items in the category. + method will return None if there are no fee items in the category. - :returns: Returns the price ID of the first free item it finds or None + :returns: Returns the price ID of the first fee item it finds or None if there are no free items. """ if category not in package_options['categories']: diff --git a/SoftLayer/managers/ssl.py b/SoftLayer/managers/ssl.py index 68e78dbdb..3cc13d289 100644 --- a/SoftLayer/managers/ssl.py +++ b/SoftLayer/managers/ssl.py @@ -11,6 +11,17 @@ class SSLManager(object): """Manages SSL certificates. :param SoftLayer.API.Client client: an API client instance + + Example:: + # Initialize the Manager. + # env variables. These can also be specified in ~/.softlayer, + # or passed directly to SoftLayer.Client() + # SL_USERNAME = YOUR_USERNAME + # SL_API_KEY = YOUR_API_KEY + import SoftLayer + client = SoftLayer.Client() + mgr = SoftLayer.SSLManager(client) + """ def __init__(self, client): @@ -24,6 +35,12 @@ def list_certs(self, method='all'): 'all', 'expired', and 'valid'. :returns: A list of dictionaries representing the requested SSL certs. + Example:: + + # Get all valid SSL certs + certs = mgr.list_certs(method='valid') + print certs + """ ssl = self.client['Account'] methods = { @@ -42,6 +59,11 @@ def add_certificate(self, certificate): :param dict certificate: A dictionary representing the parts of the certificate. See SLDN for more information. + Example:: + + cert = ?? + result = mgr.add_certificate(certificate=cert) + """ return self.ssl.createObject(certificate) @@ -50,6 +72,12 @@ def remove_certificate(self, cert_id): :param integer cert_id: a certificate ID to remove + Example:: + + # Removes certificate with id 1234 + result = mgr.remove_certificate(cert_id = 1234) + print result + """ return self.ssl.deleteObject(id=cert_id) @@ -61,6 +89,13 @@ def edit_certificate(self, certificate): :param dict certificate: the certificate to update. + Example:: + + # Updates the cert id 1234 + cert['id'] = 1234 + cert['certificate'] = ?? + result = mgr.edit_certificate(certificate=cert) + """ return self.ssl.editObject(certificate, id=certificate['id']) @@ -69,5 +104,10 @@ def get_certificate(self, cert_id): :param integer cert_id: the certificate ID to retrieve + Example:: + + cert = mgr.get_certificate(cert_id=1234) + print(cert) + """ return self.ssl.getObject(id=cert_id) diff --git a/SoftLayer/managers/vs.py b/SoftLayer/managers/vs.py index 6cfd0257e..4c22be783 100644 --- a/SoftLayer/managers/vs.py +++ b/SoftLayer/managers/vs.py @@ -637,7 +637,7 @@ def edit(self, instance_id, userdata=None, hostname=None, domain=None, # Change the hostname on instance 12345 to 'something' result = mgr.edit(instance_id=12345 , hostname="something") #result will be True or an Exception - print vsi + print result """ obj = {} From 7b36f03a04a1fdc4d084c661a530439131aed9fd Mon Sep 17 00:00:00 2001 From: allmightyspiff Date: Wed, 15 Apr 2015 15:50:04 -0500 Subject: [PATCH 3/7] minor changes --- SoftLayer/managers/hardware.py | 75 ++++------------------------------ SoftLayer/managers/ssl.py | 2 +- SoftLayer/managers/vs.py | 6 +-- 3 files changed, 12 insertions(+), 71 deletions(-) diff --git a/SoftLayer/managers/hardware.py b/SoftLayer/managers/hardware.py index 9f2103c49..2878e8add 100644 --- a/SoftLayer/managers/hardware.py +++ b/SoftLayer/managers/hardware.py @@ -59,7 +59,7 @@ def cancel_hardware(self, hardware_id, reason='unneeded', comment='', # Cancels hardware id 1234 result = mrg.cancel_hardware(hardware_id=1234) - print result + """ # Check to see if this is actually a pre-configured server (BMC). They # require a different cancellation call. @@ -97,7 +97,7 @@ def cancel_metal(self, hardware_id, immediate=False): Example:: result = mgr.cancel_metal(hardware_id=1234) - print result + """ hw_billing = self.get_hardware(hardware_id, mask='mask[id, billingItem.id]') @@ -136,7 +136,7 @@ def list_hardware(self, tags=None, cpus=None, memory=None, hostname=None, # These will stem from the SoftLayer_Hardware_Server datatype object_mask = "mask[hostname,monitoringRobot[robotStatus]]" result = mgr.list_hardware(mask=object_mask) - print result + """ if 'mask' not in kwargs: @@ -212,7 +212,7 @@ def get_hardware(self, hardware_id, **kwargs): object_mask = "mask[id,networkVlans[vlanNumber]]" # Object masks are optional result = mrg.get_hardware(hardware_id=1234,mask=object_mask) - print result + """ if 'mask' not in kwargs: @@ -284,7 +284,7 @@ def rescue(self, hardware_id): Example:: result = mgr.rescue(1234) - print result + """ return self.hardware.bootToRescueLayer(id=hardware_id) @@ -305,7 +305,7 @@ def change_port_speed(self, hardware_id, public, speed): result = mgr.change_port_speed(hardware_id=12345, public=True, speed=10) # result will be True or an Exception - print result + """ if public: func = self.hardware.setPublicNetworkInterfaceSpeed @@ -335,65 +335,6 @@ def place_order(self, **kwargs): :param boolean no_public: True if this server should only have private interfaces :param list extras: List of extra feature names - - .. warning:: - Due to how the ordering structure currently works, all ordering - takes place using price IDs rather than quantities. See the - following sample for an example of using HardwareManager functions - for ordering a basic server. - - Example:: - - # client is assumed to be an initialized SoftLayer.API.Client object - mgr = HardwareManager(client) - - # Package ID 32 corresponds to the 'Quad Processor, Quad Core Intel' - # package. This information can be obtained from the - # :func:`get_available_dedicated_server_packages` function. - options = mgr.get_dedicated_server_create_options(32) - - # Review the contents of options to find the information that - # applies to your order. For the sake of this example, we assume - # that your selections are a series of item IDs for each category - # organized into a key-value dictionary. - - # This contains selections for all required categories - selections = { - 'server': 542, # Quad Processor Quad Core Intel 7310 - 1.60GHz - 'pri_ip_addresses': 15, # 1 IP Address - 'notification': 51, # Email and Ticket - 'ram': 280, # 16 GB FB-DIMM Registered 533/667 - 'bandwidth': 173, # 5000 GB Bandwidth - 'lockbox': 45, # 1 GB Lockbox - 'monitoring': 49, # Host Ping - 'disk0': 14, # 500GB SATA II (for the first disk) - 'response': 52, # Automated Notification - 'port_speed': 187, # 100 Mbps Public & Private Networks - 'power_supply': 469, # Redundant Power Supplies - 'disk_controller': 487, # Non-RAID - 'vulnerability_scanner': 307, # Nessus - 'vpn_management': 309, # Unlimited SSL VPN Users - 'remote_management': 504, # Reboot / KVM over IP - 'os': 4166, # Ubuntu Linux 12.04 LTS Precise Pangolin (64 bit) - } - - args = { - 'location': 'FIRST_AVAILABLE', # Pick the first available DC - 'packageId': 32, # From above - 'disks': [], - } - - for cat, item_id in selections: - for item in options['categories'][cat]['items'].items(): - if item['id'] == item_id: - if 'disk' not in cat or 'disk_controller' == cat: - args[cat] = item['price_id'] - else: - args['disks'].append(item['price_id']) - - # You can call :func:`verify_order` here to test the order instead - # of actually placing it if you prefer. - result = mgr.place_order(**args) """ create_options = self._generate_create_dict(**kwargs) return self.client['Product_Order'].placeOrder(create_options) @@ -613,7 +554,7 @@ def edit(self, hardware_id, userdata=None, hostname=None, domain=None, # Change the hostname on instance 12345 to 'something' result = mgr.edit(hardware_id=12345 , hostname="something") #result will be True or an Exception - print result + """ @@ -656,7 +597,7 @@ def update_firmware(self, # Check the servers active transactions to see progress result = mgr.update_firmware(hardware_id=1234) - print result + """ return self.hardware.createFirmwareUpdateTransaction( diff --git a/SoftLayer/managers/ssl.py b/SoftLayer/managers/ssl.py index 3000a7ab7..1a4bde361 100644 --- a/SoftLayer/managers/ssl.py +++ b/SoftLayer/managers/ssl.py @@ -76,7 +76,7 @@ def remove_certificate(self, cert_id): # Removes certificate with id 1234 result = mgr.remove_certificate(cert_id = 1234) - print result + """ return self.ssl.deleteObject(id=cert_id) diff --git a/SoftLayer/managers/vs.py b/SoftLayer/managers/vs.py index 8b93c77da..5fc45a8cd 100644 --- a/SoftLayer/managers/vs.py +++ b/SoftLayer/managers/vs.py @@ -586,7 +586,7 @@ def change_port_speed(self, instance_id, public, speed): result = mgr.change_port_speed(instance_id=12345, public=True, speed=10) # result will be True or an Exception - print result + """ if public: func = self.guest.setPublicNetworkInterfaceSpeed @@ -637,7 +637,7 @@ def edit(self, instance_id, userdata=None, hostname=None, domain=None, # Change the hostname on instance 12345 to 'something' result = mgr.edit(instance_id=12345 , hostname="something") #result will be True or an Exception - print result + """ obj = {} @@ -690,7 +690,7 @@ def capture(self, instance_id, name, additional_disks=False, notes=None): name = "Testing Images" notes = "Some notes about this image" result = mgr.capture(instance_id=12345, name=name, notes=notes) - print result + """ vsi = self.get_instance(instance_id) From 7958a6e60e6b65ccf2aeef275383914487287369 Mon Sep 17 00:00:00 2001 From: allmightyspiff Date: Wed, 15 Apr 2015 15:56:08 -0500 Subject: [PATCH 4/7] minor changes x2 --- SoftLayer/managers/hardware.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/SoftLayer/managers/hardware.py b/SoftLayer/managers/hardware.py index 2878e8add..3cb49c015 100644 --- a/SoftLayer/managers/hardware.py +++ b/SoftLayer/managers/hardware.py @@ -93,11 +93,7 @@ def cancel_metal(self, hardware_id, immediate=False): :param int id: The ID of the bare metal instance to be cancelled. :param bool immediate: If true, the bare metal instance will be cancelled immediately. Otherwise, it will be - scheduled to cancel on the anniversary date. - Example:: - - result = mgr.cancel_metal(hardware_id=1234) - + scheduled to cancel on the anniversary date. """ hw_billing = self.get_hardware(hardware_id, mask='mask[id, billingItem.id]') From 3525b36161a58e1767831acd3483e84278522355 Mon Sep 17 00:00:00 2001 From: allmightyspiff Date: Wed, 15 Apr 2015 16:20:05 -0500 Subject: [PATCH 5/7] fixed tox errors --- SoftLayer/managers/hardware.py | 11 +---------- SoftLayer/managers/ssl.py | 2 -- SoftLayer/managers/vs.py | 3 --- 3 files changed, 1 insertion(+), 15 deletions(-) diff --git a/SoftLayer/managers/hardware.py b/SoftLayer/managers/hardware.py index 3cb49c015..097d7b4df 100644 --- a/SoftLayer/managers/hardware.py +++ b/SoftLayer/managers/hardware.py @@ -59,7 +59,6 @@ def cancel_hardware(self, hardware_id, reason='unneeded', comment='', # Cancels hardware id 1234 result = mrg.cancel_hardware(hardware_id=1234) - """ # Check to see if this is actually a pre-configured server (BMC). They # require a different cancellation call. @@ -93,7 +92,7 @@ def cancel_metal(self, hardware_id, immediate=False): :param int id: The ID of the bare metal instance to be cancelled. :param bool immediate: If true, the bare metal instance will be cancelled immediately. Otherwise, it will be - scheduled to cancel on the anniversary date. + scheduled to cancel on the anniversary date. """ hw_billing = self.get_hardware(hardware_id, mask='mask[id, billingItem.id]') @@ -132,8 +131,6 @@ def list_hardware(self, tags=None, cpus=None, memory=None, hostname=None, # These will stem from the SoftLayer_Hardware_Server datatype object_mask = "mask[hostname,monitoringRobot[robotStatus]]" result = mgr.list_hardware(mask=object_mask) - - """ if 'mask' not in kwargs: hw_items = [ @@ -208,7 +205,6 @@ def get_hardware(self, hardware_id, **kwargs): object_mask = "mask[id,networkVlans[vlanNumber]]" # Object masks are optional result = mrg.get_hardware(hardware_id=1234,mask=object_mask) - """ if 'mask' not in kwargs: @@ -280,7 +276,6 @@ def rescue(self, hardware_id): Example:: result = mgr.rescue(1234) - """ return self.hardware.bootToRescueLayer(id=hardware_id) @@ -301,7 +296,6 @@ def change_port_speed(self, hardware_id, public, speed): result = mgr.change_port_speed(hardware_id=12345, public=True, speed=10) # result will be True or an Exception - """ if public: func = self.hardware.setPublicNetworkInterfaceSpeed @@ -550,8 +544,6 @@ def edit(self, hardware_id, userdata=None, hostname=None, domain=None, # Change the hostname on instance 12345 to 'something' result = mgr.edit(hardware_id=12345 , hostname="something") #result will be True or an Exception - - """ obj = {} @@ -593,7 +585,6 @@ def update_firmware(self, # Check the servers active transactions to see progress result = mgr.update_firmware(hardware_id=1234) - """ return self.hardware.createFirmwareUpdateTransaction( diff --git a/SoftLayer/managers/ssl.py b/SoftLayer/managers/ssl.py index 1a4bde361..1ea255258 100644 --- a/SoftLayer/managers/ssl.py +++ b/SoftLayer/managers/ssl.py @@ -76,8 +76,6 @@ def remove_certificate(self, cert_id): # Removes certificate with id 1234 result = mgr.remove_certificate(cert_id = 1234) - - """ return self.ssl.deleteObject(id=cert_id) diff --git a/SoftLayer/managers/vs.py b/SoftLayer/managers/vs.py index 5fc45a8cd..d45352e4b 100644 --- a/SoftLayer/managers/vs.py +++ b/SoftLayer/managers/vs.py @@ -586,7 +586,6 @@ def change_port_speed(self, instance_id, public, speed): result = mgr.change_port_speed(instance_id=12345, public=True, speed=10) # result will be True or an Exception - """ if public: func = self.guest.setPublicNetworkInterfaceSpeed @@ -637,7 +636,6 @@ def edit(self, instance_id, userdata=None, hostname=None, domain=None, # Change the hostname on instance 12345 to 'something' result = mgr.edit(instance_id=12345 , hostname="something") #result will be True or an Exception - """ obj = {} @@ -690,7 +688,6 @@ def capture(self, instance_id, name, additional_disks=False, notes=None): name = "Testing Images" notes = "Some notes about this image" result = mgr.capture(instance_id=12345, name=name, notes=notes) - """ vsi = self.get_instance(instance_id) From 9d6fb2cb1fe5d5bb4368d46feffc7508159adaf6 Mon Sep 17 00:00:00 2001 From: allmightyspiff Date: Tue, 28 Apr 2015 15:53:35 -0500 Subject: [PATCH 6/7] doc fixes --- SoftLayer/managers/hardware.py | 7 +++++-- SoftLayer/managers/ssl.py | 1 + SoftLayer/managers/vs.py | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/SoftLayer/managers/hardware.py b/SoftLayer/managers/hardware.py index 097d7b4df..f152cfb5a 100644 --- a/SoftLayer/managers/hardware.py +++ b/SoftLayer/managers/hardware.py @@ -27,6 +27,7 @@ class HardwareManager(utils.IdentifierMixin, object): If none is provided, one will be auto initialized. Example:: + # Initialize the Manager. # env variables. These can also be specified in ~/.softlayer, # or passed directly to SoftLayer.Client() @@ -58,7 +59,7 @@ def cancel_hardware(self, hardware_id, reason='unneeded', comment='', Example:: # Cancels hardware id 1234 - result = mrg.cancel_hardware(hardware_id=1234) + result = mgr.cancel_hardware(hardware_id=1234) """ # Check to see if this is actually a pre-configured server (BMC). They # require a different cancellation call. @@ -204,7 +205,7 @@ def get_hardware(self, hardware_id, **kwargs): object_mask = "mask[id,networkVlans[vlanNumber]]" # Object masks are optional - result = mrg.get_hardware(hardware_id=1234,mask=object_mask) + result = mgr.get_hardware(hardware_id=1234,mask=object_mask) """ if 'mask' not in kwargs: @@ -292,6 +293,7 @@ def change_port_speed(self, hardware_id, public, speed): A port speed of 0 will disable the interface. Example:: + #change the Public interface to 10Mbps on instance 12345 result = mgr.change_port_speed(hardware_id=12345, public=True, speed=10) @@ -541,6 +543,7 @@ def edit(self, hardware_id, userdata=None, hostname=None, domain=None, :param string notes: notes about this particular hardware Example:: + # Change the hostname on instance 12345 to 'something' result = mgr.edit(hardware_id=12345 , hostname="something") #result will be True or an Exception diff --git a/SoftLayer/managers/ssl.py b/SoftLayer/managers/ssl.py index 1ea255258..b4bada5a2 100644 --- a/SoftLayer/managers/ssl.py +++ b/SoftLayer/managers/ssl.py @@ -13,6 +13,7 @@ class SSLManager(object): :param SoftLayer.API.Client client: an API client instance Example:: + # Initialize the Manager. # env variables. These can also be specified in ~/.softlayer, # or passed directly to SoftLayer.Client() diff --git a/SoftLayer/managers/vs.py b/SoftLayer/managers/vs.py index d45352e4b..73283efd9 100644 --- a/SoftLayer/managers/vs.py +++ b/SoftLayer/managers/vs.py @@ -25,6 +25,7 @@ class VSManager(utils.IdentifierMixin, object): auto initialized. Example:: + # Initialize the VSManager. # env variables. These can also be specified in ~/.softlayer, # or passed directly to SoftLayer.Client() @@ -390,6 +391,7 @@ def wait_for_ready(self, instance_id, limit, delay=1, pending=False): provisioning or reloads such as monitoring. Example:: + # Will return once vsi 12345 is ready, or after 10 checks ready = mgr.wait_for_ready(12345, 10) """ @@ -433,6 +435,7 @@ def verify_create_instance(self, **kwargs): See :func:`create_instance` for a list of available options. Example:: + new_vsi = { 'domain': u'test01.labs.sftlyr.ws', 'hostname': u'minion05', From c9e344585b0b2a1f9b1f3f967bac8b651e15ec00 Mon Sep 17 00:00:00 2001 From: allmightyspiff Date: Wed, 29 Apr 2015 13:23:24 -0500 Subject: [PATCH 7/7] removing trailing whitespace on empty lines --- SoftLayer/managers/hardware.py | 2 +- SoftLayer/managers/ssl.py | 2 +- SoftLayer/managers/vs.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/SoftLayer/managers/hardware.py b/SoftLayer/managers/hardware.py index 8688a0703..7fe00740f 100644 --- a/SoftLayer/managers/hardware.py +++ b/SoftLayer/managers/hardware.py @@ -514,7 +514,7 @@ def edit(self, hardware_id, userdata=None, hostname=None, domain=None, :param string notes: notes about this particular hardware Example:: - + # Change the hostname on instance 12345 to 'something' result = mgr.edit(hardware_id=12345 , hostname="something") #result will be True or an Exception diff --git a/SoftLayer/managers/ssl.py b/SoftLayer/managers/ssl.py index b4bada5a2..9b698015c 100644 --- a/SoftLayer/managers/ssl.py +++ b/SoftLayer/managers/ssl.py @@ -13,7 +13,7 @@ class SSLManager(object): :param SoftLayer.API.Client client: an API client instance Example:: - + # Initialize the Manager. # env variables. These can also be specified in ~/.softlayer, # or passed directly to SoftLayer.Client() diff --git a/SoftLayer/managers/vs.py b/SoftLayer/managers/vs.py index 150ea3bf9..ed3f744d8 100644 --- a/SoftLayer/managers/vs.py +++ b/SoftLayer/managers/vs.py @@ -435,7 +435,7 @@ def verify_create_instance(self, **kwargs): See :func:`create_instance` for a list of available options. Example:: - + new_vsi = { 'domain': u'test01.labs.sftlyr.ws', 'hostname': u'minion05',