-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding some doc examples - Issues258 #527
Changes from all commits
14b7f4d
e2fbcd9
489bba6
5cd4b10
7b36f03
7958a6e
3525b36
9d6fb2c
3856c40
57d5e4f
c9e3445
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,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 | ||
|
@@ -46,6 +56,10 @@ 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. | ||
Example:: | ||
|
||
# Cancels hardware id 1234 | ||
result = mgr.cancel_hardware(hardware_id=1234) | ||
""" | ||
|
||
# Get cancel reason | ||
|
@@ -83,6 +97,12 @@ 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) | ||
""" | ||
if 'mask' not in kwargs: | ||
hw_items = [ | ||
|
@@ -152,6 +172,11 @@ 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 = mgr.get_hardware(hardware_id=1234,mask=object_mask) | ||
""" | ||
|
||
if 'mask' not in kwargs: | ||
|
@@ -219,6 +244,10 @@ 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) | ||
""" | ||
return self.hardware.bootToRescueLayer(id=hardware_id) | ||
|
||
|
@@ -230,6 +259,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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A blank line is required after Example:: |
||
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 | ||
|
@@ -474,6 +513,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' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A blank line is required after Example:: |
||
result = mgr.edit(hardware_id=12345 , hostname="something") | ||
#result will be True or an Exception | ||
""" | ||
|
||
obj = {} | ||
|
@@ -510,6 +554,11 @@ 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) | ||
""" | ||
|
||
return self.hardware.createFirmwareUpdateTransaction( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,18 @@ class SSLManager(object): | |
"""Manages SSL certificates. | ||
|
||
:param SoftLayer.API.Client client: an API client instance | ||
|
||
Example:: | ||
|
||
# Initialize the Manager. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A blank line is required after Example:: |
||
# 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 +36,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 +60,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 +73,10 @@ 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) | ||
""" | ||
return self.ssl.deleteObject(id=cert_id) | ||
|
||
|
@@ -61,6 +88,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 +103,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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A blank line is required after Example::