-
Notifications
You must be signed in to change notification settings - Fork 1
CloudStack command line tools
License
heince/csapi-tool
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
- updated and tested on CloudStack v3.0.2, for v2.x you may need to adjust id field since new version is using uuid - support multiple connection profile - support with apikey or through integration api port 8096 (without key) (commands): console run interactively cmd-list list available commands list list [--cmd-opt] (vm|account|site|diskoffering|svcoffering| template|user|job|zone|network|domain|project| projectIvt|projectAcc|router|fwrule|pfrule|publicip| host|capacity) migrate migrate [--cmd-opt] (vm) deploy deploy [--cmd-opt] (vm) destroy destroy [--cmd-opt] (vm|router) stop stop [--cmd-opt] (vm|router) start start [--cmd-opt] (vm|router) reboot reboot [--cmd-opt] (vm|router) sync sync [--cmd-opt] (ldap) set set [--cmd-opt] (ldap) remove remove [--cmd-opt] (ldap) usage usage -s 2012-05-01 -e 2012-06-01 -a 1 -type (1|2|6) create create [--cmd-opt] (account|domain|project|fwrule|pfrule) delete delete [--cmd-opt] (account|domain|project|projectIvt|accountfromproject|fwrule|pfrule) update update [--cmd-opt] (account|domain|project|projectIvt) suspend suspend [--cmd-opt] project activate activate [--cmd-opt] project disable disable [--cmd-opt] account enable enable [--cmd-opt] account add add [--cmd-opt] account available cmd-opt on list command: --ia => 'use integration api url (legacy port 8096)' -p | --param [comma separated api param] => 'parameter field' -r | --response [comma separated api response] => 'response field' --nh | --noheader => 'do not print header' --sp | --showparams => 'print supported parameter' --sr | --showresponses => 'print supported responses' --json => 'print output in json' -s | --site [site profile name] => 'set site to be use' -i | --id [id|uuid] => 'set id or uuid for cmd-arg' --geturl => 'get api url' --field [comma separated field+value] => 'custom field size' example: cloudcmd ls -a vm => list all vm cloudcmd ls --nh vm => list vm without header cloudcmd ls -p account=heince,domainid=2 vm => list vm with specified API parameter cloudcmd ls -r displayname,account,domain vm => list vm with specified responses field cloudcmd ls --sp vm => list parameter supported on listing vm cloudcmd ls --sr vm => list response supported on listing vm cloudcmd ls -i xxx job => query async job by jobid cloudcmd ls -s office-admin vm => list vm using 'office-admin' site profile More Example: * cloudcmd ls -s branch-profile vm (listing vm using 'branch-profile' connection) output: DISPLAYNAME STATE ACCOUNT DOMAIN NIC-IP HOST1 Stopped heince DEV 192.168.89.134 VIEWPOINT Running heince DEV 192.168.89.38 Cougar-c01 Running heince DEV 192.168.89.141 * cloudcmd set -H ldap.example.com -f "(&(uid=%u))" -b "ou=example,dc=com" -D "uid=user1,dc=example,dc=com" -w "demo" --ia ldap * #open source LDAP example (This will get all uid user, excluding batman,robin & mrbean) cloudcmd sync -d xxx -H ldap.example.com -b "dc=example,dc=com" -D "uid=admin,dc=example,dc=com" -w "mypass" -f "(uid=*)" -a "uid" -x "batman,robin,mrbean" --ia ldap #Microsoft AD example (This will get all user with 'user' and 'guest' prefix ) cloudcmd sync -d xxx -H ldap.example.com -b "cn=users,dc=example,dc=com" -f "(|(sAMAccountName=guest*) (sAMAccountName=user*))" -D "cn=administrator,cn=users,dc=example,dc=com" -w "mypass" -a "sAMAccountName" --ia ldap * cloudcmd deploy --soid xxx --tid xxx --zid xxx -n testvm1 -p networkids=xxx vm * cloudcmd start -i 1,3,6 vm (start vm with id 1,3 and 6) * cloudcmd usage -s 2012-05-01 -e 2012-06-01 -a c6e3d03f-4337-44f2-af04-b4cf28709990 -type (1|2|6) Account: heince Domain : DEV Period : 2012-02-29 to 2012-03-01 Details: i-6-52-VM running time (ServiceOffering: 2) (Template: 226) Total Hours = 24.00 i-6-41-VM running time (ServiceOffering: 10) (Template: 226) Total Hours = 24.00 i-6-33-VM running time (ServiceOffering: 2) (Template: 4) Total Hours = 24.00 i-6-92-VM running time (ServiceOffering: 15) (Template: 250) Total Hours = 11.10 i-6-46-VM running time (ServiceOffering: 2) (Template: 226) Total Hours = 24.00 i-6-29-VM running time (ServiceOffering: 2) (Template: 4) Total Hours = 24.00 i-6-31-VM running time (ServiceOffering: 1) (Template: 4) Total Hours = 24.00 i-6-34-VM running time (ServiceOffering: 2) (Template: 220) Total Hours = 24.00 i-6-42-VM running time (ServiceOffering: 10) (Template: 226) Total Hours = 24.00 Summary: Offering id : 1 Name: Small Instance Hours : 24.00 Cost: $0.02 per hour Offering id : 10 Name: HA enabled VM Hours : 48.00 Cost: $0.08 per hour Offering id : 2 Name: Medium Instance Hours : 120.00 Cost: $0.05 per hour Offering id : 15 Name: 8 Cores Instance Hours : 11.10 Cost: $1.00 per hour Total Hours : 203.1 Total Costs : $21.42 Requirements: - minimum perl v5.10 - For RedHat / CentOS 6 x64, extract required perl lib from 'csapi_perl_lib_RedHat6.tgz', copy it over to /usr/local/lib64/perl5/ & /usr/local/share/perl5/, if it's a clean system run : 'tar -xf csapi_perl_lib_RedHat6.tgz -C /' - if you want to compile from cpan you will need libxml2-devel openssl-devel gcc make mysql-devel expat-devel then install required perl modules from cpan: perl install_prerequisites.pl - on config/config.xml * set apikey,secretkey, profilename, integration api url, etc * set urlpath e.g(https://10.1.1.1/client/api? or http://10.1.1.1:8080/client/api?) * if using https, set sslverifyhostname (0 disable, 1 enable) - set CSAPI_ROOT environment variable to install location, examples is under env/ directory - to show running vm usage + costs, you need to edit the usage.xml for database configuration & the charging costs for each offering, make sure you can access the database remotely.
About
CloudStack command line tools
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published