This project is now hosted at GitHub. These pages are only kept as reference.

Python Bindings

Source code available in a git repo git clone git://github.com/tjfontaine/linode-python.git and browesable at http://github.com/tjfontaine/linode-python/

There are three modules:

API Examples

import api
linode = api.Api('sekritmmmcakekey')
for domain in linode.domain_list():
  print domain
  for rr in linode.domain_resource_list(domainid=domain['DOMAINID']):
    print rr

produces

{u'STATUS': 1, u'RETRY_SEC': 0, u'DOMAIN': u'example.com', u'DOMAINID': 12, u'DESCRIPTION': u'', u'MASTER_IPS': u'', u'SOA_EMAIL': u'tjfontaine@linode.com', u'REFRESH_SEC': 0, u'TYPE': u'master', u'EXPIRE_SEC': 0, u'TTL_SEC': 0}
{u'DOMAINID': 12, u'PROTOCOL': u'', u'TTL_SEC': 0, u'WEIGHT': 0, u'NAME': u'', u'RESOURCEID': 21, u'PRIORITY': 0, u'TYPE': u'A', u'PORT': 0, u'TARGET': u'127.0.0.1'}
{u'DOMAINID': 12, u'PROTOCOL': u'', u'TTL_SEC': 0, u'WEIGHT': 0, u'NAME': u'www', u'RESOURCEID': 22, u'PRIORITY': 0, u'TYPE': u'A', u'PORT': 0, u'TARGET': u'127.0.0.1'}
{u'DOMAINID': 12, u'PROTOCOL': u'', u'TTL_SEC': 0, u'WEIGHT': 0, u'NAME': u'mail', u'RESOURCEID': 23, u'PRIORITY': 0, u'TYPE': u'A', u'PORT': 0, u'TARGET': u'127.0.0.1'}
{u'DOMAINID': 12, u'PROTOCOL': u'', u'TTL_SEC': 0, u'WEIGHT': 0, u'NAME': u'', u'RESOURCEID': 24, u'PRIORITY': 10, u'TYPE': u'MX', u'PORT': 0, u'TARGET': u'mail.example.com'}

shell example

tjlappy:linode tjfontaine$ ./shell.py --domain_list
[
  {
    "STATUS": 1, 
    "RETRY_SEC": 0, 
    "DOMAIN": "example.com", 
    "DOMAINID": 12, 
    "DESCRIPTION": "", 
    "MASTER_IPS": "", 
    "SOA_EMAIL": "tjfontaine@example.com", 
    "REFRESH_SEC": 0, 
    "TYPE": "master", 
    "EXPIRE_SEC": 0, 
    "TTL_SEC": 0
  }
]

The shell generates dynamic help, if you modify shell.py to load an alternative library that descends from Api you’ll be able to access those methods and parameters and you’ll be able to do more higher level operations like updating a resource record by domain name and not by domain id.

shell help

Passing –help to the shell will return all the valid actions, if you additionally pass –all you will see all valid parameters as well

tjlappy:linode tjfontaine$ ./shell.py --help --all
shell.py --<api action> [--parameter1=value [--parameter2=value [...]]]
Valid Actions
  --avail_datacenters
  --avail_distributions
  --avail_kernels
  --avail_linodeplans
  --domain_create
  --domain_delete
  --domain_list
  --domain_resource_create
  --domain_resource_delete
  --domain_resource_list
  --domain_resource_update
  --domain_update
  --linode_boot
  --linode_config_create
  --linode_config_delete
  --linode_config_list
  --linode_config_update
  --linode_create
  --linode_delete
  --linode_disk_create
  --linode_disk_createfromdistribution
  --linode_disk_delete
  --linode_disk_duplicate
  --linode_disk_list
  --linode_disk_resize
  --linode_disk_update
  --linode_ip_list
  --linode_job_list
  --linode_list
  --linode_reboot
  --linode_shutdown
  --linode_update
  --user_getapikey
Valid Named Parameters
  --alert_bwin_enabled=
  --alert_bwin_threshold=
  --alert_bwout_enabled=
  --alert_bwout_threshold=
  --alert_bwquota_enabled=
  --alert_bwquota_threshold=
  --alert_cpu_enabled=
  --alert_cpu_threshold=
  --alert_diskio_enabled=
  --alert_diskio_threshold=
  --backupweeklyday=
  --backupwindow=
  --comments=
  --configid=
  --datacenterid=
  --diskid=
  --disklist=
  --distributionid=
  --domain=
  --domainid=
  --expire_sec=
  --helper_depmod=
  --helper_disableupdatedb=
  --helper_xen=
  --ipaddressid=
  --isreadonly=
  --isxen=
  --jobid=
  --kernelid=
  --label=
  --linodeid=
  --lpm_displaygroup=
  --master_ips=
  --name=
  --password=
  --paymentterm=
  --pendingonly=
  --planid=
  --port=
  --priority=
  --protocol=
  --ramlimit=
  --refresh_sec=
  --resourceid=
  --retry_sec=
  --rootdevicecustom=
  --rootdevicenum=
  --rootdevicero=
  --rootpass=
  --rootsshkey=
  --runlevel=
  --size=
  --soa_email=
  --status=
  --target=
  --ttl_sec=
  --type=
  --username=
  --watchdog=
  --weight=

Development history available in 3 blog posts: Part 1, Part 2, Part 3.