@@ -21,6 +21,16 @@ class HardwareManager(utils.IdentifierMixin, object):
2121 manager to handle ordering.
2222 If none is provided, one will be
2323 auto initialized.
24+ Example::
25+ # Initialize the Manager.
26+ # env variables. These can also be specified in ~/.softlayer,
27+ # or passed directly to SoftLayer.Client()
28+ # SL_USERNAME = YOUR_USERNAME
29+ # SL_API_KEY = YOUR_API_KEY
30+ import SoftLayer
31+ client = SoftLayer.Client()
32+ mgr = SoftLayer.HardwareManager(client)
33+
2434 """
2535 def __init__ (self , client , ordering_manager = None ):
2636 self .client = client
@@ -41,6 +51,14 @@ def cancel_hardware(self, hardware_id, reason='unneeded', comment='',
4151 come from :func:`get_cancellation_reasons`.
4252 :param string comment: An optional comment to include with the
4353 cancellation.
54+ :param immediate bool: False = Cancel at end of billing cycle.
55+ True = Cancel now, only for bareMetalInstances
56+
57+ Example::
58+
59+ # Cancels hardware id 1234
60+ result = mrg.cancel_hardware(hardware_id=1234)
61+ print result
4462 """
4563 # Check to see if this is actually a pre-configured server (BMC). They
4664 # require a different cancellation call.
@@ -75,6 +93,11 @@ def cancel_metal(self, hardware_id, immediate=False):
7593 :param bool immediate: If true, the bare metal instance will be
7694 cancelled immediately. Otherwise, it will be
7795 scheduled to cancel on the anniversary date.
96+
97+ Example::
98+
99+ result = mgr.cancel_metal(hardware_id=1234)
100+ print result
78101 """
79102 hw_billing = self .get_hardware (hardware_id ,
80103 mask = 'mask[id, billingItem.id]' )
@@ -107,6 +130,14 @@ def list_hardware(self, tags=None, cpus=None, memory=None, hostname=None,
107130 hardware. This list will contain both dedicated servers and
108131 bare metal computing instances
109132
133+ Example::
134+
135+ # Using a custom object-mask. Will get ONLY what is specified
136+ # These will stem from the SoftLayer_Hardware_Server datatype
137+ object_mask = "mask[hostname,monitoringRobot[robotStatus]]"
138+ result = mgr.list_hardware(mask=object_mask)
139+ print result
140+
110141 """
111142 if 'mask' not in kwargs :
112143 hw_items = [
@@ -183,6 +214,11 @@ def get_bare_metal_create_options(self):
183214 function will make those calls and reformat the results into a
184215 dictionary that's easier to manage. It's recommended that you cache
185216 these results with a reasonable lifetime for performance reasons.
217+
218+ Example::
219+
220+ result = mgr.get_bare_metal_create_options()
221+ print result
186222 """
187223 hw_id = self .get_bare_metal_package_id ()
188224
@@ -192,7 +228,15 @@ def get_bare_metal_create_options(self):
192228 return self ._parse_package_data (hw_id )
193229
194230 def get_bare_metal_package_id (self ):
195- """Return the bare metal package id."""
231+ """Return the bare metal package id.
232+
233+ :resturns: the id of the BARE_METAL_CORE package
234+
235+ Example::
236+
237+ result = mgr.get_bare_metal_package_id
238+
239+ """
196240 ordering_manager = self .ordering_manager
197241 mask = "mask[id,name,description,type[keyName]]"
198242 package = ordering_manager .get_package_by_type ('BARE_METAL_CORE' , mask )
@@ -204,6 +248,11 @@ def get_available_dedicated_server_packages(self):
204248
205249 :returns: A list of tuples of available dedicated server packages in
206250 the form (id, name, description)
251+
252+ Example::
253+
254+ result = mgr.get_available_dedicated_server_packages()
255+ print result
207256 """
208257 available_packages = []
209258 ordering_manager = self .ordering_manager
@@ -246,6 +295,14 @@ def get_dedicated_server_create_options(self, package_id):
246295 make those calls and reformat the results into a dictionary that's
247296 easier to manage. It's recommended that you cache these results with
248297 a reasonable lifetime for performance reasons.
298+
299+ Example::
300+
301+ package_ids = mgr.get_available_dedicated_server_packages()
302+ #pick which package you want the create options for
303+ package_id = ??
304+ result = mgr.get_dedicated_server_create_options(package_id)
305+ print result
249306 """
250307 return self ._parse_package_data (package_id )
251308
@@ -256,6 +313,12 @@ def get_hardware(self, hardware_id, **kwargs):
256313 :returns: A dictionary containing a large amount of information about
257314 the specified server.
258315
316+ Example::
317+
318+ object_mask = "mask[id,networkVlans[vlanNumber]]"
319+ # Object masks are optional
320+ result = mrg.get_hardware(hardware_id=1234,mask=object_mask)
321+ print result
259322 """
260323
261324 if 'mask' not in kwargs :
@@ -323,6 +386,11 @@ def rescue(self, hardware_id):
323386 """Reboot a server into the a recsue kernel.
324387
325388 :param integer instance_id: the server ID to rescue
389+
390+ Example::
391+
392+ result = mgr.rescue(1234)
393+ print result
326394 """
327395 return self .hardware .bootToRescueLayer (id = hardware_id )
328396
@@ -334,6 +402,16 @@ def change_port_speed(self, hardware_id, public, speed):
334402 True (default) means the public interface.
335403 False indicates the private interface.
336404 :param int speed: The port speed to set.
405+
406+ .. warning::
407+ A port speed of 0 will disable the interface.
408+
409+ Example::
410+ #change the Public interface to 10Mbps on instance 12345
411+ result = mgr.change_port_speed(hardware_id=12345,
412+ public=True, speed=10)
413+ # result will be True or an Exception
414+ print result
337415 """
338416 if public :
339417 func = self .hardware .setPublicNetworkInterfaceSpeed
@@ -390,7 +468,7 @@ def place_order(self, **kwargs):
390468 following sample for an example of using HardwareManager functions
391469 for ordering a basic server.
392470
393- ::
471+ Example ::
394472
395473 # client is assumed to be an initialized SoftLayer.API.Client object
396474 mgr = HardwareManager(client)
@@ -449,8 +527,17 @@ def place_order(self, **kwargs):
449527
450528 def verify_order (self , ** kwargs ):
451529 """Verifies an order for a piece of hardware.
530+ Behaves exactly like place_order, except it doesnt actually
531+ add a server to your account. Will let you know if the ordering
532+ system likes your order or not.
452533
453534 See :func:`place_order` for a list of available options.
535+
536+ Example::
537+
538+ # Use the place_order example for the content of args
539+ result = mgr.verify_order(**args)
540+ print result
454541 """
455542 create_options = self ._generate_create_dict (** kwargs )
456543 return self .client ['Product_Order' ].verifyOrder (create_options )
@@ -460,6 +547,11 @@ def get_cancellation_reasons(self):
460547
461548 These can be used when cancelling a dedicated server
462549 via :func:`cancel_hardware`.
550+
551+ Example::
552+
553+ result = mgr.get_cancellation_reasons()
554+ print result
463555 """
464556 return {
465557 'unneeded' : 'No longer needed' ,
@@ -726,6 +818,11 @@ def edit(self, hardware_id, userdata=None, hostname=None, domain=None,
726818 :param string domain: valid domain name
727819 :param string notes: notes about this particular hardware
728820
821+ Example::
822+ # Change the hostname on instance 12345 to 'something'
823+ result = mgr.edit(hardware_id=12345 , hostname="something")
824+ #result will be True or an Exception
825+ print result
729826 """
730827
731828 obj = {}
@@ -746,12 +843,8 @@ def edit(self, hardware_id, userdata=None, hostname=None, domain=None,
746843
747844 return self .hardware .editObject (obj , id = hardware_id )
748845
749- def update_firmware (self ,
750- hardware_id ,
751- ipmi = True ,
752- raid_controller = True ,
753- bios = True ,
754- hard_drive = True ):
846+ def update_firmware (self , hardware_id , ipmi = True , raid_controller = True ,
847+ bios = True , hard_drive = True ):
755848 """Update hardware firmware.
756849
757850 This will cause the server to be unavailable for ~20 minutes.
@@ -762,6 +855,12 @@ def update_firmware(self,
762855 :param bool raid_controller: Update the raid controller firmware.
763856 :param bool bios: Update the bios firmware.
764857 :param bool hard_drive: Update the hard drive firmware.
858+
859+ Example::
860+
861+ # Check the servers active transactions to see progress
862+ result = mgr.update_firmware(hardware_id=1234)
863+ print result
765864 """
766865
767866 return self .hardware .createFirmwareUpdateTransaction (
@@ -780,9 +879,9 @@ def get_default_value(package_options, category, hourly=False):
780879 If the category has multiple items with no fee, this will return the
781880 first it finds and then short circuit. This may not match the default
782881 value presented on the SoftLayer ordering portal. Additionally, this
783- method will return None if there are no free items in the category.
882+ method will return None if there are no fee items in the category.
784883
785- :returns: Returns the price ID of the first free item it finds or None
884+ :returns: Returns the price ID of the first fee item it finds or None
786885 if there are no free items.
787886 """
788887 if category not in package_options ['categories' ]:
0 commit comments