incubator-cloudstack-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rohit Yadav <>
Subject CLI for CloudStack: cloudmonkey
Date Wed, 31 Oct 2012 18:10:25 GMT

I was working on a CLI for cloudstack, it's based on Marvin (the neglected robot) and called
cloudmonkey after our beloved mascot :D

I've committed that on master, please review:;a=commit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c

- it's a shell and also a terminal tool, accepts file redirection and pipes
- scalable to find and run old and new APIs
- intuitive grammar and verbs
- autocompletion (functional hack)
- shell execution using ! or shell
- cfg support: user defined variables, like prompt, ruler, host, port etc.
- history
- colors (disable using set color false)
- dynamic API loading and rule generation
- leverages Marvin to get latest autogenerated APIs
- emacs like shortcuts on prompt
- uses apiKey and secretKey to interact with mgmt server
- logs all client commands
- PEP-8 compliant code

- Reverse search over history
- Fix input and output processing

It requires python and clint;
pip install clint (or if you have to easy_install clint)
mvn clean install -P developer
cd tools/cli/cloudmonkey

If you want to have the terminal tool installed;
cd tools/cli
python sdist
cd dist
pip install cloudmonkey-0.0.4.tar.gz (or easy_install etc.)

You can do stuff like;
cloudmonkey < file-with-commands, or
cloudmonkey list Users, or as shell;

(If you see unicode chars cloud and monkey below, yes they were put intentionally :)

$ cloudmonkey
☁ Apache CloudStack CLI. Type help or ? to list commands.
🙉 cloudmonkey>  set apiKey <your key here>
🙉 cloudmonkey>  set secretKey <your key here>
🙉 cloudmonkey>  <tab><tab>
add      api      create   delete   disable  enable   help     list     quit     remove  
set      shell    update 
🙉 cloudmonkey>  list <tab><tab>
Accounts                   Alerts                     AsyncJobs                  Capabilities
              Capacity                   Clusters                   Configurations       
DiskOfferings              DomainChildren             Domains                    Events  
                  EventTypes                 FirewallRules              Hosts            
HypervisorCapabilities     Hypervisors                InstanceGroups             IpForwardingRules
         IsoPermissions             Isos                       LBStickinessPolicies     
LoadBalancerRuleInstances  LoadBalancerRules          NetworkACLs                NetworkDevice
             NetworkOfferings           Networks                   NetworkServiceProviders
OsCategories               OsTypes                    PhysicalNetworks           Pods    
                  PortForwardingRules        PrivateGateways            ProjectAccounts  
ProjectInvitations         Projects                   PublicIpAddresses          RemoteAccessVpns
          ResourceLimits             Routers                    SecurityGroups           
ServiceOfferings           SnapshotPolicies           Snapshots                  SSHKeyPairs
               StaticRoutes               StorageNetworkIpRange      StoragePools        
SupportedNetworkServices   Swifts                     SystemVms                  Tags    
                  TemplatePermissions        Templates                  TrafficTypeImplementors
TrafficTypes               Users                      VirtualMachines            VirtualRouterElements
     VlanIpRanges               Volumes                    VPCOfferings             
VPCs                       VpnConnections             VpnCustomerGateways        VpnGateways
               VpnUsers                   Zones                    
🙉 cloudmonkey>  list Users
🙉 cloudmonkey>  !ls
# this give you a shell too and one can do things like
🙉 cloudmonkey>  !for i in Users Account; do echo `cloudmonkey list $i | grep id`; done;

Example commands to deploy a datacenter; (fill in dynamic ids etc.)
create Zone dns1= internaldns1= name=Zone1 networktype=Basic      
create PhysicalNetwork name=test-network zoneid=                                    
add TrafficType traffictype=Guest physicalnetworkid=                                
add TrafficType traffictype=Management physicalnetworkid=                           
update PhysicalNetwork state=Enabled id=                                            
list NetworkServiceProviders name=VirtualRouter physicalNetworkId=                  
list VirtualRouterElements nspid=                                                   
api configureVirtualRouterElement enabled=true id=                                  
update NetworkServiceProvider state=Enabled id=                                     
list NetworkServiceProviders name=SecurityGroupProvider physicalNetworkId=          
update NetworkServiceProvider state=Enabled id=                                     
create Network zoneid= name=guestNetworkForBasicZone displaytext=guestNetworkForBasicZone
create Pod zoneid= name=Pod1 gateway= netmask= startip=
create VlanIpRange podid= networkid= gateway= netmask= startip=
endip= forVirtualNetwork=false
add Cluster zoneid= hypervisor=XenServer clustertype=CloudManaged podid= clustername=Cluster1
add Host zoneid= podid= clusterid= hypervisor=XenServer clustertype=CloudManaged username=root
password=password url=
create StoragePool zoneid= clusterid= name=NFS1 url=nfs://
add SecondaryStorage zoneId= url=nfs://      
update Zone allocationstate=Enabled id= 

After some stabilisation, I can put it on pypi so any user can just do pip install cloudmonkey
to get the CLI.

PS. Marvin the neglected robot and hipster cloudmonkey should rule the world :D
View raw message