API/Dreamhost ps commands
DreamHost PS commands
The dreamhost_ps API module allows you to manage Virtual Private Servers on your account.
NOTE: Like many api commands, these commands are all subject to rate limiting to ensure that single users don't flood the system and cause instability. The current rate limit for the dreamhost_ps module is 2500 commands per user per day (500 per hour). If you are running into this limit, you should revise how you're using the api, and perhaps cache results from commands like list_ps and list_usage so that you don't make repeated unnecessary calls to the api. (Also note that this is the limit overall for the module. Other per-command limits may apply as well)
Commands
dreamhost_ps-add_ps
Schedule the creation of a new DreamHost PS to your account (currently may take a day or more to actually complete). This will reserve a name for your new PS and return it in the Data section. A Service token will also be returned (see Service Control Commands).
Values:
account_id : what account you'd like to add this PS to (optional) type : either web or mysql movedata : if type is web, you must specify yes or no for whether you'd like to copy all your existing users to this new PS.
Result:
success ps_name token ps12345 gcnaBcD12eFgH34iJkL
Possible Errors:
no_type type_must_be_mysql_or_web no_movedata movedata_must_be_yes_or_no no_such_account_id account_not_approved you_cant_add_to_account account_has_no_hosting account_has_frontpage account_has_over_14_ips (may have specifics after a tab) already_has_mysql (may have specifics after a tab) already_has_pending_mysql (may have specifics after a tab)
dreamhost_ps-remove_ps
Schedule the destruction of a DreamHost PS on your account (currently may take a day or more to actually complete). A Service token will also be returned (see Service Control Commands).
Values:
ps : the machine name of the ps you'd like to destroy.
Result:
success removed token web gcnaBcD12eFgH34iJkL
Possible Errors:
no_ps no_such_ps cannot_remove_ps (contact support to find out why!)
dreamhost_ps-list_pending_ps
List all DreamHost PSes scheduled to be created on this account.
Values:
(none)
Result:
success account_id ip type stamp 1234 10.5.3.2 web 2009-03-12 06:43:30 1234 10.5.3.2 web 2009-03-12 06:43:36 1234 10.5.3.2 mysql 2009-03-12 06:43:48
Possible Errors:
(none)
dreamhost_ps-remove_pending_ps
Removes all DreamHost PSes scheduled to be created on this account.
Values:
(none)
Result:
success account_id ip type stamp 1234 10.5.3.2 web 2009-03-12 06:43:30 1234 10.5.3.2 web 2009-03-12 06:43:36 1234 10.5.3.2 mysql 2009-03-12 06:43:48
Possible Errors:
(none)
dreamhost_ps-list_ps
Lists all active DreamHost PSes on this account.
Values:
(none)
Result:
success account_id ps description status type memory_mb start_date ip 1234 ps11111 My PS up web 2300 2010-01-01 173.236.246.100 1234 ps11112 down web 2300 2010-01-01 173.236.167.63 1234 psmysql11113 up mysql 2300 2010-01-01 67.205.46.236
Possible Errors:
(none)
dreamhost_ps-list_settings
Lists all the current settings for a DreamHost PS.
Values:
ps : the name of the ps (get it from list_ps)
Result:
success setting value apache2_enabled 1 comment My first PS! courier_enabled 0 jabber_transports_enabled 0 lighttpd_enabled 0 machine ps2322 modphp_4_selected 1 php_cache_xcache 0 proftpd_enabled 1
Possible Errors:
no_ps no_such_ps
dreamhost_ps-set_settings
Set all the settings for a DreamHost PS. Anything you don't pass in will remain untouched. Descriptions of the various settings are at https://panel.dreamhost.com/?tree=vserver.settings
Values:
ps : the name of the ps (get it from list_ps) apache2_enabled : 0 or 1 (optional) comment : Any string you'd like to describe this ps. (optional) courier_enabled : 0 or 1 (optional) jabber_transports_enabled : 0 or 1 (optional) lighttpd_enabled : 0 or 1 (optional) modphp_4_selected : 0 or 1 (optional) php_cache_xcache : 0 or 1 (optional) proftpd_enabled : 0 or 1 (optional)
Result:
success setting value apache2_enabled 1 comment My first PS! courier_enabled 0 jabber_transports_enabled 0 lighttpd_enabled 0 machine ps2322 modphp_4_selected 1 php_cache_xcache 1 proftpd_enabled 1
Possible Errors:
no_ps no_such_ps internal_error_setting_settings
dreamhost_ps-list_size_history
Shows a full list of all resizes and associated charges for a DreamHost PS.
Values:
ps : the name of the ps (get it from list_ps)
Result:
success stamp period_seconds memory_mb monthly_cost period_cost 2007-07-30 08:46:19 431313 150 15.00 2.4960 2007-08-04 08:34:52 71 193 21.40 0.0006 2007-08-04 08:36:03 574662 408 40.80 9.0456 2007-08-11 00:13:45 525551 150 15.00 3.0414 2007-08-17 02:12:56 215679 279 30.00 2.4963 2007-08-19 14:07:35 29726670 580 60.10 689.2642 2008-07-28 15:32:05 19582503 1182 120.30 908.8639
Possible Errors:
no_ps no_such_ps
Example Script:
[someuser@ps11111 ~]$ sed s/^/\ / bin/dreamhost_ps-list_size_history.sh #!/bin/sh #### #### USE ARE YOUR OWN RISK #### ALL=false if [ "$1" = "-a" ]; then ALL=true shift fi PS=$1 KEY=YOUR-KEY-HERE UUID=`uuidgen` CMD=dreamhost_ps-list_size_history if [ "$1" = "-h" ] || [ "$1" = "--help" ] ; then echo "usage: `basename $0` [-a] [hostname]" exit 1; fi if [ "$PS" = "" ]; then PS=`hostname | cut -f1 -d.` fi LINK="https://api.dreamhost.com/?key=$KEY&unique_id=$UUID&cmd=$CMD&ps=$PS" OUT=`wget -O- -q "$LINK"` if $ALL; then echo -e "$OUT" else echo stamp period_seconds memory_mb monthly_cost period_cost echo -e "$OUT" | tail -3 fi
dreamhost_ps-set_size
Resize the memory of a DreamHost PS. You are limited to 30 resizes per day per VPS -- use them wisely! A Service token will also be returned (see Service Control Commands).
Values:
ps : the name of the ps (get it from list_ps) size : the new size you'd like for your PS, in MB between 300 and 4000
Result:
success memory_mb token 300 gcnaBcD12eFgH34iJkL
Possible Errors:
no_ps no_such_ps no_size size_under_300 size_over_4000 cant_modify_billing exceeded_30_resizes_today resize_pending internal_error_setting_size
Example Script:
[someuser@ps11111 ~]$ cat bin/dreamhost_ps-set_size.sh #!/bin/sh #### #### USE THIS SCRIPT AT YOUR OWN RISK. #### MEM_MAX=1024 MEM=$1 PS=$2 KEY=YOUR-KEY-HERE UUID=`uuidgen` CMD=dreamhost_ps-set_size if [ $# -lt 1 ]; then echo "usage: `basename $0` memory [hostname]" exit 1 fi if [ "$PS" = "" ]; then PS=`hostname | cut -f1 -d.` fi if [ "$MEM" -gt "$MEM_MAX" ]; then echo "$MEM exceeds maximum memory allowed: $MEM_MAX"; exit 1 fi LINK="https://api.dreamhost.com/?key=$KEY&unique_id=$UUID&cmd=$CMD&ps=$PS&size=$MEM" RESPONSE=`wget -O- -q "$LINK"` echo "$LINK" echo "$RESPONSE" if ! (echo $RESPONSE | grep -q 'success'); then exit 1 fi COUNTER=900 CURMEM=$(echo `free -m | grep Mem:` | cut -f2 -d' ') PREVMEM="$CURMEM" echo "`date`: curmem=$CURMEM" while [ "$CURMEM" -ne "$MEM" ] && [ "$COUNTER" -gt 0 ]; do CURMEM=$(echo `free -m | grep Mem: ` | cut -f2 -d' ') if [ "$CURMEM" -ne "$PREVMEM " ]; then echo "`date`: curmem=$CURMEM" fi COUNTER=`expr $COUNTER - 1` sleep 1 PREVMEM="$CURMEM" done if [ "$COUNTER" = "0" ]; then exit 1 else exit 0 fi
dreamhost_ps-list_reboot_history
List the full history of reboots to a DreamHost PS from most recent to oldest.
Values:
ps : the name of the ps (get it from list_ps)
Result:
success stamp 2009-02-06 19:53:37 2009-02-03 11:42:18 2008-10-09 17:13:26 2008-10-03 22:57:20 2008-09-12 23:44:56
Possible Errors:
no_ps no_such_ps
dreamhost_ps-reboot
Schedule a reboot to a DreamHost PS now.
Values:
ps : the name of the ps (get it from list_ps)
Result:
success reboot_scheduled
Possible Errors:
no_ps no_such_ps cannot_reboot_ps_mysql internal_error_rebooting
dreamhost_ps-list_usage
List the last 30ish days of our memory usage and cpu load readings for a DreamHost PS (the 00:00:00 timestamp values are daily averages).
Values:
ps : the name of the ps (get it from list_ps)
Result:
success stamp memory_mb load 2009-03-12 06:17:40 454 0.18 2009-03-12 00:47:48 311 0.00 2009-03-11 22:48:36 346 0.02 2009-03-11 20:01:30 356 0.03 2009-03-11 17:35:35 338 0.14 2009-03-11 11:24:34 359 0.17 2009-03-11 09:13:02 346 0.20 2009-03-11 05:48:54 327 0.09 2009-03-11 01:45:55 324 0.14 2009-03-10 00:00:00 294 0.16 2009-03-09 00:00:00 209 0.06 2009-03-08 00:00:00 156 0.08 2009-03-07 00:00:00 161 0.07 2009-03-06 00:00:00 166 0.06 2009-03-05 00:00:00 153 0.06 2009-03-04 00:00:00 144 0.02 2009-03-04 00:00:00 150 0.07 2009-03-03 00:00:00 188 0.04 2009-03-02 00:00:00 159 0.05 2009-03-01 00:00:00 171 0.02 2009-02-28 00:00:00 166 0.08 2009-02-27 00:00:00 166 0.04 2009-02-26 00:00:00 170 0.02 2009-02-25 00:00:00 169 0.03 2009-02-24 00:00:00 169 0.08 2009-02-23 00:00:00 177 0.02 2009-02-22 00:00:00 171 0.14 2009-02-21 00:00:00 148 0.01 2009-02-20 00:00:00 146 0.05 2009-02-19 00:00:00 163 0.03 2009-02-18 00:00:00 155 0.03 2009-02-17 00:00:00 154 0.04 2009-02-16 00:00:00 158 0.05 2009-02-15 00:00:00 157 0.04 2009-02-14 00:00:00 159 0.02 2009-02-14 00:00:00 174 0.00 2009-02-13 00:00:00 158 0.01 2009-02-12 00:00:00 168 0.03
Possible Errors:
no_ps no_such_ps
dreamhost_ps-list_images
List all the images available for DreamHost Private Servers. The image name can be used for the "type" value for dreamhost_ps-add_ps.
Values:
(none)
Result:
success image description web Private web server mysql Private MySQL server
Possible Errors:
(none)