You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cloudstack.apache.org by Rohit Yadav <ro...@citrix.com> on 2012/10/31 19:10:25 UTC

CLI for CloudStack: cloudmonkey

Hi,

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:
https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.git;a=commit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c

Features:
- 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

FIXMEs:
- 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
python cloudmonkey.py

If you want to have the terminal tool installed;
cd tools/cli
python setup.py 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=8.8.8.8 internaldns1=10.147.28.6 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 networkofferingid=
create Pod zoneid= name=Pod1 gateway=10.147.28.1 netmask=255.255.255.0 startip=10.147.28.220 endip=10.147.28.235
create VlanIpRange podid= networkid= gateway=10.147.28.1 netmask=255.255.255.0 startip=10.147.28.236 endip=10.147.28.250 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=http://10.147.28.60
create StoragePool zoneid= clusterid= name=NFS1 url=nfs://10.147.28.7/export/home/rohit/primary
add SecondaryStorage zoneId= url=nfs://10.147.28.7/export/home/rohit/secondary      
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.

Regards.
PS. Marvin the neglected robot and hipster cloudmonkey should rule the world :D

RE: CLI for CloudStack: cloudmonkey

Posted by "Musayev, Ilya" <im...@webmd.net>.
Thanks Rohit,

I will give it a try shortly.

-----Original Message-----
From: Rohit Yadav [mailto:rohit.yadav@citrix.com] 
Sent: Wednesday, October 31, 2012 2:10 PM
To: cloudstack-dev@incubator.apache.org
Subject: CLI for CloudStack: cloudmonkey

Hi,

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:
https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.git;a=commit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c

Features:
- 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

FIXMEs:
- 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
python cloudmonkey.py

If you want to have the terminal tool installed;
cd tools/cli
python setup.py 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=8.8.8.8 internaldns1=10.147.28.6 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 networkofferingid=
create Pod zoneid= name=Pod1 gateway=10.147.28.1 netmask=255.255.255.0 startip=10.147.28.220 endip=10.147.28.235
create VlanIpRange podid= networkid= gateway=10.147.28.1 netmask=255.255.255.0 startip=10.147.28.236 endip=10.147.28.250 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=http://10.147.28.60
create StoragePool zoneid= clusterid= name=NFS1 url=nfs://10.147.28.7/export/home/rohit/primary
add SecondaryStorage zoneId= url=nfs://10.147.28.7/export/home/rohit/secondary      
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.

Regards.
PS. Marvin the neglected robot and hipster cloudmonkey should rule the world :D

RE: CLI for CloudStack: cloudmonkey

Posted by Edison Su <Ed...@citrix.com>.
> -----Original Message-----
> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
> Sent: Wednesday, October 31, 2012 10:45 PM
> To: cloudstack-dev@incubator.apache.org
> Subject: Re: CLI for CloudStack: cloudmonkey
> 
> 
> On 01-Nov-2012, at 4:40 AM, Edison Su <Ed...@citrix.com> wrote:
> 
> > Never mind, this stuff can be done in python. Seems we just need to
> override completedefault in cmd, then get parameters for the API from the
> python files generated by marvin.
> 
> Yes, we're overriding completedefault on cmd.Cmd. Please let me know if it
> won't work for you, probably it won't if you've incorrect
> readline.parse_and_bind for your environment.

It works me, but as I said before, we'd better add auto completion for api parameter. 

> 
> --
> Rohit
> 
> >
> >> -----Original Message-----
> >> From: Frank Zhang [mailto:Frank.Zhang@citrix.com]
> >> Sent: Wednesday, October 31, 2012 2:51 PM
> >> To: cloudstack-dev@incubator.apache.org
> >> Subject: RE: CLI for CloudStack: cloudmonkey
> >>
> >> Then you cite a wrong example in your former mail. You stated:
> >>
> >>>>> Seems doesn't support auto-completion for api parameters?
> >>>>>
> >>>>> 🙉 cloudmonkey> api listUsers
> >>
> >> This is running in cloudmonkey's terminal, what xe does is in native
> >> bash terminal.
> >> if you want native command line, bash-auto-completion is your friend.
> >> But my reply is for your former mail which refers to cloudmonkey's
> terminal.
> >>
> >>> -----Original Message-----
> >>> From: Edison Su [mailto:Edison.su@citrix.com]
> >>> Sent: Wednesday, October 31, 2012 2:46 PM
> >>> To: cloudstack-dev@incubator.apache.org
> >>> Subject: RE: CLI for CloudStack: cloudmonkey
> >>>
> >>> Xenserver xe cli works great, and it uses bash auto completion. I
> >>> don't see any difference between xe cli and cloudstack cli from the
> >>> auto completion point view. If it can work for ocaml, it should work
> >>> for
> >> python.
> >>> If there are python library can get it done, that's fine.
> >>>
> >>>> -----Original Message-----
> >>>> From: Frank Zhang [mailto:Frank.Zhang@citrix.com]
> >>>> Sent: Wednesday, October 31, 2012 2:37 PM
> >>>> To: cloudstack-dev@incubator.apache.org
> >>>> Subject: RE: CLI for CloudStack: cloudmonkey
> >>>>
> >>>> No.  I don't think so
> >>>> bash auto completion is not for this purpose. You cannot run it in
> >>>> your terminal as you grab the stdin by readline.
> >>>> Bash-auto-completion essentially using compgen and several built-in
> >>>> array must run in native bash terminal, otherwise you have to
> >>>> complexly redirect user input from your terminal to a fake terminal
> >>>> and
> >>> parse the output.
> >>>> I am sure there must be some python library supporting
> >>>> auto-completion in own terminal, no needs to make your hands dirty
> >>>> with the obscured
> >>>> bash- auto-completion
> >>>>
> >>>>> -----Original Message-----
> >>>>> From: Edison Su [mailto:Edison.su@citrix.com]
> >>>>> Sent: Wednesday, October 31, 2012 2:25 PM
> >>>>> To: cloudstack-dev@incubator.apache.org
> >>>>> Subject: RE: CLI for CloudStack: cloudmonkey
> >>>>>
> >>>>> For a better auto completion support, you may take a look at bash
> >>>>> auto
> >>>>> completion(http://info2html.sourceforge.net/cgi-bin/info2html-
> >>>>>
> demo/info2html?%28bash.info.gz%29Programmable%2520Completion),
> >>>> and
> >>>>> there is a great example written by xenserver guys:
> >>>>> https://github.com/xen-org/xen-api/tree/master/ocaml/xe-cli
> >>>>>
> >>>>>> -----Original Message-----
> >>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
> >>>>>> Sent: Wednesday, October 31, 2012 12:27 PM
> >>>>>> To: cloudstack-dev@incubator.apache.org
> >>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
> >>>>>>
> >>>>>> I did an autocompletion fix for Mac OSX (10.8 in my case, you
> >>>>>> have to have
> >>>>>> readline) and it works for me.
> >>>>>>
> >>>>>> Are you using Windows or Linux, I have n't tested on Linux/Windows?
> >>>>>>
> >>>>>> Check following code for your os?
> >>>>>>        # Fix autocompletion issue
> >>>>>>        if sys.platform == "darwin":
> >>>>>>            readline.parse_and_bind("bind ^I rl_complete")
> >>>>>>        else:
> >>>>>>            readline.parse_and_bind("tab: complete")
> >>>>>>
> >>>>>> Yes, help/doc and completion for parameters and parsing input is
> >>>>>> tricky but I'm working on it, any help welcome!
> >>>>>>
> >>>>>> ________________________________________
> >>>>>> From: Edison Su [Edison.su@citrix.com]
> >>>>>> Sent: Thursday, November 01, 2012 12:25 AM
> >>>>>> To: cloudstack-dev@incubator.apache.org
> >>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
> >>>>>>
> >>>>>> Seems doesn't support auto-completion for api parameters?
> >>>>>>
> >>>>>> 🙉 cloudmonkey> api listUsers
> >>>>>>
> >>>>>> The ideal cli should list all the parameter names for listUsers
> >>>>>> api, if I type "tab" at the end of listUsers.
> >>>>>>> -----Original Message-----
> >>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
> >>>>>>> Sent: Wednesday, October 31, 2012 11:10 AM
> >>>>>>> To: cloudstack-dev@incubator.apache.org
> >>>>>>> Subject: CLI for CloudStack: cloudmonkey
> >>>>>>>
> >>>>>>> Hi,
> >>>>>>>
> >>>>>>> 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:
> >>>>>>> https://git-wip-us.apache.org/repos/asf?p=incubator-
> >>>>>>>
> >>>>>
> >>>
> cloudstack.git;a=commit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
> >>>>>>>
> >>>>>>> Features:
> >>>>>>> - 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
> >>>>>>>
> >>>>>>> FIXMEs:
> >>>>>>> - 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 python
> >>>>>>> cloudmonkey.py
> >>>>>>>
> >>>>>>> If you want to have the terminal tool installed; cd tools/cli
> >>>>>>> python setup.py 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=8.8.8.8 internaldns1=10.147.28.6
> >>>>>>> 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
> >>>>>>> networkofferingid= create Pod zoneid= name=Pod1
> >>>>> gateway=10.147.28.1
> >>>>>>> netmask=255.255.255.0
> >>>>>>> startip=10.147.28.220 endip=10.147.28.235 create VlanIpRange
> >>>>>>> podid= networkid= gateway=10.147.28.1 netmask=255.255.255.0
> >>>>>>> startip=10.147.28.236 endip=10.147.28.250
> >>>>>>> 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=http://10.147.28.60 create StoragePool
> >>>>>>> zoneid= clusterid= name=NFS1
> >>>>>>> url=nfs://10.147.28.7/export/home/rohit/primary
> >>>>>>> add SecondaryStorage zoneId=
> >>>>>>> url=nfs://10.147.28.7/export/home/rohit/secondary
> >>>>>>> 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.
> >>>>>>>
> >>>>>>> Regards.
> >>>>>>> PS. Marvin the neglected robot and hipster cloudmonkey should
> >>>>>>> rule the world :D


Re: CLI for CloudStack: cloudmonkey

Posted by Rohit Yadav <ro...@citrix.com>.
On 01-Nov-2012, at 4:40 AM, Edison Su <Ed...@citrix.com> wrote:

> Never mind, this stuff can be done in python. Seems we just need to override completedefault in cmd, then get parameters for the API from the python files generated by marvin.

Yes, we're overriding completedefault on cmd.Cmd. Please let me know if it won't work for you, probably it won't if you've incorrect readline.parse_and_bind for your environment.

--
Rohit

> 
>> -----Original Message-----
>> From: Frank Zhang [mailto:Frank.Zhang@citrix.com]
>> Sent: Wednesday, October 31, 2012 2:51 PM
>> To: cloudstack-dev@incubator.apache.org
>> Subject: RE: CLI for CloudStack: cloudmonkey
>> 
>> Then you cite a wrong example in your former mail. You stated:
>> 
>>>>> Seems doesn't support auto-completion for api parameters?
>>>>> 
>>>>> 🙉 cloudmonkey> api listUsers
>> 
>> This is running in cloudmonkey's terminal, what xe does is in native bash
>> terminal.
>> if you want native command line, bash-auto-completion is your friend. But
>> my reply is for your former mail which refers to cloudmonkey's terminal.
>> 
>>> -----Original Message-----
>>> From: Edison Su [mailto:Edison.su@citrix.com]
>>> Sent: Wednesday, October 31, 2012 2:46 PM
>>> To: cloudstack-dev@incubator.apache.org
>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>> 
>>> Xenserver xe cli works great, and it uses bash auto completion. I
>>> don't see any difference between xe cli and cloudstack cli from the
>>> auto completion point view. If it can work for ocaml, it should work for
>> python.
>>> If there are python library can get it done, that's fine.
>>> 
>>>> -----Original Message-----
>>>> From: Frank Zhang [mailto:Frank.Zhang@citrix.com]
>>>> Sent: Wednesday, October 31, 2012 2:37 PM
>>>> To: cloudstack-dev@incubator.apache.org
>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>> 
>>>> No.  I don't think so
>>>> bash auto completion is not for this purpose. You cannot run it in
>>>> your terminal as you grab the stdin by readline.
>>>> Bash-auto-completion essentially using compgen and several built-in
>>>> array must run in native bash terminal, otherwise you have to
>>>> complexly redirect user input from your terminal to a fake terminal
>>>> and
>>> parse the output.
>>>> I am sure there must be some python library supporting
>>>> auto-completion in own terminal, no needs to make your hands dirty
>>>> with the obscured
>>>> bash- auto-completion
>>>> 
>>>>> -----Original Message-----
>>>>> From: Edison Su [mailto:Edison.su@citrix.com]
>>>>> Sent: Wednesday, October 31, 2012 2:25 PM
>>>>> To: cloudstack-dev@incubator.apache.org
>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>> 
>>>>> For a better auto completion support, you may take a look at bash
>>>>> auto
>>>>> completion(http://info2html.sourceforge.net/cgi-bin/info2html-
>>>>> demo/info2html?%28bash.info.gz%29Programmable%2520Completion),
>>>> and
>>>>> there is a great example written by xenserver guys:
>>>>> https://github.com/xen-org/xen-api/tree/master/ocaml/xe-cli
>>>>> 
>>>>>> -----Original Message-----
>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>> Sent: Wednesday, October 31, 2012 12:27 PM
>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>> 
>>>>>> I did an autocompletion fix for Mac OSX (10.8 in my case, you
>>>>>> have to have
>>>>>> readline) and it works for me.
>>>>>> 
>>>>>> Are you using Windows or Linux, I have n't tested on Linux/Windows?
>>>>>> 
>>>>>> Check following code for your os?
>>>>>>        # Fix autocompletion issue
>>>>>>        if sys.platform == "darwin":
>>>>>>            readline.parse_and_bind("bind ^I rl_complete")
>>>>>>        else:
>>>>>>            readline.parse_and_bind("tab: complete")
>>>>>> 
>>>>>> Yes, help/doc and completion for parameters and parsing input is
>>>>>> tricky but I'm working on it, any help welcome!
>>>>>> 
>>>>>> ________________________________________
>>>>>> From: Edison Su [Edison.su@citrix.com]
>>>>>> Sent: Thursday, November 01, 2012 12:25 AM
>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>> 
>>>>>> Seems doesn't support auto-completion for api parameters?
>>>>>> 
>>>>>> 🙉 cloudmonkey> api listUsers
>>>>>> 
>>>>>> The ideal cli should list all the parameter names for listUsers
>>>>>> api, if I type "tab" at the end of listUsers.
>>>>>>> -----Original Message-----
>>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>>> Sent: Wednesday, October 31, 2012 11:10 AM
>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>> Subject: CLI for CloudStack: cloudmonkey
>>>>>>> 
>>>>>>> Hi,
>>>>>>> 
>>>>>>> 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:
>>>>>>> https://git-wip-us.apache.org/repos/asf?p=incubator-
>>>>>>> 
>>>>> 
>>> cloudstack.git;a=commit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
>>>>>>> 
>>>>>>> Features:
>>>>>>> - 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
>>>>>>> 
>>>>>>> FIXMEs:
>>>>>>> - 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 python
>>>>>>> cloudmonkey.py
>>>>>>> 
>>>>>>> If you want to have the terminal tool installed; cd tools/cli
>>>>>>> python setup.py 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=8.8.8.8 internaldns1=10.147.28.6
>>>>>>> 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
>>>>>>> networkofferingid= create Pod zoneid= name=Pod1
>>>>> gateway=10.147.28.1
>>>>>>> netmask=255.255.255.0
>>>>>>> startip=10.147.28.220 endip=10.147.28.235 create VlanIpRange
>>>>>>> podid= networkid= gateway=10.147.28.1 netmask=255.255.255.0
>>>>>>> startip=10.147.28.236 endip=10.147.28.250
>>>>>>> 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=http://10.147.28.60 create StoragePool
>>>>>>> zoneid= clusterid= name=NFS1
>>>>>>> url=nfs://10.147.28.7/export/home/rohit/primary
>>>>>>> add SecondaryStorage zoneId=
>>>>>>> url=nfs://10.147.28.7/export/home/rohit/secondary
>>>>>>> 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.
>>>>>>> 
>>>>>>> Regards.
>>>>>>> PS. Marvin the neglected robot and hipster cloudmonkey should
>>>>>>> rule the world :D


RE: CLI for CloudStack: cloudmonkey

Posted by Edison Su <Ed...@citrix.com>.
Never mind, this stuff can be done in python. Seems we just need to override completedefault in cmd, then get parameters for the API from the python files generated by marvin.

> -----Original Message-----
> From: Frank Zhang [mailto:Frank.Zhang@citrix.com]
> Sent: Wednesday, October 31, 2012 2:51 PM
> To: cloudstack-dev@incubator.apache.org
> Subject: RE: CLI for CloudStack: cloudmonkey
> 
> Then you cite a wrong example in your former mail. You stated:
> 
> > > > Seems doesn't support auto-completion for api parameters?
> > > >
> > > > 🙉 cloudmonkey> api listUsers
> 
> This is running in cloudmonkey's terminal, what xe does is in native bash
> terminal.
> if you want native command line, bash-auto-completion is your friend. But
> my reply is for your former mail which refers to cloudmonkey's terminal.
> 
> > -----Original Message-----
> > From: Edison Su [mailto:Edison.su@citrix.com]
> > Sent: Wednesday, October 31, 2012 2:46 PM
> > To: cloudstack-dev@incubator.apache.org
> > Subject: RE: CLI for CloudStack: cloudmonkey
> >
> > Xenserver xe cli works great, and it uses bash auto completion. I
> > don't see any difference between xe cli and cloudstack cli from the
> > auto completion point view. If it can work for ocaml, it should work for
> python.
> >  If there are python library can get it done, that's fine.
> >
> > > -----Original Message-----
> > > From: Frank Zhang [mailto:Frank.Zhang@citrix.com]
> > > Sent: Wednesday, October 31, 2012 2:37 PM
> > > To: cloudstack-dev@incubator.apache.org
> > > Subject: RE: CLI for CloudStack: cloudmonkey
> > >
> > > No.  I don't think so
> > > bash auto completion is not for this purpose. You cannot run it in
> > > your terminal as you grab the stdin by readline.
> > > Bash-auto-completion essentially using compgen and several built-in
> > > array must run in native bash terminal, otherwise you have to
> > > complexly redirect user input from your terminal to a fake terminal
> > > and
> > parse the output.
> > > I am sure there must be some python library supporting
> > > auto-completion in own terminal, no needs to make your hands dirty
> > > with the obscured
> > > bash- auto-completion
> > >
> > > > -----Original Message-----
> > > > From: Edison Su [mailto:Edison.su@citrix.com]
> > > > Sent: Wednesday, October 31, 2012 2:25 PM
> > > > To: cloudstack-dev@incubator.apache.org
> > > > Subject: RE: CLI for CloudStack: cloudmonkey
> > > >
> > > > For a better auto completion support, you may take a look at bash
> > > > auto
> > > > completion(http://info2html.sourceforge.net/cgi-bin/info2html-
> > > > demo/info2html?%28bash.info.gz%29Programmable%2520Completion),
> > > and
> > > > there is a great example written by xenserver guys:
> > > > https://github.com/xen-org/xen-api/tree/master/ocaml/xe-cli
> > > >
> > > > > -----Original Message-----
> > > > > From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
> > > > > Sent: Wednesday, October 31, 2012 12:27 PM
> > > > > To: cloudstack-dev@incubator.apache.org
> > > > > Subject: RE: CLI for CloudStack: cloudmonkey
> > > > >
> > > > > I did an autocompletion fix for Mac OSX (10.8 in my case, you
> > > > > have to have
> > > > > readline) and it works for me.
> > > > >
> > > > > Are you using Windows or Linux, I have n't tested on Linux/Windows?
> > > > >
> > > > > Check following code for your os?
> > > > >         # Fix autocompletion issue
> > > > >         if sys.platform == "darwin":
> > > > >             readline.parse_and_bind("bind ^I rl_complete")
> > > > >         else:
> > > > >             readline.parse_and_bind("tab: complete")
> > > > >
> > > > > Yes, help/doc and completion for parameters and parsing input is
> > > > > tricky but I'm working on it, any help welcome!
> > > > >
> > > > > ________________________________________
> > > > > From: Edison Su [Edison.su@citrix.com]
> > > > > Sent: Thursday, November 01, 2012 12:25 AM
> > > > > To: cloudstack-dev@incubator.apache.org
> > > > > Subject: RE: CLI for CloudStack: cloudmonkey
> > > > >
> > > > > Seems doesn't support auto-completion for api parameters?
> > > > >
> > > > > 🙉 cloudmonkey> api listUsers
> > > > >
> > > > > The ideal cli should list all the parameter names for listUsers
> > > > > api, if I type "tab" at the end of listUsers.
> > > > > > -----Original Message-----
> > > > > > From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
> > > > > > Sent: Wednesday, October 31, 2012 11:10 AM
> > > > > > To: cloudstack-dev@incubator.apache.org
> > > > > > Subject: CLI for CloudStack: cloudmonkey
> > > > > >
> > > > > > Hi,
> > > > > >
> > > > > > 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:
> > > > > > https://git-wip-us.apache.org/repos/asf?p=incubator-
> > > > > >
> > > >
> > cloudstack.git;a=commit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
> > > > > >
> > > > > > Features:
> > > > > > - 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
> > > > > >
> > > > > > FIXMEs:
> > > > > > - 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 python
> > > > > > cloudmonkey.py
> > > > > >
> > > > > > If you want to have the terminal tool installed; cd tools/cli
> > > > > > python setup.py 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=8.8.8.8 internaldns1=10.147.28.6
> > > > > > 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
> > > > > > networkofferingid= create Pod zoneid= name=Pod1
> > > > gateway=10.147.28.1
> > > > > > netmask=255.255.255.0
> > > > > > startip=10.147.28.220 endip=10.147.28.235 create VlanIpRange
> > > > > > podid= networkid= gateway=10.147.28.1 netmask=255.255.255.0
> > > > > > startip=10.147.28.236 endip=10.147.28.250
> > > > > > 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=http://10.147.28.60 create StoragePool
> > > > > > zoneid= clusterid= name=NFS1
> > > > > > url=nfs://10.147.28.7/export/home/rohit/primary
> > > > > > add SecondaryStorage zoneId=
> > > > > > url=nfs://10.147.28.7/export/home/rohit/secondary
> > > > > > 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.
> > > > > >
> > > > > > Regards.
> > > > > > PS. Marvin the neglected robot and hipster cloudmonkey should
> > > > > > rule the world :D

RE: CLI for CloudStack: cloudmonkey

Posted by Frank Zhang <Fr...@citrix.com>.
Then you cite a wrong example in your former mail. You stated:

> > > Seems doesn't support auto-completion for api parameters?
> > >
> > > 🙉 cloudmonkey> api listUsers

This is running in cloudmonkey's terminal, what xe does is in native bash terminal.
if you want native command line, bash-auto-completion is your friend. But my reply is for your former mail which refers to cloudmonkey's terminal.

> -----Original Message-----
> From: Edison Su [mailto:Edison.su@citrix.com]
> Sent: Wednesday, October 31, 2012 2:46 PM
> To: cloudstack-dev@incubator.apache.org
> Subject: RE: CLI for CloudStack: cloudmonkey
> 
> Xenserver xe cli works great, and it uses bash auto completion. I don't see
> any difference between xe cli and cloudstack cli from the auto completion
> point view. If it can work for ocaml, it should work for python.
>  If there are python library can get it done, that's fine.
> 
> > -----Original Message-----
> > From: Frank Zhang [mailto:Frank.Zhang@citrix.com]
> > Sent: Wednesday, October 31, 2012 2:37 PM
> > To: cloudstack-dev@incubator.apache.org
> > Subject: RE: CLI for CloudStack: cloudmonkey
> >
> > No.  I don't think so
> > bash auto completion is not for this purpose. You cannot run it in
> > your terminal as you grab the stdin by readline.
> > Bash-auto-completion essentially using compgen and several built-in
> > array must run in native bash terminal, otherwise you have to
> > complexly redirect user input from your terminal to a fake terminal and
> parse the output.
> > I am sure there must be some python library supporting auto-completion
> > in own terminal, no needs to make your hands dirty with the obscured
> > bash- auto-completion
> >
> > > -----Original Message-----
> > > From: Edison Su [mailto:Edison.su@citrix.com]
> > > Sent: Wednesday, October 31, 2012 2:25 PM
> > > To: cloudstack-dev@incubator.apache.org
> > > Subject: RE: CLI for CloudStack: cloudmonkey
> > >
> > > For a better auto completion support, you may take a look at bash
> > > auto
> > > completion(http://info2html.sourceforge.net/cgi-bin/info2html-
> > > demo/info2html?%28bash.info.gz%29Programmable%2520Completion),
> > and
> > > there is a great example written by xenserver guys:
> > > https://github.com/xen-org/xen-api/tree/master/ocaml/xe-cli
> > >
> > > > -----Original Message-----
> > > > From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
> > > > Sent: Wednesday, October 31, 2012 12:27 PM
> > > > To: cloudstack-dev@incubator.apache.org
> > > > Subject: RE: CLI for CloudStack: cloudmonkey
> > > >
> > > > I did an autocompletion fix for Mac OSX (10.8 in my case, you have
> > > > to have
> > > > readline) and it works for me.
> > > >
> > > > Are you using Windows or Linux, I have n't tested on Linux/Windows?
> > > >
> > > > Check following code for your os?
> > > >         # Fix autocompletion issue
> > > >         if sys.platform == "darwin":
> > > >             readline.parse_and_bind("bind ^I rl_complete")
> > > >         else:
> > > >             readline.parse_and_bind("tab: complete")
> > > >
> > > > Yes, help/doc and completion for parameters and parsing input is
> > > > tricky but I'm working on it, any help welcome!
> > > >
> > > > ________________________________________
> > > > From: Edison Su [Edison.su@citrix.com]
> > > > Sent: Thursday, November 01, 2012 12:25 AM
> > > > To: cloudstack-dev@incubator.apache.org
> > > > Subject: RE: CLI for CloudStack: cloudmonkey
> > > >
> > > > Seems doesn't support auto-completion for api parameters?
> > > >
> > > > 🙉 cloudmonkey> api listUsers
> > > >
> > > > The ideal cli should list all the parameter names for listUsers
> > > > api, if I type "tab" at the end of listUsers.
> > > > > -----Original Message-----
> > > > > From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
> > > > > Sent: Wednesday, October 31, 2012 11:10 AM
> > > > > To: cloudstack-dev@incubator.apache.org
> > > > > Subject: CLI for CloudStack: cloudmonkey
> > > > >
> > > > > Hi,
> > > > >
> > > > > 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:
> > > > > https://git-wip-us.apache.org/repos/asf?p=incubator-
> > > > >
> > >
> cloudstack.git;a=commit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
> > > > >
> > > > > Features:
> > > > > - 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
> > > > >
> > > > > FIXMEs:
> > > > > - 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 python
> > > > > cloudmonkey.py
> > > > >
> > > > > If you want to have the terminal tool installed; cd tools/cli
> > > > > python setup.py 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=8.8.8.8 internaldns1=10.147.28.6
> > > > > 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
> > > > > networkofferingid= create Pod zoneid= name=Pod1
> > > gateway=10.147.28.1
> > > > > netmask=255.255.255.0
> > > > > startip=10.147.28.220 endip=10.147.28.235 create VlanIpRange
> > > > > podid= networkid= gateway=10.147.28.1 netmask=255.255.255.0
> > > > > startip=10.147.28.236 endip=10.147.28.250
> > > > > 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=http://10.147.28.60 create StoragePool
> > > > > zoneid= clusterid= name=NFS1
> > > > > url=nfs://10.147.28.7/export/home/rohit/primary
> > > > > add SecondaryStorage zoneId=
> > > > > url=nfs://10.147.28.7/export/home/rohit/secondary
> > > > > 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.
> > > > >
> > > > > Regards.
> > > > > PS. Marvin the neglected robot and hipster cloudmonkey should
> > > > > rule the world :D

RE: CLI for CloudStack: cloudmonkey

Posted by Edison Su <Ed...@citrix.com>.
Xenserver xe cli works great, and it uses bash auto completion. I don't see any difference between xe cli and cloudstack cli from the auto completion point view. If it can work for ocaml, it should work for python.
 If there are python library can get it done, that's fine.

> -----Original Message-----
> From: Frank Zhang [mailto:Frank.Zhang@citrix.com]
> Sent: Wednesday, October 31, 2012 2:37 PM
> To: cloudstack-dev@incubator.apache.org
> Subject: RE: CLI for CloudStack: cloudmonkey
> 
> No.  I don't think so
> bash auto completion is not for this purpose. You cannot run it in your
> terminal as you grab the stdin by readline.
> Bash-auto-completion essentially using compgen and several built-in array
> must run in native bash terminal, otherwise you have to complexly redirect
> user input from your terminal to a fake terminal and parse the output.
> I am sure there must be some python library supporting auto-completion in
> own terminal, no needs to make your hands dirty with the obscured bash-
> auto-completion
> 
> > -----Original Message-----
> > From: Edison Su [mailto:Edison.su@citrix.com]
> > Sent: Wednesday, October 31, 2012 2:25 PM
> > To: cloudstack-dev@incubator.apache.org
> > Subject: RE: CLI for CloudStack: cloudmonkey
> >
> > For a better auto completion support, you may take a look at bash auto
> > completion(http://info2html.sourceforge.net/cgi-bin/info2html-
> > demo/info2html?%28bash.info.gz%29Programmable%2520Completion),
> and
> > there is a great example written by xenserver guys:
> > https://github.com/xen-org/xen-api/tree/master/ocaml/xe-cli
> >
> > > -----Original Message-----
> > > From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
> > > Sent: Wednesday, October 31, 2012 12:27 PM
> > > To: cloudstack-dev@incubator.apache.org
> > > Subject: RE: CLI for CloudStack: cloudmonkey
> > >
> > > I did an autocompletion fix for Mac OSX (10.8 in my case, you have
> > > to have
> > > readline) and it works for me.
> > >
> > > Are you using Windows or Linux, I have n't tested on Linux/Windows?
> > >
> > > Check following code for your os?
> > >         # Fix autocompletion issue
> > >         if sys.platform == "darwin":
> > >             readline.parse_and_bind("bind ^I rl_complete")
> > >         else:
> > >             readline.parse_and_bind("tab: complete")
> > >
> > > Yes, help/doc and completion for parameters and parsing input is
> > > tricky but I'm working on it, any help welcome!
> > >
> > > ________________________________________
> > > From: Edison Su [Edison.su@citrix.com]
> > > Sent: Thursday, November 01, 2012 12:25 AM
> > > To: cloudstack-dev@incubator.apache.org
> > > Subject: RE: CLI for CloudStack: cloudmonkey
> > >
> > > Seems doesn't support auto-completion for api parameters?
> > >
> > > 🙉 cloudmonkey> api listUsers
> > >
> > > The ideal cli should list all the parameter names for listUsers api,
> > > if I type "tab" at the end of listUsers.
> > > > -----Original Message-----
> > > > From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
> > > > Sent: Wednesday, October 31, 2012 11:10 AM
> > > > To: cloudstack-dev@incubator.apache.org
> > > > Subject: CLI for CloudStack: cloudmonkey
> > > >
> > > > Hi,
> > > >
> > > > 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:
> > > > https://git-wip-us.apache.org/repos/asf?p=incubator-
> > > >
> > cloudstack.git;a=commit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
> > > >
> > > > Features:
> > > > - 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
> > > >
> > > > FIXMEs:
> > > > - 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 python
> > > > cloudmonkey.py
> > > >
> > > > If you want to have the terminal tool installed; cd tools/cli
> > > > python setup.py 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=8.8.8.8 internaldns1=10.147.28.6 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
> > > > networkofferingid= create Pod zoneid= name=Pod1
> > gateway=10.147.28.1
> > > > netmask=255.255.255.0
> > > > startip=10.147.28.220 endip=10.147.28.235 create VlanIpRange
> > > > podid= networkid= gateway=10.147.28.1 netmask=255.255.255.0
> > > > startip=10.147.28.236 endip=10.147.28.250 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=http://10.147.28.60 create StoragePool
> > > > zoneid= clusterid= name=NFS1
> > > > url=nfs://10.147.28.7/export/home/rohit/primary
> > > > add SecondaryStorage zoneId=
> > > > url=nfs://10.147.28.7/export/home/rohit/secondary
> > > > 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.
> > > >
> > > > Regards.
> > > > PS. Marvin the neglected robot and hipster cloudmonkey should rule
> > > > the world :D

RE: CLI for CloudStack: cloudmonkey

Posted by Frank Zhang <Fr...@citrix.com>.
No.  I don't think so
bash auto completion is not for this purpose. You cannot run it in your terminal as you grab the stdin by readline.
Bash-auto-completion essentially using compgen and several built-in array must run in native bash terminal, otherwise you have to complexly redirect user input from your terminal to a fake terminal and parse the output.
I am sure there must be some python library supporting auto-completion in own terminal, no needs to make your hands dirty with the obscured bash-auto-completion

> -----Original Message-----
> From: Edison Su [mailto:Edison.su@citrix.com]
> Sent: Wednesday, October 31, 2012 2:25 PM
> To: cloudstack-dev@incubator.apache.org
> Subject: RE: CLI for CloudStack: cloudmonkey
> 
> For a better auto completion support, you may take a look at bash auto
> completion(http://info2html.sourceforge.net/cgi-bin/info2html-
> demo/info2html?%28bash.info.gz%29Programmable%2520Completion), and
> there is a great example written by xenserver guys:
> https://github.com/xen-org/xen-api/tree/master/ocaml/xe-cli
> 
> > -----Original Message-----
> > From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
> > Sent: Wednesday, October 31, 2012 12:27 PM
> > To: cloudstack-dev@incubator.apache.org
> > Subject: RE: CLI for CloudStack: cloudmonkey
> >
> > I did an autocompletion fix for Mac OSX (10.8 in my case, you have to
> > have
> > readline) and it works for me.
> >
> > Are you using Windows or Linux, I have n't tested on Linux/Windows?
> >
> > Check following code for your os?
> >         # Fix autocompletion issue
> >         if sys.platform == "darwin":
> >             readline.parse_and_bind("bind ^I rl_complete")
> >         else:
> >             readline.parse_and_bind("tab: complete")
> >
> > Yes, help/doc and completion for parameters and parsing input is
> > tricky but I'm working on it, any help welcome!
> >
> > ________________________________________
> > From: Edison Su [Edison.su@citrix.com]
> > Sent: Thursday, November 01, 2012 12:25 AM
> > To: cloudstack-dev@incubator.apache.org
> > Subject: RE: CLI for CloudStack: cloudmonkey
> >
> > Seems doesn't support auto-completion for api parameters?
> >
> > 🙉 cloudmonkey> api listUsers
> >
> > The ideal cli should list all the parameter names for listUsers api,
> > if I type "tab" at the end of listUsers.
> > > -----Original Message-----
> > > From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
> > > Sent: Wednesday, October 31, 2012 11:10 AM
> > > To: cloudstack-dev@incubator.apache.org
> > > Subject: CLI for CloudStack: cloudmonkey
> > >
> > > Hi,
> > >
> > > 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:
> > > https://git-wip-us.apache.org/repos/asf?p=incubator-
> > >
> cloudstack.git;a=commit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
> > >
> > > Features:
> > > - 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
> > >
> > > FIXMEs:
> > > - 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 python cloudmonkey.py
> > >
> > > If you want to have the terminal tool installed; cd tools/cli python
> > > setup.py 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=8.8.8.8 internaldns1=10.147.28.6 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
> > > networkofferingid= create Pod zoneid= name=Pod1
> gateway=10.147.28.1
> > > netmask=255.255.255.0
> > > startip=10.147.28.220 endip=10.147.28.235 create VlanIpRange podid=
> > > networkid= gateway=10.147.28.1 netmask=255.255.255.0
> > > startip=10.147.28.236 endip=10.147.28.250 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=http://10.147.28.60 create StoragePool zoneid=
> > > clusterid= name=NFS1 url=nfs://10.147.28.7/export/home/rohit/primary
> > > add SecondaryStorage zoneId=
> > > url=nfs://10.147.28.7/export/home/rohit/secondary
> > > 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.
> > >
> > > Regards.
> > > PS. Marvin the neglected robot and hipster cloudmonkey should rule
> > > the world :D

RE: CLI for CloudStack: cloudmonkey

Posted by Edison Su <Ed...@citrix.com>.
For a better auto completion support, you may take a look at bash auto completion(http://info2html.sourceforge.net/cgi-bin/info2html-demo/info2html?%28bash.info.gz%29Programmable%2520Completion), and there is a great example written by xenserver guys:
https://github.com/xen-org/xen-api/tree/master/ocaml/xe-cli

> -----Original Message-----
> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
> Sent: Wednesday, October 31, 2012 12:27 PM
> To: cloudstack-dev@incubator.apache.org
> Subject: RE: CLI for CloudStack: cloudmonkey
> 
> I did an autocompletion fix for Mac OSX (10.8 in my case, you have to have
> readline) and it works for me.
> 
> Are you using Windows or Linux, I have n't tested on Linux/Windows?
> 
> Check following code for your os?
>         # Fix autocompletion issue
>         if sys.platform == "darwin":
>             readline.parse_and_bind("bind ^I rl_complete")
>         else:
>             readline.parse_and_bind("tab: complete")
> 
> Yes, help/doc and completion for parameters and parsing input is tricky but
> I'm working on it, any help welcome!
> 
> ________________________________________
> From: Edison Su [Edison.su@citrix.com]
> Sent: Thursday, November 01, 2012 12:25 AM
> To: cloudstack-dev@incubator.apache.org
> Subject: RE: CLI for CloudStack: cloudmonkey
> 
> Seems doesn't support auto-completion for api parameters?
> 
> 🙉 cloudmonkey> api listUsers
> 
> The ideal cli should list all the parameter names for listUsers api, if I type
> "tab" at the end of listUsers.
> > -----Original Message-----
> > From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
> > Sent: Wednesday, October 31, 2012 11:10 AM
> > To: cloudstack-dev@incubator.apache.org
> > Subject: CLI for CloudStack: cloudmonkey
> >
> > Hi,
> >
> > 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:
> > https://git-wip-us.apache.org/repos/asf?p=incubator-
> > cloudstack.git;a=commit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
> >
> > Features:
> > - 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
> >
> > FIXMEs:
> > - 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 python cloudmonkey.py
> >
> > If you want to have the terminal tool installed; cd tools/cli python
> > setup.py 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=8.8.8.8 internaldns1=10.147.28.6 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
> > networkofferingid= create Pod zoneid= name=Pod1 gateway=10.147.28.1
> > netmask=255.255.255.0
> > startip=10.147.28.220 endip=10.147.28.235 create VlanIpRange podid=
> > networkid= gateway=10.147.28.1 netmask=255.255.255.0
> > startip=10.147.28.236 endip=10.147.28.250 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=http://10.147.28.60 create StoragePool zoneid=
> > clusterid= name=NFS1 url=nfs://10.147.28.7/export/home/rohit/primary
> > add SecondaryStorage zoneId=
> > url=nfs://10.147.28.7/export/home/rohit/secondary
> > 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.
> >
> > Regards.
> > PS. Marvin the neglected robot and hipster cloudmonkey should rule the
> > world :D

RE: CLI for CloudStack: cloudmonkey

Posted by Rohit Yadav <ro...@citrix.com>.
I did an autocompletion fix for Mac OSX (10.8 in my case, you have to have readline) and it works for me.

Are you using Windows or Linux, I have n't tested on Linux/Windows?

Check following code for your os?
        # Fix autocompletion issue                                                  
        if sys.platform == "darwin":                                                
            readline.parse_and_bind("bind ^I rl_complete")                          
        else:                                                                       
            readline.parse_and_bind("tab: complete")  

Yes, help/doc and completion for parameters and parsing input is tricky but I'm working on it, any help welcome!

________________________________________
From: Edison Su [Edison.su@citrix.com]
Sent: Thursday, November 01, 2012 12:25 AM
To: cloudstack-dev@incubator.apache.org
Subject: RE: CLI for CloudStack: cloudmonkey

Seems doesn't support auto-completion for api parameters?

🙉 cloudmonkey> api listUsers

The ideal cli should list all the parameter names for listUsers api, if I type "tab" at the end of listUsers.
> -----Original Message-----
> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
> Sent: Wednesday, October 31, 2012 11:10 AM
> To: cloudstack-dev@incubator.apache.org
> Subject: CLI for CloudStack: cloudmonkey
>
> Hi,
>
> 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:
> https://git-wip-us.apache.org/repos/asf?p=incubator-
> cloudstack.git;a=commit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
>
> Features:
> - 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
>
> FIXMEs:
> - 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 python cloudmonkey.py
>
> If you want to have the terminal tool installed; cd tools/cli python setup.py
> 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=8.8.8.8 internaldns1=10.147.28.6 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 networkofferingid= create Pod
> zoneid= name=Pod1 gateway=10.147.28.1 netmask=255.255.255.0
> startip=10.147.28.220 endip=10.147.28.235 create VlanIpRange podid=
> networkid= gateway=10.147.28.1 netmask=255.255.255.0
> startip=10.147.28.236 endip=10.147.28.250 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=http://10.147.28.60 create StoragePool zoneid=
> clusterid= name=NFS1 url=nfs://10.147.28.7/export/home/rohit/primary
> add SecondaryStorage zoneId=
> url=nfs://10.147.28.7/export/home/rohit/secondary
> 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.
>
> Regards.
> PS. Marvin the neglected robot and hipster cloudmonkey should rule the
> world :D

RE: CLI for CloudStack: cloudmonkey

Posted by Edison Su <Ed...@citrix.com>.
Seems doesn't support auto-completion for api parameters?

🙉 cloudmonkey> api listUsers

The ideal cli should list all the parameter names for listUsers api, if I type "tab" at the end of listUsers.
> -----Original Message-----
> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
> Sent: Wednesday, October 31, 2012 11:10 AM
> To: cloudstack-dev@incubator.apache.org
> Subject: CLI for CloudStack: cloudmonkey
> 
> Hi,
> 
> 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:
> https://git-wip-us.apache.org/repos/asf?p=incubator-
> cloudstack.git;a=commit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
> 
> Features:
> - 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
> 
> FIXMEs:
> - 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 python cloudmonkey.py
> 
> If you want to have the terminal tool installed; cd tools/cli python setup.py
> 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=8.8.8.8 internaldns1=10.147.28.6 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 networkofferingid= create Pod
> zoneid= name=Pod1 gateway=10.147.28.1 netmask=255.255.255.0
> startip=10.147.28.220 endip=10.147.28.235 create VlanIpRange podid=
> networkid= gateway=10.147.28.1 netmask=255.255.255.0
> startip=10.147.28.236 endip=10.147.28.250 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=http://10.147.28.60 create StoragePool zoneid=
> clusterid= name=NFS1 url=nfs://10.147.28.7/export/home/rohit/primary
> add SecondaryStorage zoneId=
> url=nfs://10.147.28.7/export/home/rohit/secondary
> 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.
> 
> Regards.
> PS. Marvin the neglected robot and hipster cloudmonkey should rule the
> world :D

RE: CLI for CloudStack: cloudmonkey

Posted by Rohit Yadav <ro...@citrix.com>.
Yes, it is there, and clint will be fetched, but for developers, we will most probably cd tools/cli/cloudmonkey and do python cloudmonkey.py (which will fail if we won't have clint).

If you don't like colors, we can do:
set color false

________________________________________
From: Frank Zhang [Frank.Zhang@citrix.com]
Sent: Thursday, November 01, 2012 1:32 AM
To: cloudstack-dev@incubator.apache.org
Subject: RE: CLI for CloudStack: cloudmonkey

Cool! I like it.
It's better to add 'clint' to install_requires field of setup.py, then I don't need manually install it myself


> -----Original Message-----
> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
> Sent: Wednesday, October 31, 2012 11:10 AM
> To: cloudstack-dev@incubator.apache.org
> Subject: CLI for CloudStack: cloudmonkey
>
> Hi,
>
> 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:
> https://git-wip-us.apache.org/repos/asf?p=incubator-
> cloudstack.git;a=commit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
>
> Features:
> - 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
>
> FIXMEs:
> - 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 python cloudmonkey.py
>
> If you want to have the terminal tool installed; cd tools/cli python setup.py
> 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=8.8.8.8 internaldns1=10.147.28.6 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 networkofferingid= create Pod
> zoneid= name=Pod1 gateway=10.147.28.1 netmask=255.255.255.0
> startip=10.147.28.220 endip=10.147.28.235 create VlanIpRange podid=
> networkid= gateway=10.147.28.1 netmask=255.255.255.0
> startip=10.147.28.236 endip=10.147.28.250 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=http://10.147.28.60 create StoragePool zoneid=
> clusterid= name=NFS1 url=nfs://10.147.28.7/export/home/rohit/primary
> add SecondaryStorage zoneId=
> url=nfs://10.147.28.7/export/home/rohit/secondary
> 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.
>
> Regards.
> PS. Marvin the neglected robot and hipster cloudmonkey should rule the
> world :D

RE: CLI for CloudStack: cloudmonkey

Posted by Frank Zhang <Fr...@citrix.com>.
Cool! I like it.
It's better to add 'clint' to install_requires field of setup.py, then I don't need manually install it myself


> -----Original Message-----
> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
> Sent: Wednesday, October 31, 2012 11:10 AM
> To: cloudstack-dev@incubator.apache.org
> Subject: CLI for CloudStack: cloudmonkey
> 
> Hi,
> 
> 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:
> https://git-wip-us.apache.org/repos/asf?p=incubator-
> cloudstack.git;a=commit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
> 
> Features:
> - 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
> 
> FIXMEs:
> - 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 python cloudmonkey.py
> 
> If you want to have the terminal tool installed; cd tools/cli python setup.py
> 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=8.8.8.8 internaldns1=10.147.28.6 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 networkofferingid= create Pod
> zoneid= name=Pod1 gateway=10.147.28.1 netmask=255.255.255.0
> startip=10.147.28.220 endip=10.147.28.235 create VlanIpRange podid=
> networkid= gateway=10.147.28.1 netmask=255.255.255.0
> startip=10.147.28.236 endip=10.147.28.250 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=http://10.147.28.60 create StoragePool zoneid=
> clusterid= name=NFS1 url=nfs://10.147.28.7/export/home/rohit/primary
> add SecondaryStorage zoneId=
> url=nfs://10.147.28.7/export/home/rohit/secondary
> 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.
> 
> Regards.
> PS. Marvin the neglected robot and hipster cloudmonkey should rule the
> world :D

RE: CLI for CloudStack: cloudmonkey

Posted by Rohit Yadav <ro...@citrix.com>.
Alright let's keep it, I like the emoji too [0] :)
On first run we can tell users to set their own prompt using:
set prompt my-awesome-prompt

Thanks.
[0] create your own fun prompts using unicode chars/emoji :) http://zachholman.com/posts/abusing-emoji/
________________________________________
From: Chip Childers [chip.childers@sungard.com]
Sent: Friday, November 02, 2012 12:19 AM
To: cloudstack-dev@incubator.apache.org
Subject: Re: CLI for CloudStack: cloudmonkey

On Thu, Nov 1, 2012 at 2:45 PM, Rohit Yadav <ro...@citrix.com> wrote:
> Hi Chip, please go ahead if we can fix the http/s issue. The connection is based on marvin, I'm sure using CLI we'll find out more bugs and fix anything in marvin thereby help maintain marvin->tests and CLI.
> Please hack that up on tools/marvin/marvin/cloudstackConnection.py

Yup, ok

> One more thing, for people who may not have unicode support the prompt may appear weird and history search (up, down ) can mess up the visuals. For example on Mac it appears as a colorful emoji, but I found that it looks weird on other platforms. Will probably remove it, or the user can custom set their prompt, using: set prompt myprompt>

If you remove it, can it be an optionally enabled prompt please ;-)  I like it.

Re: CLI for CloudStack: cloudmonkey

Posted by Chip Childers <ch...@sungard.com>.
On Thu, Nov 1, 2012 at 2:45 PM, Rohit Yadav <ro...@citrix.com> wrote:
> Hi Chip, please go ahead if we can fix the http/s issue. The connection is based on marvin, I'm sure using CLI we'll find out more bugs and fix anything in marvin thereby help maintain marvin->tests and CLI.
> Please hack that up on tools/marvin/marvin/cloudstackConnection.py

Yup, ok

> One more thing, for people who may not have unicode support the prompt may appear weird and history search (up, down ) can mess up the visuals. For example on Mac it appears as a colorful emoji, but I found that it looks weird on other platforms. Will probably remove it, or the user can custom set their prompt, using: set prompt myprompt>

If you remove it, can it be an optionally enabled prompt please ;-)  I like it.

RE: CLI for CloudStack: cloudmonkey

Posted by Rohit Yadav <ro...@citrix.com>.
Forgot to mention one more thing, you can actually fire up bash/shell cmds from cloudmonkey using shell <cmd> or !<cmd>
So, fire up a !for loop; or !vim my-script etc. or shell inside cloudmonkey that executes cloudmonkey etc. makes things easy to hack.

________________________________________
From: Edison Su [Edison.su@citrix.com]
Sent: Friday, November 02, 2012 1:55 AM
To: cloudstack-dev@incubator.apache.org
Subject: RE: CLI for CloudStack: cloudmonkey

Oh, it reminds me that how to use the CLI on the bash command line?
I think admin may want to call cloudstack API in a bash script, how can I do that?

> -----Original Message-----
> From: Marcus Sorensen [mailto:shadowsor@gmail.com]
> Sent: Thursday, November 01, 2012 1:11 PM
> To: cloudstack-dev@incubator.apache.org
> Subject: Re: CLI for CloudStack: cloudmonkey
>
> Yes, I look forward to using it instead of local curl calls on the command line :-)
>
> On Thu, Nov 1, 2012 at 2:02 PM, Edison Su <Ed...@citrix.com> wrote:
> >
> >
> >> -----Original Message-----
> >> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
> >> Sent: Thursday, November 01, 2012 11:45 AM
> >> To: cloudstack-dev@incubator.apache.org
> >> Subject: RE: CLI for CloudStack: cloudmonkey
> >>
> >> Hi Chip, please go ahead if we can fix the http/s issue. The
> >> connection is based on marvin, I'm sure using CLI we'll find out more
> >> bugs and fix anything in marvin thereby help maintain marvin->tests and
> CLI.
> >> Please hack that up on tools/marvin/marvin/cloudstackConnection.py
> >>
> >> Edison, yes I'm working on the completedefault, I've figured a
> >> solution to the parsing and tabbing issue to show params for any api
> >> and added more verbs to the grammar like deploy, start etc.
> >> In the new approach doc strings and params needed for an api are
> >> fetched and cached in the class locally to speed up the loading process.
> >> Till it gets committed, cloudmonkey (now) will keep telling the user
> >> what params they are missing until it gets all the required ones.
> >
> > Great! Thanks for your awesome CLI, people will like it.
> >
> >>
> >> One more thing, for people who may not have unicode support the
> >> prompt may appear weird and history search (up, down ) can mess up
> >> the visuals. For example on Mac it appears as a colorful emoji, but I
> >> found that it looks weird on other platforms. Will probably remove
> >> it, or the user can custom set their prompt, using: set prompt
> >> myprompt>
> >>
> >> Regards.
> >> PS. the set command is full of (fun :)  hacks because of
> >> funtional/generic programming, it basically can set any attribute on
> >> the class, so one can do something like creating something (var,
> >> func). For example set ruler # (so instead of - you will have a #
> >> separator)
> >>
> >> ________________________________________
> >> From: Chip Childers [chip.childers@sungard.com]
> >> Sent: Thursday, November 01, 2012 11:15 PM
> >> To: cloudstack-dev@incubator.apache.org
> >> Subject: Re: CLI for CloudStack: cloudmonkey
> >>
> >> On Wed, Oct 31, 2012 at 2:10 PM, Rohit Yadav <ro...@citrix.com>
> >> wrote:
> >> > Hi,
> >> >
> >> > 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:
> >> > https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.git;
> >> > a=c ommit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
> >> >
> >> > Features:
> >> > - 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
> >> >
> >> > FIXMEs:
> >> > - 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 python cloudmonkey.py
> >> >
> >> > If you want to have the terminal tool installed; cd tools/cli
> >> > python setup.py 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=8.8.8.8 internaldns1=10.147.28.6 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
> >> > networkofferingid= create Pod zoneid= name=Pod1
> gateway=10.147.28.1
> >> > netmask=255.255.255.0 startip=10.147.28.220 endip=10.147.28.235
> >> > create VlanIpRange podid= networkid= gateway=10.147.28.1
> >> > netmask=255.255.255.0 startip=10.147.28.236 endip=10.147.28.250
> >> > 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=http://10.147.28.60 create
> >> > StoragePool zoneid= clusterid= name=NFS1
> >> > url=nfs://10.147.28.7/export/home/rohit/primary
> >> > add SecondaryStorage zoneId=
> >> > url=nfs://10.147.28.7/export/home/rohit/secondary
> >> > 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.
> >> >
> >> > Regards.
> >> > PS. Marvin the neglected robot and hipster cloudmonkey should rule
> >> > the world :D
> >>
> >> Rohit,
> >>
> >> This is really really cool.  It puts the "fun" in managing instances
> >> from a command line.  I've been testing it against a production
> >> CloudStack environment, and it's working pretty well.
> >>
> >> If you don't mind, I might hack at the code a bit to fill in some
> >> gaps that I'm seeing.  First example is that it assumes http, which
> >> doesn't work in a public deployment where the endpoint is over https.
> >>
> >> -chip

RE: CLI for CloudStack: cloudmonkey

Posted by Rohit Yadav <ro...@citrix.com>.
Not sure what can be the issue if b key is accepted, can you check the values in ~/.cloudmonkey_config against the actual apikey and help debug?
May be try regenerating new keys, as far as parsing is concerned anything after set <cmd><space> is set to the key.

Regards.

________________________________________
From: Sebastien Goasguen [runseb@gmail.com]
Sent: Thursday, November 08, 2012 10:00 PM
To: cloudstack-dev@incubator.apache.org
Subject: Re: CLI for CloudStack: cloudmonkey

Actually it does not work yet.

Now I can type 'b' but it does not get passed properly:

🙉 cloudmonkey> set apiKey KEbkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzjRB9UNrBybVr3kcZ6Q

Gives:

INFO  [cloud.api.ApiServer] (92734721@qtp-1601733969-7:) apiKey does not map to a valid user -- ignoring request, apiKey: KEkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzjRB9UNrByVr3kcZ6Q

On Nov 8, 2012, at 5:19 PM, Sebastien Goasguen <ru...@gmail.com> wrote:

>
> On Nov 8, 2012, at 3:28 PM, Rohit Yadav <ro...@citrix.com> wrote:
>
>> Hi Sebastien,
>>
>> Are you using it from pypi/pip, if so do this:
>> sudo pip uninstall cloudmonkey
>> sudo pip install cloudmonkey
>>
>
> no, I am doing: sudo python ./setup.py install from the source tree
>
>> I've had this bug on mac osx, fixed it:
>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.git;a=commit;h=36e7a7884efef7c41ac369549b7bdb93e5122110
>>
>
> pulled that and reinstalled…and it works.
>
> thanks
>
> -sebastien
>
>
>> If it still persists for you, checkout  http://superuser.com/questions/297527/cant-type-the-b-letter-in-python-shell-in-os-x
>>
>> Let me know if this still fails then.
>>
>> Regards.
>>
>> ________________________________________
>> From: Sebastien Goasguen [runseb@gmail.com]
>> Sent: Thursday, November 08, 2012 5:37 PM
>> To: cloudstack-dev@incubator.apache.org
>> Subject: Re: CLI for CloudStack: cloudmonkey
>>
>> Hi,
>>
>> I am testing the cli and I have the weirdest issue. When I set the apikey or secretkey, the lower case 'b' letter does not print at the prompt.
>> So if my keys contain 'b' they don't work..
>>
>> I tried all the other letters and they work.
>>
>> Anyone seeing this,
>>
>> -Sebastien
>>
>> On Nov 7, 2012, at 7:25 PM, Rohit Yadav <ro...@citrix.com> wrote:
>>
>>> yes, I think I'd mentioned in the thread or somewhere. Just use pip or easy_install (apt-get install python-setuptools on ubuntu, install python2.6 or above and pip if you don't have it);
>>>
>>> sudo pip install cloudmonkey
>>>
>>> or sudo easy_install cloudmonkey
>>>
>>> now start cloudmonkey:
>>> $ cloudmonkey
>>> ...
>>>
>>> Will post a blog/screencast this weekend and update doc so everyone can get help on its usage, though it's pretty intuitive.
>>> ________________________________________
>>> From: Musayev, Ilya [imusayev@webmd.net]
>>> Sent: Wednesday, November 07, 2012 11:41 PM
>>> To: cloudstack-dev@incubator.apache.org
>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>
>>> Rohit,
>>>
>>> Can I get the CLI only without going through the whole source code maven install? Is it part of any RPM?
>>>
>>> Thanks
>>> ilya
>>>
>>> -----Original Message-----
>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>> Sent: Monday, November 05, 2012 11:35 AM
>>> To: cloudstack-dev@incubator.apache.org
>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>
>>> Checkout latest code. Few changes to share:
>>>
>>> - All lowercase now
>>> - Tab tab over verbs to see list of params for that api, example list users <tab><tab>
>>> - This needs improvement but help string, using --help: list user --help
>>> - Caching to speedup runtime
>>> - Color and Parsing fixes
>>>
>>> Last, I'm now able to get the doc strings for each attribute/param, will see this tomorrow.
>>>
>>> Need your help, just incase you want to contribute, these are the TODOs:
>>>
>>> - search over history
>>> - fix parsing
>>> - doc strings for parameters
>>> - testing for various kinds of apis (I'm able to deploy a zone with this, but needs testing)
>>> - unicode char monkey, used in prompt may mess up history searching and text display
>>>
>>>
>>> Regards.
>>>
>>> On 02-Nov-2012, at 4:58 AM, Edison Su <Ed...@citrix.com> wrote:
>>>
>>>>
>>>>
>>>>> -----Original Message-----
>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>> Sent: Thursday, November 01, 2012 2:23 PM
>>>>> To: cloudstack-dev@incubator.apache.org
>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>
>>>>> After you install the tool, so that cloudmonkey is in your
>>>>> /usr/local/bin or in $PATH...
>>>>>
>>>>> Two ways;
>>>>> 1. As command line tool, on bash/zsh, use the BNF grammar; <command
>>>>> line tool
>>>>> name>:<separator>:<verb>:<separator>:<action>:<separator>:<params>
>>>>> <command line tool name>={'cloudmonkey'} <separator>={' '}
>>>>> <verb>={'list', 'create', 'delete', 'update'.... etc.}
>>>>> <action>={'Users'... etc.} <params>={'listall=#'... etc.} So; $
>>>>> cloudmonkey list Users
>>>>
>>>>
>>>> Got it, thanks!
>>>>
>>>>>
>>>>> 2. file redirector:
>>>>>
>>>>> $ cat test-file:
>>>>> list Users
>>>>> list <some other action>
>>>>> <some verb> <some action>
>>>>>
>>>>> $ cloudmonkey < test-file
>>>>>
>>>>> Note, I'll change the actions (Users, VirtualMachine etc.) to
>>>>> lowercase (users, virtualmachine etc.) if that's okay?
>>>>
>>>> Please do, nobody wants to type extra keystroke, if it's not necessary.
>>>>>
>>>>> Regards.
>>>>>
>>>>> ________________________________________
>>>>> From: Edison Su [Edison.su@citrix.com]
>>>>> Sent: Friday, November 02, 2012 1:55 AM
>>>>> To: cloudstack-dev@incubator.apache.org
>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>
>>>>> Oh, it reminds me that how to use the CLI on the bash command line?
>>>>> I think admin may want to call cloudstack API in a bash script, how
>>>>> can I do that?
>>>>>
>>>>>> -----Original Message-----
>>>>>> From: Marcus Sorensen [mailto:shadowsor@gmail.com]
>>>>>> Sent: Thursday, November 01, 2012 1:11 PM
>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>
>>>>>> Yes, I look forward to using it instead of local curl calls on the
>>>>>> command line :-)
>>>>>>
>>>>>> On Thu, Nov 1, 2012 at 2:02 PM, Edison Su <Ed...@citrix.com> wrote:
>>>>>>>
>>>>>>>
>>>>>>>> -----Original Message-----
>>>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>>>> Sent: Thursday, November 01, 2012 11:45 AM
>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>>>
>>>>>>>> Hi Chip, please go ahead if we can fix the http/s issue. The
>>>>>>>> connection is based on marvin, I'm sure using CLI we'll find out
>>>>>>>> more bugs and fix anything in marvin thereby help maintain
>>>>>>>> marvin->tests and
>>>>>> CLI.
>>>>>>>> Please hack that up on tools/marvin/marvin/cloudstackConnection.py
>>>>>>>>
>>>>>>>> Edison, yes I'm working on the completedefault, I've figured a
>>>>>>>> solution to the parsing and tabbing issue to show params for any
>>>>>>>> api and added more verbs to the grammar like deploy, start etc.
>>>>>>>> In the new approach doc strings and params needed for an api are
>>>>>>>> fetched and cached in the class locally to speed up the loading process.
>>>>>>>> Till it gets committed, cloudmonkey (now) will keep telling the
>>>>>>>> user what params they are missing until it gets all the required ones.
>>>>>>>
>>>>>>> Great! Thanks for your awesome CLI, people will like it.
>>>>>>>
>>>>>>>>
>>>>>>>> One more thing, for people who may not have unicode support the
>>>>>>>> prompt may appear weird and history search (up, down ) can mess up
>>>>>>>> the visuals. For example on Mac it appears as a colorful emoji,
>>>>>>>> but I found that it looks weird on other platforms. Will probably
>>>>>>>> remove it, or the user can custom set their prompt, using: set
>>>>>>>> prompt
>>>>>>>> myprompt>
>>>>>>>>
>>>>>>>> Regards.
>>>>>>>> PS. the set command is full of (fun :)  hacks because of
>>>>>>>> funtional/generic programming, it basically can set any attribute
>>>>>>>> on the class, so one can do something like creating something
>>>>>>>> (var, func). For example set ruler # (so instead of - you will
>>>>>>>> have a #
>>>>>>>> separator)
>>>>>>>>
>>>>>>>> ________________________________________
>>>>>>>> From: Chip Childers [chip.childers@sungard.com]
>>>>>>>> Sent: Thursday, November 01, 2012 11:15 PM
>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>>
>>>>>>>> On Wed, Oct 31, 2012 at 2:10 PM, Rohit Yadav
>>>>>>>> <ro...@citrix.com>
>>>>>>>> wrote:
>>>>>>>>> Hi,
>>>>>>>>>
>>>>>>>>> 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:
>>>>>>>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.gi
>>>>>>>>> t; a=c ommit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
>>>>>>>>>
>>>>>>>>> Features:
>>>>>>>>> - 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
>>>>>>>>>
>>>>>>>>> FIXMEs:
>>>>>>>>> - 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 python
>>>>>>>>> cloudmonkey.py
>>>>>>>>>
>>>>>>>>> If you want to have the terminal tool installed; cd tools/cli
>>>>>>>>> python setup.py 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=8.8.8.8 internaldns1=10.147.28.6
>>>>>>>>> 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
>>>>>>>>> networkofferingid= create Pod zoneid= name=Pod1
>>>>>> gateway=10.147.28.1
>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.220 endip=10.147.28.235
>>>>>>>>> create VlanIpRange podid= networkid= gateway=10.147.28.1
>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.236 endip=10.147.28.250
>>>>>>>>> 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=http://10.147.28.60 create
>>>>>>>>> StoragePool zoneid= clusterid= name=NFS1
>>>>>>>>> url=nfs://10.147.28.7/export/home/rohit/primary
>>>>>>>>> add SecondaryStorage zoneId=
>>>>>>>>> url=nfs://10.147.28.7/export/home/rohit/secondary
>>>>>>>>> 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.
>>>>>>>>>
>>>>>>>>> Regards.
>>>>>>>>> PS. Marvin the neglected robot and hipster cloudmonkey should
>>>>>>>>> rule the world :D
>>>>>>>>
>>>>>>>> Rohit,
>>>>>>>>
>>>>>>>> This is really really cool.  It puts the "fun" in managing
>>>>>>>> instances from a command line.  I've been testing it against a
>>>>>>>> production CloudStack environment, and it's working pretty well.
>>>>>>>>
>>>>>>>> If you don't mind, I might hack at the code a bit to fill in some
>>>>>>>> gaps that I'm seeing.  First example is that it assumes http,
>>>>>>>> which doesn't work in a public deployment where the endpoint is over https.
>>>>>>>>
>>>>>>>> -chip
>>>
>>
>


RE: CLI for CloudStack: cloudmonkey

Posted by "Musayev, Ilya" <im...@webmd.net>.
I've just installed and have it running :) awesome

Not a big deal by any means, I have this weird character in front of cloudmonkey prompt, looks like a square with 6 digits - is it by design or some encoding gone wrong?

Thanks
ilya




-----Original Message-----
From: Rohit Yadav [mailto:rohit.yadav@citrix.com] 
Sent: Thursday, November 08, 2012 3:45 PM
To: cloudstack-dev@incubator.apache.org
Subject: RE: CLI for CloudStack: cloudmonkey

Yes, easy_install will work too using sudo easy_install cloudmonkey.
Or, using pip: http://www.pip-installer.org/en/latest/installing.html#using-the-installer

Python 2.5+ should work, if not please report any issues you face with the cli.

Regards.

________________________________________
From: Musayev, Ilya [imusayev@webmd.net]
Sent: Friday, November 09, 2012 1:25 AM
To: cloudstack-dev@incubator.apache.org
Subject: RE: CLI for CloudStack: cloudmonkey

Never mind, I also have easy_install, I'll try that route...

Thanks


-----Original Message-----
From: Musayev, Ilya [mailto:imusayev@webmd.net]
Sent: Thursday, November 08, 2012 2:53 PM
To: cloudstack-dev@incubator.apache.org
Subject: RE: CLI for CloudStack: cloudmonkey

So pip comes with python 2.7 which is not available by default on CentOS 6.3

Any other method I could use, other than installing python 2.7?

Thanks
ilya

-----Original Message-----
From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
Sent: Thursday, November 08, 2012 2:14 PM
To: cloudstack-dev@incubator.apache.org
Subject: RE: CLI for CloudStack: cloudmonkey

Oh, forgot to see that. Yes, now all the cmds are lowercase (except for few params liks isAsync=) and tab completion is advised.

Regards.
________________________________________
From: Kishan Kavala [Kishan.Kavala@citrix.com]
Sent: Thursday, November 08, 2012 11:29 PM
To: cloudstack-dev@incubator.apache.org
Cc: cloudstack-dev@incubator.apache.org
Subject: Re: CLI for CloudStack: cloudmonkey

Sebastian,
  Try set apikey in lower case. Same with set secretkey.

~kishan

On 08-Nov-2012, at 10:00 PM, "Sebastien Goasguen" <ru...@gmail.com> wrote:

> Actually it does not work yet.
>
> Now I can type 'b' but it does not get passed properly:
>
> 🙉 cloudmonkey> set apiKey
> KEbkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzjR
> B9UNrBybVr3kcZ6Q
>
> Gives:
>
> INFO  [cloud.api.ApiServer] (92734721@qtp-1601733969-7:) apiKey does 
> not map to a valid user -- ignoring request, apiKey:
> KEkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzjRB
> 9UNrByVr3kcZ6Q
>
> On Nov 8, 2012, at 5:19 PM, Sebastien Goasguen <ru...@gmail.com> wrote:
>
>>
>> On Nov 8, 2012, at 3:28 PM, Rohit Yadav <ro...@citrix.com> wrote:
>>
>>> Hi Sebastien,
>>>
>>> Are you using it from pypi/pip, if so do this:
>>> sudo pip uninstall cloudmonkey
>>> sudo pip install cloudmonkey
>>
>> no, I am doing: sudo python ./setup.py install from the source tree
>>
>>> I've had this bug on mac osx, fixed it:
>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.git;a
>>> =commit;h=36e7a7884efef7c41ac369549b7bdb93e5122110
>>
>> pulled that and reinstalled…and it works.
>>
>> thanks
>>
>> -sebastien
>>
>>
>>> If it still persists for you, checkout 
>>> http://superuser.com/questions/297527/cant-type-the-b-letter-in-pyth
>>> on-shell-in-os-x
>>>
>>> Let me know if this still fails then.
>>>
>>> Regards.
>>>
>>> ________________________________________
>>> From: Sebastien Goasguen [runseb@gmail.com]
>>> Sent: Thursday, November 08, 2012 5:37 PM
>>> To: cloudstack-dev@incubator.apache.org
>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>
>>> Hi,
>>>
>>> I am testing the cli and I have the weirdest issue. When I set the apikey or secretkey, the lower case 'b' letter does not print at the prompt.
>>> So if my keys contain 'b' they don't work..
>>>
>>> I tried all the other letters and they work.
>>>
>>> Anyone seeing this,
>>>
>>> -Sebastien
>>>
>>> On Nov 7, 2012, at 7:25 PM, Rohit Yadav <ro...@citrix.com> wrote:
>>>
>>>> yes, I think I'd mentioned in the thread or somewhere. Just use pip 
>>>> or easy_install (apt-get install python-setuptools on ubuntu, 
>>>> install python2.6 or above and pip if you don't have it);
>>>>
>>>> sudo pip install cloudmonkey
>>>>
>>>> or sudo easy_install cloudmonkey
>>>>
>>>> now start cloudmonkey:
>>>> $ cloudmonkey
>>>> ...
>>>>
>>>> Will post a blog/screencast this weekend and update doc so everyone can get help on its usage, though it's pretty intuitive.
>>>> ________________________________________
>>>> From: Musayev, Ilya [imusayev@webmd.net]
>>>> Sent: Wednesday, November 07, 2012 11:41 PM
>>>> To: cloudstack-dev@incubator.apache.org
>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>
>>>> Rohit,
>>>>
>>>> Can I get the CLI only without going through the whole source code maven install? Is it part of any RPM?
>>>>
>>>> Thanks
>>>> ilya
>>>>
>>>> -----Original Message-----
>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>> Sent: Monday, November 05, 2012 11:35 AM
>>>> To: cloudstack-dev@incubator.apache.org
>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>
>>>> Checkout latest code. Few changes to share:
>>>>
>>>> - All lowercase now
>>>> - Tab tab over verbs to see list of params for that api, example 
>>>> list users <tab><tab>
>>>> - This needs improvement but help string, using --help: list user 
>>>> --help
>>>> - Caching to speedup runtime
>>>> - Color and Parsing fixes
>>>>
>>>> Last, I'm now able to get the doc strings for each attribute/param, will see this tomorrow.
>>>>
>>>> Need your help, just incase you want to contribute, these are the TODOs:
>>>>
>>>> - search over history
>>>> - fix parsing
>>>> - doc strings for parameters
>>>> - testing for various kinds of apis (I'm able to deploy a zone with 
>>>> this, but needs testing)
>>>> - unicode char monkey, used in prompt may mess up history searching 
>>>> and text display
>>>>
>>>>
>>>> Regards.
>>>>
>>>> On 02-Nov-2012, at 4:58 AM, Edison Su <Ed...@citrix.com> wrote:
>>>>
>>>>>
>>>>>
>>>>>> -----Original Message-----
>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>> Sent: Thursday, November 01, 2012 2:23 PM
>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>
>>>>>> After you install the tool, so that cloudmonkey is in your 
>>>>>> /usr/local/bin or in $PATH...
>>>>>>
>>>>>> Two ways;
>>>>>> 1. As command line tool, on bash/zsh, use the BNF grammar; 
>>>>>> <command line tool
>>>>>> name>:<separator>:<verb>:<separator>:<action>:<separator>:<params
>>>>>> name>>
>>>>>> <command line tool name>={'cloudmonkey'} <separator>={' '} 
>>>>>> <verb>={'list', 'create', 'delete', 'update'.... etc.} 
>>>>>> <action>={'Users'... etc.} <params>={'listall=#'... etc.} So; $ 
>>>>>> cloudmonkey list Users
>>>>>
>>>>>
>>>>> Got it, thanks!
>>>>>
>>>>>>
>>>>>> 2. file redirector:
>>>>>>
>>>>>> $ cat test-file:
>>>>>> list Users
>>>>>> list <some other action>
>>>>>> <some verb> <some action>
>>>>>>
>>>>>> $ cloudmonkey < test-file
>>>>>>
>>>>>> Note, I'll change the actions (Users, VirtualMachine etc.) to 
>>>>>> lowercase (users, virtualmachine etc.) if that's okay?
>>>>>
>>>>> Please do, nobody wants to type extra keystroke, if it's not necessary.
>>>>>>
>>>>>> Regards.
>>>>>>
>>>>>> ________________________________________
>>>>>> From: Edison Su [Edison.su@citrix.com]
>>>>>> Sent: Friday, November 02, 2012 1:55 AM
>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>
>>>>>> Oh, it reminds me that how to use the CLI on the bash command line?
>>>>>> I think admin may want to call cloudstack API in a bash script, 
>>>>>> how can I do that?
>>>>>>
>>>>>>> -----Original Message-----
>>>>>>> From: Marcus Sorensen [mailto:shadowsor@gmail.com]
>>>>>>> Sent: Thursday, November 01, 2012 1:11 PM
>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>
>>>>>>> Yes, I look forward to using it instead of local curl calls on 
>>>>>>> the command line :-)
>>>>>>>
>>>>>>> On Thu, Nov 1, 2012 at 2:02 PM, Edison Su <Ed...@citrix.com> wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>> -----Original Message-----
>>>>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>>>>> Sent: Thursday, November 01, 2012 11:45 AM
>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>>>>
>>>>>>>>> Hi Chip, please go ahead if we can fix the http/s issue. The 
>>>>>>>>> connection is based on marvin, I'm sure using CLI we'll find 
>>>>>>>>> out more bugs and fix anything in marvin thereby help maintain
>>>>>>>>> marvin->tests and
>>>>>>> CLI.
>>>>>>>>> Please hack that up on
>>>>>>>>> tools/marvin/marvin/cloudstackConnection.py
>>>>>>>>>
>>>>>>>>> Edison, yes I'm working on the completedefault, I've figured a 
>>>>>>>>> solution to the parsing and tabbing issue to show params for 
>>>>>>>>> any api and added more verbs to the grammar like deploy, start etc.
>>>>>>>>> In the new approach doc strings and params needed for an api 
>>>>>>>>> are fetched and cached in the class locally to speed up the loading process.
>>>>>>>>> Till it gets committed, cloudmonkey (now) will keep telling 
>>>>>>>>> the user what params they are missing until it gets all the required ones.
>>>>>>>>
>>>>>>>> Great! Thanks for your awesome CLI, people will like it.
>>>>>>>>
>>>>>>>>>
>>>>>>>>> One more thing, for people who may not have unicode support 
>>>>>>>>> the prompt may appear weird and history search (up, down ) can 
>>>>>>>>> mess up the visuals. For example on Mac it appears as a 
>>>>>>>>> colorful emoji, but I found that it looks weird on other 
>>>>>>>>> platforms. Will probably remove it, or the user can custom set 
>>>>>>>>> their prompt, using: set prompt
>>>>>>>>> myprompt>
>>>>>>>>>
>>>>>>>>> Regards.
>>>>>>>>> PS. the set command is full of (fun :)  hacks because of 
>>>>>>>>> funtional/generic programming, it basically can set any 
>>>>>>>>> attribute on the class, so one can do something like creating 
>>>>>>>>> something (var, func). For example set ruler # (so instead of
>>>>>>>>> - you will have a #
>>>>>>>>> separator)
>>>>>>>>>
>>>>>>>>> ________________________________________
>>>>>>>>> From: Chip Childers [chip.childers@sungard.com]
>>>>>>>>> Sent: Thursday, November 01, 2012 11:15 PM
>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>>>
>>>>>>>>> On Wed, Oct 31, 2012 at 2:10 PM, Rohit Yadav 
>>>>>>>>> <ro...@citrix.com>
>>>>>>>>> wrote:
>>>>>>>>>> Hi,
>>>>>>>>>>
>>>>>>>>>> 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:
>>>>>>>>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstac
>>>>>>>>>> k.gi t; a=c ommit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
>>>>>>>>>>
>>>>>>>>>> Features:
>>>>>>>>>> - 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
>>>>>>>>>>
>>>>>>>>>> FIXMEs:
>>>>>>>>>> - 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 python cloudmonkey.py
>>>>>>>>>>
>>>>>>>>>> If you want to have the terminal tool installed; cd tools/cli 
>>>>>>>>>> python setup.py 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=8.8.8.8 internaldns1=10.147.28.6
>>>>>>>>>> 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
>>>>>>>>>> networkofferingid= create Pod zoneid= name=Pod1
>>>>>>> gateway=10.147.28.1
>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.220
>>>>>>>>>> endip=10.147.28.235 create VlanIpRange podid= networkid=
>>>>>>>>>> gateway=10.147.28.1
>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.236
>>>>>>>>>> endip=10.147.28.250 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=http://10.147.28.60 create StoragePool zoneid= clusterid=
>>>>>>>>>> name=NFS1 url=nfs://10.147.28.7/export/home/rohit/primary
>>>>>>>>>> add SecondaryStorage zoneId=
>>>>>>>>>> url=nfs://10.147.28.7/export/home/rohit/secondary
>>>>>>>>>> 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.
>>>>>>>>>>
>>>>>>>>>> Regards.
>>>>>>>>>> PS. Marvin the neglected robot and hipster cloudmonkey should 
>>>>>>>>>> rule the world :D
>>>>>>>>>
>>>>>>>>> Rohit,
>>>>>>>>>
>>>>>>>>> This is really really cool.  It puts the "fun" in managing 
>>>>>>>>> instances from a command line.  I've been testing it against a 
>>>>>>>>> production CloudStack environment, and it's working pretty well.
>>>>>>>>>
>>>>>>>>> If you don't mind, I might hack at the code a bit to fill in 
>>>>>>>>> some gaps that I'm seeing.  First example is that it assumes 
>>>>>>>>> http, which doesn't work in a public deployment where the endpoint is over https.
>>>>>>>>>
>>>>>>>>> -chip
>

RE: CLI for CloudStack: cloudmonkey

Posted by Rohit Yadav <ro...@citrix.com>.
Thanks Ilya, to answer you:

1. Your terminal does not support unicode probably so you see the weird char which is a unicode monkey char. You may change the prompt using:
 set prompt mycloudpromt>
2. The urllib error is not well handled in connection class in marvin, this needs to be fixed in marvin, please open an issue?
3. For object separating, I agree the visual/output should be fixed. should be have a newline, I'm not sure about 2 dashed line, you can do this: set ruler = (so the separator is =, sort of two dashed lines)
Right now there is a ruler (- char) which is printed in color green (to disable color: set color false, to enable: set color true).
You can also grep or pipe through your commands within the cli using '|':
list accounts | more
list networkofferingids | grep id

Regards.

________________________________________
From: Musayev, Ilya [imusayev@webmd.net]
Sent: Friday, November 09, 2012 5:21 AM
To: cloudstack-dev@incubator.apache.org
Subject: RE: CLI for CloudStack: cloudmonkey

One more enhancement request, when going through each large object (for example network or networkoffering), maybe we can add 2 dashed lines or something else - so user knows where new object begins and previous one - ends.

Thanks
ilya

-----Original Message-----
From: Musayev, Ilya [mailto:imusayev@webmd.net]
Sent: Thursday, November 08, 2012 6:44 PM
To: cloudstack-dev@incubator.apache.org
Subject: RE: CLI for CloudStack: cloudmonkey

Rohit

This would be an enhacement request, can we have cloudmonkey don’t terminate if object is not found..

Below is the example of what just happened:

🐵 cloudmonkey> list networkofferings id=5834b1f0-2305-4ee6-ab31-880e5d615a90
Traceback (most recent call last):
  File "/usr/bin/cloudmonkey", line 9, in <module>
    load_entry_point('cloudmonkey==0.0.4', 'console_scripts', 'cloudmonkey')()
  File "/usr/lib/python2.6/site-packages/cloudmonkey-0.0.4-py2.6.egg/cloudmonkey/cloudmonkey.py", line 450, in main
    shell.cmdloop()
  File "/usr/lib64/python2.6/cmd.py", line 142, in cmdloop
    stop = self.onecmd(line)
  File "/usr/lib64/python2.6/cmd.py", line 219, in onecmd
    return func(arg)
  File "/usr/lib/python2.6/site-packages/cloudmonkey-0.0.4-py2.6.egg/cloudmonkey/cloudmonkey.py", line 437, in grammar_closure
    self.default(res[0] + " " + args_partition[2])
  File "/usr/lib/python2.6/site-packages/cloudmonkey-0.0.4-py2.6.egg/cloudmonkey/cloudmonkey.py", line 249, in default
    result = self.make_request(command, response)
  File "/usr/lib/python2.6/site-packages/cloudmonkey-0.0.4-py2.6.egg/cloudmonkey/cloudmonkey.py", line 210, in make_request
    response = conn.make_request(command, requests)
  File "/usr/lib/python2.6/site-packages/cloudmonkey-0.0.4-py2.6.egg/cloudmonkey/marvin/cloudstackConnection.py", line 171, in make_request
    result = self.make_request_without_auth(commandName, requests)
  File "/usr/lib/python2.6/site-packages/cloudmonkey-0.0.4-py2.6.egg/cloudmonkey/marvin/cloudstackConnection.py", line 102, in make_request_without_auth
    self.connection = urllib2.urlopen("http://%s:%d/client/api?%s"%(self.mgtSvr, self.port, requestUrl))
  File "/usr/lib64/python2.6/urllib2.py", line 126, in urlopen
    return _opener.open(url, data, timeout)
  File "/usr/lib64/python2.6/urllib2.py", line 397, in open
    response = meth(req, response)
  File "/usr/lib64/python2.6/urllib2.py", line 510, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib64/python2.6/urllib2.py", line 435, in error
    return self._call_chain(*args)
  File "/usr/lib64/python2.6/urllib2.py", line 369, in _call_chain
    result = func(*args)
  File "/usr/lib64/python2.6/urllib2.py", line 518, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 431: Unable to execute API command listnetworkofferings due to invalid value. Object network_offerings(uuid: 5834b1f0-2305-4ee6-ab31-880e5d615a90) does not exist.
# back to bash prompt...

Thanks
ilya
-----Original Message-----
From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
Sent: Thursday, November 08, 2012 3:45 PM
To: cloudstack-dev@incubator.apache.org
Subject: RE: CLI for CloudStack: cloudmonkey

Yes, easy_install will work too using sudo easy_install cloudmonkey.
Or, using pip: http://www.pip-installer.org/en/latest/installing.html#using-the-installer

Python 2.5+ should work, if not please report any issues you face with the cli.

Regards.

________________________________________
From: Musayev, Ilya [imusayev@webmd.net]
Sent: Friday, November 09, 2012 1:25 AM
To: cloudstack-dev@incubator.apache.org
Subject: RE: CLI for CloudStack: cloudmonkey

Never mind, I also have easy_install, I'll try that route...

Thanks


-----Original Message-----
From: Musayev, Ilya [mailto:imusayev@webmd.net]
Sent: Thursday, November 08, 2012 2:53 PM
To: cloudstack-dev@incubator.apache.org
Subject: RE: CLI for CloudStack: cloudmonkey

So pip comes with python 2.7 which is not available by default on CentOS 6.3

Any other method I could use, other than installing python 2.7?

Thanks
ilya

-----Original Message-----
From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
Sent: Thursday, November 08, 2012 2:14 PM
To: cloudstack-dev@incubator.apache.org
Subject: RE: CLI for CloudStack: cloudmonkey

Oh, forgot to see that. Yes, now all the cmds are lowercase (except for few params liks isAsync=) and tab completion is advised.

Regards.
________________________________________
From: Kishan Kavala [Kishan.Kavala@citrix.com]
Sent: Thursday, November 08, 2012 11:29 PM
To: cloudstack-dev@incubator.apache.org
Cc: cloudstack-dev@incubator.apache.org
Subject: Re: CLI for CloudStack: cloudmonkey

Sebastian,
  Try set apikey in lower case. Same with set secretkey.

~kishan

On 08-Nov-2012, at 10:00 PM, "Sebastien Goasguen" <ru...@gmail.com> wrote:

> Actually it does not work yet.
>
> Now I can type 'b' but it does not get passed properly:
>
> 🙉 cloudmonkey> set apiKey
> KEbkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzjR
> B9UNrBybVr3kcZ6Q
>
> Gives:
>
> INFO  [cloud.api.ApiServer] (92734721@qtp-1601733969-7:) apiKey does
> not map to a valid user -- ignoring request, apiKey:
> KEkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzjRB
> 9UNrByVr3kcZ6Q
>
> On Nov 8, 2012, at 5:19 PM, Sebastien Goasguen <ru...@gmail.com> wrote:
>
>>
>> On Nov 8, 2012, at 3:28 PM, Rohit Yadav <ro...@citrix.com> wrote:
>>
>>> Hi Sebastien,
>>>
>>> Are you using it from pypi/pip, if so do this:
>>> sudo pip uninstall cloudmonkey
>>> sudo pip install cloudmonkey
>>
>> no, I am doing: sudo python ./setup.py install from the source tree
>>
>>> I've had this bug on mac osx, fixed it:
>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.git;a
>>> =commit;h=36e7a7884efef7c41ac369549b7bdb93e5122110
>>
>> pulled that and reinstalled…and it works.
>>
>> thanks
>>
>> -sebastien
>>
>>
>>> If it still persists for you, checkout
>>> http://superuser.com/questions/297527/cant-type-the-b-letter-in-pyth
>>> on-shell-in-os-x
>>>
>>> Let me know if this still fails then.
>>>
>>> Regards.
>>>
>>> ________________________________________
>>> From: Sebastien Goasguen [runseb@gmail.com]
>>> Sent: Thursday, November 08, 2012 5:37 PM
>>> To: cloudstack-dev@incubator.apache.org
>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>
>>> Hi,
>>>
>>> I am testing the cli and I have the weirdest issue. When I set the apikey or secretkey, the lower case 'b' letter does not print at the prompt.
>>> So if my keys contain 'b' they don't work..
>>>
>>> I tried all the other letters and they work.
>>>
>>> Anyone seeing this,
>>>
>>> -Sebastien
>>>
>>> On Nov 7, 2012, at 7:25 PM, Rohit Yadav <ro...@citrix.com> wrote:
>>>
>>>> yes, I think I'd mentioned in the thread or somewhere. Just use pip
>>>> or easy_install (apt-get install python-setuptools on ubuntu,
>>>> install python2.6 or above and pip if you don't have it);
>>>>
>>>> sudo pip install cloudmonkey
>>>>
>>>> or sudo easy_install cloudmonkey
>>>>
>>>> now start cloudmonkey:
>>>> $ cloudmonkey
>>>> ...
>>>>
>>>> Will post a blog/screencast this weekend and update doc so everyone can get help on its usage, though it's pretty intuitive.
>>>> ________________________________________
>>>> From: Musayev, Ilya [imusayev@webmd.net]
>>>> Sent: Wednesday, November 07, 2012 11:41 PM
>>>> To: cloudstack-dev@incubator.apache.org
>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>
>>>> Rohit,
>>>>
>>>> Can I get the CLI only without going through the whole source code maven install? Is it part of any RPM?
>>>>
>>>> Thanks
>>>> ilya
>>>>
>>>> -----Original Message-----
>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>> Sent: Monday, November 05, 2012 11:35 AM
>>>> To: cloudstack-dev@incubator.apache.org
>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>
>>>> Checkout latest code. Few changes to share:
>>>>
>>>> - All lowercase now
>>>> - Tab tab over verbs to see list of params for that api, example
>>>> list users <tab><tab>
>>>> - This needs improvement but help string, using --help: list user
>>>> --help
>>>> - Caching to speedup runtime
>>>> - Color and Parsing fixes
>>>>
>>>> Last, I'm now able to get the doc strings for each attribute/param, will see this tomorrow.
>>>>
>>>> Need your help, just incase you want to contribute, these are the TODOs:
>>>>
>>>> - search over history
>>>> - fix parsing
>>>> - doc strings for parameters
>>>> - testing for various kinds of apis (I'm able to deploy a zone with
>>>> this, but needs testing)
>>>> - unicode char monkey, used in prompt may mess up history searching
>>>> and text display
>>>>
>>>>
>>>> Regards.
>>>>
>>>> On 02-Nov-2012, at 4:58 AM, Edison Su <Ed...@citrix.com> wrote:
>>>>
>>>>>
>>>>>
>>>>>> -----Original Message-----
>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>> Sent: Thursday, November 01, 2012 2:23 PM
>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>
>>>>>> After you install the tool, so that cloudmonkey is in your
>>>>>> /usr/local/bin or in $PATH...
>>>>>>
>>>>>> Two ways;
>>>>>> 1. As command line tool, on bash/zsh, use the BNF grammar;
>>>>>> <command line tool
>>>>>> name>:<separator>:<verb>:<separator>:<action>:<separator>:<params
>>>>>> name>>
>>>>>> <command line tool name>={'cloudmonkey'} <separator>={' '}
>>>>>> <verb>={'list', 'create', 'delete', 'update'.... etc.}
>>>>>> <action>={'Users'... etc.} <params>={'listall=#'... etc.} So; $
>>>>>> cloudmonkey list Users
>>>>>
>>>>>
>>>>> Got it, thanks!
>>>>>
>>>>>>
>>>>>> 2. file redirector:
>>>>>>
>>>>>> $ cat test-file:
>>>>>> list Users
>>>>>> list <some other action>
>>>>>> <some verb> <some action>
>>>>>>
>>>>>> $ cloudmonkey < test-file
>>>>>>
>>>>>> Note, I'll change the actions (Users, VirtualMachine etc.) to
>>>>>> lowercase (users, virtualmachine etc.) if that's okay?
>>>>>
>>>>> Please do, nobody wants to type extra keystroke, if it's not necessary.
>>>>>>
>>>>>> Regards.
>>>>>>
>>>>>> ________________________________________
>>>>>> From: Edison Su [Edison.su@citrix.com]
>>>>>> Sent: Friday, November 02, 2012 1:55 AM
>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>
>>>>>> Oh, it reminds me that how to use the CLI on the bash command line?
>>>>>> I think admin may want to call cloudstack API in a bash script,
>>>>>> how can I do that?
>>>>>>
>>>>>>> -----Original Message-----
>>>>>>> From: Marcus Sorensen [mailto:shadowsor@gmail.com]
>>>>>>> Sent: Thursday, November 01, 2012 1:11 PM
>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>
>>>>>>> Yes, I look forward to using it instead of local curl calls on
>>>>>>> the command line :-)
>>>>>>>
>>>>>>> On Thu, Nov 1, 2012 at 2:02 PM, Edison Su <Ed...@citrix.com> wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>> -----Original Message-----
>>>>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>>>>> Sent: Thursday, November 01, 2012 11:45 AM
>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>>>>
>>>>>>>>> Hi Chip, please go ahead if we can fix the http/s issue. The
>>>>>>>>> connection is based on marvin, I'm sure using CLI we'll find
>>>>>>>>> out more bugs and fix anything in marvin thereby help maintain
>>>>>>>>> marvin->tests and
>>>>>>> CLI.
>>>>>>>>> Please hack that up on
>>>>>>>>> tools/marvin/marvin/cloudstackConnection.py
>>>>>>>>>
>>>>>>>>> Edison, yes I'm working on the completedefault, I've figured a
>>>>>>>>> solution to the parsing and tabbing issue to show params for
>>>>>>>>> any api and added more verbs to the grammar like deploy, start etc.
>>>>>>>>> In the new approach doc strings and params needed for an api
>>>>>>>>> are fetched and cached in the class locally to speed up the loading process.
>>>>>>>>> Till it gets committed, cloudmonkey (now) will keep telling
>>>>>>>>> the user what params they are missing until it gets all the required ones.
>>>>>>>>
>>>>>>>> Great! Thanks for your awesome CLI, people will like it.
>>>>>>>>
>>>>>>>>>
>>>>>>>>> One more thing, for people who may not have unicode support
>>>>>>>>> the prompt may appear weird and history search (up, down ) can
>>>>>>>>> mess up the visuals. For example on Mac it appears as a
>>>>>>>>> colorful emoji, but I found that it looks weird on other
>>>>>>>>> platforms. Will probably remove it, or the user can custom set
>>>>>>>>> their prompt, using: set prompt
>>>>>>>>> myprompt>
>>>>>>>>>
>>>>>>>>> Regards.
>>>>>>>>> PS. the set command is full of (fun :)  hacks because of
>>>>>>>>> funtional/generic programming, it basically can set any
>>>>>>>>> attribute on the class, so one can do something like creating
>>>>>>>>> something (var, func). For example set ruler # (so instead of
>>>>>>>>> - you will have a #
>>>>>>>>> separator)
>>>>>>>>>
>>>>>>>>> ________________________________________
>>>>>>>>> From: Chip Childers [chip.childers@sungard.com]
>>>>>>>>> Sent: Thursday, November 01, 2012 11:15 PM
>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>>>
>>>>>>>>> On Wed, Oct 31, 2012 at 2:10 PM, Rohit Yadav
>>>>>>>>> <ro...@citrix.com>
>>>>>>>>> wrote:
>>>>>>>>>> Hi,
>>>>>>>>>>
>>>>>>>>>> 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:
>>>>>>>>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstac
>>>>>>>>>> k.gi t; a=c ommit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
>>>>>>>>>>
>>>>>>>>>> Features:
>>>>>>>>>> - 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
>>>>>>>>>>
>>>>>>>>>> FIXMEs:
>>>>>>>>>> - 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 python cloudmonkey.py
>>>>>>>>>>
>>>>>>>>>> If you want to have the terminal tool installed; cd tools/cli
>>>>>>>>>> python setup.py 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=8.8.8.8 internaldns1=10.147.28.6
>>>>>>>>>> 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
>>>>>>>>>> networkofferingid= create Pod zoneid= name=Pod1
>>>>>>> gateway=10.147.28.1
>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.220
>>>>>>>>>> endip=10.147.28.235 create VlanIpRange podid= networkid=
>>>>>>>>>> gateway=10.147.28.1
>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.236
>>>>>>>>>> endip=10.147.28.250 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=http://10.147.28.60 create StoragePool zoneid= clusterid=
>>>>>>>>>> name=NFS1 url=nfs://10.147.28.7/export/home/rohit/primary
>>>>>>>>>> add SecondaryStorage zoneId=
>>>>>>>>>> url=nfs://10.147.28.7/export/home/rohit/secondary
>>>>>>>>>> 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.
>>>>>>>>>>
>>>>>>>>>> Regards.
>>>>>>>>>> PS. Marvin the neglected robot and hipster cloudmonkey should
>>>>>>>>>> rule the world :D
>>>>>>>>>
>>>>>>>>> Rohit,
>>>>>>>>>
>>>>>>>>> This is really really cool.  It puts the "fun" in managing
>>>>>>>>> instances from a command line.  I've been testing it against a
>>>>>>>>> production CloudStack environment, and it's working pretty well.
>>>>>>>>>
>>>>>>>>> If you don't mind, I might hack at the code a bit to fill in
>>>>>>>>> some gaps that I'm seeing.  First example is that it assumes
>>>>>>>>> http, which doesn't work in a public deployment where the endpoint is over https.
>>>>>>>>>
>>>>>>>>> -chip
>

RE: CLI for CloudStack: cloudmonkey

Posted by "Musayev, Ilya" <im...@webmd.net>.
One more enhancement request, when going through each large object (for example network or networkoffering), maybe we can add 2 dashed lines or something else - so user knows where new object begins and previous one - ends.

Thanks
ilya

-----Original Message-----
From: Musayev, Ilya [mailto:imusayev@webmd.net] 
Sent: Thursday, November 08, 2012 6:44 PM
To: cloudstack-dev@incubator.apache.org
Subject: RE: CLI for CloudStack: cloudmonkey

Rohit

This would be an enhacement request, can we have cloudmonkey don’t terminate if object is not found..

Below is the example of what just happened:

🐵 cloudmonkey> list networkofferings id=5834b1f0-2305-4ee6-ab31-880e5d615a90
Traceback (most recent call last):
  File "/usr/bin/cloudmonkey", line 9, in <module>
    load_entry_point('cloudmonkey==0.0.4', 'console_scripts', 'cloudmonkey')()
  File "/usr/lib/python2.6/site-packages/cloudmonkey-0.0.4-py2.6.egg/cloudmonkey/cloudmonkey.py", line 450, in main
    shell.cmdloop()
  File "/usr/lib64/python2.6/cmd.py", line 142, in cmdloop
    stop = self.onecmd(line)
  File "/usr/lib64/python2.6/cmd.py", line 219, in onecmd
    return func(arg)
  File "/usr/lib/python2.6/site-packages/cloudmonkey-0.0.4-py2.6.egg/cloudmonkey/cloudmonkey.py", line 437, in grammar_closure
    self.default(res[0] + " " + args_partition[2])
  File "/usr/lib/python2.6/site-packages/cloudmonkey-0.0.4-py2.6.egg/cloudmonkey/cloudmonkey.py", line 249, in default
    result = self.make_request(command, response)
  File "/usr/lib/python2.6/site-packages/cloudmonkey-0.0.4-py2.6.egg/cloudmonkey/cloudmonkey.py", line 210, in make_request
    response = conn.make_request(command, requests)
  File "/usr/lib/python2.6/site-packages/cloudmonkey-0.0.4-py2.6.egg/cloudmonkey/marvin/cloudstackConnection.py", line 171, in make_request
    result = self.make_request_without_auth(commandName, requests)
  File "/usr/lib/python2.6/site-packages/cloudmonkey-0.0.4-py2.6.egg/cloudmonkey/marvin/cloudstackConnection.py", line 102, in make_request_without_auth
    self.connection = urllib2.urlopen("http://%s:%d/client/api?%s"%(self.mgtSvr, self.port, requestUrl))
  File "/usr/lib64/python2.6/urllib2.py", line 126, in urlopen
    return _opener.open(url, data, timeout)
  File "/usr/lib64/python2.6/urllib2.py", line 397, in open
    response = meth(req, response)
  File "/usr/lib64/python2.6/urllib2.py", line 510, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib64/python2.6/urllib2.py", line 435, in error
    return self._call_chain(*args)
  File "/usr/lib64/python2.6/urllib2.py", line 369, in _call_chain
    result = func(*args)
  File "/usr/lib64/python2.6/urllib2.py", line 518, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 431: Unable to execute API command listnetworkofferings due to invalid value. Object network_offerings(uuid: 5834b1f0-2305-4ee6-ab31-880e5d615a90) does not exist.
# back to bash prompt... 

Thanks
ilya
-----Original Message-----
From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
Sent: Thursday, November 08, 2012 3:45 PM
To: cloudstack-dev@incubator.apache.org
Subject: RE: CLI for CloudStack: cloudmonkey

Yes, easy_install will work too using sudo easy_install cloudmonkey.
Or, using pip: http://www.pip-installer.org/en/latest/installing.html#using-the-installer

Python 2.5+ should work, if not please report any issues you face with the cli.

Regards.

________________________________________
From: Musayev, Ilya [imusayev@webmd.net]
Sent: Friday, November 09, 2012 1:25 AM
To: cloudstack-dev@incubator.apache.org
Subject: RE: CLI for CloudStack: cloudmonkey

Never mind, I also have easy_install, I'll try that route...

Thanks


-----Original Message-----
From: Musayev, Ilya [mailto:imusayev@webmd.net]
Sent: Thursday, November 08, 2012 2:53 PM
To: cloudstack-dev@incubator.apache.org
Subject: RE: CLI for CloudStack: cloudmonkey

So pip comes with python 2.7 which is not available by default on CentOS 6.3

Any other method I could use, other than installing python 2.7?

Thanks
ilya

-----Original Message-----
From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
Sent: Thursday, November 08, 2012 2:14 PM
To: cloudstack-dev@incubator.apache.org
Subject: RE: CLI for CloudStack: cloudmonkey

Oh, forgot to see that. Yes, now all the cmds are lowercase (except for few params liks isAsync=) and tab completion is advised.

Regards.
________________________________________
From: Kishan Kavala [Kishan.Kavala@citrix.com]
Sent: Thursday, November 08, 2012 11:29 PM
To: cloudstack-dev@incubator.apache.org
Cc: cloudstack-dev@incubator.apache.org
Subject: Re: CLI for CloudStack: cloudmonkey

Sebastian,
  Try set apikey in lower case. Same with set secretkey.

~kishan

On 08-Nov-2012, at 10:00 PM, "Sebastien Goasguen" <ru...@gmail.com> wrote:

> Actually it does not work yet.
>
> Now I can type 'b' but it does not get passed properly:
>
> 🙉 cloudmonkey> set apiKey
> KEbkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzjR
> B9UNrBybVr3kcZ6Q
>
> Gives:
>
> INFO  [cloud.api.ApiServer] (92734721@qtp-1601733969-7:) apiKey does 
> not map to a valid user -- ignoring request, apiKey:
> KEkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzjRB
> 9UNrByVr3kcZ6Q
>
> On Nov 8, 2012, at 5:19 PM, Sebastien Goasguen <ru...@gmail.com> wrote:
>
>>
>> On Nov 8, 2012, at 3:28 PM, Rohit Yadav <ro...@citrix.com> wrote:
>>
>>> Hi Sebastien,
>>>
>>> Are you using it from pypi/pip, if so do this:
>>> sudo pip uninstall cloudmonkey
>>> sudo pip install cloudmonkey
>>
>> no, I am doing: sudo python ./setup.py install from the source tree
>>
>>> I've had this bug on mac osx, fixed it:
>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.git;a
>>> =commit;h=36e7a7884efef7c41ac369549b7bdb93e5122110
>>
>> pulled that and reinstalled…and it works.
>>
>> thanks
>>
>> -sebastien
>>
>>
>>> If it still persists for you, checkout 
>>> http://superuser.com/questions/297527/cant-type-the-b-letter-in-pyth
>>> on-shell-in-os-x
>>>
>>> Let me know if this still fails then.
>>>
>>> Regards.
>>>
>>> ________________________________________
>>> From: Sebastien Goasguen [runseb@gmail.com]
>>> Sent: Thursday, November 08, 2012 5:37 PM
>>> To: cloudstack-dev@incubator.apache.org
>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>
>>> Hi,
>>>
>>> I am testing the cli and I have the weirdest issue. When I set the apikey or secretkey, the lower case 'b' letter does not print at the prompt.
>>> So if my keys contain 'b' they don't work..
>>>
>>> I tried all the other letters and they work.
>>>
>>> Anyone seeing this,
>>>
>>> -Sebastien
>>>
>>> On Nov 7, 2012, at 7:25 PM, Rohit Yadav <ro...@citrix.com> wrote:
>>>
>>>> yes, I think I'd mentioned in the thread or somewhere. Just use pip 
>>>> or easy_install (apt-get install python-setuptools on ubuntu, 
>>>> install python2.6 or above and pip if you don't have it);
>>>>
>>>> sudo pip install cloudmonkey
>>>>
>>>> or sudo easy_install cloudmonkey
>>>>
>>>> now start cloudmonkey:
>>>> $ cloudmonkey
>>>> ...
>>>>
>>>> Will post a blog/screencast this weekend and update doc so everyone can get help on its usage, though it's pretty intuitive.
>>>> ________________________________________
>>>> From: Musayev, Ilya [imusayev@webmd.net]
>>>> Sent: Wednesday, November 07, 2012 11:41 PM
>>>> To: cloudstack-dev@incubator.apache.org
>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>
>>>> Rohit,
>>>>
>>>> Can I get the CLI only without going through the whole source code maven install? Is it part of any RPM?
>>>>
>>>> Thanks
>>>> ilya
>>>>
>>>> -----Original Message-----
>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>> Sent: Monday, November 05, 2012 11:35 AM
>>>> To: cloudstack-dev@incubator.apache.org
>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>
>>>> Checkout latest code. Few changes to share:
>>>>
>>>> - All lowercase now
>>>> - Tab tab over verbs to see list of params for that api, example 
>>>> list users <tab><tab>
>>>> - This needs improvement but help string, using --help: list user 
>>>> --help
>>>> - Caching to speedup runtime
>>>> - Color and Parsing fixes
>>>>
>>>> Last, I'm now able to get the doc strings for each attribute/param, will see this tomorrow.
>>>>
>>>> Need your help, just incase you want to contribute, these are the TODOs:
>>>>
>>>> - search over history
>>>> - fix parsing
>>>> - doc strings for parameters
>>>> - testing for various kinds of apis (I'm able to deploy a zone with 
>>>> this, but needs testing)
>>>> - unicode char monkey, used in prompt may mess up history searching 
>>>> and text display
>>>>
>>>>
>>>> Regards.
>>>>
>>>> On 02-Nov-2012, at 4:58 AM, Edison Su <Ed...@citrix.com> wrote:
>>>>
>>>>>
>>>>>
>>>>>> -----Original Message-----
>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>> Sent: Thursday, November 01, 2012 2:23 PM
>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>
>>>>>> After you install the tool, so that cloudmonkey is in your 
>>>>>> /usr/local/bin or in $PATH...
>>>>>>
>>>>>> Two ways;
>>>>>> 1. As command line tool, on bash/zsh, use the BNF grammar; 
>>>>>> <command line tool
>>>>>> name>:<separator>:<verb>:<separator>:<action>:<separator>:<params
>>>>>> name>>
>>>>>> <command line tool name>={'cloudmonkey'} <separator>={' '} 
>>>>>> <verb>={'list', 'create', 'delete', 'update'.... etc.} 
>>>>>> <action>={'Users'... etc.} <params>={'listall=#'... etc.} So; $ 
>>>>>> cloudmonkey list Users
>>>>>
>>>>>
>>>>> Got it, thanks!
>>>>>
>>>>>>
>>>>>> 2. file redirector:
>>>>>>
>>>>>> $ cat test-file:
>>>>>> list Users
>>>>>> list <some other action>
>>>>>> <some verb> <some action>
>>>>>>
>>>>>> $ cloudmonkey < test-file
>>>>>>
>>>>>> Note, I'll change the actions (Users, VirtualMachine etc.) to 
>>>>>> lowercase (users, virtualmachine etc.) if that's okay?
>>>>>
>>>>> Please do, nobody wants to type extra keystroke, if it's not necessary.
>>>>>>
>>>>>> Regards.
>>>>>>
>>>>>> ________________________________________
>>>>>> From: Edison Su [Edison.su@citrix.com]
>>>>>> Sent: Friday, November 02, 2012 1:55 AM
>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>
>>>>>> Oh, it reminds me that how to use the CLI on the bash command line?
>>>>>> I think admin may want to call cloudstack API in a bash script, 
>>>>>> how can I do that?
>>>>>>
>>>>>>> -----Original Message-----
>>>>>>> From: Marcus Sorensen [mailto:shadowsor@gmail.com]
>>>>>>> Sent: Thursday, November 01, 2012 1:11 PM
>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>
>>>>>>> Yes, I look forward to using it instead of local curl calls on 
>>>>>>> the command line :-)
>>>>>>>
>>>>>>> On Thu, Nov 1, 2012 at 2:02 PM, Edison Su <Ed...@citrix.com> wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>> -----Original Message-----
>>>>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>>>>> Sent: Thursday, November 01, 2012 11:45 AM
>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>>>>
>>>>>>>>> Hi Chip, please go ahead if we can fix the http/s issue. The 
>>>>>>>>> connection is based on marvin, I'm sure using CLI we'll find 
>>>>>>>>> out more bugs and fix anything in marvin thereby help maintain
>>>>>>>>> marvin->tests and
>>>>>>> CLI.
>>>>>>>>> Please hack that up on
>>>>>>>>> tools/marvin/marvin/cloudstackConnection.py
>>>>>>>>>
>>>>>>>>> Edison, yes I'm working on the completedefault, I've figured a 
>>>>>>>>> solution to the parsing and tabbing issue to show params for 
>>>>>>>>> any api and added more verbs to the grammar like deploy, start etc.
>>>>>>>>> In the new approach doc strings and params needed for an api 
>>>>>>>>> are fetched and cached in the class locally to speed up the loading process.
>>>>>>>>> Till it gets committed, cloudmonkey (now) will keep telling 
>>>>>>>>> the user what params they are missing until it gets all the required ones.
>>>>>>>>
>>>>>>>> Great! Thanks for your awesome CLI, people will like it.
>>>>>>>>
>>>>>>>>>
>>>>>>>>> One more thing, for people who may not have unicode support 
>>>>>>>>> the prompt may appear weird and history search (up, down ) can 
>>>>>>>>> mess up the visuals. For example on Mac it appears as a 
>>>>>>>>> colorful emoji, but I found that it looks weird on other 
>>>>>>>>> platforms. Will probably remove it, or the user can custom set 
>>>>>>>>> their prompt, using: set prompt
>>>>>>>>> myprompt>
>>>>>>>>>
>>>>>>>>> Regards.
>>>>>>>>> PS. the set command is full of (fun :)  hacks because of 
>>>>>>>>> funtional/generic programming, it basically can set any 
>>>>>>>>> attribute on the class, so one can do something like creating 
>>>>>>>>> something (var, func). For example set ruler # (so instead of
>>>>>>>>> - you will have a #
>>>>>>>>> separator)
>>>>>>>>>
>>>>>>>>> ________________________________________
>>>>>>>>> From: Chip Childers [chip.childers@sungard.com]
>>>>>>>>> Sent: Thursday, November 01, 2012 11:15 PM
>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>>>
>>>>>>>>> On Wed, Oct 31, 2012 at 2:10 PM, Rohit Yadav 
>>>>>>>>> <ro...@citrix.com>
>>>>>>>>> wrote:
>>>>>>>>>> Hi,
>>>>>>>>>>
>>>>>>>>>> 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:
>>>>>>>>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstac
>>>>>>>>>> k.gi t; a=c ommit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
>>>>>>>>>>
>>>>>>>>>> Features:
>>>>>>>>>> - 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
>>>>>>>>>>
>>>>>>>>>> FIXMEs:
>>>>>>>>>> - 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 python cloudmonkey.py
>>>>>>>>>>
>>>>>>>>>> If you want to have the terminal tool installed; cd tools/cli 
>>>>>>>>>> python setup.py 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=8.8.8.8 internaldns1=10.147.28.6
>>>>>>>>>> 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
>>>>>>>>>> networkofferingid= create Pod zoneid= name=Pod1
>>>>>>> gateway=10.147.28.1
>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.220
>>>>>>>>>> endip=10.147.28.235 create VlanIpRange podid= networkid=
>>>>>>>>>> gateway=10.147.28.1
>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.236
>>>>>>>>>> endip=10.147.28.250 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=http://10.147.28.60 create StoragePool zoneid= clusterid=
>>>>>>>>>> name=NFS1 url=nfs://10.147.28.7/export/home/rohit/primary
>>>>>>>>>> add SecondaryStorage zoneId=
>>>>>>>>>> url=nfs://10.147.28.7/export/home/rohit/secondary
>>>>>>>>>> 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.
>>>>>>>>>>
>>>>>>>>>> Regards.
>>>>>>>>>> PS. Marvin the neglected robot and hipster cloudmonkey should 
>>>>>>>>>> rule the world :D
>>>>>>>>>
>>>>>>>>> Rohit,
>>>>>>>>>
>>>>>>>>> This is really really cool.  It puts the "fun" in managing 
>>>>>>>>> instances from a command line.  I've been testing it against a 
>>>>>>>>> production CloudStack environment, and it's working pretty well.
>>>>>>>>>
>>>>>>>>> If you don't mind, I might hack at the code a bit to fill in 
>>>>>>>>> some gaps that I'm seeing.  First example is that it assumes 
>>>>>>>>> http, which doesn't work in a public deployment where the endpoint is over https.
>>>>>>>>>
>>>>>>>>> -chip
>

RE: CLI for CloudStack: cloudmonkey

Posted by "Musayev, Ilya" <im...@webmd.net>.
Rohit

This would be an enhacement request, can we have cloudmonkey don’t terminate if object is not found..

Below is the example of what just happened:

🐵 cloudmonkey> list networkofferings id=5834b1f0-2305-4ee6-ab31-880e5d615a90
Traceback (most recent call last):
  File "/usr/bin/cloudmonkey", line 9, in <module>
    load_entry_point('cloudmonkey==0.0.4', 'console_scripts', 'cloudmonkey')()
  File "/usr/lib/python2.6/site-packages/cloudmonkey-0.0.4-py2.6.egg/cloudmonkey/cloudmonkey.py", line 450, in main
    shell.cmdloop()
  File "/usr/lib64/python2.6/cmd.py", line 142, in cmdloop
    stop = self.onecmd(line)
  File "/usr/lib64/python2.6/cmd.py", line 219, in onecmd
    return func(arg)
  File "/usr/lib/python2.6/site-packages/cloudmonkey-0.0.4-py2.6.egg/cloudmonkey/cloudmonkey.py", line 437, in grammar_closure
    self.default(res[0] + " " + args_partition[2])
  File "/usr/lib/python2.6/site-packages/cloudmonkey-0.0.4-py2.6.egg/cloudmonkey/cloudmonkey.py", line 249, in default
    result = self.make_request(command, response)
  File "/usr/lib/python2.6/site-packages/cloudmonkey-0.0.4-py2.6.egg/cloudmonkey/cloudmonkey.py", line 210, in make_request
    response = conn.make_request(command, requests)
  File "/usr/lib/python2.6/site-packages/cloudmonkey-0.0.4-py2.6.egg/cloudmonkey/marvin/cloudstackConnection.py", line 171, in make_request
    result = self.make_request_without_auth(commandName, requests)
  File "/usr/lib/python2.6/site-packages/cloudmonkey-0.0.4-py2.6.egg/cloudmonkey/marvin/cloudstackConnection.py", line 102, in make_request_without_auth
    self.connection = urllib2.urlopen("http://%s:%d/client/api?%s"%(self.mgtSvr, self.port, requestUrl))
  File "/usr/lib64/python2.6/urllib2.py", line 126, in urlopen
    return _opener.open(url, data, timeout)
  File "/usr/lib64/python2.6/urllib2.py", line 397, in open
    response = meth(req, response)
  File "/usr/lib64/python2.6/urllib2.py", line 510, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib64/python2.6/urllib2.py", line 435, in error
    return self._call_chain(*args)
  File "/usr/lib64/python2.6/urllib2.py", line 369, in _call_chain
    result = func(*args)
  File "/usr/lib64/python2.6/urllib2.py", line 518, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 431: Unable to execute API command listnetworkofferings due to invalid value. Object network_offerings(uuid: 5834b1f0-2305-4ee6-ab31-880e5d615a90) does not exist.
# back to bash prompt... 

Thanks
ilya
-----Original Message-----
From: Rohit Yadav [mailto:rohit.yadav@citrix.com] 
Sent: Thursday, November 08, 2012 3:45 PM
To: cloudstack-dev@incubator.apache.org
Subject: RE: CLI for CloudStack: cloudmonkey

Yes, easy_install will work too using sudo easy_install cloudmonkey.
Or, using pip: http://www.pip-installer.org/en/latest/installing.html#using-the-installer

Python 2.5+ should work, if not please report any issues you face with the cli.

Regards.

________________________________________
From: Musayev, Ilya [imusayev@webmd.net]
Sent: Friday, November 09, 2012 1:25 AM
To: cloudstack-dev@incubator.apache.org
Subject: RE: CLI for CloudStack: cloudmonkey

Never mind, I also have easy_install, I'll try that route...

Thanks


-----Original Message-----
From: Musayev, Ilya [mailto:imusayev@webmd.net]
Sent: Thursday, November 08, 2012 2:53 PM
To: cloudstack-dev@incubator.apache.org
Subject: RE: CLI for CloudStack: cloudmonkey

So pip comes with python 2.7 which is not available by default on CentOS 6.3

Any other method I could use, other than installing python 2.7?

Thanks
ilya

-----Original Message-----
From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
Sent: Thursday, November 08, 2012 2:14 PM
To: cloudstack-dev@incubator.apache.org
Subject: RE: CLI for CloudStack: cloudmonkey

Oh, forgot to see that. Yes, now all the cmds are lowercase (except for few params liks isAsync=) and tab completion is advised.

Regards.
________________________________________
From: Kishan Kavala [Kishan.Kavala@citrix.com]
Sent: Thursday, November 08, 2012 11:29 PM
To: cloudstack-dev@incubator.apache.org
Cc: cloudstack-dev@incubator.apache.org
Subject: Re: CLI for CloudStack: cloudmonkey

Sebastian,
  Try set apikey in lower case. Same with set secretkey.

~kishan

On 08-Nov-2012, at 10:00 PM, "Sebastien Goasguen" <ru...@gmail.com> wrote:

> Actually it does not work yet.
>
> Now I can type 'b' but it does not get passed properly:
>
> 🙉 cloudmonkey> set apiKey
> KEbkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzjR
> B9UNrBybVr3kcZ6Q
>
> Gives:
>
> INFO  [cloud.api.ApiServer] (92734721@qtp-1601733969-7:) apiKey does 
> not map to a valid user -- ignoring request, apiKey:
> KEkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzjRB
> 9UNrByVr3kcZ6Q
>
> On Nov 8, 2012, at 5:19 PM, Sebastien Goasguen <ru...@gmail.com> wrote:
>
>>
>> On Nov 8, 2012, at 3:28 PM, Rohit Yadav <ro...@citrix.com> wrote:
>>
>>> Hi Sebastien,
>>>
>>> Are you using it from pypi/pip, if so do this:
>>> sudo pip uninstall cloudmonkey
>>> sudo pip install cloudmonkey
>>
>> no, I am doing: sudo python ./setup.py install from the source tree
>>
>>> I've had this bug on mac osx, fixed it:
>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.git;a
>>> =commit;h=36e7a7884efef7c41ac369549b7bdb93e5122110
>>
>> pulled that and reinstalled…and it works.
>>
>> thanks
>>
>> -sebastien
>>
>>
>>> If it still persists for you, checkout 
>>> http://superuser.com/questions/297527/cant-type-the-b-letter-in-pyth
>>> on-shell-in-os-x
>>>
>>> Let me know if this still fails then.
>>>
>>> Regards.
>>>
>>> ________________________________________
>>> From: Sebastien Goasguen [runseb@gmail.com]
>>> Sent: Thursday, November 08, 2012 5:37 PM
>>> To: cloudstack-dev@incubator.apache.org
>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>
>>> Hi,
>>>
>>> I am testing the cli and I have the weirdest issue. When I set the apikey or secretkey, the lower case 'b' letter does not print at the prompt.
>>> So if my keys contain 'b' they don't work..
>>>
>>> I tried all the other letters and they work.
>>>
>>> Anyone seeing this,
>>>
>>> -Sebastien
>>>
>>> On Nov 7, 2012, at 7:25 PM, Rohit Yadav <ro...@citrix.com> wrote:
>>>
>>>> yes, I think I'd mentioned in the thread or somewhere. Just use pip 
>>>> or easy_install (apt-get install python-setuptools on ubuntu, 
>>>> install python2.6 or above and pip if you don't have it);
>>>>
>>>> sudo pip install cloudmonkey
>>>>
>>>> or sudo easy_install cloudmonkey
>>>>
>>>> now start cloudmonkey:
>>>> $ cloudmonkey
>>>> ...
>>>>
>>>> Will post a blog/screencast this weekend and update doc so everyone can get help on its usage, though it's pretty intuitive.
>>>> ________________________________________
>>>> From: Musayev, Ilya [imusayev@webmd.net]
>>>> Sent: Wednesday, November 07, 2012 11:41 PM
>>>> To: cloudstack-dev@incubator.apache.org
>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>
>>>> Rohit,
>>>>
>>>> Can I get the CLI only without going through the whole source code maven install? Is it part of any RPM?
>>>>
>>>> Thanks
>>>> ilya
>>>>
>>>> -----Original Message-----
>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>> Sent: Monday, November 05, 2012 11:35 AM
>>>> To: cloudstack-dev@incubator.apache.org
>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>
>>>> Checkout latest code. Few changes to share:
>>>>
>>>> - All lowercase now
>>>> - Tab tab over verbs to see list of params for that api, example 
>>>> list users <tab><tab>
>>>> - This needs improvement but help string, using --help: list user 
>>>> --help
>>>> - Caching to speedup runtime
>>>> - Color and Parsing fixes
>>>>
>>>> Last, I'm now able to get the doc strings for each attribute/param, will see this tomorrow.
>>>>
>>>> Need your help, just incase you want to contribute, these are the TODOs:
>>>>
>>>> - search over history
>>>> - fix parsing
>>>> - doc strings for parameters
>>>> - testing for various kinds of apis (I'm able to deploy a zone with 
>>>> this, but needs testing)
>>>> - unicode char monkey, used in prompt may mess up history searching 
>>>> and text display
>>>>
>>>>
>>>> Regards.
>>>>
>>>> On 02-Nov-2012, at 4:58 AM, Edison Su <Ed...@citrix.com> wrote:
>>>>
>>>>>
>>>>>
>>>>>> -----Original Message-----
>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>> Sent: Thursday, November 01, 2012 2:23 PM
>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>
>>>>>> After you install the tool, so that cloudmonkey is in your 
>>>>>> /usr/local/bin or in $PATH...
>>>>>>
>>>>>> Two ways;
>>>>>> 1. As command line tool, on bash/zsh, use the BNF grammar; 
>>>>>> <command line tool
>>>>>> name>:<separator>:<verb>:<separator>:<action>:<separator>:<params
>>>>>> name>>
>>>>>> <command line tool name>={'cloudmonkey'} <separator>={' '} 
>>>>>> <verb>={'list', 'create', 'delete', 'update'.... etc.} 
>>>>>> <action>={'Users'... etc.} <params>={'listall=#'... etc.} So; $ 
>>>>>> cloudmonkey list Users
>>>>>
>>>>>
>>>>> Got it, thanks!
>>>>>
>>>>>>
>>>>>> 2. file redirector:
>>>>>>
>>>>>> $ cat test-file:
>>>>>> list Users
>>>>>> list <some other action>
>>>>>> <some verb> <some action>
>>>>>>
>>>>>> $ cloudmonkey < test-file
>>>>>>
>>>>>> Note, I'll change the actions (Users, VirtualMachine etc.) to 
>>>>>> lowercase (users, virtualmachine etc.) if that's okay?
>>>>>
>>>>> Please do, nobody wants to type extra keystroke, if it's not necessary.
>>>>>>
>>>>>> Regards.
>>>>>>
>>>>>> ________________________________________
>>>>>> From: Edison Su [Edison.su@citrix.com]
>>>>>> Sent: Friday, November 02, 2012 1:55 AM
>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>
>>>>>> Oh, it reminds me that how to use the CLI on the bash command line?
>>>>>> I think admin may want to call cloudstack API in a bash script, 
>>>>>> how can I do that?
>>>>>>
>>>>>>> -----Original Message-----
>>>>>>> From: Marcus Sorensen [mailto:shadowsor@gmail.com]
>>>>>>> Sent: Thursday, November 01, 2012 1:11 PM
>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>
>>>>>>> Yes, I look forward to using it instead of local curl calls on 
>>>>>>> the command line :-)
>>>>>>>
>>>>>>> On Thu, Nov 1, 2012 at 2:02 PM, Edison Su <Ed...@citrix.com> wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>> -----Original Message-----
>>>>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>>>>> Sent: Thursday, November 01, 2012 11:45 AM
>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>>>>
>>>>>>>>> Hi Chip, please go ahead if we can fix the http/s issue. The 
>>>>>>>>> connection is based on marvin, I'm sure using CLI we'll find 
>>>>>>>>> out more bugs and fix anything in marvin thereby help maintain
>>>>>>>>> marvin->tests and
>>>>>>> CLI.
>>>>>>>>> Please hack that up on
>>>>>>>>> tools/marvin/marvin/cloudstackConnection.py
>>>>>>>>>
>>>>>>>>> Edison, yes I'm working on the completedefault, I've figured a 
>>>>>>>>> solution to the parsing and tabbing issue to show params for 
>>>>>>>>> any api and added more verbs to the grammar like deploy, start etc.
>>>>>>>>> In the new approach doc strings and params needed for an api 
>>>>>>>>> are fetched and cached in the class locally to speed up the loading process.
>>>>>>>>> Till it gets committed, cloudmonkey (now) will keep telling 
>>>>>>>>> the user what params they are missing until it gets all the required ones.
>>>>>>>>
>>>>>>>> Great! Thanks for your awesome CLI, people will like it.
>>>>>>>>
>>>>>>>>>
>>>>>>>>> One more thing, for people who may not have unicode support 
>>>>>>>>> the prompt may appear weird and history search (up, down ) can 
>>>>>>>>> mess up the visuals. For example on Mac it appears as a 
>>>>>>>>> colorful emoji, but I found that it looks weird on other 
>>>>>>>>> platforms. Will probably remove it, or the user can custom set 
>>>>>>>>> their prompt, using: set prompt
>>>>>>>>> myprompt>
>>>>>>>>>
>>>>>>>>> Regards.
>>>>>>>>> PS. the set command is full of (fun :)  hacks because of 
>>>>>>>>> funtional/generic programming, it basically can set any 
>>>>>>>>> attribute on the class, so one can do something like creating 
>>>>>>>>> something (var, func). For example set ruler # (so instead of
>>>>>>>>> - you will have a #
>>>>>>>>> separator)
>>>>>>>>>
>>>>>>>>> ________________________________________
>>>>>>>>> From: Chip Childers [chip.childers@sungard.com]
>>>>>>>>> Sent: Thursday, November 01, 2012 11:15 PM
>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>>>
>>>>>>>>> On Wed, Oct 31, 2012 at 2:10 PM, Rohit Yadav 
>>>>>>>>> <ro...@citrix.com>
>>>>>>>>> wrote:
>>>>>>>>>> Hi,
>>>>>>>>>>
>>>>>>>>>> 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:
>>>>>>>>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstac
>>>>>>>>>> k.gi t; a=c ommit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
>>>>>>>>>>
>>>>>>>>>> Features:
>>>>>>>>>> - 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
>>>>>>>>>>
>>>>>>>>>> FIXMEs:
>>>>>>>>>> - 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 python cloudmonkey.py
>>>>>>>>>>
>>>>>>>>>> If you want to have the terminal tool installed; cd tools/cli 
>>>>>>>>>> python setup.py 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=8.8.8.8 internaldns1=10.147.28.6
>>>>>>>>>> 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
>>>>>>>>>> networkofferingid= create Pod zoneid= name=Pod1
>>>>>>> gateway=10.147.28.1
>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.220
>>>>>>>>>> endip=10.147.28.235 create VlanIpRange podid= networkid=
>>>>>>>>>> gateway=10.147.28.1
>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.236
>>>>>>>>>> endip=10.147.28.250 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=http://10.147.28.60 create StoragePool zoneid= clusterid=
>>>>>>>>>> name=NFS1 url=nfs://10.147.28.7/export/home/rohit/primary
>>>>>>>>>> add SecondaryStorage zoneId=
>>>>>>>>>> url=nfs://10.147.28.7/export/home/rohit/secondary
>>>>>>>>>> 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.
>>>>>>>>>>
>>>>>>>>>> Regards.
>>>>>>>>>> PS. Marvin the neglected robot and hipster cloudmonkey should 
>>>>>>>>>> rule the world :D
>>>>>>>>>
>>>>>>>>> Rohit,
>>>>>>>>>
>>>>>>>>> This is really really cool.  It puts the "fun" in managing 
>>>>>>>>> instances from a command line.  I've been testing it against a 
>>>>>>>>> production CloudStack environment, and it's working pretty well.
>>>>>>>>>
>>>>>>>>> If you don't mind, I might hack at the code a bit to fill in 
>>>>>>>>> some gaps that I'm seeing.  First example is that it assumes 
>>>>>>>>> http, which doesn't work in a public deployment where the endpoint is over https.
>>>>>>>>>
>>>>>>>>> -chip
>

RE: CLI for CloudStack: cloudmonkey

Posted by Rohit Yadav <ro...@citrix.com>.
Yes, easy_install will work too using sudo easy_install cloudmonkey.
Or, using pip: http://www.pip-installer.org/en/latest/installing.html#using-the-installer

Python 2.5+ should work, if not please report any issues you face with the cli.

Regards.

________________________________________
From: Musayev, Ilya [imusayev@webmd.net]
Sent: Friday, November 09, 2012 1:25 AM
To: cloudstack-dev@incubator.apache.org
Subject: RE: CLI for CloudStack: cloudmonkey

Never mind, I also have easy_install, I'll try that route...

Thanks


-----Original Message-----
From: Musayev, Ilya [mailto:imusayev@webmd.net]
Sent: Thursday, November 08, 2012 2:53 PM
To: cloudstack-dev@incubator.apache.org
Subject: RE: CLI for CloudStack: cloudmonkey

So pip comes with python 2.7 which is not available by default on CentOS 6.3

Any other method I could use, other than installing python 2.7?

Thanks
ilya

-----Original Message-----
From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
Sent: Thursday, November 08, 2012 2:14 PM
To: cloudstack-dev@incubator.apache.org
Subject: RE: CLI for CloudStack: cloudmonkey

Oh, forgot to see that. Yes, now all the cmds are lowercase (except for few params liks isAsync=) and tab completion is advised.

Regards.
________________________________________
From: Kishan Kavala [Kishan.Kavala@citrix.com]
Sent: Thursday, November 08, 2012 11:29 PM
To: cloudstack-dev@incubator.apache.org
Cc: cloudstack-dev@incubator.apache.org
Subject: Re: CLI for CloudStack: cloudmonkey

Sebastian,
  Try set apikey in lower case. Same with set secretkey.

~kishan

On 08-Nov-2012, at 10:00 PM, "Sebastien Goasguen" <ru...@gmail.com> wrote:

> Actually it does not work yet.
>
> Now I can type 'b' but it does not get passed properly:
>
> 🙉 cloudmonkey> set apiKey
> KEbkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzjR
> B9UNrBybVr3kcZ6Q
>
> Gives:
>
> INFO  [cloud.api.ApiServer] (92734721@qtp-1601733969-7:) apiKey does
> not map to a valid user -- ignoring request, apiKey:
> KEkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzjRB
> 9UNrByVr3kcZ6Q
>
> On Nov 8, 2012, at 5:19 PM, Sebastien Goasguen <ru...@gmail.com> wrote:
>
>>
>> On Nov 8, 2012, at 3:28 PM, Rohit Yadav <ro...@citrix.com> wrote:
>>
>>> Hi Sebastien,
>>>
>>> Are you using it from pypi/pip, if so do this:
>>> sudo pip uninstall cloudmonkey
>>> sudo pip install cloudmonkey
>>
>> no, I am doing: sudo python ./setup.py install from the source tree
>>
>>> I've had this bug on mac osx, fixed it:
>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.git;a
>>> =commit;h=36e7a7884efef7c41ac369549b7bdb93e5122110
>>
>> pulled that and reinstalled…and it works.
>>
>> thanks
>>
>> -sebastien
>>
>>
>>> If it still persists for you, checkout
>>> http://superuser.com/questions/297527/cant-type-the-b-letter-in-pyth
>>> on-shell-in-os-x
>>>
>>> Let me know if this still fails then.
>>>
>>> Regards.
>>>
>>> ________________________________________
>>> From: Sebastien Goasguen [runseb@gmail.com]
>>> Sent: Thursday, November 08, 2012 5:37 PM
>>> To: cloudstack-dev@incubator.apache.org
>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>
>>> Hi,
>>>
>>> I am testing the cli and I have the weirdest issue. When I set the apikey or secretkey, the lower case 'b' letter does not print at the prompt.
>>> So if my keys contain 'b' they don't work..
>>>
>>> I tried all the other letters and they work.
>>>
>>> Anyone seeing this,
>>>
>>> -Sebastien
>>>
>>> On Nov 7, 2012, at 7:25 PM, Rohit Yadav <ro...@citrix.com> wrote:
>>>
>>>> yes, I think I'd mentioned in the thread or somewhere. Just use pip
>>>> or easy_install (apt-get install python-setuptools on ubuntu,
>>>> install python2.6 or above and pip if you don't have it);
>>>>
>>>> sudo pip install cloudmonkey
>>>>
>>>> or sudo easy_install cloudmonkey
>>>>
>>>> now start cloudmonkey:
>>>> $ cloudmonkey
>>>> ...
>>>>
>>>> Will post a blog/screencast this weekend and update doc so everyone can get help on its usage, though it's pretty intuitive.
>>>> ________________________________________
>>>> From: Musayev, Ilya [imusayev@webmd.net]
>>>> Sent: Wednesday, November 07, 2012 11:41 PM
>>>> To: cloudstack-dev@incubator.apache.org
>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>
>>>> Rohit,
>>>>
>>>> Can I get the CLI only without going through the whole source code maven install? Is it part of any RPM?
>>>>
>>>> Thanks
>>>> ilya
>>>>
>>>> -----Original Message-----
>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>> Sent: Monday, November 05, 2012 11:35 AM
>>>> To: cloudstack-dev@incubator.apache.org
>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>
>>>> Checkout latest code. Few changes to share:
>>>>
>>>> - All lowercase now
>>>> - Tab tab over verbs to see list of params for that api, example
>>>> list users <tab><tab>
>>>> - This needs improvement but help string, using --help: list user
>>>> --help
>>>> - Caching to speedup runtime
>>>> - Color and Parsing fixes
>>>>
>>>> Last, I'm now able to get the doc strings for each attribute/param, will see this tomorrow.
>>>>
>>>> Need your help, just incase you want to contribute, these are the TODOs:
>>>>
>>>> - search over history
>>>> - fix parsing
>>>> - doc strings for parameters
>>>> - testing for various kinds of apis (I'm able to deploy a zone with
>>>> this, but needs testing)
>>>> - unicode char monkey, used in prompt may mess up history searching
>>>> and text display
>>>>
>>>>
>>>> Regards.
>>>>
>>>> On 02-Nov-2012, at 4:58 AM, Edison Su <Ed...@citrix.com> wrote:
>>>>
>>>>>
>>>>>
>>>>>> -----Original Message-----
>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>> Sent: Thursday, November 01, 2012 2:23 PM
>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>
>>>>>> After you install the tool, so that cloudmonkey is in your
>>>>>> /usr/local/bin or in $PATH...
>>>>>>
>>>>>> Two ways;
>>>>>> 1. As command line tool, on bash/zsh, use the BNF grammar;
>>>>>> <command line tool
>>>>>> name>:<separator>:<verb>:<separator>:<action>:<separator>:<params
>>>>>> name>>
>>>>>> <command line tool name>={'cloudmonkey'} <separator>={' '}
>>>>>> <verb>={'list', 'create', 'delete', 'update'.... etc.}
>>>>>> <action>={'Users'... etc.} <params>={'listall=#'... etc.} So; $
>>>>>> cloudmonkey list Users
>>>>>
>>>>>
>>>>> Got it, thanks!
>>>>>
>>>>>>
>>>>>> 2. file redirector:
>>>>>>
>>>>>> $ cat test-file:
>>>>>> list Users
>>>>>> list <some other action>
>>>>>> <some verb> <some action>
>>>>>>
>>>>>> $ cloudmonkey < test-file
>>>>>>
>>>>>> Note, I'll change the actions (Users, VirtualMachine etc.) to
>>>>>> lowercase (users, virtualmachine etc.) if that's okay?
>>>>>
>>>>> Please do, nobody wants to type extra keystroke, if it's not necessary.
>>>>>>
>>>>>> Regards.
>>>>>>
>>>>>> ________________________________________
>>>>>> From: Edison Su [Edison.su@citrix.com]
>>>>>> Sent: Friday, November 02, 2012 1:55 AM
>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>
>>>>>> Oh, it reminds me that how to use the CLI on the bash command line?
>>>>>> I think admin may want to call cloudstack API in a bash script,
>>>>>> how can I do that?
>>>>>>
>>>>>>> -----Original Message-----
>>>>>>> From: Marcus Sorensen [mailto:shadowsor@gmail.com]
>>>>>>> Sent: Thursday, November 01, 2012 1:11 PM
>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>
>>>>>>> Yes, I look forward to using it instead of local curl calls on
>>>>>>> the command line :-)
>>>>>>>
>>>>>>> On Thu, Nov 1, 2012 at 2:02 PM, Edison Su <Ed...@citrix.com> wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>> -----Original Message-----
>>>>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>>>>> Sent: Thursday, November 01, 2012 11:45 AM
>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>>>>
>>>>>>>>> Hi Chip, please go ahead if we can fix the http/s issue. The
>>>>>>>>> connection is based on marvin, I'm sure using CLI we'll find
>>>>>>>>> out more bugs and fix anything in marvin thereby help maintain
>>>>>>>>> marvin->tests and
>>>>>>> CLI.
>>>>>>>>> Please hack that up on
>>>>>>>>> tools/marvin/marvin/cloudstackConnection.py
>>>>>>>>>
>>>>>>>>> Edison, yes I'm working on the completedefault, I've figured a
>>>>>>>>> solution to the parsing and tabbing issue to show params for
>>>>>>>>> any api and added more verbs to the grammar like deploy, start etc.
>>>>>>>>> In the new approach doc strings and params needed for an api
>>>>>>>>> are fetched and cached in the class locally to speed up the loading process.
>>>>>>>>> Till it gets committed, cloudmonkey (now) will keep telling
>>>>>>>>> the user what params they are missing until it gets all the required ones.
>>>>>>>>
>>>>>>>> Great! Thanks for your awesome CLI, people will like it.
>>>>>>>>
>>>>>>>>>
>>>>>>>>> One more thing, for people who may not have unicode support
>>>>>>>>> the prompt may appear weird and history search (up, down ) can
>>>>>>>>> mess up the visuals. For example on Mac it appears as a
>>>>>>>>> colorful emoji, but I found that it looks weird on other
>>>>>>>>> platforms. Will probably remove it, or the user can custom set
>>>>>>>>> their prompt, using: set prompt
>>>>>>>>> myprompt>
>>>>>>>>>
>>>>>>>>> Regards.
>>>>>>>>> PS. the set command is full of (fun :)  hacks because of
>>>>>>>>> funtional/generic programming, it basically can set any
>>>>>>>>> attribute on the class, so one can do something like creating
>>>>>>>>> something (var, func). For example set ruler # (so instead of
>>>>>>>>> - you will have a #
>>>>>>>>> separator)
>>>>>>>>>
>>>>>>>>> ________________________________________
>>>>>>>>> From: Chip Childers [chip.childers@sungard.com]
>>>>>>>>> Sent: Thursday, November 01, 2012 11:15 PM
>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>>>
>>>>>>>>> On Wed, Oct 31, 2012 at 2:10 PM, Rohit Yadav
>>>>>>>>> <ro...@citrix.com>
>>>>>>>>> wrote:
>>>>>>>>>> Hi,
>>>>>>>>>>
>>>>>>>>>> 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:
>>>>>>>>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstac
>>>>>>>>>> k.gi t; a=c ommit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
>>>>>>>>>>
>>>>>>>>>> Features:
>>>>>>>>>> - 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
>>>>>>>>>>
>>>>>>>>>> FIXMEs:
>>>>>>>>>> - 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 python cloudmonkey.py
>>>>>>>>>>
>>>>>>>>>> If you want to have the terminal tool installed; cd tools/cli
>>>>>>>>>> python setup.py 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=8.8.8.8 internaldns1=10.147.28.6
>>>>>>>>>> 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
>>>>>>>>>> networkofferingid= create Pod zoneid= name=Pod1
>>>>>>> gateway=10.147.28.1
>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.220
>>>>>>>>>> endip=10.147.28.235 create VlanIpRange podid= networkid=
>>>>>>>>>> gateway=10.147.28.1
>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.236
>>>>>>>>>> endip=10.147.28.250 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=http://10.147.28.60 create StoragePool zoneid= clusterid=
>>>>>>>>>> name=NFS1 url=nfs://10.147.28.7/export/home/rohit/primary
>>>>>>>>>> add SecondaryStorage zoneId=
>>>>>>>>>> url=nfs://10.147.28.7/export/home/rohit/secondary
>>>>>>>>>> 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.
>>>>>>>>>>
>>>>>>>>>> Regards.
>>>>>>>>>> PS. Marvin the neglected robot and hipster cloudmonkey should
>>>>>>>>>> rule the world :D
>>>>>>>>>
>>>>>>>>> Rohit,
>>>>>>>>>
>>>>>>>>> This is really really cool.  It puts the "fun" in managing
>>>>>>>>> instances from a command line.  I've been testing it against a
>>>>>>>>> production CloudStack environment, and it's working pretty well.
>>>>>>>>>
>>>>>>>>> If you don't mind, I might hack at the code a bit to fill in
>>>>>>>>> some gaps that I'm seeing.  First example is that it assumes
>>>>>>>>> http, which doesn't work in a public deployment where the endpoint is over https.
>>>>>>>>>
>>>>>>>>> -chip
>

RE: CLI for CloudStack: cloudmonkey

Posted by "Musayev, Ilya" <im...@webmd.net>.
Never mind, I also have easy_install, I'll try that route...

Thanks


-----Original Message-----
From: Musayev, Ilya [mailto:imusayev@webmd.net] 
Sent: Thursday, November 08, 2012 2:53 PM
To: cloudstack-dev@incubator.apache.org
Subject: RE: CLI for CloudStack: cloudmonkey

So pip comes with python 2.7 which is not available by default on CentOS 6.3

Any other method I could use, other than installing python 2.7?

Thanks
ilya

-----Original Message-----
From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
Sent: Thursday, November 08, 2012 2:14 PM
To: cloudstack-dev@incubator.apache.org
Subject: RE: CLI for CloudStack: cloudmonkey

Oh, forgot to see that. Yes, now all the cmds are lowercase (except for few params liks isAsync=) and tab completion is advised.

Regards.
________________________________________
From: Kishan Kavala [Kishan.Kavala@citrix.com]
Sent: Thursday, November 08, 2012 11:29 PM
To: cloudstack-dev@incubator.apache.org
Cc: cloudstack-dev@incubator.apache.org
Subject: Re: CLI for CloudStack: cloudmonkey

Sebastian,
  Try set apikey in lower case. Same with set secretkey.

~kishan

On 08-Nov-2012, at 10:00 PM, "Sebastien Goasguen" <ru...@gmail.com> wrote:

> Actually it does not work yet.
>
> Now I can type 'b' but it does not get passed properly:
>
> 🙉 cloudmonkey> set apiKey
> KEbkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzjR
> B9UNrBybVr3kcZ6Q
>
> Gives:
>
> INFO  [cloud.api.ApiServer] (92734721@qtp-1601733969-7:) apiKey does 
> not map to a valid user -- ignoring request, apiKey:
> KEkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzjRB
> 9UNrByVr3kcZ6Q
>
> On Nov 8, 2012, at 5:19 PM, Sebastien Goasguen <ru...@gmail.com> wrote:
>
>>
>> On Nov 8, 2012, at 3:28 PM, Rohit Yadav <ro...@citrix.com> wrote:
>>
>>> Hi Sebastien,
>>>
>>> Are you using it from pypi/pip, if so do this:
>>> sudo pip uninstall cloudmonkey
>>> sudo pip install cloudmonkey
>>
>> no, I am doing: sudo python ./setup.py install from the source tree
>>
>>> I've had this bug on mac osx, fixed it:
>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.git;a
>>> =commit;h=36e7a7884efef7c41ac369549b7bdb93e5122110
>>
>> pulled that and reinstalled…and it works.
>>
>> thanks
>>
>> -sebastien
>>
>>
>>> If it still persists for you, checkout 
>>> http://superuser.com/questions/297527/cant-type-the-b-letter-in-pyth
>>> on-shell-in-os-x
>>>
>>> Let me know if this still fails then.
>>>
>>> Regards.
>>>
>>> ________________________________________
>>> From: Sebastien Goasguen [runseb@gmail.com]
>>> Sent: Thursday, November 08, 2012 5:37 PM
>>> To: cloudstack-dev@incubator.apache.org
>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>
>>> Hi,
>>>
>>> I am testing the cli and I have the weirdest issue. When I set the apikey or secretkey, the lower case 'b' letter does not print at the prompt.
>>> So if my keys contain 'b' they don't work..
>>>
>>> I tried all the other letters and they work.
>>>
>>> Anyone seeing this,
>>>
>>> -Sebastien
>>>
>>> On Nov 7, 2012, at 7:25 PM, Rohit Yadav <ro...@citrix.com> wrote:
>>>
>>>> yes, I think I'd mentioned in the thread or somewhere. Just use pip 
>>>> or easy_install (apt-get install python-setuptools on ubuntu, 
>>>> install python2.6 or above and pip if you don't have it);
>>>>
>>>> sudo pip install cloudmonkey
>>>>
>>>> or sudo easy_install cloudmonkey
>>>>
>>>> now start cloudmonkey:
>>>> $ cloudmonkey
>>>> ...
>>>>
>>>> Will post a blog/screencast this weekend and update doc so everyone can get help on its usage, though it's pretty intuitive.
>>>> ________________________________________
>>>> From: Musayev, Ilya [imusayev@webmd.net]
>>>> Sent: Wednesday, November 07, 2012 11:41 PM
>>>> To: cloudstack-dev@incubator.apache.org
>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>
>>>> Rohit,
>>>>
>>>> Can I get the CLI only without going through the whole source code maven install? Is it part of any RPM?
>>>>
>>>> Thanks
>>>> ilya
>>>>
>>>> -----Original Message-----
>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>> Sent: Monday, November 05, 2012 11:35 AM
>>>> To: cloudstack-dev@incubator.apache.org
>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>
>>>> Checkout latest code. Few changes to share:
>>>>
>>>> - All lowercase now
>>>> - Tab tab over verbs to see list of params for that api, example 
>>>> list users <tab><tab>
>>>> - This needs improvement but help string, using --help: list user 
>>>> --help
>>>> - Caching to speedup runtime
>>>> - Color and Parsing fixes
>>>>
>>>> Last, I'm now able to get the doc strings for each attribute/param, will see this tomorrow.
>>>>
>>>> Need your help, just incase you want to contribute, these are the TODOs:
>>>>
>>>> - search over history
>>>> - fix parsing
>>>> - doc strings for parameters
>>>> - testing for various kinds of apis (I'm able to deploy a zone with 
>>>> this, but needs testing)
>>>> - unicode char monkey, used in prompt may mess up history searching 
>>>> and text display
>>>>
>>>>
>>>> Regards.
>>>>
>>>> On 02-Nov-2012, at 4:58 AM, Edison Su <Ed...@citrix.com> wrote:
>>>>
>>>>>
>>>>>
>>>>>> -----Original Message-----
>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>> Sent: Thursday, November 01, 2012 2:23 PM
>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>
>>>>>> After you install the tool, so that cloudmonkey is in your 
>>>>>> /usr/local/bin or in $PATH...
>>>>>>
>>>>>> Two ways;
>>>>>> 1. As command line tool, on bash/zsh, use the BNF grammar; 
>>>>>> <command line tool
>>>>>> name>:<separator>:<verb>:<separator>:<action>:<separator>:<params
>>>>>> name>>
>>>>>> <command line tool name>={'cloudmonkey'} <separator>={' '} 
>>>>>> <verb>={'list', 'create', 'delete', 'update'.... etc.} 
>>>>>> <action>={'Users'... etc.} <params>={'listall=#'... etc.} So; $ 
>>>>>> cloudmonkey list Users
>>>>>
>>>>>
>>>>> Got it, thanks!
>>>>>
>>>>>>
>>>>>> 2. file redirector:
>>>>>>
>>>>>> $ cat test-file:
>>>>>> list Users
>>>>>> list <some other action>
>>>>>> <some verb> <some action>
>>>>>>
>>>>>> $ cloudmonkey < test-file
>>>>>>
>>>>>> Note, I'll change the actions (Users, VirtualMachine etc.) to 
>>>>>> lowercase (users, virtualmachine etc.) if that's okay?
>>>>>
>>>>> Please do, nobody wants to type extra keystroke, if it's not necessary.
>>>>>>
>>>>>> Regards.
>>>>>>
>>>>>> ________________________________________
>>>>>> From: Edison Su [Edison.su@citrix.com]
>>>>>> Sent: Friday, November 02, 2012 1:55 AM
>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>
>>>>>> Oh, it reminds me that how to use the CLI on the bash command line?
>>>>>> I think admin may want to call cloudstack API in a bash script, 
>>>>>> how can I do that?
>>>>>>
>>>>>>> -----Original Message-----
>>>>>>> From: Marcus Sorensen [mailto:shadowsor@gmail.com]
>>>>>>> Sent: Thursday, November 01, 2012 1:11 PM
>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>
>>>>>>> Yes, I look forward to using it instead of local curl calls on 
>>>>>>> the command line :-)
>>>>>>>
>>>>>>> On Thu, Nov 1, 2012 at 2:02 PM, Edison Su <Ed...@citrix.com> wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>> -----Original Message-----
>>>>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>>>>> Sent: Thursday, November 01, 2012 11:45 AM
>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>>>>
>>>>>>>>> Hi Chip, please go ahead if we can fix the http/s issue. The 
>>>>>>>>> connection is based on marvin, I'm sure using CLI we'll find 
>>>>>>>>> out more bugs and fix anything in marvin thereby help maintain
>>>>>>>>> marvin->tests and
>>>>>>> CLI.
>>>>>>>>> Please hack that up on
>>>>>>>>> tools/marvin/marvin/cloudstackConnection.py
>>>>>>>>>
>>>>>>>>> Edison, yes I'm working on the completedefault, I've figured a 
>>>>>>>>> solution to the parsing and tabbing issue to show params for 
>>>>>>>>> any api and added more verbs to the grammar like deploy, start etc.
>>>>>>>>> In the new approach doc strings and params needed for an api 
>>>>>>>>> are fetched and cached in the class locally to speed up the loading process.
>>>>>>>>> Till it gets committed, cloudmonkey (now) will keep telling 
>>>>>>>>> the user what params they are missing until it gets all the required ones.
>>>>>>>>
>>>>>>>> Great! Thanks for your awesome CLI, people will like it.
>>>>>>>>
>>>>>>>>>
>>>>>>>>> One more thing, for people who may not have unicode support 
>>>>>>>>> the prompt may appear weird and history search (up, down ) can 
>>>>>>>>> mess up the visuals. For example on Mac it appears as a 
>>>>>>>>> colorful emoji, but I found that it looks weird on other 
>>>>>>>>> platforms. Will probably remove it, or the user can custom set 
>>>>>>>>> their prompt, using: set prompt
>>>>>>>>> myprompt>
>>>>>>>>>
>>>>>>>>> Regards.
>>>>>>>>> PS. the set command is full of (fun :)  hacks because of 
>>>>>>>>> funtional/generic programming, it basically can set any 
>>>>>>>>> attribute on the class, so one can do something like creating 
>>>>>>>>> something (var, func). For example set ruler # (so instead of
>>>>>>>>> - you will have a #
>>>>>>>>> separator)
>>>>>>>>>
>>>>>>>>> ________________________________________
>>>>>>>>> From: Chip Childers [chip.childers@sungard.com]
>>>>>>>>> Sent: Thursday, November 01, 2012 11:15 PM
>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>>>
>>>>>>>>> On Wed, Oct 31, 2012 at 2:10 PM, Rohit Yadav 
>>>>>>>>> <ro...@citrix.com>
>>>>>>>>> wrote:
>>>>>>>>>> Hi,
>>>>>>>>>>
>>>>>>>>>> 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:
>>>>>>>>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstac
>>>>>>>>>> k.gi t; a=c ommit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
>>>>>>>>>>
>>>>>>>>>> Features:
>>>>>>>>>> - 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
>>>>>>>>>>
>>>>>>>>>> FIXMEs:
>>>>>>>>>> - 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 python cloudmonkey.py
>>>>>>>>>>
>>>>>>>>>> If you want to have the terminal tool installed; cd tools/cli 
>>>>>>>>>> python setup.py 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=8.8.8.8 internaldns1=10.147.28.6
>>>>>>>>>> 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
>>>>>>>>>> networkofferingid= create Pod zoneid= name=Pod1
>>>>>>> gateway=10.147.28.1
>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.220
>>>>>>>>>> endip=10.147.28.235 create VlanIpRange podid= networkid=
>>>>>>>>>> gateway=10.147.28.1
>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.236
>>>>>>>>>> endip=10.147.28.250 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=http://10.147.28.60 create StoragePool zoneid= clusterid=
>>>>>>>>>> name=NFS1 url=nfs://10.147.28.7/export/home/rohit/primary
>>>>>>>>>> add SecondaryStorage zoneId=
>>>>>>>>>> url=nfs://10.147.28.7/export/home/rohit/secondary
>>>>>>>>>> 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.
>>>>>>>>>>
>>>>>>>>>> Regards.
>>>>>>>>>> PS. Marvin the neglected robot and hipster cloudmonkey should 
>>>>>>>>>> rule the world :D
>>>>>>>>>
>>>>>>>>> Rohit,
>>>>>>>>>
>>>>>>>>> This is really really cool.  It puts the "fun" in managing 
>>>>>>>>> instances from a command line.  I've been testing it against a 
>>>>>>>>> production CloudStack environment, and it's working pretty well.
>>>>>>>>>
>>>>>>>>> If you don't mind, I might hack at the code a bit to fill in 
>>>>>>>>> some gaps that I'm seeing.  First example is that it assumes 
>>>>>>>>> http, which doesn't work in a public deployment where the endpoint is over https.
>>>>>>>>>
>>>>>>>>> -chip
>

RE: CLI for CloudStack: cloudmonkey

Posted by "Musayev, Ilya" <im...@webmd.net>.
So pip comes with python 2.7 which is not available by default on CentOS 6.3

Any other method I could use, other than installing python 2.7?

Thanks
ilya

-----Original Message-----
From: Rohit Yadav [mailto:rohit.yadav@citrix.com] 
Sent: Thursday, November 08, 2012 2:14 PM
To: cloudstack-dev@incubator.apache.org
Subject: RE: CLI for CloudStack: cloudmonkey

Oh, forgot to see that. Yes, now all the cmds are lowercase (except for few params liks isAsync=) and tab completion is advised.

Regards.
________________________________________
From: Kishan Kavala [Kishan.Kavala@citrix.com]
Sent: Thursday, November 08, 2012 11:29 PM
To: cloudstack-dev@incubator.apache.org
Cc: cloudstack-dev@incubator.apache.org
Subject: Re: CLI for CloudStack: cloudmonkey

Sebastian,
  Try set apikey in lower case. Same with set secretkey.

~kishan

On 08-Nov-2012, at 10:00 PM, "Sebastien Goasguen" <ru...@gmail.com> wrote:

> Actually it does not work yet.
>
> Now I can type 'b' but it does not get passed properly:
>
> 🙉 cloudmonkey> set apiKey 
> KEbkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzjR
> B9UNrBybVr3kcZ6Q
>
> Gives:
>
> INFO  [cloud.api.ApiServer] (92734721@qtp-1601733969-7:) apiKey does 
> not map to a valid user -- ignoring request, apiKey: 
> KEkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzjRB
> 9UNrByVr3kcZ6Q
>
> On Nov 8, 2012, at 5:19 PM, Sebastien Goasguen <ru...@gmail.com> wrote:
>
>>
>> On Nov 8, 2012, at 3:28 PM, Rohit Yadav <ro...@citrix.com> wrote:
>>
>>> Hi Sebastien,
>>>
>>> Are you using it from pypi/pip, if so do this:
>>> sudo pip uninstall cloudmonkey
>>> sudo pip install cloudmonkey
>>
>> no, I am doing: sudo python ./setup.py install from the source tree
>>
>>> I've had this bug on mac osx, fixed it:
>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.git;a
>>> =commit;h=36e7a7884efef7c41ac369549b7bdb93e5122110
>>
>> pulled that and reinstalled…and it works.
>>
>> thanks
>>
>> -sebastien
>>
>>
>>> If it still persists for you, checkout  
>>> http://superuser.com/questions/297527/cant-type-the-b-letter-in-pyth
>>> on-shell-in-os-x
>>>
>>> Let me know if this still fails then.
>>>
>>> Regards.
>>>
>>> ________________________________________
>>> From: Sebastien Goasguen [runseb@gmail.com]
>>> Sent: Thursday, November 08, 2012 5:37 PM
>>> To: cloudstack-dev@incubator.apache.org
>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>
>>> Hi,
>>>
>>> I am testing the cli and I have the weirdest issue. When I set the apikey or secretkey, the lower case 'b' letter does not print at the prompt.
>>> So if my keys contain 'b' they don't work..
>>>
>>> I tried all the other letters and they work.
>>>
>>> Anyone seeing this,
>>>
>>> -Sebastien
>>>
>>> On Nov 7, 2012, at 7:25 PM, Rohit Yadav <ro...@citrix.com> wrote:
>>>
>>>> yes, I think I'd mentioned in the thread or somewhere. Just use pip 
>>>> or easy_install (apt-get install python-setuptools on ubuntu, 
>>>> install python2.6 or above and pip if you don't have it);
>>>>
>>>> sudo pip install cloudmonkey
>>>>
>>>> or sudo easy_install cloudmonkey
>>>>
>>>> now start cloudmonkey:
>>>> $ cloudmonkey
>>>> ...
>>>>
>>>> Will post a blog/screencast this weekend and update doc so everyone can get help on its usage, though it's pretty intuitive.
>>>> ________________________________________
>>>> From: Musayev, Ilya [imusayev@webmd.net]
>>>> Sent: Wednesday, November 07, 2012 11:41 PM
>>>> To: cloudstack-dev@incubator.apache.org
>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>
>>>> Rohit,
>>>>
>>>> Can I get the CLI only without going through the whole source code maven install? Is it part of any RPM?
>>>>
>>>> Thanks
>>>> ilya
>>>>
>>>> -----Original Message-----
>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>> Sent: Monday, November 05, 2012 11:35 AM
>>>> To: cloudstack-dev@incubator.apache.org
>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>
>>>> Checkout latest code. Few changes to share:
>>>>
>>>> - All lowercase now
>>>> - Tab tab over verbs to see list of params for that api, example 
>>>> list users <tab><tab>
>>>> - This needs improvement but help string, using --help: list user 
>>>> --help
>>>> - Caching to speedup runtime
>>>> - Color and Parsing fixes
>>>>
>>>> Last, I'm now able to get the doc strings for each attribute/param, will see this tomorrow.
>>>>
>>>> Need your help, just incase you want to contribute, these are the TODOs:
>>>>
>>>> - search over history
>>>> - fix parsing
>>>> - doc strings for parameters
>>>> - testing for various kinds of apis (I'm able to deploy a zone with 
>>>> this, but needs testing)
>>>> - unicode char monkey, used in prompt may mess up history searching 
>>>> and text display
>>>>
>>>>
>>>> Regards.
>>>>
>>>> On 02-Nov-2012, at 4:58 AM, Edison Su <Ed...@citrix.com> wrote:
>>>>
>>>>>
>>>>>
>>>>>> -----Original Message-----
>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>> Sent: Thursday, November 01, 2012 2:23 PM
>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>
>>>>>> After you install the tool, so that cloudmonkey is in your 
>>>>>> /usr/local/bin or in $PATH...
>>>>>>
>>>>>> Two ways;
>>>>>> 1. As command line tool, on bash/zsh, use the BNF grammar; 
>>>>>> <command line tool
>>>>>> name>:<separator>:<verb>:<separator>:<action>:<separator>:<params
>>>>>> name>>
>>>>>> <command line tool name>={'cloudmonkey'} <separator>={' '} 
>>>>>> <verb>={'list', 'create', 'delete', 'update'.... etc.} 
>>>>>> <action>={'Users'... etc.} <params>={'listall=#'... etc.} So; $ 
>>>>>> cloudmonkey list Users
>>>>>
>>>>>
>>>>> Got it, thanks!
>>>>>
>>>>>>
>>>>>> 2. file redirector:
>>>>>>
>>>>>> $ cat test-file:
>>>>>> list Users
>>>>>> list <some other action>
>>>>>> <some verb> <some action>
>>>>>>
>>>>>> $ cloudmonkey < test-file
>>>>>>
>>>>>> Note, I'll change the actions (Users, VirtualMachine etc.) to 
>>>>>> lowercase (users, virtualmachine etc.) if that's okay?
>>>>>
>>>>> Please do, nobody wants to type extra keystroke, if it's not necessary.
>>>>>>
>>>>>> Regards.
>>>>>>
>>>>>> ________________________________________
>>>>>> From: Edison Su [Edison.su@citrix.com]
>>>>>> Sent: Friday, November 02, 2012 1:55 AM
>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>
>>>>>> Oh, it reminds me that how to use the CLI on the bash command line?
>>>>>> I think admin may want to call cloudstack API in a bash script, 
>>>>>> how can I do that?
>>>>>>
>>>>>>> -----Original Message-----
>>>>>>> From: Marcus Sorensen [mailto:shadowsor@gmail.com]
>>>>>>> Sent: Thursday, November 01, 2012 1:11 PM
>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>
>>>>>>> Yes, I look forward to using it instead of local curl calls on 
>>>>>>> the command line :-)
>>>>>>>
>>>>>>> On Thu, Nov 1, 2012 at 2:02 PM, Edison Su <Ed...@citrix.com> wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>> -----Original Message-----
>>>>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>>>>> Sent: Thursday, November 01, 2012 11:45 AM
>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>>>>
>>>>>>>>> Hi Chip, please go ahead if we can fix the http/s issue. The 
>>>>>>>>> connection is based on marvin, I'm sure using CLI we'll find 
>>>>>>>>> out more bugs and fix anything in marvin thereby help maintain
>>>>>>>>> marvin->tests and
>>>>>>> CLI.
>>>>>>>>> Please hack that up on 
>>>>>>>>> tools/marvin/marvin/cloudstackConnection.py
>>>>>>>>>
>>>>>>>>> Edison, yes I'm working on the completedefault, I've figured a 
>>>>>>>>> solution to the parsing and tabbing issue to show params for 
>>>>>>>>> any api and added more verbs to the grammar like deploy, start etc.
>>>>>>>>> In the new approach doc strings and params needed for an api 
>>>>>>>>> are fetched and cached in the class locally to speed up the loading process.
>>>>>>>>> Till it gets committed, cloudmonkey (now) will keep telling 
>>>>>>>>> the user what params they are missing until it gets all the required ones.
>>>>>>>>
>>>>>>>> Great! Thanks for your awesome CLI, people will like it.
>>>>>>>>
>>>>>>>>>
>>>>>>>>> One more thing, for people who may not have unicode support 
>>>>>>>>> the prompt may appear weird and history search (up, down ) can 
>>>>>>>>> mess up the visuals. For example on Mac it appears as a 
>>>>>>>>> colorful emoji, but I found that it looks weird on other 
>>>>>>>>> platforms. Will probably remove it, or the user can custom set 
>>>>>>>>> their prompt, using: set prompt
>>>>>>>>> myprompt>
>>>>>>>>>
>>>>>>>>> Regards.
>>>>>>>>> PS. the set command is full of (fun :)  hacks because of 
>>>>>>>>> funtional/generic programming, it basically can set any 
>>>>>>>>> attribute on the class, so one can do something like creating 
>>>>>>>>> something (var, func). For example set ruler # (so instead of 
>>>>>>>>> - you will have a #
>>>>>>>>> separator)
>>>>>>>>>
>>>>>>>>> ________________________________________
>>>>>>>>> From: Chip Childers [chip.childers@sungard.com]
>>>>>>>>> Sent: Thursday, November 01, 2012 11:15 PM
>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>>>
>>>>>>>>> On Wed, Oct 31, 2012 at 2:10 PM, Rohit Yadav 
>>>>>>>>> <ro...@citrix.com>
>>>>>>>>> wrote:
>>>>>>>>>> Hi,
>>>>>>>>>>
>>>>>>>>>> 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:
>>>>>>>>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstac
>>>>>>>>>> k.gi t; a=c ommit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
>>>>>>>>>>
>>>>>>>>>> Features:
>>>>>>>>>> - 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
>>>>>>>>>>
>>>>>>>>>> FIXMEs:
>>>>>>>>>> - 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 python cloudmonkey.py
>>>>>>>>>>
>>>>>>>>>> If you want to have the terminal tool installed; cd tools/cli 
>>>>>>>>>> python setup.py 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=8.8.8.8 internaldns1=10.147.28.6
>>>>>>>>>> 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
>>>>>>>>>> networkofferingid= create Pod zoneid= name=Pod1
>>>>>>> gateway=10.147.28.1
>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.220 
>>>>>>>>>> endip=10.147.28.235 create VlanIpRange podid= networkid= 
>>>>>>>>>> gateway=10.147.28.1
>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.236 
>>>>>>>>>> endip=10.147.28.250 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=http://10.147.28.60 create StoragePool zoneid= clusterid= 
>>>>>>>>>> name=NFS1 url=nfs://10.147.28.7/export/home/rohit/primary
>>>>>>>>>> add SecondaryStorage zoneId=
>>>>>>>>>> url=nfs://10.147.28.7/export/home/rohit/secondary
>>>>>>>>>> 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.
>>>>>>>>>>
>>>>>>>>>> Regards.
>>>>>>>>>> PS. Marvin the neglected robot and hipster cloudmonkey should 
>>>>>>>>>> rule the world :D
>>>>>>>>>
>>>>>>>>> Rohit,
>>>>>>>>>
>>>>>>>>> This is really really cool.  It puts the "fun" in managing 
>>>>>>>>> instances from a command line.  I've been testing it against a 
>>>>>>>>> production CloudStack environment, and it's working pretty well.
>>>>>>>>>
>>>>>>>>> If you don't mind, I might hack at the code a bit to fill in 
>>>>>>>>> some gaps that I'm seeing.  First example is that it assumes 
>>>>>>>>> http, which doesn't work in a public deployment where the endpoint is over https.
>>>>>>>>>
>>>>>>>>> -chip
>

Re: CLI for CloudStack: cloudmonkey

Posted by Rohit Yadav <ro...@citrix.com>.
Okay fixed, just do this:

sudo pip uninstall cloudmonkey
sudo pip install cloudmonkey

in your config add timeout = 3600 and asyncblock = true, cloudmonkey will guide you where to do it.

Checkout bug issue, or commit on usage.

Regards.

On 16-Nov-2012, at 1:49 PM, Dave Cahill <dc...@midokura.jp> wrote:

> Fantastic, thanks Rohit. I have saved a bunch of time already using
> CloudMonkey!
>
>
> On Fri, Nov 16, 2012 at 5:17 PM, Rohit Yadav <ro...@citrix.com> wrote:
>
>> Thanks Dave for filing the issue, will try to fix this by end of the day.
>> If not, I will post my solution on the issue.
>> Regards.
>> On 16-Nov-2012, at 1:19 PM, Dave Cahill <dc...@midokura.jp> wrote:
>>
>>> Thanks Rohit - filed this bug to track the issue:
>>> https://issues.apache.org/jira/browse/CLOUDSTACK-499
>>>
>>> If you have time to write a description of how you're planning to fix
>> it, I
>>> could take a look at it - I have my setup 99% automated, just need to get
>>> this param passing working. :)
>>>
>>> Thanks,
>>> Dave.
>>>
>>>
>>> On Thu, Nov 15, 2012 at 11:20 PM, Rohit Yadav <rohit.yadav@citrix.com
>>> wrote:
>>>
>>>>
>>>> On 15-Nov-2012, at 3:26 PM, Dave Cahill <dc...@midokura.jp> wrote:
>>>>
>>>>> Hi Rohit,
>>>>>
>>>>> I've been using cloudmonkey to script my CloudStack setup process in
>> dev,
>>>>> and had one question.
>>>>>
>>>>> How do we pass complex (MAP) parameters to cloudmonkey? For example,
>> when
>>>>> setting up a networkoffering, there's a serviceProviderList parameter
>>>> which
>>>>> is a list of items, each of which has several key value pairs. I tried
>> a
>>>>> couple of syntaxes to pass this parameter, but didn't come across the
>>>>> correct one yet - can you enlighten me? ;)
>>>>
>>>> Hi Dave, thanks for catching the bug. The way maps are handled in url
>> are
>>>> very different than how cloudmonkey parses and passing key,values.
>>>> This actually needs to be fixed in Marvin, I've figured out a way but it
>>>> may cause issues with marvin, will discuss with Prasanna and fix it
>> soon.
>>>>
>>>> You may file an issues if you want to.
>>>>
>>>> Regards.
>>>>
>>>>>
>>>>> Thanks for your work on this, very useful.
>>>>>
>>>>> Thanks,
>>>>> Dave.
>>>>>
>>>>>
>>>>> On Mon, Nov 12, 2012 at 7:01 PM, Rohit Yadav <ro...@citrix.com>
>>>> wrote:
>>>>>
>>>>>> Hi Charles,
>>>>>>
>>>>>> Karaf seems nice, and no worries I don't see any suggestions as flames
>>>> or
>>>>>> war. I would anytime throw away any code for something better, so feel
>>>> free
>>>>>> to start writing your own client and share with us. Patches welcome!
>>>>>>
>>>>>> Let me share why I wrote it in Python:
>>>>>>
>>>>>> - First of all the CLI is not even a client to start with, I mean I've
>>>>>> totally based it off marvin. It's a small wrapper I would say around
>>>> marvin.
>>>>>> - Python because, the environment is preinstalled on Macs and almost
>> all
>>>>>> Linux distros.
>>>>>> - Scripting environment that Python provides so one can fork and edit
>>>>>> their own versions of cloudmonkey CLI, this saves the user from
>>>>>> hack->compile->build->run loop; one can just hack and run.
>>>>>> - The best part again is marvin as dependency, you write javadocs etc.
>>>> in
>>>>>> your java code, apidocs gets interface definition and requirements
>> from
>>>> the
>>>>>> java code, the commands.xml created in the process is used by marvin's
>>>>>> codegenerator  which generates api modules with Cmd and Response
>>>> classes.
>>>>>> The generated cloudstackAPI is used by both marvin clients and the
>> CLI.
>>>> The
>>>>>> CLI which is about 400 lines of Python, in turn loads these modules
>> and
>>>>>> generates grammar and command handlers on the fly using some
>> functional
>>>>>> magic (injects functions into the classes), I don't think this kind of
>>>>>> programming is even possible with Java, they don't have functions as
>>>> first
>>>>>> class citizens.
>>>>>>
>>>>>> What does the last statement mean for the developers:
>>>>>> So, if a developer simply adds a new API which is java code, with
>>>> required
>>>>>> docs etc. apidocs will pick it up automatically and in turn marvin
>> (and
>>>>>> it's test clients) will get new cloudstackAPI and CLI too gets the new
>>>> APIs
>>>>>> on the fly. The functional closures in CLI will make sure the new APIs
>>>> and
>>>>>> its handlers are created with grammar rules. The developer won't need
>> to
>>>>>> change apidocs, marvin or CLI. I think this is one of my best hacks
>> [0]
>>>>>> which leverages on existing code and I think it would be very
>>>> maintainable
>>>>>> in future.
>>>>>>
>>>>>> Sorry everyone, I'm caught up with some other issues, I want to post a
>>>>>> screencast and blog explaining the CLI but only after I finalize the
>>>> specs
>>>>>> for the CLI. Thanks for the feedback so far.
>>>>>> The top TODOs left now are:
>>>>>> - Reverse search
>>>>>> - Bash/zsh completion
>>>>>>
>>>>>> Regards.
>>>>>> PS. Just in case you're curious:
>>>>>> [0] https://github.com/bhaisaab/hacktools
>>>>>>
>>>>>> ________________________________________
>>>>>> From: Charles Moulliard [ch007m@gmail.com]
>>>>>> Sent: Monday, November 12, 2012 12:49 PM
>>>>>> To: cloudstack-dev
>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I don't want to create a developer war or position a technology
>> against
>>>>>> another (python against java) but we could leverage Apache Karaf (OSGI
>>>>>> runtime container) project to provide the cloudmonkey client. This
>> work
>>>> has
>>>>>> already be done for jclouds (
>> http://www.youtube.com/watch?v=EKVkm6AV19U
>>>> ,
>>>>>> https://github.com/jclouds/jclouds-karaf) and could be easily
>>>>>> created
>>>>>> created for cloudmonkey. Karaf which is a shell environment proposes a
>>>> lot
>>>>>> of by default features (http://karaf.apache.org/ : ssh, jaas,
>>>>>> provisioning,
>>>>>> administration, history, config files support, ... -
>>>>>>
>> http://karaf.apache.org/manual/latest-2.3.x/developers-guide/index.html
>>>> )
>>>>>> that we could extend with cloudmonkey commands (
>>>>>>
>>>>>>
>>>>
>> http://karaf.apache.org/manual/latest-2.3.x/developers-guide/extending-console.html
>>>>>> )
>>>>>> and rebrand Karaf into a cloudmonkey karaf container.
>>>>>>
>>>>>> Regards,
>>>>>>
>>>>>> Charles
>>>>>>
>>>>>>
>>>>>> On Fri, Nov 9, 2012 at 10:53 PM, Musayev, Ilya <im...@webmd.net>
>>>> wrote:
>>>>>>
>>>>>>> I guess mine got wiped somehow...
>>>>>>>
>>>>>>> -----Original Message-----
>>>>>>> From: Musayev, Ilya [mailto:imusayev@webmd.net]
>>>>>>> Sent: Friday, November 09, 2012 4:51 PM
>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>>
>>>>>>> Rohit
>>>>>>>
>>>>>>> History seems to retain only last session and not previous - is this
>> by
>>>>>>> design?
>>>>>>>
>>>>>>> Thanks
>>>>>>> ilya
>>>>>>>
>>>>>>> -----Original Message-----
>>>>>>> From: sebgoa [mailto:runseb@gmail.com]
>>>>>>> Sent: Friday, November 09, 2012 4:52 AM
>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>
>>>>>>> Using lower case commands solved the issue
>>>>>>>
>>>>>>> thanks, and happy Diwali
>>>>>>>
>>>>>>> -Sebastien
>>>>>>>
>>>>>>> On Nov 8, 2012, at 8:14 PM, Rohit Yadav wrote:
>>>>>>>
>>>>>>>> Oh, forgot to see that. Yes, now all the cmds are lowercase (except
>>>> for
>>>>>>> few params liks isAsync=) and tab completion is advised.
>>>>>>>>
>>>>>>>> Regards.
>>>>>>>> ________________________________________
>>>>>>>> From: Kishan Kavala [Kishan.Kavala@citrix.com]
>>>>>>>> Sent: Thursday, November 08, 2012 11:29 PM
>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>> Cc: cloudstack-dev@incubator.apache.org
>>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>>
>>>>>>>> Sebastian,
>>>>>>>> Try set apikey in lower case. Same with set secretkey.
>>>>>>>>
>>>>>>>> ~kishan
>>>>>>>>
>>>>>>>> On 08-Nov-2012, at 10:00 PM, "Sebastien Goasguen" <runseb@gmail.com
>>>
>>>>>>> wrote:
>>>>>>>>
>>>>>>>>> Actually it does not work yet.
>>>>>>>>>
>>>>>>>>> Now I can type 'b' but it does not get passed properly:
>>>>>>>>>
>>>>>>>>> 🙉 cloudmonkey> set apiKey
>>>>>>>>>
>> KEbkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzj
>>>>>>>>> RB9UNrBybVr3kcZ6Q
>>>>>>>>>
>>>>>>>>> Gives:
>>>>>>>>>
>>>>>>>>> INFO  [cloud.api.ApiServer] (92734721@qtp-1601733969-7:) apiKey
>> does
>>>>>>>>> not map to a valid user -- ignoring request, apiKey:
>>>>>>>>>
>> KEkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzjR
>>>>>>>>> B9UNrByVr3kcZ6Q
>>>>>>>>>
>>>>>>>>> On Nov 8, 2012, at 5:19 PM, Sebastien Goasguen <ru...@gmail.com>
>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Nov 8, 2012, at 3:28 PM, Rohit Yadav <ro...@citrix.com>
>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>>> Hi Sebastien,
>>>>>>>>>>>
>>>>>>>>>>> Are you using it from pypi/pip, if so do this:
>>>>>>>>>>> sudo pip uninstall cloudmonkey
>>>>>>>>>>> sudo pip install cloudmonkey
>>>>>>>>>>
>>>>>>>>>> no, I am doing: sudo python ./setup.py install from the source
>> tree
>>>>>>>>>>
>>>>>>>>>>> I've had this bug on mac osx, fixed it:
>>>>>>>>>>>
>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.git
>>>> ;
>>>>>>>>>>> a=commit;h=36e7a7884efef7c41ac369549b7bdb93e5122110
>>>>>>>>>>
>>>>>>>>>> pulled that and reinstalled…and it works.
>>>>>>>>>>
>>>>>>>>>> thanks
>>>>>>>>>>
>>>>>>>>>> -sebastien
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>> If it still persists for you, checkout
>>>>>>>>>>>
>>>> http://superuser.com/questions/297527/cant-type-the-b-letter-in-pyt
>>>>>>>>>>> hon-shell-in-os-x
>>>>>>>>>>>
>>>>>>>>>>> Let me know if this still fails then.
>>>>>>>>>>>
>>>>>>>>>>> Regards.
>>>>>>>>>>>
>>>>>>>>>>> ________________________________________
>>>>>>>>>>> From: Sebastien Goasguen [runseb@gmail.com]
>>>>>>>>>>> Sent: Thursday, November 08, 2012 5:37 PM
>>>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>>>>>
>>>>>>>>>>> Hi,
>>>>>>>>>>>
>>>>>>>>>>> I am testing the cli and I have the weirdest issue. When I set
>> the
>>>>>>> apikey or secretkey, the lower case 'b' letter does not print at the
>>>>>> prompt.
>>>>>>>>>>> So if my keys contain 'b' they don't work..
>>>>>>>>>>>
>>>>>>>>>>> I tried all the other letters and they work.
>>>>>>>>>>>
>>>>>>>>>>> Anyone seeing this,
>>>>>>>>>>>
>>>>>>>>>>> -Sebastien
>>>>>>>>>>>
>>>>>>>>>>> On Nov 7, 2012, at 7:25 PM, Rohit Yadav <ro...@citrix.com>
>>>>>>> wrote:
>>>>>>>>>>>
>>>>>>>>>>>> yes, I think I'd mentioned in the thread or somewhere. Just use
>>>>>>>>>>>> pip or easy_install (apt-get install python-setuptools on
>> ubuntu,
>>>>>>>>>>>> install python2.6 or above and pip if you don't have it);
>>>>>>>>>>>>
>>>>>>>>>>>> sudo pip install cloudmonkey
>>>>>>>>>>>>
>>>>>>>>>>>> or sudo easy_install cloudmonkey
>>>>>>>>>>>>
>>>>>>>>>>>> now start cloudmonkey:
>>>>>>>>>>>> $ cloudmonkey
>>>>>>>>>>>> ...
>>>>>>>>>>>>
>>>>>>>>>>>> Will post a blog/screencast this weekend and update doc so
>>>> everyone
>>>>>>> can get help on its usage, though it's pretty intuitive.
>>>>>>>>>>>> ________________________________________
>>>>>>>>>>>> From: Musayev, Ilya [imusayev@webmd.net]
>>>>>>>>>>>> Sent: Wednesday, November 07, 2012 11:41 PM
>>>>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>>>>>>>
>>>>>>>>>>>> Rohit,
>>>>>>>>>>>>
>>>>>>>>>>>> Can I get the CLI only without going through the whole source
>> code
>>>>>>> maven install? Is it part of any RPM?
>>>>>>>>>>>>
>>>>>>>>>>>> Thanks
>>>>>>>>>>>> ilya
>>>>>>>>>>>>
>>>>>>>>>>>> -----Original Message-----
>>>>>>>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>>>>>>>> Sent: Monday, November 05, 2012 11:35 AM
>>>>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>>>>>>
>>>>>>>>>>>> Checkout latest code. Few changes to share:
>>>>>>>>>>>>
>>>>>>>>>>>> - All lowercase now
>>>>>>>>>>>> - Tab tab over verbs to see list of params for that api, example
>>>>>>>>>>>> list users <tab><tab>
>>>>>>>>>>>> - This needs improvement but help string, using --help: list
>> user
>>>>>>>>>>>> --help
>>>>>>>>>>>> - Caching to speedup runtime
>>>>>>>>>>>> - Color and Parsing fixes
>>>>>>>>>>>>
>>>>>>>>>>>> Last, I'm now able to get the doc strings for each
>>>> attribute/param,
>>>>>>> will see this tomorrow.
>>>>>>>>>>>>
>>>>>>>>>>>> Need your help, just incase you want to contribute, these are
>> the
>>>>>>> TODOs:
>>>>>>>>>>>>
>>>>>>>>>>>> - search over history
>>>>>>>>>>>> - fix parsing
>>>>>>>>>>>> - doc strings for parameters
>>>>>>>>>>>> - testing for various kinds of apis (I'm able to deploy a zone
>>>>>>>>>>>> with this, but needs testing)
>>>>>>>>>>>> - unicode char monkey, used in prompt may mess up history
>>>>>>>>>>>> searching and text display
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Regards.
>>>>>>>>>>>>
>>>>>>>>>>>> On 02-Nov-2012, at 4:58 AM, Edison Su <Ed...@citrix.com>
>>>>>> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>> -----Original Message-----
>>>>>>>>>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>>>>>>>>>> Sent: Thursday, November 01, 2012 2:23 PM
>>>>>>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> After you install the tool, so that cloudmonkey is in your
>>>>>>>>>>>>>> /usr/local/bin or in $PATH...
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Two ways;
>>>>>>>>>>>>>> 1. As command line tool, on bash/zsh, use the BNF grammar;
>>>>>>>>>>>>>> <command line tool
>>>>>>>>>>>>>>
>> name>:<separator>:<verb>:<separator>:<action>:<separator>:<param
>>>>>>>>>>>>>> name>s>
>>>>>>>>>>>>>> <command line tool name>={'cloudmonkey'} <separator>={' '}
>>>>>>>>>>>>>> <verb>={'list', 'create', 'delete', 'update'.... etc.}
>>>>>>>>>>>>>> <action>={'Users'... etc.} <params>={'listall=#'... etc.} So;
>> $
>>>>>>>>>>>>>> cloudmonkey list Users
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> Got it, thanks!
>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> 2. file redirector:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> $ cat test-file:
>>>>>>>>>>>>>> list Users
>>>>>>>>>>>>>> list <some other action>
>>>>>>>>>>>>>> <some verb> <some action>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> $ cloudmonkey < test-file
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Note, I'll change the actions (Users, VirtualMachine etc.) to
>>>>>>>>>>>>>> lowercase (users, virtualmachine etc.) if that's okay?
>>>>>>>>>>>>>
>>>>>>>>>>>>> Please do, nobody wants to type extra keystroke, if it's not
>>>>>>> necessary.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Regards.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> ________________________________________
>>>>>>>>>>>>>> From: Edison Su [Edison.su@citrix.com]
>>>>>>>>>>>>>> Sent: Friday, November 02, 2012 1:55 AM
>>>>>>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Oh, it reminds me that how to use the CLI on the bash command
>>>>>> line?
>>>>>>>>>>>>>> I think admin may want to call cloudstack API in a bash
>> script,
>>>>>>>>>>>>>> how can I do that?
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> -----Original Message-----
>>>>>>>>>>>>>>> From: Marcus Sorensen [mailto:shadowsor@gmail.com]
>>>>>>>>>>>>>>> Sent: Thursday, November 01, 2012 1:11 PM
>>>>>>>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Yes, I look forward to using it instead of local curl calls
>> on
>>>>>>>>>>>>>>> the command line :-)
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> On Thu, Nov 1, 2012 at 2:02 PM, Edison Su <
>>>> Edison.su@citrix.com
>>>>>>>
>>>>>>> wrote:
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> -----Original Message-----
>>>>>>>>>>>>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>>>>>>>>>>>>> Sent: Thursday, November 01, 2012 11:45 AM
>>>>>>>>>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>>>>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Hi Chip, please go ahead if we can fix the http/s issue.
>> The
>>>>>>>>>>>>>>>>> connection is based on marvin, I'm sure using CLI we'll
>> find
>>>>>>>>>>>>>>>>> out more bugs and fix anything in marvin thereby help
>>>>>>>>>>>>>>>>> maintain
>>>>>>>>>>>>>>>>> marvin->tests and
>>>>>>>>>>>>>>> CLI.
>>>>>>>>>>>>>>>>> Please hack that up on
>>>>>>>>>>>>>>>>> tools/marvin/marvin/cloudstackConnection.py
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Edison, yes I'm working on the completedefault, I've
>> figured
>>>>>>>>>>>>>>>>> a solution to the parsing and tabbing issue to show params
>>>>>>>>>>>>>>>>> for any api and added more verbs to the grammar like
>> deploy,
>>>>>>> start etc.
>>>>>>>>>>>>>>>>> In the new approach doc strings and params needed for an
>> api
>>>>>>>>>>>>>>>>> are fetched and cached in the class locally to speed up the
>>>>>>> loading process.
>>>>>>>>>>>>>>>>> Till it gets committed, cloudmonkey (now) will keep telling
>>>>>>>>>>>>>>>>> the user what params they are missing until it gets all the
>>>>>>> required ones.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Great! Thanks for your awesome CLI, people will like it.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> One more thing, for people who may not have unicode support
>>>>>>>>>>>>>>>>> the prompt may appear weird and history search (up, down )
>>>>>>>>>>>>>>>>> can mess up the visuals. For example on Mac it appears as a
>>>>>>>>>>>>>>>>> colorful emoji, but I found that it looks weird on other
>>>>>>>>>>>>>>>>> platforms. Will probably remove it, or the user can custom
>>>>>>>>>>>>>>>>> set their prompt, using: set prompt
>>>>>>>>>>>>>>>>> myprompt>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Regards.
>>>>>>>>>>>>>>>>> PS. the set command is full of (fun :)  hacks because of
>>>>>>>>>>>>>>>>> funtional/generic programming, it basically can set any
>>>>>>>>>>>>>>>>> attribute on the class, so one can do something like
>> creating
>>>>>>>>>>>>>>>>> something (var, func). For example set ruler # (so instead
>> of
>>>>>>>>>>>>>>>>> - you will have a #
>>>>>>>>>>>>>>>>> separator)
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> ________________________________________
>>>>>>>>>>>>>>>>> From: Chip Childers [chip.childers@sungard.com]
>>>>>>>>>>>>>>>>> Sent: Thursday, November 01, 2012 11:15 PM
>>>>>>>>>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>>>>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> On Wed, Oct 31, 2012 at 2:10 PM, Rohit Yadav
>>>>>>>>>>>>>>>>> <ro...@citrix.com>
>>>>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>>>> Hi,
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> 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:
>>>>>>>>>>>>>>>>>>
>>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudsta
>>>>>>>>>>>>>>>>>> ck.gi t; a=c
>>>>>>>>>>>>>>>>>> ommit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> Features:
>>>>>>>>>>>>>>>>>> - 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
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> FIXMEs:
>>>>>>>>>>>>>>>>>> - 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 python cloudmonkey.py
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> If you want to have the terminal tool installed; cd
>>>>>>>>>>>>>>>>>> tools/cli python setup.py 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=8.8.8.8 internaldns1=10.147.28.6
>>>>>>>>>>>>>>>>>> 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
>>>>>>>>>>>>>>>>>> networkofferingid= create Pod zoneid= name=Pod1
>>>>>>>>>>>>>>> gateway=10.147.28.1
>>>>>>>>>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.220
>>>>>>>>>>>>>>>>>> endip=10.147.28.235 create VlanIpRange podid= networkid=
>>>>>>>>>>>>>>>>>> gateway=10.147.28.1
>>>>>>>>>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.236
>>>>>>>>>>>>>>>>>> endip=10.147.28.250 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=http://10.147.28.60 create StoragePool zoneid=
>>>>>>>>>>>>>>>>>> clusterid= name=NFS1
>>>>>>>>>>>>>>>>>> url=nfs://10.147.28.7/export/home/rohit/primary
>>>>>>>>>>>>>>>>>> add SecondaryStorage zoneId=
>>>>>>>>>>>>>>>>>> url=nfs://10.147.28.7/export/home/rohit/secondary
>>>>>>>>>>>>>>>>>> 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.
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> Regards.
>>>>>>>>>>>>>>>>>> PS. Marvin the neglected robot and hipster cloudmonkey
>>>>>>>>>>>>>>>>>> should rule the world :D
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Rohit,
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> This is really really cool.  It puts the "fun" in managing
>>>>>>>>>>>>>>>>> instances from a command line.  I've been testing it
>> against
>>>>>>>>>>>>>>>>> a production CloudStack environment, and it's working
>> pretty
>>>>>>> well.
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> If you don't mind, I might hack at the code a bit to fill
>> in
>>>>>>>>>>>>>>>>> some gaps that I'm seeing.  First example is that it
>> assumes
>>>>>>>>>>>>>>>>> http, which doesn't work in a public deployment where the
>>>>>>> endpoint is over https.
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> -chip
>>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Charles Moulliard
>>>>>> Apache Committer / Sr. Enterprise Architect (RedHat)
>>>>>> Twitter : @cmoulliard | Blog : http://cmoulliard.blogspot.com
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Thanks,
>>>>> Dave.
>>>>
>>>>
>>>
>>>
>>> --
>>> Thanks,
>>> Dave.
>>
>>
>
>
> --
> Thanks,
> Dave.


Re: CLI for CloudStack: cloudmonkey

Posted by Dave Cahill <dc...@midokura.jp>.
Fantastic, thanks Rohit. I have saved a bunch of time already using
CloudMonkey!


On Fri, Nov 16, 2012 at 5:17 PM, Rohit Yadav <ro...@citrix.com> wrote:

> Thanks Dave for filing the issue, will try to fix this by end of the day.
> If not, I will post my solution on the issue.
> Regards.
> On 16-Nov-2012, at 1:19 PM, Dave Cahill <dc...@midokura.jp> wrote:
>
> > Thanks Rohit - filed this bug to track the issue:
> > https://issues.apache.org/jira/browse/CLOUDSTACK-499
> >
> > If you have time to write a description of how you're planning to fix
> it, I
> > could take a look at it - I have my setup 99% automated, just need to get
> > this param passing working. :)
> >
> > Thanks,
> > Dave.
> >
> >
> > On Thu, Nov 15, 2012 at 11:20 PM, Rohit Yadav <rohit.yadav@citrix.com
> >wrote:
> >
> >>
> >> On 15-Nov-2012, at 3:26 PM, Dave Cahill <dc...@midokura.jp> wrote:
> >>
> >>> Hi Rohit,
> >>>
> >>> I've been using cloudmonkey to script my CloudStack setup process in
> dev,
> >>> and had one question.
> >>>
> >>> How do we pass complex (MAP) parameters to cloudmonkey? For example,
> when
> >>> setting up a networkoffering, there's a serviceProviderList parameter
> >> which
> >>> is a list of items, each of which has several key value pairs. I tried
> a
> >>> couple of syntaxes to pass this parameter, but didn't come across the
> >>> correct one yet - can you enlighten me? ;)
> >>
> >> Hi Dave, thanks for catching the bug. The way maps are handled in url
> are
> >> very different than how cloudmonkey parses and passing key,values.
> >> This actually needs to be fixed in Marvin, I've figured out a way but it
> >> may cause issues with marvin, will discuss with Prasanna and fix it
> soon.
> >>
> >> You may file an issues if you want to.
> >>
> >> Regards.
> >>
> >>>
> >>> Thanks for your work on this, very useful.
> >>>
> >>> Thanks,
> >>> Dave.
> >>>
> >>>
> >>> On Mon, Nov 12, 2012 at 7:01 PM, Rohit Yadav <ro...@citrix.com>
> >> wrote:
> >>>
> >>>> Hi Charles,
> >>>>
> >>>> Karaf seems nice, and no worries I don't see any suggestions as flames
> >> or
> >>>> war. I would anytime throw away any code for something better, so feel
> >> free
> >>>> to start writing your own client and share with us. Patches welcome!
> >>>>
> >>>> Let me share why I wrote it in Python:
> >>>>
> >>>> - First of all the CLI is not even a client to start with, I mean I've
> >>>> totally based it off marvin. It's a small wrapper I would say around
> >> marvin.
> >>>> - Python because, the environment is preinstalled on Macs and almost
> all
> >>>> Linux distros.
> >>>> - Scripting environment that Python provides so one can fork and edit
> >>>> their own versions of cloudmonkey CLI, this saves the user from
> >>>> hack->compile->build->run loop; one can just hack and run.
> >>>> - The best part again is marvin as dependency, you write javadocs etc.
> >> in
> >>>> your java code, apidocs gets interface definition and requirements
> from
> >> the
> >>>> java code, the commands.xml created in the process is used by marvin's
> >>>> codegenerator  which generates api modules with Cmd and Response
> >> classes.
> >>>> The generated cloudstackAPI is used by both marvin clients and the
> CLI.
> >> The
> >>>> CLI which is about 400 lines of Python, in turn loads these modules
> and
> >>>> generates grammar and command handlers on the fly using some
> functional
> >>>> magic (injects functions into the classes), I don't think this kind of
> >>>> programming is even possible with Java, they don't have functions as
> >> first
> >>>> class citizens.
> >>>>
> >>>> What does the last statement mean for the developers:
> >>>> So, if a developer simply adds a new API which is java code, with
> >> required
> >>>> docs etc. apidocs will pick it up automatically and in turn marvin
> (and
> >>>> it's test clients) will get new cloudstackAPI and CLI too gets the new
> >> APIs
> >>>> on the fly. The functional closures in CLI will make sure the new APIs
> >> and
> >>>> its handlers are created with grammar rules. The developer won't need
> to
> >>>> change apidocs, marvin or CLI. I think this is one of my best hacks
> [0]
> >>>> which leverages on existing code and I think it would be very
> >> maintainable
> >>>> in future.
> >>>>
> >>>> Sorry everyone, I'm caught up with some other issues, I want to post a
> >>>> screencast and blog explaining the CLI but only after I finalize the
> >> specs
> >>>> for the CLI. Thanks for the feedback so far.
> >>>> The top TODOs left now are:
> >>>> - Reverse search
> >>>> - Bash/zsh completion
> >>>>
> >>>> Regards.
> >>>> PS. Just in case you're curious:
> >>>> [0] https://github.com/bhaisaab/hacktools
> >>>>
> >>>> ________________________________________
> >>>> From: Charles Moulliard [ch007m@gmail.com]
> >>>> Sent: Monday, November 12, 2012 12:49 PM
> >>>> To: cloudstack-dev
> >>>> Subject: Re: CLI for CloudStack: cloudmonkey
> >>>>
> >>>> Hi,
> >>>>
> >>>> I don't want to create a developer war or position a technology
> against
> >>>> another (python against java) but we could leverage Apache Karaf (OSGI
> >>>> runtime container) project to provide the cloudmonkey client. This
> work
> >> has
> >>>> already be done for jclouds (
> http://www.youtube.com/watch?v=EKVkm6AV19U
> >> ,
> >>>> https://github.com/jclouds/jclouds-karaf) and could be easily
> >>>> created
> >>>> created for cloudmonkey. Karaf which is a shell environment proposes a
> >> lot
> >>>> of by default features (http://karaf.apache.org/ : ssh, jaas,
> >>>> provisioning,
> >>>> administration, history, config files support, ... -
> >>>>
> http://karaf.apache.org/manual/latest-2.3.x/developers-guide/index.html
> >> )
> >>>> that we could extend with cloudmonkey commands (
> >>>>
> >>>>
> >>
> http://karaf.apache.org/manual/latest-2.3.x/developers-guide/extending-console.html
> >>>> )
> >>>> and rebrand Karaf into a cloudmonkey karaf container.
> >>>>
> >>>> Regards,
> >>>>
> >>>> Charles
> >>>>
> >>>>
> >>>> On Fri, Nov 9, 2012 at 10:53 PM, Musayev, Ilya <im...@webmd.net>
> >> wrote:
> >>>>
> >>>>> I guess mine got wiped somehow...
> >>>>>
> >>>>> -----Original Message-----
> >>>>> From: Musayev, Ilya [mailto:imusayev@webmd.net]
> >>>>> Sent: Friday, November 09, 2012 4:51 PM
> >>>>> To: cloudstack-dev@incubator.apache.org
> >>>>> Subject: RE: CLI for CloudStack: cloudmonkey
> >>>>>
> >>>>> Rohit
> >>>>>
> >>>>> History seems to retain only last session and not previous - is this
> by
> >>>>> design?
> >>>>>
> >>>>> Thanks
> >>>>> ilya
> >>>>>
> >>>>> -----Original Message-----
> >>>>> From: sebgoa [mailto:runseb@gmail.com]
> >>>>> Sent: Friday, November 09, 2012 4:52 AM
> >>>>> To: cloudstack-dev@incubator.apache.org
> >>>>> Subject: Re: CLI for CloudStack: cloudmonkey
> >>>>>
> >>>>> Using lower case commands solved the issue
> >>>>>
> >>>>> thanks, and happy Diwali
> >>>>>
> >>>>> -Sebastien
> >>>>>
> >>>>> On Nov 8, 2012, at 8:14 PM, Rohit Yadav wrote:
> >>>>>
> >>>>>> Oh, forgot to see that. Yes, now all the cmds are lowercase (except
> >> for
> >>>>> few params liks isAsync=) and tab completion is advised.
> >>>>>>
> >>>>>> Regards.
> >>>>>> ________________________________________
> >>>>>> From: Kishan Kavala [Kishan.Kavala@citrix.com]
> >>>>>> Sent: Thursday, November 08, 2012 11:29 PM
> >>>>>> To: cloudstack-dev@incubator.apache.org
> >>>>>> Cc: cloudstack-dev@incubator.apache.org
> >>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
> >>>>>>
> >>>>>> Sebastian,
> >>>>>> Try set apikey in lower case. Same with set secretkey.
> >>>>>>
> >>>>>> ~kishan
> >>>>>>
> >>>>>> On 08-Nov-2012, at 10:00 PM, "Sebastien Goasguen" <runseb@gmail.com
> >
> >>>>> wrote:
> >>>>>>
> >>>>>>> Actually it does not work yet.
> >>>>>>>
> >>>>>>> Now I can type 'b' but it does not get passed properly:
> >>>>>>>
> >>>>>>> 🙉 cloudmonkey> set apiKey
> >>>>>>>
> KEbkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzj
> >>>>>>> RB9UNrBybVr3kcZ6Q
> >>>>>>>
> >>>>>>> Gives:
> >>>>>>>
> >>>>>>> INFO  [cloud.api.ApiServer] (92734721@qtp-1601733969-7:) apiKey
> does
> >>>>>>> not map to a valid user -- ignoring request, apiKey:
> >>>>>>>
> KEkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzjR
> >>>>>>> B9UNrByVr3kcZ6Q
> >>>>>>>
> >>>>>>> On Nov 8, 2012, at 5:19 PM, Sebastien Goasguen <ru...@gmail.com>
> >>>>> wrote:
> >>>>>>>
> >>>>>>>>
> >>>>>>>> On Nov 8, 2012, at 3:28 PM, Rohit Yadav <ro...@citrix.com>
> >>>>> wrote:
> >>>>>>>>
> >>>>>>>>> Hi Sebastien,
> >>>>>>>>>
> >>>>>>>>> Are you using it from pypi/pip, if so do this:
> >>>>>>>>> sudo pip uninstall cloudmonkey
> >>>>>>>>> sudo pip install cloudmonkey
> >>>>>>>>
> >>>>>>>> no, I am doing: sudo python ./setup.py install from the source
> tree
> >>>>>>>>
> >>>>>>>>> I've had this bug on mac osx, fixed it:
> >>>>>>>>>
> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.git
> >> ;
> >>>>>>>>> a=commit;h=36e7a7884efef7c41ac369549b7bdb93e5122110
> >>>>>>>>
> >>>>>>>> pulled that and reinstalled…and it works.
> >>>>>>>>
> >>>>>>>> thanks
> >>>>>>>>
> >>>>>>>> -sebastien
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>> If it still persists for you, checkout
> >>>>>>>>>
> >> http://superuser.com/questions/297527/cant-type-the-b-letter-in-pyt
> >>>>>>>>> hon-shell-in-os-x
> >>>>>>>>>
> >>>>>>>>> Let me know if this still fails then.
> >>>>>>>>>
> >>>>>>>>> Regards.
> >>>>>>>>>
> >>>>>>>>> ________________________________________
> >>>>>>>>> From: Sebastien Goasguen [runseb@gmail.com]
> >>>>>>>>> Sent: Thursday, November 08, 2012 5:37 PM
> >>>>>>>>> To: cloudstack-dev@incubator.apache.org
> >>>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
> >>>>>>>>>
> >>>>>>>>> Hi,
> >>>>>>>>>
> >>>>>>>>> I am testing the cli and I have the weirdest issue. When I set
> the
> >>>>> apikey or secretkey, the lower case 'b' letter does not print at the
> >>>> prompt.
> >>>>>>>>> So if my keys contain 'b' they don't work..
> >>>>>>>>>
> >>>>>>>>> I tried all the other letters and they work.
> >>>>>>>>>
> >>>>>>>>> Anyone seeing this,
> >>>>>>>>>
> >>>>>>>>> -Sebastien
> >>>>>>>>>
> >>>>>>>>> On Nov 7, 2012, at 7:25 PM, Rohit Yadav <ro...@citrix.com>
> >>>>> wrote:
> >>>>>>>>>
> >>>>>>>>>> yes, I think I'd mentioned in the thread or somewhere. Just use
> >>>>>>>>>> pip or easy_install (apt-get install python-setuptools on
> ubuntu,
> >>>>>>>>>> install python2.6 or above and pip if you don't have it);
> >>>>>>>>>>
> >>>>>>>>>> sudo pip install cloudmonkey
> >>>>>>>>>>
> >>>>>>>>>> or sudo easy_install cloudmonkey
> >>>>>>>>>>
> >>>>>>>>>> now start cloudmonkey:
> >>>>>>>>>> $ cloudmonkey
> >>>>>>>>>> ...
> >>>>>>>>>>
> >>>>>>>>>> Will post a blog/screencast this weekend and update doc so
> >> everyone
> >>>>> can get help on its usage, though it's pretty intuitive.
> >>>>>>>>>> ________________________________________
> >>>>>>>>>> From: Musayev, Ilya [imusayev@webmd.net]
> >>>>>>>>>> Sent: Wednesday, November 07, 2012 11:41 PM
> >>>>>>>>>> To: cloudstack-dev@incubator.apache.org
> >>>>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
> >>>>>>>>>>
> >>>>>>>>>> Rohit,
> >>>>>>>>>>
> >>>>>>>>>> Can I get the CLI only without going through the whole source
> code
> >>>>> maven install? Is it part of any RPM?
> >>>>>>>>>>
> >>>>>>>>>> Thanks
> >>>>>>>>>> ilya
> >>>>>>>>>>
> >>>>>>>>>> -----Original Message-----
> >>>>>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
> >>>>>>>>>> Sent: Monday, November 05, 2012 11:35 AM
> >>>>>>>>>> To: cloudstack-dev@incubator.apache.org
> >>>>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
> >>>>>>>>>>
> >>>>>>>>>> Checkout latest code. Few changes to share:
> >>>>>>>>>>
> >>>>>>>>>> - All lowercase now
> >>>>>>>>>> - Tab tab over verbs to see list of params for that api, example
> >>>>>>>>>> list users <tab><tab>
> >>>>>>>>>> - This needs improvement but help string, using --help: list
> user
> >>>>>>>>>> --help
> >>>>>>>>>> - Caching to speedup runtime
> >>>>>>>>>> - Color and Parsing fixes
> >>>>>>>>>>
> >>>>>>>>>> Last, I'm now able to get the doc strings for each
> >> attribute/param,
> >>>>> will see this tomorrow.
> >>>>>>>>>>
> >>>>>>>>>> Need your help, just incase you want to contribute, these are
> the
> >>>>> TODOs:
> >>>>>>>>>>
> >>>>>>>>>> - search over history
> >>>>>>>>>> - fix parsing
> >>>>>>>>>> - doc strings for parameters
> >>>>>>>>>> - testing for various kinds of apis (I'm able to deploy a zone
> >>>>>>>>>> with this, but needs testing)
> >>>>>>>>>> - unicode char monkey, used in prompt may mess up history
> >>>>>>>>>> searching and text display
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>> Regards.
> >>>>>>>>>>
> >>>>>>>>>> On 02-Nov-2012, at 4:58 AM, Edison Su <Ed...@citrix.com>
> >>>> wrote:
> >>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>> -----Original Message-----
> >>>>>>>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
> >>>>>>>>>>>> Sent: Thursday, November 01, 2012 2:23 PM
> >>>>>>>>>>>> To: cloudstack-dev@incubator.apache.org
> >>>>>>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
> >>>>>>>>>>>>
> >>>>>>>>>>>> After you install the tool, so that cloudmonkey is in your
> >>>>>>>>>>>> /usr/local/bin or in $PATH...
> >>>>>>>>>>>>
> >>>>>>>>>>>> Two ways;
> >>>>>>>>>>>> 1. As command line tool, on bash/zsh, use the BNF grammar;
> >>>>>>>>>>>> <command line tool
> >>>>>>>>>>>>
> name>:<separator>:<verb>:<separator>:<action>:<separator>:<param
> >>>>>>>>>>>> name>s>
> >>>>>>>>>>>> <command line tool name>={'cloudmonkey'} <separator>={' '}
> >>>>>>>>>>>> <verb>={'list', 'create', 'delete', 'update'.... etc.}
> >>>>>>>>>>>> <action>={'Users'... etc.} <params>={'listall=#'... etc.} So;
> $
> >>>>>>>>>>>> cloudmonkey list Users
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>> Got it, thanks!
> >>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>> 2. file redirector:
> >>>>>>>>>>>>
> >>>>>>>>>>>> $ cat test-file:
> >>>>>>>>>>>> list Users
> >>>>>>>>>>>> list <some other action>
> >>>>>>>>>>>> <some verb> <some action>
> >>>>>>>>>>>>
> >>>>>>>>>>>> $ cloudmonkey < test-file
> >>>>>>>>>>>>
> >>>>>>>>>>>> Note, I'll change the actions (Users, VirtualMachine etc.) to
> >>>>>>>>>>>> lowercase (users, virtualmachine etc.) if that's okay?
> >>>>>>>>>>>
> >>>>>>>>>>> Please do, nobody wants to type extra keystroke, if it's not
> >>>>> necessary.
> >>>>>>>>>>>>
> >>>>>>>>>>>> Regards.
> >>>>>>>>>>>>
> >>>>>>>>>>>> ________________________________________
> >>>>>>>>>>>> From: Edison Su [Edison.su@citrix.com]
> >>>>>>>>>>>> Sent: Friday, November 02, 2012 1:55 AM
> >>>>>>>>>>>> To: cloudstack-dev@incubator.apache.org
> >>>>>>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
> >>>>>>>>>>>>
> >>>>>>>>>>>> Oh, it reminds me that how to use the CLI on the bash command
> >>>> line?
> >>>>>>>>>>>> I think admin may want to call cloudstack API in a bash
> script,
> >>>>>>>>>>>> how can I do that?
> >>>>>>>>>>>>
> >>>>>>>>>>>>> -----Original Message-----
> >>>>>>>>>>>>> From: Marcus Sorensen [mailto:shadowsor@gmail.com]
> >>>>>>>>>>>>> Sent: Thursday, November 01, 2012 1:11 PM
> >>>>>>>>>>>>> To: cloudstack-dev@incubator.apache.org
> >>>>>>>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> Yes, I look forward to using it instead of local curl calls
> on
> >>>>>>>>>>>>> the command line :-)
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> On Thu, Nov 1, 2012 at 2:02 PM, Edison Su <
> >> Edison.su@citrix.com
> >>>>>
> >>>>> wrote:
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> -----Original Message-----
> >>>>>>>>>>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
> >>>>>>>>>>>>>>> Sent: Thursday, November 01, 2012 11:45 AM
> >>>>>>>>>>>>>>> To: cloudstack-dev@incubator.apache.org
> >>>>>>>>>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> Hi Chip, please go ahead if we can fix the http/s issue.
> The
> >>>>>>>>>>>>>>> connection is based on marvin, I'm sure using CLI we'll
> find
> >>>>>>>>>>>>>>> out more bugs and fix anything in marvin thereby help
> >>>>>>>>>>>>>>> maintain
> >>>>>>>>>>>>>>> marvin->tests and
> >>>>>>>>>>>>> CLI.
> >>>>>>>>>>>>>>> Please hack that up on
> >>>>>>>>>>>>>>> tools/marvin/marvin/cloudstackConnection.py
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> Edison, yes I'm working on the completedefault, I've
> figured
> >>>>>>>>>>>>>>> a solution to the parsing and tabbing issue to show params
> >>>>>>>>>>>>>>> for any api and added more verbs to the grammar like
> deploy,
> >>>>> start etc.
> >>>>>>>>>>>>>>> In the new approach doc strings and params needed for an
> api
> >>>>>>>>>>>>>>> are fetched and cached in the class locally to speed up the
> >>>>> loading process.
> >>>>>>>>>>>>>>> Till it gets committed, cloudmonkey (now) will keep telling
> >>>>>>>>>>>>>>> the user what params they are missing until it gets all the
> >>>>> required ones.
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> Great! Thanks for your awesome CLI, people will like it.
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> One more thing, for people who may not have unicode support
> >>>>>>>>>>>>>>> the prompt may appear weird and history search (up, down )
> >>>>>>>>>>>>>>> can mess up the visuals. For example on Mac it appears as a
> >>>>>>>>>>>>>>> colorful emoji, but I found that it looks weird on other
> >>>>>>>>>>>>>>> platforms. Will probably remove it, or the user can custom
> >>>>>>>>>>>>>>> set their prompt, using: set prompt
> >>>>>>>>>>>>>>> myprompt>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> Regards.
> >>>>>>>>>>>>>>> PS. the set command is full of (fun :)  hacks because of
> >>>>>>>>>>>>>>> funtional/generic programming, it basically can set any
> >>>>>>>>>>>>>>> attribute on the class, so one can do something like
> creating
> >>>>>>>>>>>>>>> something (var, func). For example set ruler # (so instead
> of
> >>>>>>>>>>>>>>> - you will have a #
> >>>>>>>>>>>>>>> separator)
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> ________________________________________
> >>>>>>>>>>>>>>> From: Chip Childers [chip.childers@sungard.com]
> >>>>>>>>>>>>>>> Sent: Thursday, November 01, 2012 11:15 PM
> >>>>>>>>>>>>>>> To: cloudstack-dev@incubator.apache.org
> >>>>>>>>>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> On Wed, Oct 31, 2012 at 2:10 PM, Rohit Yadav
> >>>>>>>>>>>>>>> <ro...@citrix.com>
> >>>>>>>>>>>>>>> wrote:
> >>>>>>>>>>>>>>>> Hi,
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>> 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:
> >>>>>>>>>>>>>>>>
> >> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudsta
> >>>>>>>>>>>>>>>> ck.gi t; a=c
> >>>>>>>>>>>>>>>> ommit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>> Features:
> >>>>>>>>>>>>>>>> - 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
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>> FIXMEs:
> >>>>>>>>>>>>>>>> - 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 python cloudmonkey.py
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>> If you want to have the terminal tool installed; cd
> >>>>>>>>>>>>>>>> tools/cli python setup.py 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=8.8.8.8 internaldns1=10.147.28.6
> >>>>>>>>>>>>>>>> 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
> >>>>>>>>>>>>>>>> networkofferingid= create Pod zoneid= name=Pod1
> >>>>>>>>>>>>> gateway=10.147.28.1
> >>>>>>>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.220
> >>>>>>>>>>>>>>>> endip=10.147.28.235 create VlanIpRange podid= networkid=
> >>>>>>>>>>>>>>>> gateway=10.147.28.1
> >>>>>>>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.236
> >>>>>>>>>>>>>>>> endip=10.147.28.250 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=http://10.147.28.60 create StoragePool zoneid=
> >>>>>>>>>>>>>>>> clusterid= name=NFS1
> >>>>>>>>>>>>>>>> url=nfs://10.147.28.7/export/home/rohit/primary
> >>>>>>>>>>>>>>>> add SecondaryStorage zoneId=
> >>>>>>>>>>>>>>>> url=nfs://10.147.28.7/export/home/rohit/secondary
> >>>>>>>>>>>>>>>> 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.
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>> Regards.
> >>>>>>>>>>>>>>>> PS. Marvin the neglected robot and hipster cloudmonkey
> >>>>>>>>>>>>>>>> should rule the world :D
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> Rohit,
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> This is really really cool.  It puts the "fun" in managing
> >>>>>>>>>>>>>>> instances from a command line.  I've been testing it
> against
> >>>>>>>>>>>>>>> a production CloudStack environment, and it's working
> pretty
> >>>>> well.
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> If you don't mind, I might hack at the code a bit to fill
> in
> >>>>>>>>>>>>>>> some gaps that I'm seeing.  First example is that it
> assumes
> >>>>>>>>>>>>>>> http, which doesn't work in a public deployment where the
> >>>>> endpoint is over https.
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> -chip
> >>>>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>
> >>>>
> >>>> --
> >>>> Charles Moulliard
> >>>> Apache Committer / Sr. Enterprise Architect (RedHat)
> >>>> Twitter : @cmoulliard | Blog : http://cmoulliard.blogspot.com
> >>>>
> >>>
> >>>
> >>>
> >>> --
> >>> Thanks,
> >>> Dave.
> >>
> >>
> >
> >
> > --
> > Thanks,
> > Dave.
>
>


-- 
Thanks,
Dave.

Re: CLI for CloudStack: cloudmonkey

Posted by Rohit Yadav <ro...@citrix.com>.
Thanks Dave for filing the issue, will try to fix this by end of the day. If not, I will post my solution on the issue.
Regards.
On 16-Nov-2012, at 1:19 PM, Dave Cahill <dc...@midokura.jp> wrote:

> Thanks Rohit - filed this bug to track the issue:
> https://issues.apache.org/jira/browse/CLOUDSTACK-499
>
> If you have time to write a description of how you're planning to fix it, I
> could take a look at it - I have my setup 99% automated, just need to get
> this param passing working. :)
>
> Thanks,
> Dave.
>
>
> On Thu, Nov 15, 2012 at 11:20 PM, Rohit Yadav <ro...@citrix.com>wrote:
>
>>
>> On 15-Nov-2012, at 3:26 PM, Dave Cahill <dc...@midokura.jp> wrote:
>>
>>> Hi Rohit,
>>>
>>> I've been using cloudmonkey to script my CloudStack setup process in dev,
>>> and had one question.
>>>
>>> How do we pass complex (MAP) parameters to cloudmonkey? For example, when
>>> setting up a networkoffering, there's a serviceProviderList parameter
>> which
>>> is a list of items, each of which has several key value pairs. I tried a
>>> couple of syntaxes to pass this parameter, but didn't come across the
>>> correct one yet - can you enlighten me? ;)
>>
>> Hi Dave, thanks for catching the bug. The way maps are handled in url are
>> very different than how cloudmonkey parses and passing key,values.
>> This actually needs to be fixed in Marvin, I've figured out a way but it
>> may cause issues with marvin, will discuss with Prasanna and fix it soon.
>>
>> You may file an issues if you want to.
>>
>> Regards.
>>
>>>
>>> Thanks for your work on this, very useful.
>>>
>>> Thanks,
>>> Dave.
>>>
>>>
>>> On Mon, Nov 12, 2012 at 7:01 PM, Rohit Yadav <ro...@citrix.com>
>> wrote:
>>>
>>>> Hi Charles,
>>>>
>>>> Karaf seems nice, and no worries I don't see any suggestions as flames
>> or
>>>> war. I would anytime throw away any code for something better, so feel
>> free
>>>> to start writing your own client and share with us. Patches welcome!
>>>>
>>>> Let me share why I wrote it in Python:
>>>>
>>>> - First of all the CLI is not even a client to start with, I mean I've
>>>> totally based it off marvin. It's a small wrapper I would say around
>> marvin.
>>>> - Python because, the environment is preinstalled on Macs and almost all
>>>> Linux distros.
>>>> - Scripting environment that Python provides so one can fork and edit
>>>> their own versions of cloudmonkey CLI, this saves the user from
>>>> hack->compile->build->run loop; one can just hack and run.
>>>> - The best part again is marvin as dependency, you write javadocs etc.
>> in
>>>> your java code, apidocs gets interface definition and requirements from
>> the
>>>> java code, the commands.xml created in the process is used by marvin's
>>>> codegenerator  which generates api modules with Cmd and Response
>> classes.
>>>> The generated cloudstackAPI is used by both marvin clients and the CLI.
>> The
>>>> CLI which is about 400 lines of Python, in turn loads these modules and
>>>> generates grammar and command handlers on the fly using some functional
>>>> magic (injects functions into the classes), I don't think this kind of
>>>> programming is even possible with Java, they don't have functions as
>> first
>>>> class citizens.
>>>>
>>>> What does the last statement mean for the developers:
>>>> So, if a developer simply adds a new API which is java code, with
>> required
>>>> docs etc. apidocs will pick it up automatically and in turn marvin (and
>>>> it's test clients) will get new cloudstackAPI and CLI too gets the new
>> APIs
>>>> on the fly. The functional closures in CLI will make sure the new APIs
>> and
>>>> its handlers are created with grammar rules. The developer won't need to
>>>> change apidocs, marvin or CLI. I think this is one of my best hacks [0]
>>>> which leverages on existing code and I think it would be very
>> maintainable
>>>> in future.
>>>>
>>>> Sorry everyone, I'm caught up with some other issues, I want to post a
>>>> screencast and blog explaining the CLI but only after I finalize the
>> specs
>>>> for the CLI. Thanks for the feedback so far.
>>>> The top TODOs left now are:
>>>> - Reverse search
>>>> - Bash/zsh completion
>>>>
>>>> Regards.
>>>> PS. Just in case you're curious:
>>>> [0] https://github.com/bhaisaab/hacktools
>>>>
>>>> ________________________________________
>>>> From: Charles Moulliard [ch007m@gmail.com]
>>>> Sent: Monday, November 12, 2012 12:49 PM
>>>> To: cloudstack-dev
>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>
>>>> Hi,
>>>>
>>>> I don't want to create a developer war or position a technology against
>>>> another (python against java) but we could leverage Apache Karaf (OSGI
>>>> runtime container) project to provide the cloudmonkey client. This work
>> has
>>>> already be done for jclouds (http://www.youtube.com/watch?v=EKVkm6AV19U
>> ,
>>>> https://github.com/jclouds/jclouds-karaf) and could be easily
>>>> created
>>>> created for cloudmonkey. Karaf which is a shell environment proposes a
>> lot
>>>> of by default features (http://karaf.apache.org/ : ssh, jaas,
>>>> provisioning,
>>>> administration, history, config files support, ... -
>>>> http://karaf.apache.org/manual/latest-2.3.x/developers-guide/index.html
>> )
>>>> that we could extend with cloudmonkey commands (
>>>>
>>>>
>> http://karaf.apache.org/manual/latest-2.3.x/developers-guide/extending-console.html
>>>> )
>>>> and rebrand Karaf into a cloudmonkey karaf container.
>>>>
>>>> Regards,
>>>>
>>>> Charles
>>>>
>>>>
>>>> On Fri, Nov 9, 2012 at 10:53 PM, Musayev, Ilya <im...@webmd.net>
>> wrote:
>>>>
>>>>> I guess mine got wiped somehow...
>>>>>
>>>>> -----Original Message-----
>>>>> From: Musayev, Ilya [mailto:imusayev@webmd.net]
>>>>> Sent: Friday, November 09, 2012 4:51 PM
>>>>> To: cloudstack-dev@incubator.apache.org
>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>
>>>>> Rohit
>>>>>
>>>>> History seems to retain only last session and not previous - is this by
>>>>> design?
>>>>>
>>>>> Thanks
>>>>> ilya
>>>>>
>>>>> -----Original Message-----
>>>>> From: sebgoa [mailto:runseb@gmail.com]
>>>>> Sent: Friday, November 09, 2012 4:52 AM
>>>>> To: cloudstack-dev@incubator.apache.org
>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>
>>>>> Using lower case commands solved the issue
>>>>>
>>>>> thanks, and happy Diwali
>>>>>
>>>>> -Sebastien
>>>>>
>>>>> On Nov 8, 2012, at 8:14 PM, Rohit Yadav wrote:
>>>>>
>>>>>> Oh, forgot to see that. Yes, now all the cmds are lowercase (except
>> for
>>>>> few params liks isAsync=) and tab completion is advised.
>>>>>>
>>>>>> Regards.
>>>>>> ________________________________________
>>>>>> From: Kishan Kavala [Kishan.Kavala@citrix.com]
>>>>>> Sent: Thursday, November 08, 2012 11:29 PM
>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>> Cc: cloudstack-dev@incubator.apache.org
>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>
>>>>>> Sebastian,
>>>>>> Try set apikey in lower case. Same with set secretkey.
>>>>>>
>>>>>> ~kishan
>>>>>>
>>>>>> On 08-Nov-2012, at 10:00 PM, "Sebastien Goasguen" <ru...@gmail.com>
>>>>> wrote:
>>>>>>
>>>>>>> Actually it does not work yet.
>>>>>>>
>>>>>>> Now I can type 'b' but it does not get passed properly:
>>>>>>>
>>>>>>> 🙉 cloudmonkey> set apiKey
>>>>>>> KEbkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzj
>>>>>>> RB9UNrBybVr3kcZ6Q
>>>>>>>
>>>>>>> Gives:
>>>>>>>
>>>>>>> INFO  [cloud.api.ApiServer] (92734721@qtp-1601733969-7:) apiKey does
>>>>>>> not map to a valid user -- ignoring request, apiKey:
>>>>>>> KEkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzjR
>>>>>>> B9UNrByVr3kcZ6Q
>>>>>>>
>>>>>>> On Nov 8, 2012, at 5:19 PM, Sebastien Goasguen <ru...@gmail.com>
>>>>> wrote:
>>>>>>>
>>>>>>>>
>>>>>>>> On Nov 8, 2012, at 3:28 PM, Rohit Yadav <ro...@citrix.com>
>>>>> wrote:
>>>>>>>>
>>>>>>>>> Hi Sebastien,
>>>>>>>>>
>>>>>>>>> Are you using it from pypi/pip, if so do this:
>>>>>>>>> sudo pip uninstall cloudmonkey
>>>>>>>>> sudo pip install cloudmonkey
>>>>>>>>
>>>>>>>> no, I am doing: sudo python ./setup.py install from the source tree
>>>>>>>>
>>>>>>>>> I've had this bug on mac osx, fixed it:
>>>>>>>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.git
>> ;
>>>>>>>>> a=commit;h=36e7a7884efef7c41ac369549b7bdb93e5122110
>>>>>>>>
>>>>>>>> pulled that and reinstalled…and it works.
>>>>>>>>
>>>>>>>> thanks
>>>>>>>>
>>>>>>>> -sebastien
>>>>>>>>
>>>>>>>>
>>>>>>>>> If it still persists for you, checkout
>>>>>>>>>
>> http://superuser.com/questions/297527/cant-type-the-b-letter-in-pyt
>>>>>>>>> hon-shell-in-os-x
>>>>>>>>>
>>>>>>>>> Let me know if this still fails then.
>>>>>>>>>
>>>>>>>>> Regards.
>>>>>>>>>
>>>>>>>>> ________________________________________
>>>>>>>>> From: Sebastien Goasguen [runseb@gmail.com]
>>>>>>>>> Sent: Thursday, November 08, 2012 5:37 PM
>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>>>
>>>>>>>>> Hi,
>>>>>>>>>
>>>>>>>>> I am testing the cli and I have the weirdest issue. When I set the
>>>>> apikey or secretkey, the lower case 'b' letter does not print at the
>>>> prompt.
>>>>>>>>> So if my keys contain 'b' they don't work..
>>>>>>>>>
>>>>>>>>> I tried all the other letters and they work.
>>>>>>>>>
>>>>>>>>> Anyone seeing this,
>>>>>>>>>
>>>>>>>>> -Sebastien
>>>>>>>>>
>>>>>>>>> On Nov 7, 2012, at 7:25 PM, Rohit Yadav <ro...@citrix.com>
>>>>> wrote:
>>>>>>>>>
>>>>>>>>>> yes, I think I'd mentioned in the thread or somewhere. Just use
>>>>>>>>>> pip or easy_install (apt-get install python-setuptools on ubuntu,
>>>>>>>>>> install python2.6 or above and pip if you don't have it);
>>>>>>>>>>
>>>>>>>>>> sudo pip install cloudmonkey
>>>>>>>>>>
>>>>>>>>>> or sudo easy_install cloudmonkey
>>>>>>>>>>
>>>>>>>>>> now start cloudmonkey:
>>>>>>>>>> $ cloudmonkey
>>>>>>>>>> ...
>>>>>>>>>>
>>>>>>>>>> Will post a blog/screencast this weekend and update doc so
>> everyone
>>>>> can get help on its usage, though it's pretty intuitive.
>>>>>>>>>> ________________________________________
>>>>>>>>>> From: Musayev, Ilya [imusayev@webmd.net]
>>>>>>>>>> Sent: Wednesday, November 07, 2012 11:41 PM
>>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>>>>>
>>>>>>>>>> Rohit,
>>>>>>>>>>
>>>>>>>>>> Can I get the CLI only without going through the whole source code
>>>>> maven install? Is it part of any RPM?
>>>>>>>>>>
>>>>>>>>>> Thanks
>>>>>>>>>> ilya
>>>>>>>>>>
>>>>>>>>>> -----Original Message-----
>>>>>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>>>>>> Sent: Monday, November 05, 2012 11:35 AM
>>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>>>>
>>>>>>>>>> Checkout latest code. Few changes to share:
>>>>>>>>>>
>>>>>>>>>> - All lowercase now
>>>>>>>>>> - Tab tab over verbs to see list of params for that api, example
>>>>>>>>>> list users <tab><tab>
>>>>>>>>>> - This needs improvement but help string, using --help: list user
>>>>>>>>>> --help
>>>>>>>>>> - Caching to speedup runtime
>>>>>>>>>> - Color and Parsing fixes
>>>>>>>>>>
>>>>>>>>>> Last, I'm now able to get the doc strings for each
>> attribute/param,
>>>>> will see this tomorrow.
>>>>>>>>>>
>>>>>>>>>> Need your help, just incase you want to contribute, these are the
>>>>> TODOs:
>>>>>>>>>>
>>>>>>>>>> - search over history
>>>>>>>>>> - fix parsing
>>>>>>>>>> - doc strings for parameters
>>>>>>>>>> - testing for various kinds of apis (I'm able to deploy a zone
>>>>>>>>>> with this, but needs testing)
>>>>>>>>>> - unicode char monkey, used in prompt may mess up history
>>>>>>>>>> searching and text display
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Regards.
>>>>>>>>>>
>>>>>>>>>> On 02-Nov-2012, at 4:58 AM, Edison Su <Ed...@citrix.com>
>>>> wrote:
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>> -----Original Message-----
>>>>>>>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>>>>>>>> Sent: Thursday, November 01, 2012 2:23 PM
>>>>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>>>>>>>
>>>>>>>>>>>> After you install the tool, so that cloudmonkey is in your
>>>>>>>>>>>> /usr/local/bin or in $PATH...
>>>>>>>>>>>>
>>>>>>>>>>>> Two ways;
>>>>>>>>>>>> 1. As command line tool, on bash/zsh, use the BNF grammar;
>>>>>>>>>>>> <command line tool
>>>>>>>>>>>> name>:<separator>:<verb>:<separator>:<action>:<separator>:<param
>>>>>>>>>>>> name>s>
>>>>>>>>>>>> <command line tool name>={'cloudmonkey'} <separator>={' '}
>>>>>>>>>>>> <verb>={'list', 'create', 'delete', 'update'.... etc.}
>>>>>>>>>>>> <action>={'Users'... etc.} <params>={'listall=#'... etc.} So; $
>>>>>>>>>>>> cloudmonkey list Users
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Got it, thanks!
>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> 2. file redirector:
>>>>>>>>>>>>
>>>>>>>>>>>> $ cat test-file:
>>>>>>>>>>>> list Users
>>>>>>>>>>>> list <some other action>
>>>>>>>>>>>> <some verb> <some action>
>>>>>>>>>>>>
>>>>>>>>>>>> $ cloudmonkey < test-file
>>>>>>>>>>>>
>>>>>>>>>>>> Note, I'll change the actions (Users, VirtualMachine etc.) to
>>>>>>>>>>>> lowercase (users, virtualmachine etc.) if that's okay?
>>>>>>>>>>>
>>>>>>>>>>> Please do, nobody wants to type extra keystroke, if it's not
>>>>> necessary.
>>>>>>>>>>>>
>>>>>>>>>>>> Regards.
>>>>>>>>>>>>
>>>>>>>>>>>> ________________________________________
>>>>>>>>>>>> From: Edison Su [Edison.su@citrix.com]
>>>>>>>>>>>> Sent: Friday, November 02, 2012 1:55 AM
>>>>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>>>>>>>
>>>>>>>>>>>> Oh, it reminds me that how to use the CLI on the bash command
>>>> line?
>>>>>>>>>>>> I think admin may want to call cloudstack API in a bash script,
>>>>>>>>>>>> how can I do that?
>>>>>>>>>>>>
>>>>>>>>>>>>> -----Original Message-----
>>>>>>>>>>>>> From: Marcus Sorensen [mailto:shadowsor@gmail.com]
>>>>>>>>>>>>> Sent: Thursday, November 01, 2012 1:11 PM
>>>>>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>>>>>>>
>>>>>>>>>>>>> Yes, I look forward to using it instead of local curl calls on
>>>>>>>>>>>>> the command line :-)
>>>>>>>>>>>>>
>>>>>>>>>>>>> On Thu, Nov 1, 2012 at 2:02 PM, Edison Su <
>> Edison.su@citrix.com
>>>>>
>>>>> wrote:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> -----Original Message-----
>>>>>>>>>>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>>>>>>>>>>> Sent: Thursday, November 01, 2012 11:45 AM
>>>>>>>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Hi Chip, please go ahead if we can fix the http/s issue. The
>>>>>>>>>>>>>>> connection is based on marvin, I'm sure using CLI we'll find
>>>>>>>>>>>>>>> out more bugs and fix anything in marvin thereby help
>>>>>>>>>>>>>>> maintain
>>>>>>>>>>>>>>> marvin->tests and
>>>>>>>>>>>>> CLI.
>>>>>>>>>>>>>>> Please hack that up on
>>>>>>>>>>>>>>> tools/marvin/marvin/cloudstackConnection.py
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Edison, yes I'm working on the completedefault, I've figured
>>>>>>>>>>>>>>> a solution to the parsing and tabbing issue to show params
>>>>>>>>>>>>>>> for any api and added more verbs to the grammar like deploy,
>>>>> start etc.
>>>>>>>>>>>>>>> In the new approach doc strings and params needed for an api
>>>>>>>>>>>>>>> are fetched and cached in the class locally to speed up the
>>>>> loading process.
>>>>>>>>>>>>>>> Till it gets committed, cloudmonkey (now) will keep telling
>>>>>>>>>>>>>>> the user what params they are missing until it gets all the
>>>>> required ones.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Great! Thanks for your awesome CLI, people will like it.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> One more thing, for people who may not have unicode support
>>>>>>>>>>>>>>> the prompt may appear weird and history search (up, down )
>>>>>>>>>>>>>>> can mess up the visuals. For example on Mac it appears as a
>>>>>>>>>>>>>>> colorful emoji, but I found that it looks weird on other
>>>>>>>>>>>>>>> platforms. Will probably remove it, or the user can custom
>>>>>>>>>>>>>>> set their prompt, using: set prompt
>>>>>>>>>>>>>>> myprompt>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Regards.
>>>>>>>>>>>>>>> PS. the set command is full of (fun :)  hacks because of
>>>>>>>>>>>>>>> funtional/generic programming, it basically can set any
>>>>>>>>>>>>>>> attribute on the class, so one can do something like creating
>>>>>>>>>>>>>>> something (var, func). For example set ruler # (so instead of
>>>>>>>>>>>>>>> - you will have a #
>>>>>>>>>>>>>>> separator)
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> ________________________________________
>>>>>>>>>>>>>>> From: Chip Childers [chip.childers@sungard.com]
>>>>>>>>>>>>>>> Sent: Thursday, November 01, 2012 11:15 PM
>>>>>>>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> On Wed, Oct 31, 2012 at 2:10 PM, Rohit Yadav
>>>>>>>>>>>>>>> <ro...@citrix.com>
>>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>> Hi,
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> 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:
>>>>>>>>>>>>>>>>
>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudsta
>>>>>>>>>>>>>>>> ck.gi t; a=c
>>>>>>>>>>>>>>>> ommit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Features:
>>>>>>>>>>>>>>>> - 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
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> FIXMEs:
>>>>>>>>>>>>>>>> - 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 python cloudmonkey.py
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> If you want to have the terminal tool installed; cd
>>>>>>>>>>>>>>>> tools/cli python setup.py 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=8.8.8.8 internaldns1=10.147.28.6
>>>>>>>>>>>>>>>> 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
>>>>>>>>>>>>>>>> networkofferingid= create Pod zoneid= name=Pod1
>>>>>>>>>>>>> gateway=10.147.28.1
>>>>>>>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.220
>>>>>>>>>>>>>>>> endip=10.147.28.235 create VlanIpRange podid= networkid=
>>>>>>>>>>>>>>>> gateway=10.147.28.1
>>>>>>>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.236
>>>>>>>>>>>>>>>> endip=10.147.28.250 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=http://10.147.28.60 create StoragePool zoneid=
>>>>>>>>>>>>>>>> clusterid= name=NFS1
>>>>>>>>>>>>>>>> url=nfs://10.147.28.7/export/home/rohit/primary
>>>>>>>>>>>>>>>> add SecondaryStorage zoneId=
>>>>>>>>>>>>>>>> url=nfs://10.147.28.7/export/home/rohit/secondary
>>>>>>>>>>>>>>>> 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.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Regards.
>>>>>>>>>>>>>>>> PS. Marvin the neglected robot and hipster cloudmonkey
>>>>>>>>>>>>>>>> should rule the world :D
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Rohit,
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> This is really really cool.  It puts the "fun" in managing
>>>>>>>>>>>>>>> instances from a command line.  I've been testing it against
>>>>>>>>>>>>>>> a production CloudStack environment, and it's working pretty
>>>>> well.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> If you don't mind, I might hack at the code a bit to fill in
>>>>>>>>>>>>>>> some gaps that I'm seeing.  First example is that it assumes
>>>>>>>>>>>>>>> http, which doesn't work in a public deployment where the
>>>>> endpoint is over https.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> -chip
>>>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Charles Moulliard
>>>> Apache Committer / Sr. Enterprise Architect (RedHat)
>>>> Twitter : @cmoulliard | Blog : http://cmoulliard.blogspot.com
>>>>
>>>
>>>
>>>
>>> --
>>> Thanks,
>>> Dave.
>>
>>
>
>
> --
> Thanks,
> Dave.


Re: CLI for CloudStack: cloudmonkey

Posted by Dave Cahill <dc...@midokura.jp>.
Thanks Rohit - filed this bug to track the issue:
https://issues.apache.org/jira/browse/CLOUDSTACK-499

If you have time to write a description of how you're planning to fix it, I
could take a look at it - I have my setup 99% automated, just need to get
this param passing working. :)

Thanks,
Dave.


On Thu, Nov 15, 2012 at 11:20 PM, Rohit Yadav <ro...@citrix.com>wrote:

>
> On 15-Nov-2012, at 3:26 PM, Dave Cahill <dc...@midokura.jp> wrote:
>
> > Hi Rohit,
> >
> > I've been using cloudmonkey to script my CloudStack setup process in dev,
> > and had one question.
> >
> > How do we pass complex (MAP) parameters to cloudmonkey? For example, when
> > setting up a networkoffering, there's a serviceProviderList parameter
> which
> > is a list of items, each of which has several key value pairs. I tried a
> > couple of syntaxes to pass this parameter, but didn't come across the
> > correct one yet - can you enlighten me? ;)
>
> Hi Dave, thanks for catching the bug. The way maps are handled in url are
> very different than how cloudmonkey parses and passing key,values.
> This actually needs to be fixed in Marvin, I've figured out a way but it
> may cause issues with marvin, will discuss with Prasanna and fix it soon.
>
> You may file an issues if you want to.
>
> Regards.
>
> >
> > Thanks for your work on this, very useful.
> >
> > Thanks,
> > Dave.
> >
> >
> > On Mon, Nov 12, 2012 at 7:01 PM, Rohit Yadav <ro...@citrix.com>
> wrote:
> >
> >> Hi Charles,
> >>
> >> Karaf seems nice, and no worries I don't see any suggestions as flames
> or
> >> war. I would anytime throw away any code for something better, so feel
> free
> >> to start writing your own client and share with us. Patches welcome!
> >>
> >> Let me share why I wrote it in Python:
> >>
> >> - First of all the CLI is not even a client to start with, I mean I've
> >> totally based it off marvin. It's a small wrapper I would say around
> marvin.
> >> - Python because, the environment is preinstalled on Macs and almost all
> >> Linux distros.
> >> - Scripting environment that Python provides so one can fork and edit
> >> their own versions of cloudmonkey CLI, this saves the user from
> >> hack->compile->build->run loop; one can just hack and run.
> >> - The best part again is marvin as dependency, you write javadocs etc.
> in
> >> your java code, apidocs gets interface definition and requirements from
> the
> >> java code, the commands.xml created in the process is used by marvin's
> >> codegenerator  which generates api modules with Cmd and Response
> classes.
> >> The generated cloudstackAPI is used by both marvin clients and the CLI.
> The
> >> CLI which is about 400 lines of Python, in turn loads these modules and
> >> generates grammar and command handlers on the fly using some functional
> >> magic (injects functions into the classes), I don't think this kind of
> >> programming is even possible with Java, they don't have functions as
> first
> >> class citizens.
> >>
> >> What does the last statement mean for the developers:
> >> So, if a developer simply adds a new API which is java code, with
> required
> >> docs etc. apidocs will pick it up automatically and in turn marvin (and
> >> it's test clients) will get new cloudstackAPI and CLI too gets the new
> APIs
> >> on the fly. The functional closures in CLI will make sure the new APIs
> and
> >> its handlers are created with grammar rules. The developer won't need to
> >> change apidocs, marvin or CLI. I think this is one of my best hacks [0]
> >> which leverages on existing code and I think it would be very
> maintainable
> >> in future.
> >>
> >> Sorry everyone, I'm caught up with some other issues, I want to post a
> >> screencast and blog explaining the CLI but only after I finalize the
> specs
> >> for the CLI. Thanks for the feedback so far.
> >> The top TODOs left now are:
> >> - Reverse search
> >> - Bash/zsh completion
> >>
> >> Regards.
> >> PS. Just in case you're curious:
> >> [0] https://github.com/bhaisaab/hacktools
> >>
> >> ________________________________________
> >> From: Charles Moulliard [ch007m@gmail.com]
> >> Sent: Monday, November 12, 2012 12:49 PM
> >> To: cloudstack-dev
> >> Subject: Re: CLI for CloudStack: cloudmonkey
> >>
> >> Hi,
> >>
> >> I don't want to create a developer war or position a technology against
> >> another (python against java) but we could leverage Apache Karaf (OSGI
> >> runtime container) project to provide the cloudmonkey client. This work
> has
> >> already be done for jclouds (http://www.youtube.com/watch?v=EKVkm6AV19U
> ,
> >> https://github.com/jclouds/jclouds-karaf) and could be easily
> >> created
> >> created for cloudmonkey. Karaf which is a shell environment proposes a
> lot
> >> of by default features (http://karaf.apache.org/ : ssh, jaas,
> >> provisioning,
> >> administration, history, config files support, ... -
> >> http://karaf.apache.org/manual/latest-2.3.x/developers-guide/index.html
> )
> >> that we could extend with cloudmonkey commands (
> >>
> >>
> http://karaf.apache.org/manual/latest-2.3.x/developers-guide/extending-console.html
> >> )
> >> and rebrand Karaf into a cloudmonkey karaf container.
> >>
> >> Regards,
> >>
> >> Charles
> >>
> >>
> >> On Fri, Nov 9, 2012 at 10:53 PM, Musayev, Ilya <im...@webmd.net>
> wrote:
> >>
> >>> I guess mine got wiped somehow...
> >>>
> >>> -----Original Message-----
> >>> From: Musayev, Ilya [mailto:imusayev@webmd.net]
> >>> Sent: Friday, November 09, 2012 4:51 PM
> >>> To: cloudstack-dev@incubator.apache.org
> >>> Subject: RE: CLI for CloudStack: cloudmonkey
> >>>
> >>> Rohit
> >>>
> >>> History seems to retain only last session and not previous - is this by
> >>> design?
> >>>
> >>> Thanks
> >>> ilya
> >>>
> >>> -----Original Message-----
> >>> From: sebgoa [mailto:runseb@gmail.com]
> >>> Sent: Friday, November 09, 2012 4:52 AM
> >>> To: cloudstack-dev@incubator.apache.org
> >>> Subject: Re: CLI for CloudStack: cloudmonkey
> >>>
> >>> Using lower case commands solved the issue
> >>>
> >>> thanks, and happy Diwali
> >>>
> >>> -Sebastien
> >>>
> >>> On Nov 8, 2012, at 8:14 PM, Rohit Yadav wrote:
> >>>
> >>>> Oh, forgot to see that. Yes, now all the cmds are lowercase (except
> for
> >>> few params liks isAsync=) and tab completion is advised.
> >>>>
> >>>> Regards.
> >>>> ________________________________________
> >>>> From: Kishan Kavala [Kishan.Kavala@citrix.com]
> >>>> Sent: Thursday, November 08, 2012 11:29 PM
> >>>> To: cloudstack-dev@incubator.apache.org
> >>>> Cc: cloudstack-dev@incubator.apache.org
> >>>> Subject: Re: CLI for CloudStack: cloudmonkey
> >>>>
> >>>> Sebastian,
> >>>> Try set apikey in lower case. Same with set secretkey.
> >>>>
> >>>> ~kishan
> >>>>
> >>>> On 08-Nov-2012, at 10:00 PM, "Sebastien Goasguen" <ru...@gmail.com>
> >>> wrote:
> >>>>
> >>>>> Actually it does not work yet.
> >>>>>
> >>>>> Now I can type 'b' but it does not get passed properly:
> >>>>>
> >>>>> 🙉 cloudmonkey> set apiKey
> >>>>> KEbkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzj
> >>>>> RB9UNrBybVr3kcZ6Q
> >>>>>
> >>>>> Gives:
> >>>>>
> >>>>> INFO  [cloud.api.ApiServer] (92734721@qtp-1601733969-7:) apiKey does
> >>>>> not map to a valid user -- ignoring request, apiKey:
> >>>>> KEkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzjR
> >>>>> B9UNrByVr3kcZ6Q
> >>>>>
> >>>>> On Nov 8, 2012, at 5:19 PM, Sebastien Goasguen <ru...@gmail.com>
> >>> wrote:
> >>>>>
> >>>>>>
> >>>>>> On Nov 8, 2012, at 3:28 PM, Rohit Yadav <ro...@citrix.com>
> >>> wrote:
> >>>>>>
> >>>>>>> Hi Sebastien,
> >>>>>>>
> >>>>>>> Are you using it from pypi/pip, if so do this:
> >>>>>>> sudo pip uninstall cloudmonkey
> >>>>>>> sudo pip install cloudmonkey
> >>>>>>
> >>>>>> no, I am doing: sudo python ./setup.py install from the source tree
> >>>>>>
> >>>>>>> I've had this bug on mac osx, fixed it:
> >>>>>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.git
> ;
> >>>>>>> a=commit;h=36e7a7884efef7c41ac369549b7bdb93e5122110
> >>>>>>
> >>>>>> pulled that and reinstalled…and it works.
> >>>>>>
> >>>>>> thanks
> >>>>>>
> >>>>>> -sebastien
> >>>>>>
> >>>>>>
> >>>>>>> If it still persists for you, checkout
> >>>>>>>
> http://superuser.com/questions/297527/cant-type-the-b-letter-in-pyt
> >>>>>>> hon-shell-in-os-x
> >>>>>>>
> >>>>>>> Let me know if this still fails then.
> >>>>>>>
> >>>>>>> Regards.
> >>>>>>>
> >>>>>>> ________________________________________
> >>>>>>> From: Sebastien Goasguen [runseb@gmail.com]
> >>>>>>> Sent: Thursday, November 08, 2012 5:37 PM
> >>>>>>> To: cloudstack-dev@incubator.apache.org
> >>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
> >>>>>>>
> >>>>>>> Hi,
> >>>>>>>
> >>>>>>> I am testing the cli and I have the weirdest issue. When I set the
> >>> apikey or secretkey, the lower case 'b' letter does not print at the
> >> prompt.
> >>>>>>> So if my keys contain 'b' they don't work..
> >>>>>>>
> >>>>>>> I tried all the other letters and they work.
> >>>>>>>
> >>>>>>> Anyone seeing this,
> >>>>>>>
> >>>>>>> -Sebastien
> >>>>>>>
> >>>>>>> On Nov 7, 2012, at 7:25 PM, Rohit Yadav <ro...@citrix.com>
> >>> wrote:
> >>>>>>>
> >>>>>>>> yes, I think I'd mentioned in the thread or somewhere. Just use
> >>>>>>>> pip or easy_install (apt-get install python-setuptools on ubuntu,
> >>>>>>>> install python2.6 or above and pip if you don't have it);
> >>>>>>>>
> >>>>>>>> sudo pip install cloudmonkey
> >>>>>>>>
> >>>>>>>> or sudo easy_install cloudmonkey
> >>>>>>>>
> >>>>>>>> now start cloudmonkey:
> >>>>>>>> $ cloudmonkey
> >>>>>>>> ...
> >>>>>>>>
> >>>>>>>> Will post a blog/screencast this weekend and update doc so
> everyone
> >>> can get help on its usage, though it's pretty intuitive.
> >>>>>>>> ________________________________________
> >>>>>>>> From: Musayev, Ilya [imusayev@webmd.net]
> >>>>>>>> Sent: Wednesday, November 07, 2012 11:41 PM
> >>>>>>>> To: cloudstack-dev@incubator.apache.org
> >>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
> >>>>>>>>
> >>>>>>>> Rohit,
> >>>>>>>>
> >>>>>>>> Can I get the CLI only without going through the whole source code
> >>> maven install? Is it part of any RPM?
> >>>>>>>>
> >>>>>>>> Thanks
> >>>>>>>> ilya
> >>>>>>>>
> >>>>>>>> -----Original Message-----
> >>>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
> >>>>>>>> Sent: Monday, November 05, 2012 11:35 AM
> >>>>>>>> To: cloudstack-dev@incubator.apache.org
> >>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
> >>>>>>>>
> >>>>>>>> Checkout latest code. Few changes to share:
> >>>>>>>>
> >>>>>>>> - All lowercase now
> >>>>>>>> - Tab tab over verbs to see list of params for that api, example
> >>>>>>>> list users <tab><tab>
> >>>>>>>> - This needs improvement but help string, using --help: list user
> >>>>>>>> --help
> >>>>>>>> - Caching to speedup runtime
> >>>>>>>> - Color and Parsing fixes
> >>>>>>>>
> >>>>>>>> Last, I'm now able to get the doc strings for each
> attribute/param,
> >>> will see this tomorrow.
> >>>>>>>>
> >>>>>>>> Need your help, just incase you want to contribute, these are the
> >>> TODOs:
> >>>>>>>>
> >>>>>>>> - search over history
> >>>>>>>> - fix parsing
> >>>>>>>> - doc strings for parameters
> >>>>>>>> - testing for various kinds of apis (I'm able to deploy a zone
> >>>>>>>> with this, but needs testing)
> >>>>>>>> - unicode char monkey, used in prompt may mess up history
> >>>>>>>> searching and text display
> >>>>>>>>
> >>>>>>>>
> >>>>>>>> Regards.
> >>>>>>>>
> >>>>>>>> On 02-Nov-2012, at 4:58 AM, Edison Su <Ed...@citrix.com>
> >> wrote:
> >>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>> -----Original Message-----
> >>>>>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
> >>>>>>>>>> Sent: Thursday, November 01, 2012 2:23 PM
> >>>>>>>>>> To: cloudstack-dev@incubator.apache.org
> >>>>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
> >>>>>>>>>>
> >>>>>>>>>> After you install the tool, so that cloudmonkey is in your
> >>>>>>>>>> /usr/local/bin or in $PATH...
> >>>>>>>>>>
> >>>>>>>>>> Two ways;
> >>>>>>>>>> 1. As command line tool, on bash/zsh, use the BNF grammar;
> >>>>>>>>>> <command line tool
> >>>>>>>>>> name>:<separator>:<verb>:<separator>:<action>:<separator>:<param
> >>>>>>>>>> name>s>
> >>>>>>>>>> <command line tool name>={'cloudmonkey'} <separator>={' '}
> >>>>>>>>>> <verb>={'list', 'create', 'delete', 'update'.... etc.}
> >>>>>>>>>> <action>={'Users'... etc.} <params>={'listall=#'... etc.} So; $
> >>>>>>>>>> cloudmonkey list Users
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>> Got it, thanks!
> >>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>> 2. file redirector:
> >>>>>>>>>>
> >>>>>>>>>> $ cat test-file:
> >>>>>>>>>> list Users
> >>>>>>>>>> list <some other action>
> >>>>>>>>>> <some verb> <some action>
> >>>>>>>>>>
> >>>>>>>>>> $ cloudmonkey < test-file
> >>>>>>>>>>
> >>>>>>>>>> Note, I'll change the actions (Users, VirtualMachine etc.) to
> >>>>>>>>>> lowercase (users, virtualmachine etc.) if that's okay?
> >>>>>>>>>
> >>>>>>>>> Please do, nobody wants to type extra keystroke, if it's not
> >>> necessary.
> >>>>>>>>>>
> >>>>>>>>>> Regards.
> >>>>>>>>>>
> >>>>>>>>>> ________________________________________
> >>>>>>>>>> From: Edison Su [Edison.su@citrix.com]
> >>>>>>>>>> Sent: Friday, November 02, 2012 1:55 AM
> >>>>>>>>>> To: cloudstack-dev@incubator.apache.org
> >>>>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
> >>>>>>>>>>
> >>>>>>>>>> Oh, it reminds me that how to use the CLI on the bash command
> >> line?
> >>>>>>>>>> I think admin may want to call cloudstack API in a bash script,
> >>>>>>>>>> how can I do that?
> >>>>>>>>>>
> >>>>>>>>>>> -----Original Message-----
> >>>>>>>>>>> From: Marcus Sorensen [mailto:shadowsor@gmail.com]
> >>>>>>>>>>> Sent: Thursday, November 01, 2012 1:11 PM
> >>>>>>>>>>> To: cloudstack-dev@incubator.apache.org
> >>>>>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
> >>>>>>>>>>>
> >>>>>>>>>>> Yes, I look forward to using it instead of local curl calls on
> >>>>>>>>>>> the command line :-)
> >>>>>>>>>>>
> >>>>>>>>>>> On Thu, Nov 1, 2012 at 2:02 PM, Edison Su <
> Edison.su@citrix.com
> >>>
> >>> wrote:
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>> -----Original Message-----
> >>>>>>>>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
> >>>>>>>>>>>>> Sent: Thursday, November 01, 2012 11:45 AM
> >>>>>>>>>>>>> To: cloudstack-dev@incubator.apache.org
> >>>>>>>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> Hi Chip, please go ahead if we can fix the http/s issue. The
> >>>>>>>>>>>>> connection is based on marvin, I'm sure using CLI we'll find
> >>>>>>>>>>>>> out more bugs and fix anything in marvin thereby help
> >>>>>>>>>>>>> maintain
> >>>>>>>>>>>>> marvin->tests and
> >>>>>>>>>>> CLI.
> >>>>>>>>>>>>> Please hack that up on
> >>>>>>>>>>>>> tools/marvin/marvin/cloudstackConnection.py
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> Edison, yes I'm working on the completedefault, I've figured
> >>>>>>>>>>>>> a solution to the parsing and tabbing issue to show params
> >>>>>>>>>>>>> for any api and added more verbs to the grammar like deploy,
> >>> start etc.
> >>>>>>>>>>>>> In the new approach doc strings and params needed for an api
> >>>>>>>>>>>>> are fetched and cached in the class locally to speed up the
> >>> loading process.
> >>>>>>>>>>>>> Till it gets committed, cloudmonkey (now) will keep telling
> >>>>>>>>>>>>> the user what params they are missing until it gets all the
> >>> required ones.
> >>>>>>>>>>>>
> >>>>>>>>>>>> Great! Thanks for your awesome CLI, people will like it.
> >>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> One more thing, for people who may not have unicode support
> >>>>>>>>>>>>> the prompt may appear weird and history search (up, down )
> >>>>>>>>>>>>> can mess up the visuals. For example on Mac it appears as a
> >>>>>>>>>>>>> colorful emoji, but I found that it looks weird on other
> >>>>>>>>>>>>> platforms. Will probably remove it, or the user can custom
> >>>>>>>>>>>>> set their prompt, using: set prompt
> >>>>>>>>>>>>> myprompt>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> Regards.
> >>>>>>>>>>>>> PS. the set command is full of (fun :)  hacks because of
> >>>>>>>>>>>>> funtional/generic programming, it basically can set any
> >>>>>>>>>>>>> attribute on the class, so one can do something like creating
> >>>>>>>>>>>>> something (var, func). For example set ruler # (so instead of
> >>>>>>>>>>>>> - you will have a #
> >>>>>>>>>>>>> separator)
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> ________________________________________
> >>>>>>>>>>>>> From: Chip Childers [chip.childers@sungard.com]
> >>>>>>>>>>>>> Sent: Thursday, November 01, 2012 11:15 PM
> >>>>>>>>>>>>> To: cloudstack-dev@incubator.apache.org
> >>>>>>>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> On Wed, Oct 31, 2012 at 2:10 PM, Rohit Yadav
> >>>>>>>>>>>>> <ro...@citrix.com>
> >>>>>>>>>>>>> wrote:
> >>>>>>>>>>>>>> Hi,
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> 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:
> >>>>>>>>>>>>>>
> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudsta
> >>>>>>>>>>>>>> ck.gi t; a=c
> >>>>>>>>>>>>>> ommit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> Features:
> >>>>>>>>>>>>>> - 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
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> FIXMEs:
> >>>>>>>>>>>>>> - 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 python cloudmonkey.py
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> If you want to have the terminal tool installed; cd
> >>>>>>>>>>>>>> tools/cli python setup.py 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=8.8.8.8 internaldns1=10.147.28.6
> >>>>>>>>>>>>>> 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
> >>>>>>>>>>>>>> networkofferingid= create Pod zoneid= name=Pod1
> >>>>>>>>>>> gateway=10.147.28.1
> >>>>>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.220
> >>>>>>>>>>>>>> endip=10.147.28.235 create VlanIpRange podid= networkid=
> >>>>>>>>>>>>>> gateway=10.147.28.1
> >>>>>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.236
> >>>>>>>>>>>>>> endip=10.147.28.250 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=http://10.147.28.60 create StoragePool zoneid=
> >>>>>>>>>>>>>> clusterid= name=NFS1
> >>>>>>>>>>>>>> url=nfs://10.147.28.7/export/home/rohit/primary
> >>>>>>>>>>>>>> add SecondaryStorage zoneId=
> >>>>>>>>>>>>>> url=nfs://10.147.28.7/export/home/rohit/secondary
> >>>>>>>>>>>>>> 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.
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> Regards.
> >>>>>>>>>>>>>> PS. Marvin the neglected robot and hipster cloudmonkey
> >>>>>>>>>>>>>> should rule the world :D
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> Rohit,
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> This is really really cool.  It puts the "fun" in managing
> >>>>>>>>>>>>> instances from a command line.  I've been testing it against
> >>>>>>>>>>>>> a production CloudStack environment, and it's working pretty
> >>> well.
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> If you don't mind, I might hack at the code a bit to fill in
> >>>>>>>>>>>>> some gaps that I'm seeing.  First example is that it assumes
> >>>>>>>>>>>>> http, which doesn't work in a public deployment where the
> >>> endpoint is over https.
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> -chip
> >>>>>
> >>>
> >>>
> >>>
> >>
> >>
> >> --
> >> Charles Moulliard
> >> Apache Committer / Sr. Enterprise Architect (RedHat)
> >> Twitter : @cmoulliard | Blog : http://cmoulliard.blogspot.com
> >>
> >
> >
> >
> > --
> > Thanks,
> > Dave.
>
>


-- 
Thanks,
Dave.

Re: CLI for CloudStack: cloudmonkey

Posted by Rohit Yadav <ro...@citrix.com>.
On 15-Nov-2012, at 3:26 PM, Dave Cahill <dc...@midokura.jp> wrote:

> Hi Rohit,
>
> I've been using cloudmonkey to script my CloudStack setup process in dev,
> and had one question.
>
> How do we pass complex (MAP) parameters to cloudmonkey? For example, when
> setting up a networkoffering, there's a serviceProviderList parameter which
> is a list of items, each of which has several key value pairs. I tried a
> couple of syntaxes to pass this parameter, but didn't come across the
> correct one yet - can you enlighten me? ;)

Hi Dave, thanks for catching the bug. The way maps are handled in url are very different than how cloudmonkey parses and passing key,values.
This actually needs to be fixed in Marvin, I've figured out a way but it may cause issues with marvin, will discuss with Prasanna and fix it soon.

You may file an issues if you want to.

Regards.

>
> Thanks for your work on this, very useful.
>
> Thanks,
> Dave.
>
>
> On Mon, Nov 12, 2012 at 7:01 PM, Rohit Yadav <ro...@citrix.com> wrote:
>
>> Hi Charles,
>>
>> Karaf seems nice, and no worries I don't see any suggestions as flames or
>> war. I would anytime throw away any code for something better, so feel free
>> to start writing your own client and share with us. Patches welcome!
>>
>> Let me share why I wrote it in Python:
>>
>> - First of all the CLI is not even a client to start with, I mean I've
>> totally based it off marvin. It's a small wrapper I would say around marvin.
>> - Python because, the environment is preinstalled on Macs and almost all
>> Linux distros.
>> - Scripting environment that Python provides so one can fork and edit
>> their own versions of cloudmonkey CLI, this saves the user from
>> hack->compile->build->run loop; one can just hack and run.
>> - The best part again is marvin as dependency, you write javadocs etc. in
>> your java code, apidocs gets interface definition and requirements from the
>> java code, the commands.xml created in the process is used by marvin's
>> codegenerator  which generates api modules with Cmd and Response classes.
>> The generated cloudstackAPI is used by both marvin clients and the CLI. The
>> CLI which is about 400 lines of Python, in turn loads these modules and
>> generates grammar and command handlers on the fly using some functional
>> magic (injects functions into the classes), I don't think this kind of
>> programming is even possible with Java, they don't have functions as first
>> class citizens.
>>
>> What does the last statement mean for the developers:
>> So, if a developer simply adds a new API which is java code, with required
>> docs etc. apidocs will pick it up automatically and in turn marvin (and
>> it's test clients) will get new cloudstackAPI and CLI too gets the new APIs
>> on the fly. The functional closures in CLI will make sure the new APIs and
>> its handlers are created with grammar rules. The developer won't need to
>> change apidocs, marvin or CLI. I think this is one of my best hacks [0]
>> which leverages on existing code and I think it would be very maintainable
>> in future.
>>
>> Sorry everyone, I'm caught up with some other issues, I want to post a
>> screencast and blog explaining the CLI but only after I finalize the specs
>> for the CLI. Thanks for the feedback so far.
>> The top TODOs left now are:
>> - Reverse search
>> - Bash/zsh completion
>>
>> Regards.
>> PS. Just in case you're curious:
>> [0] https://github.com/bhaisaab/hacktools
>>
>> ________________________________________
>> From: Charles Moulliard [ch007m@gmail.com]
>> Sent: Monday, November 12, 2012 12:49 PM
>> To: cloudstack-dev
>> Subject: Re: CLI for CloudStack: cloudmonkey
>>
>> Hi,
>>
>> I don't want to create a developer war or position a technology against
>> another (python against java) but we could leverage Apache Karaf (OSGI
>> runtime container) project to provide the cloudmonkey client. This work has
>> already be done for jclouds (http://www.youtube.com/watch?v=EKVkm6AV19U,
>> https://github.com/jclouds/jclouds-karaf) and could be easily
>> created
>> created for cloudmonkey. Karaf which is a shell environment proposes a lot
>> of by default features (http://karaf.apache.org/ : ssh, jaas,
>> provisioning,
>> administration, history, config files support, ... -
>> http://karaf.apache.org/manual/latest-2.3.x/developers-guide/index.html)
>> that we could extend with cloudmonkey commands (
>>
>> http://karaf.apache.org/manual/latest-2.3.x/developers-guide/extending-console.html
>> )
>> and rebrand Karaf into a cloudmonkey karaf container.
>>
>> Regards,
>>
>> Charles
>>
>>
>> On Fri, Nov 9, 2012 at 10:53 PM, Musayev, Ilya <im...@webmd.net> wrote:
>>
>>> I guess mine got wiped somehow...
>>>
>>> -----Original Message-----
>>> From: Musayev, Ilya [mailto:imusayev@webmd.net]
>>> Sent: Friday, November 09, 2012 4:51 PM
>>> To: cloudstack-dev@incubator.apache.org
>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>
>>> Rohit
>>>
>>> History seems to retain only last session and not previous - is this by
>>> design?
>>>
>>> Thanks
>>> ilya
>>>
>>> -----Original Message-----
>>> From: sebgoa [mailto:runseb@gmail.com]
>>> Sent: Friday, November 09, 2012 4:52 AM
>>> To: cloudstack-dev@incubator.apache.org
>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>
>>> Using lower case commands solved the issue
>>>
>>> thanks, and happy Diwali
>>>
>>> -Sebastien
>>>
>>> On Nov 8, 2012, at 8:14 PM, Rohit Yadav wrote:
>>>
>>>> Oh, forgot to see that. Yes, now all the cmds are lowercase (except for
>>> few params liks isAsync=) and tab completion is advised.
>>>>
>>>> Regards.
>>>> ________________________________________
>>>> From: Kishan Kavala [Kishan.Kavala@citrix.com]
>>>> Sent: Thursday, November 08, 2012 11:29 PM
>>>> To: cloudstack-dev@incubator.apache.org
>>>> Cc: cloudstack-dev@incubator.apache.org
>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>
>>>> Sebastian,
>>>> Try set apikey in lower case. Same with set secretkey.
>>>>
>>>> ~kishan
>>>>
>>>> On 08-Nov-2012, at 10:00 PM, "Sebastien Goasguen" <ru...@gmail.com>
>>> wrote:
>>>>
>>>>> Actually it does not work yet.
>>>>>
>>>>> Now I can type 'b' but it does not get passed properly:
>>>>>
>>>>> 🙉 cloudmonkey> set apiKey
>>>>> KEbkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzj
>>>>> RB9UNrBybVr3kcZ6Q
>>>>>
>>>>> Gives:
>>>>>
>>>>> INFO  [cloud.api.ApiServer] (92734721@qtp-1601733969-7:) apiKey does
>>>>> not map to a valid user -- ignoring request, apiKey:
>>>>> KEkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzjR
>>>>> B9UNrByVr3kcZ6Q
>>>>>
>>>>> On Nov 8, 2012, at 5:19 PM, Sebastien Goasguen <ru...@gmail.com>
>>> wrote:
>>>>>
>>>>>>
>>>>>> On Nov 8, 2012, at 3:28 PM, Rohit Yadav <ro...@citrix.com>
>>> wrote:
>>>>>>
>>>>>>> Hi Sebastien,
>>>>>>>
>>>>>>> Are you using it from pypi/pip, if so do this:
>>>>>>> sudo pip uninstall cloudmonkey
>>>>>>> sudo pip install cloudmonkey
>>>>>>
>>>>>> no, I am doing: sudo python ./setup.py install from the source tree
>>>>>>
>>>>>>> I've had this bug on mac osx, fixed it:
>>>>>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.git;
>>>>>>> a=commit;h=36e7a7884efef7c41ac369549b7bdb93e5122110
>>>>>>
>>>>>> pulled that and reinstalled…and it works.
>>>>>>
>>>>>> thanks
>>>>>>
>>>>>> -sebastien
>>>>>>
>>>>>>
>>>>>>> If it still persists for you, checkout
>>>>>>> http://superuser.com/questions/297527/cant-type-the-b-letter-in-pyt
>>>>>>> hon-shell-in-os-x
>>>>>>>
>>>>>>> Let me know if this still fails then.
>>>>>>>
>>>>>>> Regards.
>>>>>>>
>>>>>>> ________________________________________
>>>>>>> From: Sebastien Goasguen [runseb@gmail.com]
>>>>>>> Sent: Thursday, November 08, 2012 5:37 PM
>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> I am testing the cli and I have the weirdest issue. When I set the
>>> apikey or secretkey, the lower case 'b' letter does not print at the
>> prompt.
>>>>>>> So if my keys contain 'b' they don't work..
>>>>>>>
>>>>>>> I tried all the other letters and they work.
>>>>>>>
>>>>>>> Anyone seeing this,
>>>>>>>
>>>>>>> -Sebastien
>>>>>>>
>>>>>>> On Nov 7, 2012, at 7:25 PM, Rohit Yadav <ro...@citrix.com>
>>> wrote:
>>>>>>>
>>>>>>>> yes, I think I'd mentioned in the thread or somewhere. Just use
>>>>>>>> pip or easy_install (apt-get install python-setuptools on ubuntu,
>>>>>>>> install python2.6 or above and pip if you don't have it);
>>>>>>>>
>>>>>>>> sudo pip install cloudmonkey
>>>>>>>>
>>>>>>>> or sudo easy_install cloudmonkey
>>>>>>>>
>>>>>>>> now start cloudmonkey:
>>>>>>>> $ cloudmonkey
>>>>>>>> ...
>>>>>>>>
>>>>>>>> Will post a blog/screencast this weekend and update doc so everyone
>>> can get help on its usage, though it's pretty intuitive.
>>>>>>>> ________________________________________
>>>>>>>> From: Musayev, Ilya [imusayev@webmd.net]
>>>>>>>> Sent: Wednesday, November 07, 2012 11:41 PM
>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>>>
>>>>>>>> Rohit,
>>>>>>>>
>>>>>>>> Can I get the CLI only without going through the whole source code
>>> maven install? Is it part of any RPM?
>>>>>>>>
>>>>>>>> Thanks
>>>>>>>> ilya
>>>>>>>>
>>>>>>>> -----Original Message-----
>>>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>>>> Sent: Monday, November 05, 2012 11:35 AM
>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>>
>>>>>>>> Checkout latest code. Few changes to share:
>>>>>>>>
>>>>>>>> - All lowercase now
>>>>>>>> - Tab tab over verbs to see list of params for that api, example
>>>>>>>> list users <tab><tab>
>>>>>>>> - This needs improvement but help string, using --help: list user
>>>>>>>> --help
>>>>>>>> - Caching to speedup runtime
>>>>>>>> - Color and Parsing fixes
>>>>>>>>
>>>>>>>> Last, I'm now able to get the doc strings for each attribute/param,
>>> will see this tomorrow.
>>>>>>>>
>>>>>>>> Need your help, just incase you want to contribute, these are the
>>> TODOs:
>>>>>>>>
>>>>>>>> - search over history
>>>>>>>> - fix parsing
>>>>>>>> - doc strings for parameters
>>>>>>>> - testing for various kinds of apis (I'm able to deploy a zone
>>>>>>>> with this, but needs testing)
>>>>>>>> - unicode char monkey, used in prompt may mess up history
>>>>>>>> searching and text display
>>>>>>>>
>>>>>>>>
>>>>>>>> Regards.
>>>>>>>>
>>>>>>>> On 02-Nov-2012, at 4:58 AM, Edison Su <Ed...@citrix.com>
>> wrote:
>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> -----Original Message-----
>>>>>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>>>>>> Sent: Thursday, November 01, 2012 2:23 PM
>>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>>>>>
>>>>>>>>>> After you install the tool, so that cloudmonkey is in your
>>>>>>>>>> /usr/local/bin or in $PATH...
>>>>>>>>>>
>>>>>>>>>> Two ways;
>>>>>>>>>> 1. As command line tool, on bash/zsh, use the BNF grammar;
>>>>>>>>>> <command line tool
>>>>>>>>>> name>:<separator>:<verb>:<separator>:<action>:<separator>:<param
>>>>>>>>>> name>s>
>>>>>>>>>> <command line tool name>={'cloudmonkey'} <separator>={' '}
>>>>>>>>>> <verb>={'list', 'create', 'delete', 'update'.... etc.}
>>>>>>>>>> <action>={'Users'... etc.} <params>={'listall=#'... etc.} So; $
>>>>>>>>>> cloudmonkey list Users
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Got it, thanks!
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> 2. file redirector:
>>>>>>>>>>
>>>>>>>>>> $ cat test-file:
>>>>>>>>>> list Users
>>>>>>>>>> list <some other action>
>>>>>>>>>> <some verb> <some action>
>>>>>>>>>>
>>>>>>>>>> $ cloudmonkey < test-file
>>>>>>>>>>
>>>>>>>>>> Note, I'll change the actions (Users, VirtualMachine etc.) to
>>>>>>>>>> lowercase (users, virtualmachine etc.) if that's okay?
>>>>>>>>>
>>>>>>>>> Please do, nobody wants to type extra keystroke, if it's not
>>> necessary.
>>>>>>>>>>
>>>>>>>>>> Regards.
>>>>>>>>>>
>>>>>>>>>> ________________________________________
>>>>>>>>>> From: Edison Su [Edison.su@citrix.com]
>>>>>>>>>> Sent: Friday, November 02, 2012 1:55 AM
>>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>>>>>
>>>>>>>>>> Oh, it reminds me that how to use the CLI on the bash command
>> line?
>>>>>>>>>> I think admin may want to call cloudstack API in a bash script,
>>>>>>>>>> how can I do that?
>>>>>>>>>>
>>>>>>>>>>> -----Original Message-----
>>>>>>>>>>> From: Marcus Sorensen [mailto:shadowsor@gmail.com]
>>>>>>>>>>> Sent: Thursday, November 01, 2012 1:11 PM
>>>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>>>>>
>>>>>>>>>>> Yes, I look forward to using it instead of local curl calls on
>>>>>>>>>>> the command line :-)
>>>>>>>>>>>
>>>>>>>>>>> On Thu, Nov 1, 2012 at 2:02 PM, Edison Su <Edison.su@citrix.com
>>>
>>> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>> -----Original Message-----
>>>>>>>>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>>>>>>>>> Sent: Thursday, November 01, 2012 11:45 AM
>>>>>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>>>>>>>>
>>>>>>>>>>>>> Hi Chip, please go ahead if we can fix the http/s issue. The
>>>>>>>>>>>>> connection is based on marvin, I'm sure using CLI we'll find
>>>>>>>>>>>>> out more bugs and fix anything in marvin thereby help
>>>>>>>>>>>>> maintain
>>>>>>>>>>>>> marvin->tests and
>>>>>>>>>>> CLI.
>>>>>>>>>>>>> Please hack that up on
>>>>>>>>>>>>> tools/marvin/marvin/cloudstackConnection.py
>>>>>>>>>>>>>
>>>>>>>>>>>>> Edison, yes I'm working on the completedefault, I've figured
>>>>>>>>>>>>> a solution to the parsing and tabbing issue to show params
>>>>>>>>>>>>> for any api and added more verbs to the grammar like deploy,
>>> start etc.
>>>>>>>>>>>>> In the new approach doc strings and params needed for an api
>>>>>>>>>>>>> are fetched and cached in the class locally to speed up the
>>> loading process.
>>>>>>>>>>>>> Till it gets committed, cloudmonkey (now) will keep telling
>>>>>>>>>>>>> the user what params they are missing until it gets all the
>>> required ones.
>>>>>>>>>>>>
>>>>>>>>>>>> Great! Thanks for your awesome CLI, people will like it.
>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> One more thing, for people who may not have unicode support
>>>>>>>>>>>>> the prompt may appear weird and history search (up, down )
>>>>>>>>>>>>> can mess up the visuals. For example on Mac it appears as a
>>>>>>>>>>>>> colorful emoji, but I found that it looks weird on other
>>>>>>>>>>>>> platforms. Will probably remove it, or the user can custom
>>>>>>>>>>>>> set their prompt, using: set prompt
>>>>>>>>>>>>> myprompt>
>>>>>>>>>>>>>
>>>>>>>>>>>>> Regards.
>>>>>>>>>>>>> PS. the set command is full of (fun :)  hacks because of
>>>>>>>>>>>>> funtional/generic programming, it basically can set any
>>>>>>>>>>>>> attribute on the class, so one can do something like creating
>>>>>>>>>>>>> something (var, func). For example set ruler # (so instead of
>>>>>>>>>>>>> - you will have a #
>>>>>>>>>>>>> separator)
>>>>>>>>>>>>>
>>>>>>>>>>>>> ________________________________________
>>>>>>>>>>>>> From: Chip Childers [chip.childers@sungard.com]
>>>>>>>>>>>>> Sent: Thursday, November 01, 2012 11:15 PM
>>>>>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>>>>>>>
>>>>>>>>>>>>> On Wed, Oct 31, 2012 at 2:10 PM, Rohit Yadav
>>>>>>>>>>>>> <ro...@citrix.com>
>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>> Hi,
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> 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:
>>>>>>>>>>>>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudsta
>>>>>>>>>>>>>> ck.gi t; a=c
>>>>>>>>>>>>>> ommit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Features:
>>>>>>>>>>>>>> - 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
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> FIXMEs:
>>>>>>>>>>>>>> - 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 python cloudmonkey.py
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> If you want to have the terminal tool installed; cd
>>>>>>>>>>>>>> tools/cli python setup.py 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=8.8.8.8 internaldns1=10.147.28.6
>>>>>>>>>>>>>> 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
>>>>>>>>>>>>>> networkofferingid= create Pod zoneid= name=Pod1
>>>>>>>>>>> gateway=10.147.28.1
>>>>>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.220
>>>>>>>>>>>>>> endip=10.147.28.235 create VlanIpRange podid= networkid=
>>>>>>>>>>>>>> gateway=10.147.28.1
>>>>>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.236
>>>>>>>>>>>>>> endip=10.147.28.250 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=http://10.147.28.60 create StoragePool zoneid=
>>>>>>>>>>>>>> clusterid= name=NFS1
>>>>>>>>>>>>>> url=nfs://10.147.28.7/export/home/rohit/primary
>>>>>>>>>>>>>> add SecondaryStorage zoneId=
>>>>>>>>>>>>>> url=nfs://10.147.28.7/export/home/rohit/secondary
>>>>>>>>>>>>>> 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.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Regards.
>>>>>>>>>>>>>> PS. Marvin the neglected robot and hipster cloudmonkey
>>>>>>>>>>>>>> should rule the world :D
>>>>>>>>>>>>>
>>>>>>>>>>>>> Rohit,
>>>>>>>>>>>>>
>>>>>>>>>>>>> This is really really cool.  It puts the "fun" in managing
>>>>>>>>>>>>> instances from a command line.  I've been testing it against
>>>>>>>>>>>>> a production CloudStack environment, and it's working pretty
>>> well.
>>>>>>>>>>>>>
>>>>>>>>>>>>> If you don't mind, I might hack at the code a bit to fill in
>>>>>>>>>>>>> some gaps that I'm seeing.  First example is that it assumes
>>>>>>>>>>>>> http, which doesn't work in a public deployment where the
>>> endpoint is over https.
>>>>>>>>>>>>>
>>>>>>>>>>>>> -chip
>>>>>
>>>
>>>
>>>
>>
>>
>> --
>> Charles Moulliard
>> Apache Committer / Sr. Enterprise Architect (RedHat)
>> Twitter : @cmoulliard | Blog : http://cmoulliard.blogspot.com
>>
>
>
>
> --
> Thanks,
> Dave.


Re: CLI for CloudStack: cloudmonkey

Posted by Dave Cahill <dc...@midokura.jp>.
Hi Rohit,

I've been using cloudmonkey to script my CloudStack setup process in dev,
and had one question.

How do we pass complex (MAP) parameters to cloudmonkey? For example, when
setting up a networkoffering, there's a serviceProviderList parameter which
is a list of items, each of which has several key value pairs. I tried a
couple of syntaxes to pass this parameter, but didn't come across the
correct one yet - can you enlighten me? ;)

Thanks for your work on this, very useful.

Thanks,
Dave.


On Mon, Nov 12, 2012 at 7:01 PM, Rohit Yadav <ro...@citrix.com> wrote:

> Hi Charles,
>
> Karaf seems nice, and no worries I don't see any suggestions as flames or
> war. I would anytime throw away any code for something better, so feel free
> to start writing your own client and share with us. Patches welcome!
>
> Let me share why I wrote it in Python:
>
> - First of all the CLI is not even a client to start with, I mean I've
> totally based it off marvin. It's a small wrapper I would say around marvin.
> - Python because, the environment is preinstalled on Macs and almost all
> Linux distros.
> - Scripting environment that Python provides so one can fork and edit
> their own versions of cloudmonkey CLI, this saves the user from
> hack->compile->build->run loop; one can just hack and run.
> - The best part again is marvin as dependency, you write javadocs etc. in
> your java code, apidocs gets interface definition and requirements from the
> java code, the commands.xml created in the process is used by marvin's
> codegenerator  which generates api modules with Cmd and Response classes.
> The generated cloudstackAPI is used by both marvin clients and the CLI. The
> CLI which is about 400 lines of Python, in turn loads these modules and
> generates grammar and command handlers on the fly using some functional
> magic (injects functions into the classes), I don't think this kind of
> programming is even possible with Java, they don't have functions as first
> class citizens.
>
> What does the last statement mean for the developers:
> So, if a developer simply adds a new API which is java code, with required
> docs etc. apidocs will pick it up automatically and in turn marvin (and
> it's test clients) will get new cloudstackAPI and CLI too gets the new APIs
> on the fly. The functional closures in CLI will make sure the new APIs and
> its handlers are created with grammar rules. The developer won't need to
> change apidocs, marvin or CLI. I think this is one of my best hacks [0]
> which leverages on existing code and I think it would be very maintainable
> in future.
>
> Sorry everyone, I'm caught up with some other issues, I want to post a
> screencast and blog explaining the CLI but only after I finalize the specs
> for the CLI. Thanks for the feedback so far.
> The top TODOs left now are:
> - Reverse search
> - Bash/zsh completion
>
> Regards.
> PS. Just in case you're curious:
> [0] https://github.com/bhaisaab/hacktools
>
> ________________________________________
> From: Charles Moulliard [ch007m@gmail.com]
> Sent: Monday, November 12, 2012 12:49 PM
> To: cloudstack-dev
> Subject: Re: CLI for CloudStack: cloudmonkey
>
> Hi,
>
> I don't want to create a developer war or position a technology against
> another (python against java) but we could leverage Apache Karaf (OSGI
> runtime container) project to provide the cloudmonkey client. This work has
> already be done for jclouds (http://www.youtube.com/watch?v=EKVkm6AV19U,
> https://github.com/jclouds/jclouds-karaf) and could be easily
> created
> created for cloudmonkey. Karaf which is a shell environment proposes a lot
> of by default features (http://karaf.apache.org/ : ssh, jaas,
> provisioning,
> administration, history, config files support, ... -
> http://karaf.apache.org/manual/latest-2.3.x/developers-guide/index.html)
> that we could extend with cloudmonkey commands (
>
> http://karaf.apache.org/manual/latest-2.3.x/developers-guide/extending-console.html
> )
> and rebrand Karaf into a cloudmonkey karaf container.
>
> Regards,
>
> Charles
>
>
> On Fri, Nov 9, 2012 at 10:53 PM, Musayev, Ilya <im...@webmd.net> wrote:
>
> > I guess mine got wiped somehow...
> >
> > -----Original Message-----
> > From: Musayev, Ilya [mailto:imusayev@webmd.net]
> > Sent: Friday, November 09, 2012 4:51 PM
> > To: cloudstack-dev@incubator.apache.org
> > Subject: RE: CLI for CloudStack: cloudmonkey
> >
> > Rohit
> >
> > History seems to retain only last session and not previous - is this by
> > design?
> >
> > Thanks
> > ilya
> >
> > -----Original Message-----
> > From: sebgoa [mailto:runseb@gmail.com]
> > Sent: Friday, November 09, 2012 4:52 AM
> > To: cloudstack-dev@incubator.apache.org
> > Subject: Re: CLI for CloudStack: cloudmonkey
> >
> > Using lower case commands solved the issue
> >
> > thanks, and happy Diwali
> >
> > -Sebastien
> >
> > On Nov 8, 2012, at 8:14 PM, Rohit Yadav wrote:
> >
> > > Oh, forgot to see that. Yes, now all the cmds are lowercase (except for
> > few params liks isAsync=) and tab completion is advised.
> > >
> > > Regards.
> > > ________________________________________
> > > From: Kishan Kavala [Kishan.Kavala@citrix.com]
> > > Sent: Thursday, November 08, 2012 11:29 PM
> > > To: cloudstack-dev@incubator.apache.org
> > > Cc: cloudstack-dev@incubator.apache.org
> > > Subject: Re: CLI for CloudStack: cloudmonkey
> > >
> > > Sebastian,
> > >  Try set apikey in lower case. Same with set secretkey.
> > >
> > > ~kishan
> > >
> > > On 08-Nov-2012, at 10:00 PM, "Sebastien Goasguen" <ru...@gmail.com>
> > wrote:
> > >
> > >> Actually it does not work yet.
> > >>
> > >> Now I can type 'b' but it does not get passed properly:
> > >>
> > >> 🙉 cloudmonkey> set apiKey
> > >> KEbkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzj
> > >> RB9UNrBybVr3kcZ6Q
> > >>
> > >> Gives:
> > >>
> > >> INFO  [cloud.api.ApiServer] (92734721@qtp-1601733969-7:) apiKey does
> > >> not map to a valid user -- ignoring request, apiKey:
> > >> KEkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzjR
> > >> B9UNrByVr3kcZ6Q
> > >>
> > >> On Nov 8, 2012, at 5:19 PM, Sebastien Goasguen <ru...@gmail.com>
> > wrote:
> > >>
> > >>>
> > >>> On Nov 8, 2012, at 3:28 PM, Rohit Yadav <ro...@citrix.com>
> > wrote:
> > >>>
> > >>>> Hi Sebastien,
> > >>>>
> > >>>> Are you using it from pypi/pip, if so do this:
> > >>>> sudo pip uninstall cloudmonkey
> > >>>> sudo pip install cloudmonkey
> > >>>
> > >>> no, I am doing: sudo python ./setup.py install from the source tree
> > >>>
> > >>>> I've had this bug on mac osx, fixed it:
> > >>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.git;
> > >>>> a=commit;h=36e7a7884efef7c41ac369549b7bdb93e5122110
> > >>>
> > >>> pulled that and reinstalled…and it works.
> > >>>
> > >>> thanks
> > >>>
> > >>> -sebastien
> > >>>
> > >>>
> > >>>> If it still persists for you, checkout
> > >>>> http://superuser.com/questions/297527/cant-type-the-b-letter-in-pyt
> > >>>> hon-shell-in-os-x
> > >>>>
> > >>>> Let me know if this still fails then.
> > >>>>
> > >>>> Regards.
> > >>>>
> > >>>> ________________________________________
> > >>>> From: Sebastien Goasguen [runseb@gmail.com]
> > >>>> Sent: Thursday, November 08, 2012 5:37 PM
> > >>>> To: cloudstack-dev@incubator.apache.org
> > >>>> Subject: Re: CLI for CloudStack: cloudmonkey
> > >>>>
> > >>>> Hi,
> > >>>>
> > >>>> I am testing the cli and I have the weirdest issue. When I set the
> > apikey or secretkey, the lower case 'b' letter does not print at the
> prompt.
> > >>>> So if my keys contain 'b' they don't work..
> > >>>>
> > >>>> I tried all the other letters and they work.
> > >>>>
> > >>>> Anyone seeing this,
> > >>>>
> > >>>> -Sebastien
> > >>>>
> > >>>> On Nov 7, 2012, at 7:25 PM, Rohit Yadav <ro...@citrix.com>
> > wrote:
> > >>>>
> > >>>>> yes, I think I'd mentioned in the thread or somewhere. Just use
> > >>>>> pip or easy_install (apt-get install python-setuptools on ubuntu,
> > >>>>> install python2.6 or above and pip if you don't have it);
> > >>>>>
> > >>>>> sudo pip install cloudmonkey
> > >>>>>
> > >>>>> or sudo easy_install cloudmonkey
> > >>>>>
> > >>>>> now start cloudmonkey:
> > >>>>> $ cloudmonkey
> > >>>>> ...
> > >>>>>
> > >>>>> Will post a blog/screencast this weekend and update doc so everyone
> > can get help on its usage, though it's pretty intuitive.
> > >>>>> ________________________________________
> > >>>>> From: Musayev, Ilya [imusayev@webmd.net]
> > >>>>> Sent: Wednesday, November 07, 2012 11:41 PM
> > >>>>> To: cloudstack-dev@incubator.apache.org
> > >>>>> Subject: RE: CLI for CloudStack: cloudmonkey
> > >>>>>
> > >>>>> Rohit,
> > >>>>>
> > >>>>> Can I get the CLI only without going through the whole source code
> > maven install? Is it part of any RPM?
> > >>>>>
> > >>>>> Thanks
> > >>>>> ilya
> > >>>>>
> > >>>>> -----Original Message-----
> > >>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
> > >>>>> Sent: Monday, November 05, 2012 11:35 AM
> > >>>>> To: cloudstack-dev@incubator.apache.org
> > >>>>> Subject: Re: CLI for CloudStack: cloudmonkey
> > >>>>>
> > >>>>> Checkout latest code. Few changes to share:
> > >>>>>
> > >>>>> - All lowercase now
> > >>>>> - Tab tab over verbs to see list of params for that api, example
> > >>>>> list users <tab><tab>
> > >>>>> - This needs improvement but help string, using --help: list user
> > >>>>> --help
> > >>>>> - Caching to speedup runtime
> > >>>>> - Color and Parsing fixes
> > >>>>>
> > >>>>> Last, I'm now able to get the doc strings for each attribute/param,
> > will see this tomorrow.
> > >>>>>
> > >>>>> Need your help, just incase you want to contribute, these are the
> > TODOs:
> > >>>>>
> > >>>>> - search over history
> > >>>>> - fix parsing
> > >>>>> - doc strings for parameters
> > >>>>> - testing for various kinds of apis (I'm able to deploy a zone
> > >>>>> with this, but needs testing)
> > >>>>> - unicode char monkey, used in prompt may mess up history
> > >>>>> searching and text display
> > >>>>>
> > >>>>>
> > >>>>> Regards.
> > >>>>>
> > >>>>> On 02-Nov-2012, at 4:58 AM, Edison Su <Ed...@citrix.com>
> wrote:
> > >>>>>
> > >>>>>>
> > >>>>>>
> > >>>>>>> -----Original Message-----
> > >>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
> > >>>>>>> Sent: Thursday, November 01, 2012 2:23 PM
> > >>>>>>> To: cloudstack-dev@incubator.apache.org
> > >>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
> > >>>>>>>
> > >>>>>>> After you install the tool, so that cloudmonkey is in your
> > >>>>>>> /usr/local/bin or in $PATH...
> > >>>>>>>
> > >>>>>>> Two ways;
> > >>>>>>> 1. As command line tool, on bash/zsh, use the BNF grammar;
> > >>>>>>> <command line tool
> > >>>>>>> name>:<separator>:<verb>:<separator>:<action>:<separator>:<param
> > >>>>>>> name>s>
> > >>>>>>> <command line tool name>={'cloudmonkey'} <separator>={' '}
> > >>>>>>> <verb>={'list', 'create', 'delete', 'update'.... etc.}
> > >>>>>>> <action>={'Users'... etc.} <params>={'listall=#'... etc.} So; $
> > >>>>>>> cloudmonkey list Users
> > >>>>>>
> > >>>>>>
> > >>>>>> Got it, thanks!
> > >>>>>>
> > >>>>>>>
> > >>>>>>> 2. file redirector:
> > >>>>>>>
> > >>>>>>> $ cat test-file:
> > >>>>>>> list Users
> > >>>>>>> list <some other action>
> > >>>>>>> <some verb> <some action>
> > >>>>>>>
> > >>>>>>> $ cloudmonkey < test-file
> > >>>>>>>
> > >>>>>>> Note, I'll change the actions (Users, VirtualMachine etc.) to
> > >>>>>>> lowercase (users, virtualmachine etc.) if that's okay?
> > >>>>>>
> > >>>>>> Please do, nobody wants to type extra keystroke, if it's not
> > necessary.
> > >>>>>>>
> > >>>>>>> Regards.
> > >>>>>>>
> > >>>>>>> ________________________________________
> > >>>>>>> From: Edison Su [Edison.su@citrix.com]
> > >>>>>>> Sent: Friday, November 02, 2012 1:55 AM
> > >>>>>>> To: cloudstack-dev@incubator.apache.org
> > >>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
> > >>>>>>>
> > >>>>>>> Oh, it reminds me that how to use the CLI on the bash command
> line?
> > >>>>>>> I think admin may want to call cloudstack API in a bash script,
> > >>>>>>> how can I do that?
> > >>>>>>>
> > >>>>>>>> -----Original Message-----
> > >>>>>>>> From: Marcus Sorensen [mailto:shadowsor@gmail.com]
> > >>>>>>>> Sent: Thursday, November 01, 2012 1:11 PM
> > >>>>>>>> To: cloudstack-dev@incubator.apache.org
> > >>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
> > >>>>>>>>
> > >>>>>>>> Yes, I look forward to using it instead of local curl calls on
> > >>>>>>>> the command line :-)
> > >>>>>>>>
> > >>>>>>>> On Thu, Nov 1, 2012 at 2:02 PM, Edison Su <Edison.su@citrix.com
> >
> > wrote:
> > >>>>>>>>>
> > >>>>>>>>>
> > >>>>>>>>>> -----Original Message-----
> > >>>>>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
> > >>>>>>>>>> Sent: Thursday, November 01, 2012 11:45 AM
> > >>>>>>>>>> To: cloudstack-dev@incubator.apache.org
> > >>>>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
> > >>>>>>>>>>
> > >>>>>>>>>> Hi Chip, please go ahead if we can fix the http/s issue. The
> > >>>>>>>>>> connection is based on marvin, I'm sure using CLI we'll find
> > >>>>>>>>>> out more bugs and fix anything in marvin thereby help
> > >>>>>>>>>> maintain
> > >>>>>>>>>> marvin->tests and
> > >>>>>>>> CLI.
> > >>>>>>>>>> Please hack that up on
> > >>>>>>>>>> tools/marvin/marvin/cloudstackConnection.py
> > >>>>>>>>>>
> > >>>>>>>>>> Edison, yes I'm working on the completedefault, I've figured
> > >>>>>>>>>> a solution to the parsing and tabbing issue to show params
> > >>>>>>>>>> for any api and added more verbs to the grammar like deploy,
> > start etc.
> > >>>>>>>>>> In the new approach doc strings and params needed for an api
> > >>>>>>>>>> are fetched and cached in the class locally to speed up the
> > loading process.
> > >>>>>>>>>> Till it gets committed, cloudmonkey (now) will keep telling
> > >>>>>>>>>> the user what params they are missing until it gets all the
> > required ones.
> > >>>>>>>>>
> > >>>>>>>>> Great! Thanks for your awesome CLI, people will like it.
> > >>>>>>>>>
> > >>>>>>>>>>
> > >>>>>>>>>> One more thing, for people who may not have unicode support
> > >>>>>>>>>> the prompt may appear weird and history search (up, down )
> > >>>>>>>>>> can mess up the visuals. For example on Mac it appears as a
> > >>>>>>>>>> colorful emoji, but I found that it looks weird on other
> > >>>>>>>>>> platforms. Will probably remove it, or the user can custom
> > >>>>>>>>>> set their prompt, using: set prompt
> > >>>>>>>>>> myprompt>
> > >>>>>>>>>>
> > >>>>>>>>>> Regards.
> > >>>>>>>>>> PS. the set command is full of (fun :)  hacks because of
> > >>>>>>>>>> funtional/generic programming, it basically can set any
> > >>>>>>>>>> attribute on the class, so one can do something like creating
> > >>>>>>>>>> something (var, func). For example set ruler # (so instead of
> > >>>>>>>>>> - you will have a #
> > >>>>>>>>>> separator)
> > >>>>>>>>>>
> > >>>>>>>>>> ________________________________________
> > >>>>>>>>>> From: Chip Childers [chip.childers@sungard.com]
> > >>>>>>>>>> Sent: Thursday, November 01, 2012 11:15 PM
> > >>>>>>>>>> To: cloudstack-dev@incubator.apache.org
> > >>>>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
> > >>>>>>>>>>
> > >>>>>>>>>> On Wed, Oct 31, 2012 at 2:10 PM, Rohit Yadav
> > >>>>>>>>>> <ro...@citrix.com>
> > >>>>>>>>>> wrote:
> > >>>>>>>>>>> Hi,
> > >>>>>>>>>>>
> > >>>>>>>>>>> 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:
> > >>>>>>>>>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudsta
> > >>>>>>>>>>> ck.gi t; a=c
> > >>>>>>>>>>> ommit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
> > >>>>>>>>>>>
> > >>>>>>>>>>> Features:
> > >>>>>>>>>>> - 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
> > >>>>>>>>>>>
> > >>>>>>>>>>> FIXMEs:
> > >>>>>>>>>>> - 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 python cloudmonkey.py
> > >>>>>>>>>>>
> > >>>>>>>>>>> If you want to have the terminal tool installed; cd
> > >>>>>>>>>>> tools/cli python setup.py 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=8.8.8.8 internaldns1=10.147.28.6
> > >>>>>>>>>>> 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
> > >>>>>>>>>>> networkofferingid= create Pod zoneid= name=Pod1
> > >>>>>>>> gateway=10.147.28.1
> > >>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.220
> > >>>>>>>>>>> endip=10.147.28.235 create VlanIpRange podid= networkid=
> > >>>>>>>>>>> gateway=10.147.28.1
> > >>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.236
> > >>>>>>>>>>> endip=10.147.28.250 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=http://10.147.28.60 create StoragePool zoneid=
> > >>>>>>>>>>> clusterid= name=NFS1
> > >>>>>>>>>>> url=nfs://10.147.28.7/export/home/rohit/primary
> > >>>>>>>>>>> add SecondaryStorage zoneId=
> > >>>>>>>>>>> url=nfs://10.147.28.7/export/home/rohit/secondary
> > >>>>>>>>>>> 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.
> > >>>>>>>>>>>
> > >>>>>>>>>>> Regards.
> > >>>>>>>>>>> PS. Marvin the neglected robot and hipster cloudmonkey
> > >>>>>>>>>>> should rule the world :D
> > >>>>>>>>>>
> > >>>>>>>>>> Rohit,
> > >>>>>>>>>>
> > >>>>>>>>>> This is really really cool.  It puts the "fun" in managing
> > >>>>>>>>>> instances from a command line.  I've been testing it against
> > >>>>>>>>>> a production CloudStack environment, and it's working pretty
> > well.
> > >>>>>>>>>>
> > >>>>>>>>>> If you don't mind, I might hack at the code a bit to fill in
> > >>>>>>>>>> some gaps that I'm seeing.  First example is that it assumes
> > >>>>>>>>>> http, which doesn't work in a public deployment where the
> > endpoint is over https.
> > >>>>>>>>>>
> > >>>>>>>>>> -chip
> > >>
> >
> >
> >
>
>
> --
> Charles Moulliard
> Apache Committer / Sr. Enterprise Architect (RedHat)
> Twitter : @cmoulliard | Blog : http://cmoulliard.blogspot.com
>



-- 
Thanks,
Dave.

RE: CLI for CloudStack: cloudmonkey

Posted by Rohit Yadav <ro...@citrix.com>.
Hi Charles,

Karaf seems nice, and no worries I don't see any suggestions as flames or war. I would anytime throw away any code for something better, so feel free to start writing your own client and share with us. Patches welcome!

Let me share why I wrote it in Python:

- First of all the CLI is not even a client to start with, I mean I've totally based it off marvin. It's a small wrapper I would say around marvin.
- Python because, the environment is preinstalled on Macs and almost all Linux distros.
- Scripting environment that Python provides so one can fork and edit their own versions of cloudmonkey CLI, this saves the user from hack->compile->build->run loop; one can just hack and run.
- The best part again is marvin as dependency, you write javadocs etc. in your java code, apidocs gets interface definition and requirements from the java code, the commands.xml created in the process is used by marvin's codegenerator  which generates api modules with Cmd and Response classes. The generated cloudstackAPI is used by both marvin clients and the CLI. The CLI which is about 400 lines of Python, in turn loads these modules and generates grammar and command handlers on the fly using some functional magic (injects functions into the classes), I don't think this kind of programming is even possible with Java, they don't have functions as first class citizens.

What does the last statement mean for the developers:
So, if a developer simply adds a new API which is java code, with required docs etc. apidocs will pick it up automatically and in turn marvin (and it's test clients) will get new cloudstackAPI and CLI too gets the new APIs on the fly. The functional closures in CLI will make sure the new APIs and its handlers are created with grammar rules. The developer won't need to change apidocs, marvin or CLI. I think this is one of my best hacks [0] which leverages on existing code and I think it would be very maintainable in future.

Sorry everyone, I'm caught up with some other issues, I want to post a screencast and blog explaining the CLI but only after I finalize the specs for the CLI. Thanks for the feedback so far.
The top TODOs left now are:
- Reverse search
- Bash/zsh completion

Regards.
PS. Just in case you're curious:
[0] https://github.com/bhaisaab/hacktools

________________________________________
From: Charles Moulliard [ch007m@gmail.com]
Sent: Monday, November 12, 2012 12:49 PM
To: cloudstack-dev
Subject: Re: CLI for CloudStack: cloudmonkey

Hi,

I don't want to create a developer war or position a technology against
another (python against java) but we could leverage Apache Karaf (OSGI
runtime container) project to provide the cloudmonkey client. This work has
already be done for jclouds (http://www.youtube.com/watch?v=EKVkm6AV19U,
https://github.com/jclouds/jclouds-karaf) and could be easily
created
created for cloudmonkey. Karaf which is a shell environment proposes a lot
of by default features (http://karaf.apache.org/ : ssh, jaas, provisioning,
administration, history, config files support, ... -
http://karaf.apache.org/manual/latest-2.3.x/developers-guide/index.html)
that we could extend with cloudmonkey commands (
http://karaf.apache.org/manual/latest-2.3.x/developers-guide/extending-console.html)
and rebrand Karaf into a cloudmonkey karaf container.

Regards,

Charles


On Fri, Nov 9, 2012 at 10:53 PM, Musayev, Ilya <im...@webmd.net> wrote:

> I guess mine got wiped somehow...
>
> -----Original Message-----
> From: Musayev, Ilya [mailto:imusayev@webmd.net]
> Sent: Friday, November 09, 2012 4:51 PM
> To: cloudstack-dev@incubator.apache.org
> Subject: RE: CLI for CloudStack: cloudmonkey
>
> Rohit
>
> History seems to retain only last session and not previous - is this by
> design?
>
> Thanks
> ilya
>
> -----Original Message-----
> From: sebgoa [mailto:runseb@gmail.com]
> Sent: Friday, November 09, 2012 4:52 AM
> To: cloudstack-dev@incubator.apache.org
> Subject: Re: CLI for CloudStack: cloudmonkey
>
> Using lower case commands solved the issue
>
> thanks, and happy Diwali
>
> -Sebastien
>
> On Nov 8, 2012, at 8:14 PM, Rohit Yadav wrote:
>
> > Oh, forgot to see that. Yes, now all the cmds are lowercase (except for
> few params liks isAsync=) and tab completion is advised.
> >
> > Regards.
> > ________________________________________
> > From: Kishan Kavala [Kishan.Kavala@citrix.com]
> > Sent: Thursday, November 08, 2012 11:29 PM
> > To: cloudstack-dev@incubator.apache.org
> > Cc: cloudstack-dev@incubator.apache.org
> > Subject: Re: CLI for CloudStack: cloudmonkey
> >
> > Sebastian,
> >  Try set apikey in lower case. Same with set secretkey.
> >
> > ~kishan
> >
> > On 08-Nov-2012, at 10:00 PM, "Sebastien Goasguen" <ru...@gmail.com>
> wrote:
> >
> >> Actually it does not work yet.
> >>
> >> Now I can type 'b' but it does not get passed properly:
> >>
> >> 🙉 cloudmonkey> set apiKey
> >> KEbkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzj
> >> RB9UNrBybVr3kcZ6Q
> >>
> >> Gives:
> >>
> >> INFO  [cloud.api.ApiServer] (92734721@qtp-1601733969-7:) apiKey does
> >> not map to a valid user -- ignoring request, apiKey:
> >> KEkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzjR
> >> B9UNrByVr3kcZ6Q
> >>
> >> On Nov 8, 2012, at 5:19 PM, Sebastien Goasguen <ru...@gmail.com>
> wrote:
> >>
> >>>
> >>> On Nov 8, 2012, at 3:28 PM, Rohit Yadav <ro...@citrix.com>
> wrote:
> >>>
> >>>> Hi Sebastien,
> >>>>
> >>>> Are you using it from pypi/pip, if so do this:
> >>>> sudo pip uninstall cloudmonkey
> >>>> sudo pip install cloudmonkey
> >>>
> >>> no, I am doing: sudo python ./setup.py install from the source tree
> >>>
> >>>> I've had this bug on mac osx, fixed it:
> >>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.git;
> >>>> a=commit;h=36e7a7884efef7c41ac369549b7bdb93e5122110
> >>>
> >>> pulled that and reinstalled…and it works.
> >>>
> >>> thanks
> >>>
> >>> -sebastien
> >>>
> >>>
> >>>> If it still persists for you, checkout
> >>>> http://superuser.com/questions/297527/cant-type-the-b-letter-in-pyt
> >>>> hon-shell-in-os-x
> >>>>
> >>>> Let me know if this still fails then.
> >>>>
> >>>> Regards.
> >>>>
> >>>> ________________________________________
> >>>> From: Sebastien Goasguen [runseb@gmail.com]
> >>>> Sent: Thursday, November 08, 2012 5:37 PM
> >>>> To: cloudstack-dev@incubator.apache.org
> >>>> Subject: Re: CLI for CloudStack: cloudmonkey
> >>>>
> >>>> Hi,
> >>>>
> >>>> I am testing the cli and I have the weirdest issue. When I set the
> apikey or secretkey, the lower case 'b' letter does not print at the prompt.
> >>>> So if my keys contain 'b' they don't work..
> >>>>
> >>>> I tried all the other letters and they work.
> >>>>
> >>>> Anyone seeing this,
> >>>>
> >>>> -Sebastien
> >>>>
> >>>> On Nov 7, 2012, at 7:25 PM, Rohit Yadav <ro...@citrix.com>
> wrote:
> >>>>
> >>>>> yes, I think I'd mentioned in the thread or somewhere. Just use
> >>>>> pip or easy_install (apt-get install python-setuptools on ubuntu,
> >>>>> install python2.6 or above and pip if you don't have it);
> >>>>>
> >>>>> sudo pip install cloudmonkey
> >>>>>
> >>>>> or sudo easy_install cloudmonkey
> >>>>>
> >>>>> now start cloudmonkey:
> >>>>> $ cloudmonkey
> >>>>> ...
> >>>>>
> >>>>> Will post a blog/screencast this weekend and update doc so everyone
> can get help on its usage, though it's pretty intuitive.
> >>>>> ________________________________________
> >>>>> From: Musayev, Ilya [imusayev@webmd.net]
> >>>>> Sent: Wednesday, November 07, 2012 11:41 PM
> >>>>> To: cloudstack-dev@incubator.apache.org
> >>>>> Subject: RE: CLI for CloudStack: cloudmonkey
> >>>>>
> >>>>> Rohit,
> >>>>>
> >>>>> Can I get the CLI only without going through the whole source code
> maven install? Is it part of any RPM?
> >>>>>
> >>>>> Thanks
> >>>>> ilya
> >>>>>
> >>>>> -----Original Message-----
> >>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
> >>>>> Sent: Monday, November 05, 2012 11:35 AM
> >>>>> To: cloudstack-dev@incubator.apache.org
> >>>>> Subject: Re: CLI for CloudStack: cloudmonkey
> >>>>>
> >>>>> Checkout latest code. Few changes to share:
> >>>>>
> >>>>> - All lowercase now
> >>>>> - Tab tab over verbs to see list of params for that api, example
> >>>>> list users <tab><tab>
> >>>>> - This needs improvement but help string, using --help: list user
> >>>>> --help
> >>>>> - Caching to speedup runtime
> >>>>> - Color and Parsing fixes
> >>>>>
> >>>>> Last, I'm now able to get the doc strings for each attribute/param,
> will see this tomorrow.
> >>>>>
> >>>>> Need your help, just incase you want to contribute, these are the
> TODOs:
> >>>>>
> >>>>> - search over history
> >>>>> - fix parsing
> >>>>> - doc strings for parameters
> >>>>> - testing for various kinds of apis (I'm able to deploy a zone
> >>>>> with this, but needs testing)
> >>>>> - unicode char monkey, used in prompt may mess up history
> >>>>> searching and text display
> >>>>>
> >>>>>
> >>>>> Regards.
> >>>>>
> >>>>> On 02-Nov-2012, at 4:58 AM, Edison Su <Ed...@citrix.com> wrote:
> >>>>>
> >>>>>>
> >>>>>>
> >>>>>>> -----Original Message-----
> >>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
> >>>>>>> Sent: Thursday, November 01, 2012 2:23 PM
> >>>>>>> To: cloudstack-dev@incubator.apache.org
> >>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
> >>>>>>>
> >>>>>>> After you install the tool, so that cloudmonkey is in your
> >>>>>>> /usr/local/bin or in $PATH...
> >>>>>>>
> >>>>>>> Two ways;
> >>>>>>> 1. As command line tool, on bash/zsh, use the BNF grammar;
> >>>>>>> <command line tool
> >>>>>>> name>:<separator>:<verb>:<separator>:<action>:<separator>:<param
> >>>>>>> name>s>
> >>>>>>> <command line tool name>={'cloudmonkey'} <separator>={' '}
> >>>>>>> <verb>={'list', 'create', 'delete', 'update'.... etc.}
> >>>>>>> <action>={'Users'... etc.} <params>={'listall=#'... etc.} So; $
> >>>>>>> cloudmonkey list Users
> >>>>>>
> >>>>>>
> >>>>>> Got it, thanks!
> >>>>>>
> >>>>>>>
> >>>>>>> 2. file redirector:
> >>>>>>>
> >>>>>>> $ cat test-file:
> >>>>>>> list Users
> >>>>>>> list <some other action>
> >>>>>>> <some verb> <some action>
> >>>>>>>
> >>>>>>> $ cloudmonkey < test-file
> >>>>>>>
> >>>>>>> Note, I'll change the actions (Users, VirtualMachine etc.) to
> >>>>>>> lowercase (users, virtualmachine etc.) if that's okay?
> >>>>>>
> >>>>>> Please do, nobody wants to type extra keystroke, if it's not
> necessary.
> >>>>>>>
> >>>>>>> Regards.
> >>>>>>>
> >>>>>>> ________________________________________
> >>>>>>> From: Edison Su [Edison.su@citrix.com]
> >>>>>>> Sent: Friday, November 02, 2012 1:55 AM
> >>>>>>> To: cloudstack-dev@incubator.apache.org
> >>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
> >>>>>>>
> >>>>>>> Oh, it reminds me that how to use the CLI on the bash command line?
> >>>>>>> I think admin may want to call cloudstack API in a bash script,
> >>>>>>> how can I do that?
> >>>>>>>
> >>>>>>>> -----Original Message-----
> >>>>>>>> From: Marcus Sorensen [mailto:shadowsor@gmail.com]
> >>>>>>>> Sent: Thursday, November 01, 2012 1:11 PM
> >>>>>>>> To: cloudstack-dev@incubator.apache.org
> >>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
> >>>>>>>>
> >>>>>>>> Yes, I look forward to using it instead of local curl calls on
> >>>>>>>> the command line :-)
> >>>>>>>>
> >>>>>>>> On Thu, Nov 1, 2012 at 2:02 PM, Edison Su <Ed...@citrix.com>
> wrote:
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>> -----Original Message-----
> >>>>>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
> >>>>>>>>>> Sent: Thursday, November 01, 2012 11:45 AM
> >>>>>>>>>> To: cloudstack-dev@incubator.apache.org
> >>>>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
> >>>>>>>>>>
> >>>>>>>>>> Hi Chip, please go ahead if we can fix the http/s issue. The
> >>>>>>>>>> connection is based on marvin, I'm sure using CLI we'll find
> >>>>>>>>>> out more bugs and fix anything in marvin thereby help
> >>>>>>>>>> maintain
> >>>>>>>>>> marvin->tests and
> >>>>>>>> CLI.
> >>>>>>>>>> Please hack that up on
> >>>>>>>>>> tools/marvin/marvin/cloudstackConnection.py
> >>>>>>>>>>
> >>>>>>>>>> Edison, yes I'm working on the completedefault, I've figured
> >>>>>>>>>> a solution to the parsing and tabbing issue to show params
> >>>>>>>>>> for any api and added more verbs to the grammar like deploy,
> start etc.
> >>>>>>>>>> In the new approach doc strings and params needed for an api
> >>>>>>>>>> are fetched and cached in the class locally to speed up the
> loading process.
> >>>>>>>>>> Till it gets committed, cloudmonkey (now) will keep telling
> >>>>>>>>>> the user what params they are missing until it gets all the
> required ones.
> >>>>>>>>>
> >>>>>>>>> Great! Thanks for your awesome CLI, people will like it.
> >>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>> One more thing, for people who may not have unicode support
> >>>>>>>>>> the prompt may appear weird and history search (up, down )
> >>>>>>>>>> can mess up the visuals. For example on Mac it appears as a
> >>>>>>>>>> colorful emoji, but I found that it looks weird on other
> >>>>>>>>>> platforms. Will probably remove it, or the user can custom
> >>>>>>>>>> set their prompt, using: set prompt
> >>>>>>>>>> myprompt>
> >>>>>>>>>>
> >>>>>>>>>> Regards.
> >>>>>>>>>> PS. the set command is full of (fun :)  hacks because of
> >>>>>>>>>> funtional/generic programming, it basically can set any
> >>>>>>>>>> attribute on the class, so one can do something like creating
> >>>>>>>>>> something (var, func). For example set ruler # (so instead of
> >>>>>>>>>> - you will have a #
> >>>>>>>>>> separator)
> >>>>>>>>>>
> >>>>>>>>>> ________________________________________
> >>>>>>>>>> From: Chip Childers [chip.childers@sungard.com]
> >>>>>>>>>> Sent: Thursday, November 01, 2012 11:15 PM
> >>>>>>>>>> To: cloudstack-dev@incubator.apache.org
> >>>>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
> >>>>>>>>>>
> >>>>>>>>>> On Wed, Oct 31, 2012 at 2:10 PM, Rohit Yadav
> >>>>>>>>>> <ro...@citrix.com>
> >>>>>>>>>> wrote:
> >>>>>>>>>>> Hi,
> >>>>>>>>>>>
> >>>>>>>>>>> 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:
> >>>>>>>>>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudsta
> >>>>>>>>>>> ck.gi t; a=c
> >>>>>>>>>>> ommit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
> >>>>>>>>>>>
> >>>>>>>>>>> Features:
> >>>>>>>>>>> - 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
> >>>>>>>>>>>
> >>>>>>>>>>> FIXMEs:
> >>>>>>>>>>> - 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 python cloudmonkey.py
> >>>>>>>>>>>
> >>>>>>>>>>> If you want to have the terminal tool installed; cd
> >>>>>>>>>>> tools/cli python setup.py 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=8.8.8.8 internaldns1=10.147.28.6
> >>>>>>>>>>> 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
> >>>>>>>>>>> networkofferingid= create Pod zoneid= name=Pod1
> >>>>>>>> gateway=10.147.28.1
> >>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.220
> >>>>>>>>>>> endip=10.147.28.235 create VlanIpRange podid= networkid=
> >>>>>>>>>>> gateway=10.147.28.1
> >>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.236
> >>>>>>>>>>> endip=10.147.28.250 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=http://10.147.28.60 create StoragePool zoneid=
> >>>>>>>>>>> clusterid= name=NFS1
> >>>>>>>>>>> url=nfs://10.147.28.7/export/home/rohit/primary
> >>>>>>>>>>> add SecondaryStorage zoneId=
> >>>>>>>>>>> url=nfs://10.147.28.7/export/home/rohit/secondary
> >>>>>>>>>>> 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.
> >>>>>>>>>>>
> >>>>>>>>>>> Regards.
> >>>>>>>>>>> PS. Marvin the neglected robot and hipster cloudmonkey
> >>>>>>>>>>> should rule the world :D
> >>>>>>>>>>
> >>>>>>>>>> Rohit,
> >>>>>>>>>>
> >>>>>>>>>> This is really really cool.  It puts the "fun" in managing
> >>>>>>>>>> instances from a command line.  I've been testing it against
> >>>>>>>>>> a production CloudStack environment, and it's working pretty
> well.
> >>>>>>>>>>
> >>>>>>>>>> If you don't mind, I might hack at the code a bit to fill in
> >>>>>>>>>> some gaps that I'm seeing.  First example is that it assumes
> >>>>>>>>>> http, which doesn't work in a public deployment where the
> endpoint is over https.
> >>>>>>>>>>
> >>>>>>>>>> -chip
> >>
>
>
>


--
Charles Moulliard
Apache Committer / Sr. Enterprise Architect (RedHat)
Twitter : @cmoulliard | Blog : http://cmoulliard.blogspot.com

Re: CLI for CloudStack: cloudmonkey

Posted by Charles Moulliard <ch...@gmail.com>.
Hi,

I don't want to create a developer war or position a technology against
another (python against java) but we could leverage Apache Karaf (OSGI
runtime container) project to provide the cloudmonkey client. This work has
already be done for jclouds (http://www.youtube.com/watch?v=EKVkm6AV19U,
https://github.com/jclouds/jclouds-karaf) and could be easily
created
created for cloudmonkey. Karaf which is a shell environment proposes a lot
of by default features (http://karaf.apache.org/ : ssh, jaas, provisioning,
administration, history, config files support, ... -
http://karaf.apache.org/manual/latest-2.3.x/developers-guide/index.html)
that we could extend with cloudmonkey commands (
http://karaf.apache.org/manual/latest-2.3.x/developers-guide/extending-console.html)
and rebrand Karaf into a cloudmonkey karaf container.

Regards,

Charles


On Fri, Nov 9, 2012 at 10:53 PM, Musayev, Ilya <im...@webmd.net> wrote:

> I guess mine got wiped somehow...
>
> -----Original Message-----
> From: Musayev, Ilya [mailto:imusayev@webmd.net]
> Sent: Friday, November 09, 2012 4:51 PM
> To: cloudstack-dev@incubator.apache.org
> Subject: RE: CLI for CloudStack: cloudmonkey
>
> Rohit
>
> History seems to retain only last session and not previous - is this by
> design?
>
> Thanks
> ilya
>
> -----Original Message-----
> From: sebgoa [mailto:runseb@gmail.com]
> Sent: Friday, November 09, 2012 4:52 AM
> To: cloudstack-dev@incubator.apache.org
> Subject: Re: CLI for CloudStack: cloudmonkey
>
> Using lower case commands solved the issue
>
> thanks, and happy Diwali
>
> -Sebastien
>
> On Nov 8, 2012, at 8:14 PM, Rohit Yadav wrote:
>
> > Oh, forgot to see that. Yes, now all the cmds are lowercase (except for
> few params liks isAsync=) and tab completion is advised.
> >
> > Regards.
> > ________________________________________
> > From: Kishan Kavala [Kishan.Kavala@citrix.com]
> > Sent: Thursday, November 08, 2012 11:29 PM
> > To: cloudstack-dev@incubator.apache.org
> > Cc: cloudstack-dev@incubator.apache.org
> > Subject: Re: CLI for CloudStack: cloudmonkey
> >
> > Sebastian,
> >  Try set apikey in lower case. Same with set secretkey.
> >
> > ~kishan
> >
> > On 08-Nov-2012, at 10:00 PM, "Sebastien Goasguen" <ru...@gmail.com>
> wrote:
> >
> >> Actually it does not work yet.
> >>
> >> Now I can type 'b' but it does not get passed properly:
> >>
> >> 🙉 cloudmonkey> set apiKey
> >> KEbkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzj
> >> RB9UNrBybVr3kcZ6Q
> >>
> >> Gives:
> >>
> >> INFO  [cloud.api.ApiServer] (92734721@qtp-1601733969-7:) apiKey does
> >> not map to a valid user -- ignoring request, apiKey:
> >> KEkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzjR
> >> B9UNrByVr3kcZ6Q
> >>
> >> On Nov 8, 2012, at 5:19 PM, Sebastien Goasguen <ru...@gmail.com>
> wrote:
> >>
> >>>
> >>> On Nov 8, 2012, at 3:28 PM, Rohit Yadav <ro...@citrix.com>
> wrote:
> >>>
> >>>> Hi Sebastien,
> >>>>
> >>>> Are you using it from pypi/pip, if so do this:
> >>>> sudo pip uninstall cloudmonkey
> >>>> sudo pip install cloudmonkey
> >>>
> >>> no, I am doing: sudo python ./setup.py install from the source tree
> >>>
> >>>> I've had this bug on mac osx, fixed it:
> >>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.git;
> >>>> a=commit;h=36e7a7884efef7c41ac369549b7bdb93e5122110
> >>>
> >>> pulled that and reinstalled…and it works.
> >>>
> >>> thanks
> >>>
> >>> -sebastien
> >>>
> >>>
> >>>> If it still persists for you, checkout
> >>>> http://superuser.com/questions/297527/cant-type-the-b-letter-in-pyt
> >>>> hon-shell-in-os-x
> >>>>
> >>>> Let me know if this still fails then.
> >>>>
> >>>> Regards.
> >>>>
> >>>> ________________________________________
> >>>> From: Sebastien Goasguen [runseb@gmail.com]
> >>>> Sent: Thursday, November 08, 2012 5:37 PM
> >>>> To: cloudstack-dev@incubator.apache.org
> >>>> Subject: Re: CLI for CloudStack: cloudmonkey
> >>>>
> >>>> Hi,
> >>>>
> >>>> I am testing the cli and I have the weirdest issue. When I set the
> apikey or secretkey, the lower case 'b' letter does not print at the prompt.
> >>>> So if my keys contain 'b' they don't work..
> >>>>
> >>>> I tried all the other letters and they work.
> >>>>
> >>>> Anyone seeing this,
> >>>>
> >>>> -Sebastien
> >>>>
> >>>> On Nov 7, 2012, at 7:25 PM, Rohit Yadav <ro...@citrix.com>
> wrote:
> >>>>
> >>>>> yes, I think I'd mentioned in the thread or somewhere. Just use
> >>>>> pip or easy_install (apt-get install python-setuptools on ubuntu,
> >>>>> install python2.6 or above and pip if you don't have it);
> >>>>>
> >>>>> sudo pip install cloudmonkey
> >>>>>
> >>>>> or sudo easy_install cloudmonkey
> >>>>>
> >>>>> now start cloudmonkey:
> >>>>> $ cloudmonkey
> >>>>> ...
> >>>>>
> >>>>> Will post a blog/screencast this weekend and update doc so everyone
> can get help on its usage, though it's pretty intuitive.
> >>>>> ________________________________________
> >>>>> From: Musayev, Ilya [imusayev@webmd.net]
> >>>>> Sent: Wednesday, November 07, 2012 11:41 PM
> >>>>> To: cloudstack-dev@incubator.apache.org
> >>>>> Subject: RE: CLI for CloudStack: cloudmonkey
> >>>>>
> >>>>> Rohit,
> >>>>>
> >>>>> Can I get the CLI only without going through the whole source code
> maven install? Is it part of any RPM?
> >>>>>
> >>>>> Thanks
> >>>>> ilya
> >>>>>
> >>>>> -----Original Message-----
> >>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
> >>>>> Sent: Monday, November 05, 2012 11:35 AM
> >>>>> To: cloudstack-dev@incubator.apache.org
> >>>>> Subject: Re: CLI for CloudStack: cloudmonkey
> >>>>>
> >>>>> Checkout latest code. Few changes to share:
> >>>>>
> >>>>> - All lowercase now
> >>>>> - Tab tab over verbs to see list of params for that api, example
> >>>>> list users <tab><tab>
> >>>>> - This needs improvement but help string, using --help: list user
> >>>>> --help
> >>>>> - Caching to speedup runtime
> >>>>> - Color and Parsing fixes
> >>>>>
> >>>>> Last, I'm now able to get the doc strings for each attribute/param,
> will see this tomorrow.
> >>>>>
> >>>>> Need your help, just incase you want to contribute, these are the
> TODOs:
> >>>>>
> >>>>> - search over history
> >>>>> - fix parsing
> >>>>> - doc strings for parameters
> >>>>> - testing for various kinds of apis (I'm able to deploy a zone
> >>>>> with this, but needs testing)
> >>>>> - unicode char monkey, used in prompt may mess up history
> >>>>> searching and text display
> >>>>>
> >>>>>
> >>>>> Regards.
> >>>>>
> >>>>> On 02-Nov-2012, at 4:58 AM, Edison Su <Ed...@citrix.com> wrote:
> >>>>>
> >>>>>>
> >>>>>>
> >>>>>>> -----Original Message-----
> >>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
> >>>>>>> Sent: Thursday, November 01, 2012 2:23 PM
> >>>>>>> To: cloudstack-dev@incubator.apache.org
> >>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
> >>>>>>>
> >>>>>>> After you install the tool, so that cloudmonkey is in your
> >>>>>>> /usr/local/bin or in $PATH...
> >>>>>>>
> >>>>>>> Two ways;
> >>>>>>> 1. As command line tool, on bash/zsh, use the BNF grammar;
> >>>>>>> <command line tool
> >>>>>>> name>:<separator>:<verb>:<separator>:<action>:<separator>:<param
> >>>>>>> name>s>
> >>>>>>> <command line tool name>={'cloudmonkey'} <separator>={' '}
> >>>>>>> <verb>={'list', 'create', 'delete', 'update'.... etc.}
> >>>>>>> <action>={'Users'... etc.} <params>={'listall=#'... etc.} So; $
> >>>>>>> cloudmonkey list Users
> >>>>>>
> >>>>>>
> >>>>>> Got it, thanks!
> >>>>>>
> >>>>>>>
> >>>>>>> 2. file redirector:
> >>>>>>>
> >>>>>>> $ cat test-file:
> >>>>>>> list Users
> >>>>>>> list <some other action>
> >>>>>>> <some verb> <some action>
> >>>>>>>
> >>>>>>> $ cloudmonkey < test-file
> >>>>>>>
> >>>>>>> Note, I'll change the actions (Users, VirtualMachine etc.) to
> >>>>>>> lowercase (users, virtualmachine etc.) if that's okay?
> >>>>>>
> >>>>>> Please do, nobody wants to type extra keystroke, if it's not
> necessary.
> >>>>>>>
> >>>>>>> Regards.
> >>>>>>>
> >>>>>>> ________________________________________
> >>>>>>> From: Edison Su [Edison.su@citrix.com]
> >>>>>>> Sent: Friday, November 02, 2012 1:55 AM
> >>>>>>> To: cloudstack-dev@incubator.apache.org
> >>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
> >>>>>>>
> >>>>>>> Oh, it reminds me that how to use the CLI on the bash command line?
> >>>>>>> I think admin may want to call cloudstack API in a bash script,
> >>>>>>> how can I do that?
> >>>>>>>
> >>>>>>>> -----Original Message-----
> >>>>>>>> From: Marcus Sorensen [mailto:shadowsor@gmail.com]
> >>>>>>>> Sent: Thursday, November 01, 2012 1:11 PM
> >>>>>>>> To: cloudstack-dev@incubator.apache.org
> >>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
> >>>>>>>>
> >>>>>>>> Yes, I look forward to using it instead of local curl calls on
> >>>>>>>> the command line :-)
> >>>>>>>>
> >>>>>>>> On Thu, Nov 1, 2012 at 2:02 PM, Edison Su <Ed...@citrix.com>
> wrote:
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>> -----Original Message-----
> >>>>>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
> >>>>>>>>>> Sent: Thursday, November 01, 2012 11:45 AM
> >>>>>>>>>> To: cloudstack-dev@incubator.apache.org
> >>>>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
> >>>>>>>>>>
> >>>>>>>>>> Hi Chip, please go ahead if we can fix the http/s issue. The
> >>>>>>>>>> connection is based on marvin, I'm sure using CLI we'll find
> >>>>>>>>>> out more bugs and fix anything in marvin thereby help
> >>>>>>>>>> maintain
> >>>>>>>>>> marvin->tests and
> >>>>>>>> CLI.
> >>>>>>>>>> Please hack that up on
> >>>>>>>>>> tools/marvin/marvin/cloudstackConnection.py
> >>>>>>>>>>
> >>>>>>>>>> Edison, yes I'm working on the completedefault, I've figured
> >>>>>>>>>> a solution to the parsing and tabbing issue to show params
> >>>>>>>>>> for any api and added more verbs to the grammar like deploy,
> start etc.
> >>>>>>>>>> In the new approach doc strings and params needed for an api
> >>>>>>>>>> are fetched and cached in the class locally to speed up the
> loading process.
> >>>>>>>>>> Till it gets committed, cloudmonkey (now) will keep telling
> >>>>>>>>>> the user what params they are missing until it gets all the
> required ones.
> >>>>>>>>>
> >>>>>>>>> Great! Thanks for your awesome CLI, people will like it.
> >>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>> One more thing, for people who may not have unicode support
> >>>>>>>>>> the prompt may appear weird and history search (up, down )
> >>>>>>>>>> can mess up the visuals. For example on Mac it appears as a
> >>>>>>>>>> colorful emoji, but I found that it looks weird on other
> >>>>>>>>>> platforms. Will probably remove it, or the user can custom
> >>>>>>>>>> set their prompt, using: set prompt
> >>>>>>>>>> myprompt>
> >>>>>>>>>>
> >>>>>>>>>> Regards.
> >>>>>>>>>> PS. the set command is full of (fun :)  hacks because of
> >>>>>>>>>> funtional/generic programming, it basically can set any
> >>>>>>>>>> attribute on the class, so one can do something like creating
> >>>>>>>>>> something (var, func). For example set ruler # (so instead of
> >>>>>>>>>> - you will have a #
> >>>>>>>>>> separator)
> >>>>>>>>>>
> >>>>>>>>>> ________________________________________
> >>>>>>>>>> From: Chip Childers [chip.childers@sungard.com]
> >>>>>>>>>> Sent: Thursday, November 01, 2012 11:15 PM
> >>>>>>>>>> To: cloudstack-dev@incubator.apache.org
> >>>>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
> >>>>>>>>>>
> >>>>>>>>>> On Wed, Oct 31, 2012 at 2:10 PM, Rohit Yadav
> >>>>>>>>>> <ro...@citrix.com>
> >>>>>>>>>> wrote:
> >>>>>>>>>>> Hi,
> >>>>>>>>>>>
> >>>>>>>>>>> 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:
> >>>>>>>>>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudsta
> >>>>>>>>>>> ck.gi t; a=c
> >>>>>>>>>>> ommit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
> >>>>>>>>>>>
> >>>>>>>>>>> Features:
> >>>>>>>>>>> - 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
> >>>>>>>>>>>
> >>>>>>>>>>> FIXMEs:
> >>>>>>>>>>> - 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 python cloudmonkey.py
> >>>>>>>>>>>
> >>>>>>>>>>> If you want to have the terminal tool installed; cd
> >>>>>>>>>>> tools/cli python setup.py 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=8.8.8.8 internaldns1=10.147.28.6
> >>>>>>>>>>> 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
> >>>>>>>>>>> networkofferingid= create Pod zoneid= name=Pod1
> >>>>>>>> gateway=10.147.28.1
> >>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.220
> >>>>>>>>>>> endip=10.147.28.235 create VlanIpRange podid= networkid=
> >>>>>>>>>>> gateway=10.147.28.1
> >>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.236
> >>>>>>>>>>> endip=10.147.28.250 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=http://10.147.28.60 create StoragePool zoneid=
> >>>>>>>>>>> clusterid= name=NFS1
> >>>>>>>>>>> url=nfs://10.147.28.7/export/home/rohit/primary
> >>>>>>>>>>> add SecondaryStorage zoneId=
> >>>>>>>>>>> url=nfs://10.147.28.7/export/home/rohit/secondary
> >>>>>>>>>>> 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.
> >>>>>>>>>>>
> >>>>>>>>>>> Regards.
> >>>>>>>>>>> PS. Marvin the neglected robot and hipster cloudmonkey
> >>>>>>>>>>> should rule the world :D
> >>>>>>>>>>
> >>>>>>>>>> Rohit,
> >>>>>>>>>>
> >>>>>>>>>> This is really really cool.  It puts the "fun" in managing
> >>>>>>>>>> instances from a command line.  I've been testing it against
> >>>>>>>>>> a production CloudStack environment, and it's working pretty
> well.
> >>>>>>>>>>
> >>>>>>>>>> If you don't mind, I might hack at the code a bit to fill in
> >>>>>>>>>> some gaps that I'm seeing.  First example is that it assumes
> >>>>>>>>>> http, which doesn't work in a public deployment where the
> endpoint is over https.
> >>>>>>>>>>
> >>>>>>>>>> -chip
> >>
>
>
>


-- 
Charles Moulliard
Apache Committer / Sr. Enterprise Architect (RedHat)
Twitter : @cmoulliard | Blog : http://cmoulliard.blogspot.com

RE: CLI for CloudStack: cloudmonkey

Posted by "Musayev, Ilya" <im...@webmd.net>.
I guess mine got wiped somehow...

-----Original Message-----
From: Musayev, Ilya [mailto:imusayev@webmd.net] 
Sent: Friday, November 09, 2012 4:51 PM
To: cloudstack-dev@incubator.apache.org
Subject: RE: CLI for CloudStack: cloudmonkey

Rohit

History seems to retain only last session and not previous - is this by design?

Thanks
ilya

-----Original Message-----
From: sebgoa [mailto:runseb@gmail.com]
Sent: Friday, November 09, 2012 4:52 AM
To: cloudstack-dev@incubator.apache.org
Subject: Re: CLI for CloudStack: cloudmonkey

Using lower case commands solved the issue

thanks, and happy Diwali

-Sebastien

On Nov 8, 2012, at 8:14 PM, Rohit Yadav wrote:

> Oh, forgot to see that. Yes, now all the cmds are lowercase (except for few params liks isAsync=) and tab completion is advised.
> 
> Regards.
> ________________________________________
> From: Kishan Kavala [Kishan.Kavala@citrix.com]
> Sent: Thursday, November 08, 2012 11:29 PM
> To: cloudstack-dev@incubator.apache.org
> Cc: cloudstack-dev@incubator.apache.org
> Subject: Re: CLI for CloudStack: cloudmonkey
> 
> Sebastian,
>  Try set apikey in lower case. Same with set secretkey.
> 
> ~kishan
> 
> On 08-Nov-2012, at 10:00 PM, "Sebastien Goasguen" <ru...@gmail.com> wrote:
> 
>> Actually it does not work yet.
>> 
>> Now I can type 'b' but it does not get passed properly:
>> 
>> 🙉 cloudmonkey> set apiKey
>> KEbkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzj
>> RB9UNrBybVr3kcZ6Q
>> 
>> Gives:
>> 
>> INFO  [cloud.api.ApiServer] (92734721@qtp-1601733969-7:) apiKey does 
>> not map to a valid user -- ignoring request, apiKey:
>> KEkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzjR
>> B9UNrByVr3kcZ6Q
>> 
>> On Nov 8, 2012, at 5:19 PM, Sebastien Goasguen <ru...@gmail.com> wrote:
>> 
>>> 
>>> On Nov 8, 2012, at 3:28 PM, Rohit Yadav <ro...@citrix.com> wrote:
>>> 
>>>> Hi Sebastien,
>>>> 
>>>> Are you using it from pypi/pip, if so do this:
>>>> sudo pip uninstall cloudmonkey
>>>> sudo pip install cloudmonkey
>>> 
>>> no, I am doing: sudo python ./setup.py install from the source tree
>>> 
>>>> I've had this bug on mac osx, fixed it:
>>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.git;
>>>> a=commit;h=36e7a7884efef7c41ac369549b7bdb93e5122110
>>> 
>>> pulled that and reinstalled…and it works.
>>> 
>>> thanks
>>> 
>>> -sebastien
>>> 
>>> 
>>>> If it still persists for you, checkout 
>>>> http://superuser.com/questions/297527/cant-type-the-b-letter-in-pyt
>>>> hon-shell-in-os-x
>>>> 
>>>> Let me know if this still fails then.
>>>> 
>>>> Regards.
>>>> 
>>>> ________________________________________
>>>> From: Sebastien Goasguen [runseb@gmail.com]
>>>> Sent: Thursday, November 08, 2012 5:37 PM
>>>> To: cloudstack-dev@incubator.apache.org
>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>> 
>>>> Hi,
>>>> 
>>>> I am testing the cli and I have the weirdest issue. When I set the apikey or secretkey, the lower case 'b' letter does not print at the prompt.
>>>> So if my keys contain 'b' they don't work..
>>>> 
>>>> I tried all the other letters and they work.
>>>> 
>>>> Anyone seeing this,
>>>> 
>>>> -Sebastien
>>>> 
>>>> On Nov 7, 2012, at 7:25 PM, Rohit Yadav <ro...@citrix.com> wrote:
>>>> 
>>>>> yes, I think I'd mentioned in the thread or somewhere. Just use 
>>>>> pip or easy_install (apt-get install python-setuptools on ubuntu, 
>>>>> install python2.6 or above and pip if you don't have it);
>>>>> 
>>>>> sudo pip install cloudmonkey
>>>>> 
>>>>> or sudo easy_install cloudmonkey
>>>>> 
>>>>> now start cloudmonkey:
>>>>> $ cloudmonkey
>>>>> ...
>>>>> 
>>>>> Will post a blog/screencast this weekend and update doc so everyone can get help on its usage, though it's pretty intuitive.
>>>>> ________________________________________
>>>>> From: Musayev, Ilya [imusayev@webmd.net]
>>>>> Sent: Wednesday, November 07, 2012 11:41 PM
>>>>> To: cloudstack-dev@incubator.apache.org
>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>> 
>>>>> Rohit,
>>>>> 
>>>>> Can I get the CLI only without going through the whole source code maven install? Is it part of any RPM?
>>>>> 
>>>>> Thanks
>>>>> ilya
>>>>> 
>>>>> -----Original Message-----
>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>> Sent: Monday, November 05, 2012 11:35 AM
>>>>> To: cloudstack-dev@incubator.apache.org
>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>> 
>>>>> Checkout latest code. Few changes to share:
>>>>> 
>>>>> - All lowercase now
>>>>> - Tab tab over verbs to see list of params for that api, example 
>>>>> list users <tab><tab>
>>>>> - This needs improvement but help string, using --help: list user 
>>>>> --help
>>>>> - Caching to speedup runtime
>>>>> - Color and Parsing fixes
>>>>> 
>>>>> Last, I'm now able to get the doc strings for each attribute/param, will see this tomorrow.
>>>>> 
>>>>> Need your help, just incase you want to contribute, these are the TODOs:
>>>>> 
>>>>> - search over history
>>>>> - fix parsing
>>>>> - doc strings for parameters
>>>>> - testing for various kinds of apis (I'm able to deploy a zone 
>>>>> with this, but needs testing)
>>>>> - unicode char monkey, used in prompt may mess up history 
>>>>> searching and text display
>>>>> 
>>>>> 
>>>>> Regards.
>>>>> 
>>>>> On 02-Nov-2012, at 4:58 AM, Edison Su <Ed...@citrix.com> wrote:
>>>>> 
>>>>>> 
>>>>>> 
>>>>>>> -----Original Message-----
>>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>>> Sent: Thursday, November 01, 2012 2:23 PM
>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>> 
>>>>>>> After you install the tool, so that cloudmonkey is in your 
>>>>>>> /usr/local/bin or in $PATH...
>>>>>>> 
>>>>>>> Two ways;
>>>>>>> 1. As command line tool, on bash/zsh, use the BNF grammar; 
>>>>>>> <command line tool
>>>>>>> name>:<separator>:<verb>:<separator>:<action>:<separator>:<param
>>>>>>> name>s>
>>>>>>> <command line tool name>={'cloudmonkey'} <separator>={' '} 
>>>>>>> <verb>={'list', 'create', 'delete', 'update'.... etc.} 
>>>>>>> <action>={'Users'... etc.} <params>={'listall=#'... etc.} So; $ 
>>>>>>> cloudmonkey list Users
>>>>>> 
>>>>>> 
>>>>>> Got it, thanks!
>>>>>> 
>>>>>>> 
>>>>>>> 2. file redirector:
>>>>>>> 
>>>>>>> $ cat test-file:
>>>>>>> list Users
>>>>>>> list <some other action>
>>>>>>> <some verb> <some action>
>>>>>>> 
>>>>>>> $ cloudmonkey < test-file
>>>>>>> 
>>>>>>> Note, I'll change the actions (Users, VirtualMachine etc.) to 
>>>>>>> lowercase (users, virtualmachine etc.) if that's okay?
>>>>>> 
>>>>>> Please do, nobody wants to type extra keystroke, if it's not necessary.
>>>>>>> 
>>>>>>> Regards.
>>>>>>> 
>>>>>>> ________________________________________
>>>>>>> From: Edison Su [Edison.su@citrix.com]
>>>>>>> Sent: Friday, November 02, 2012 1:55 AM
>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>> 
>>>>>>> Oh, it reminds me that how to use the CLI on the bash command line?
>>>>>>> I think admin may want to call cloudstack API in a bash script, 
>>>>>>> how can I do that?
>>>>>>> 
>>>>>>>> -----Original Message-----
>>>>>>>> From: Marcus Sorensen [mailto:shadowsor@gmail.com]
>>>>>>>> Sent: Thursday, November 01, 2012 1:11 PM
>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>> 
>>>>>>>> Yes, I look forward to using it instead of local curl calls on 
>>>>>>>> the command line :-)
>>>>>>>> 
>>>>>>>> On Thu, Nov 1, 2012 at 2:02 PM, Edison Su <Ed...@citrix.com> wrote:
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>>> -----Original Message-----
>>>>>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>>>>>> Sent: Thursday, November 01, 2012 11:45 AM
>>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>>>>> 
>>>>>>>>>> Hi Chip, please go ahead if we can fix the http/s issue. The 
>>>>>>>>>> connection is based on marvin, I'm sure using CLI we'll find 
>>>>>>>>>> out more bugs and fix anything in marvin thereby help 
>>>>>>>>>> maintain
>>>>>>>>>> marvin->tests and
>>>>>>>> CLI.
>>>>>>>>>> Please hack that up on
>>>>>>>>>> tools/marvin/marvin/cloudstackConnection.py
>>>>>>>>>> 
>>>>>>>>>> Edison, yes I'm working on the completedefault, I've figured 
>>>>>>>>>> a solution to the parsing and tabbing issue to show params 
>>>>>>>>>> for any api and added more verbs to the grammar like deploy, start etc.
>>>>>>>>>> In the new approach doc strings and params needed for an api 
>>>>>>>>>> are fetched and cached in the class locally to speed up the loading process.
>>>>>>>>>> Till it gets committed, cloudmonkey (now) will keep telling 
>>>>>>>>>> the user what params they are missing until it gets all the required ones.
>>>>>>>>> 
>>>>>>>>> Great! Thanks for your awesome CLI, people will like it.
>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> One more thing, for people who may not have unicode support 
>>>>>>>>>> the prompt may appear weird and history search (up, down ) 
>>>>>>>>>> can mess up the visuals. For example on Mac it appears as a 
>>>>>>>>>> colorful emoji, but I found that it looks weird on other 
>>>>>>>>>> platforms. Will probably remove it, or the user can custom 
>>>>>>>>>> set their prompt, using: set prompt
>>>>>>>>>> myprompt>
>>>>>>>>>> 
>>>>>>>>>> Regards.
>>>>>>>>>> PS. the set command is full of (fun :)  hacks because of 
>>>>>>>>>> funtional/generic programming, it basically can set any 
>>>>>>>>>> attribute on the class, so one can do something like creating 
>>>>>>>>>> something (var, func). For example set ruler # (so instead of
>>>>>>>>>> - you will have a #
>>>>>>>>>> separator)
>>>>>>>>>> 
>>>>>>>>>> ________________________________________
>>>>>>>>>> From: Chip Childers [chip.childers@sungard.com]
>>>>>>>>>> Sent: Thursday, November 01, 2012 11:15 PM
>>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>>>> 
>>>>>>>>>> On Wed, Oct 31, 2012 at 2:10 PM, Rohit Yadav 
>>>>>>>>>> <ro...@citrix.com>
>>>>>>>>>> wrote:
>>>>>>>>>>> Hi,
>>>>>>>>>>> 
>>>>>>>>>>> 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:
>>>>>>>>>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudsta
>>>>>>>>>>> ck.gi t; a=c
>>>>>>>>>>> ommit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
>>>>>>>>>>> 
>>>>>>>>>>> Features:
>>>>>>>>>>> - 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
>>>>>>>>>>> 
>>>>>>>>>>> FIXMEs:
>>>>>>>>>>> - 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 python cloudmonkey.py
>>>>>>>>>>> 
>>>>>>>>>>> If you want to have the terminal tool installed; cd 
>>>>>>>>>>> tools/cli python setup.py 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=8.8.8.8 internaldns1=10.147.28.6
>>>>>>>>>>> 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
>>>>>>>>>>> networkofferingid= create Pod zoneid= name=Pod1
>>>>>>>> gateway=10.147.28.1
>>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.220
>>>>>>>>>>> endip=10.147.28.235 create VlanIpRange podid= networkid=
>>>>>>>>>>> gateway=10.147.28.1
>>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.236
>>>>>>>>>>> endip=10.147.28.250 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=http://10.147.28.60 create StoragePool zoneid= 
>>>>>>>>>>> clusterid= name=NFS1 
>>>>>>>>>>> url=nfs://10.147.28.7/export/home/rohit/primary
>>>>>>>>>>> add SecondaryStorage zoneId= 
>>>>>>>>>>> url=nfs://10.147.28.7/export/home/rohit/secondary
>>>>>>>>>>> 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.
>>>>>>>>>>> 
>>>>>>>>>>> Regards.
>>>>>>>>>>> PS. Marvin the neglected robot and hipster cloudmonkey 
>>>>>>>>>>> should rule the world :D
>>>>>>>>>> 
>>>>>>>>>> Rohit,
>>>>>>>>>> 
>>>>>>>>>> This is really really cool.  It puts the "fun" in managing 
>>>>>>>>>> instances from a command line.  I've been testing it against 
>>>>>>>>>> a production CloudStack environment, and it's working pretty well.
>>>>>>>>>> 
>>>>>>>>>> If you don't mind, I might hack at the code a bit to fill in 
>>>>>>>>>> some gaps that I'm seeing.  First example is that it assumes 
>>>>>>>>>> http, which doesn't work in a public deployment where the endpoint is over https.
>>>>>>>>>> 
>>>>>>>>>> -chip
>> 



RE: CLI for CloudStack: cloudmonkey

Posted by "Musayev, Ilya" <im...@webmd.net>.
Rohit

History seems to retain only last session and not previous - is this by design?

Thanks
ilya

-----Original Message-----
From: sebgoa [mailto:runseb@gmail.com] 
Sent: Friday, November 09, 2012 4:52 AM
To: cloudstack-dev@incubator.apache.org
Subject: Re: CLI for CloudStack: cloudmonkey

Using lower case commands solved the issue

thanks, and happy Diwali

-Sebastien

On Nov 8, 2012, at 8:14 PM, Rohit Yadav wrote:

> Oh, forgot to see that. Yes, now all the cmds are lowercase (except for few params liks isAsync=) and tab completion is advised.
> 
> Regards.
> ________________________________________
> From: Kishan Kavala [Kishan.Kavala@citrix.com]
> Sent: Thursday, November 08, 2012 11:29 PM
> To: cloudstack-dev@incubator.apache.org
> Cc: cloudstack-dev@incubator.apache.org
> Subject: Re: CLI for CloudStack: cloudmonkey
> 
> Sebastian,
>  Try set apikey in lower case. Same with set secretkey.
> 
> ~kishan
> 
> On 08-Nov-2012, at 10:00 PM, "Sebastien Goasguen" <ru...@gmail.com> wrote:
> 
>> Actually it does not work yet.
>> 
>> Now I can type 'b' but it does not get passed properly:
>> 
>> 🙉 cloudmonkey> set apiKey 
>> KEbkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzj
>> RB9UNrBybVr3kcZ6Q
>> 
>> Gives:
>> 
>> INFO  [cloud.api.ApiServer] (92734721@qtp-1601733969-7:) apiKey does 
>> not map to a valid user -- ignoring request, apiKey: 
>> KEkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzjR
>> B9UNrByVr3kcZ6Q
>> 
>> On Nov 8, 2012, at 5:19 PM, Sebastien Goasguen <ru...@gmail.com> wrote:
>> 
>>> 
>>> On Nov 8, 2012, at 3:28 PM, Rohit Yadav <ro...@citrix.com> wrote:
>>> 
>>>> Hi Sebastien,
>>>> 
>>>> Are you using it from pypi/pip, if so do this:
>>>> sudo pip uninstall cloudmonkey
>>>> sudo pip install cloudmonkey
>>> 
>>> no, I am doing: sudo python ./setup.py install from the source tree
>>> 
>>>> I've had this bug on mac osx, fixed it:
>>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.git;
>>>> a=commit;h=36e7a7884efef7c41ac369549b7bdb93e5122110
>>> 
>>> pulled that and reinstalled…and it works.
>>> 
>>> thanks
>>> 
>>> -sebastien
>>> 
>>> 
>>>> If it still persists for you, checkout  
>>>> http://superuser.com/questions/297527/cant-type-the-b-letter-in-pyt
>>>> hon-shell-in-os-x
>>>> 
>>>> Let me know if this still fails then.
>>>> 
>>>> Regards.
>>>> 
>>>> ________________________________________
>>>> From: Sebastien Goasguen [runseb@gmail.com]
>>>> Sent: Thursday, November 08, 2012 5:37 PM
>>>> To: cloudstack-dev@incubator.apache.org
>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>> 
>>>> Hi,
>>>> 
>>>> I am testing the cli and I have the weirdest issue. When I set the apikey or secretkey, the lower case 'b' letter does not print at the prompt.
>>>> So if my keys contain 'b' they don't work..
>>>> 
>>>> I tried all the other letters and they work.
>>>> 
>>>> Anyone seeing this,
>>>> 
>>>> -Sebastien
>>>> 
>>>> On Nov 7, 2012, at 7:25 PM, Rohit Yadav <ro...@citrix.com> wrote:
>>>> 
>>>>> yes, I think I'd mentioned in the thread or somewhere. Just use 
>>>>> pip or easy_install (apt-get install python-setuptools on ubuntu, 
>>>>> install python2.6 or above and pip if you don't have it);
>>>>> 
>>>>> sudo pip install cloudmonkey
>>>>> 
>>>>> or sudo easy_install cloudmonkey
>>>>> 
>>>>> now start cloudmonkey:
>>>>> $ cloudmonkey
>>>>> ...
>>>>> 
>>>>> Will post a blog/screencast this weekend and update doc so everyone can get help on its usage, though it's pretty intuitive.
>>>>> ________________________________________
>>>>> From: Musayev, Ilya [imusayev@webmd.net]
>>>>> Sent: Wednesday, November 07, 2012 11:41 PM
>>>>> To: cloudstack-dev@incubator.apache.org
>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>> 
>>>>> Rohit,
>>>>> 
>>>>> Can I get the CLI only without going through the whole source code maven install? Is it part of any RPM?
>>>>> 
>>>>> Thanks
>>>>> ilya
>>>>> 
>>>>> -----Original Message-----
>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>> Sent: Monday, November 05, 2012 11:35 AM
>>>>> To: cloudstack-dev@incubator.apache.org
>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>> 
>>>>> Checkout latest code. Few changes to share:
>>>>> 
>>>>> - All lowercase now
>>>>> - Tab tab over verbs to see list of params for that api, example 
>>>>> list users <tab><tab>
>>>>> - This needs improvement but help string, using --help: list user 
>>>>> --help
>>>>> - Caching to speedup runtime
>>>>> - Color and Parsing fixes
>>>>> 
>>>>> Last, I'm now able to get the doc strings for each attribute/param, will see this tomorrow.
>>>>> 
>>>>> Need your help, just incase you want to contribute, these are the TODOs:
>>>>> 
>>>>> - search over history
>>>>> - fix parsing
>>>>> - doc strings for parameters
>>>>> - testing for various kinds of apis (I'm able to deploy a zone 
>>>>> with this, but needs testing)
>>>>> - unicode char monkey, used in prompt may mess up history 
>>>>> searching and text display
>>>>> 
>>>>> 
>>>>> Regards.
>>>>> 
>>>>> On 02-Nov-2012, at 4:58 AM, Edison Su <Ed...@citrix.com> wrote:
>>>>> 
>>>>>> 
>>>>>> 
>>>>>>> -----Original Message-----
>>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>>> Sent: Thursday, November 01, 2012 2:23 PM
>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>> 
>>>>>>> After you install the tool, so that cloudmonkey is in your 
>>>>>>> /usr/local/bin or in $PATH...
>>>>>>> 
>>>>>>> Two ways;
>>>>>>> 1. As command line tool, on bash/zsh, use the BNF grammar; 
>>>>>>> <command line tool
>>>>>>> name>:<separator>:<verb>:<separator>:<action>:<separator>:<param
>>>>>>> name>s>
>>>>>>> <command line tool name>={'cloudmonkey'} <separator>={' '} 
>>>>>>> <verb>={'list', 'create', 'delete', 'update'.... etc.} 
>>>>>>> <action>={'Users'... etc.} <params>={'listall=#'... etc.} So; $ 
>>>>>>> cloudmonkey list Users
>>>>>> 
>>>>>> 
>>>>>> Got it, thanks!
>>>>>> 
>>>>>>> 
>>>>>>> 2. file redirector:
>>>>>>> 
>>>>>>> $ cat test-file:
>>>>>>> list Users
>>>>>>> list <some other action>
>>>>>>> <some verb> <some action>
>>>>>>> 
>>>>>>> $ cloudmonkey < test-file
>>>>>>> 
>>>>>>> Note, I'll change the actions (Users, VirtualMachine etc.) to 
>>>>>>> lowercase (users, virtualmachine etc.) if that's okay?
>>>>>> 
>>>>>> Please do, nobody wants to type extra keystroke, if it's not necessary.
>>>>>>> 
>>>>>>> Regards.
>>>>>>> 
>>>>>>> ________________________________________
>>>>>>> From: Edison Su [Edison.su@citrix.com]
>>>>>>> Sent: Friday, November 02, 2012 1:55 AM
>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>> 
>>>>>>> Oh, it reminds me that how to use the CLI on the bash command line?
>>>>>>> I think admin may want to call cloudstack API in a bash script, 
>>>>>>> how can I do that?
>>>>>>> 
>>>>>>>> -----Original Message-----
>>>>>>>> From: Marcus Sorensen [mailto:shadowsor@gmail.com]
>>>>>>>> Sent: Thursday, November 01, 2012 1:11 PM
>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>> 
>>>>>>>> Yes, I look forward to using it instead of local curl calls on 
>>>>>>>> the command line :-)
>>>>>>>> 
>>>>>>>> On Thu, Nov 1, 2012 at 2:02 PM, Edison Su <Ed...@citrix.com> wrote:
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>>> -----Original Message-----
>>>>>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>>>>>> Sent: Thursday, November 01, 2012 11:45 AM
>>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>>>>> 
>>>>>>>>>> Hi Chip, please go ahead if we can fix the http/s issue. The 
>>>>>>>>>> connection is based on marvin, I'm sure using CLI we'll find 
>>>>>>>>>> out more bugs and fix anything in marvin thereby help 
>>>>>>>>>> maintain
>>>>>>>>>> marvin->tests and
>>>>>>>> CLI.
>>>>>>>>>> Please hack that up on 
>>>>>>>>>> tools/marvin/marvin/cloudstackConnection.py
>>>>>>>>>> 
>>>>>>>>>> Edison, yes I'm working on the completedefault, I've figured 
>>>>>>>>>> a solution to the parsing and tabbing issue to show params 
>>>>>>>>>> for any api and added more verbs to the grammar like deploy, start etc.
>>>>>>>>>> In the new approach doc strings and params needed for an api 
>>>>>>>>>> are fetched and cached in the class locally to speed up the loading process.
>>>>>>>>>> Till it gets committed, cloudmonkey (now) will keep telling 
>>>>>>>>>> the user what params they are missing until it gets all the required ones.
>>>>>>>>> 
>>>>>>>>> Great! Thanks for your awesome CLI, people will like it.
>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> One more thing, for people who may not have unicode support 
>>>>>>>>>> the prompt may appear weird and history search (up, down ) 
>>>>>>>>>> can mess up the visuals. For example on Mac it appears as a 
>>>>>>>>>> colorful emoji, but I found that it looks weird on other 
>>>>>>>>>> platforms. Will probably remove it, or the user can custom 
>>>>>>>>>> set their prompt, using: set prompt
>>>>>>>>>> myprompt>
>>>>>>>>>> 
>>>>>>>>>> Regards.
>>>>>>>>>> PS. the set command is full of (fun :)  hacks because of 
>>>>>>>>>> funtional/generic programming, it basically can set any 
>>>>>>>>>> attribute on the class, so one can do something like creating 
>>>>>>>>>> something (var, func). For example set ruler # (so instead of 
>>>>>>>>>> - you will have a #
>>>>>>>>>> separator)
>>>>>>>>>> 
>>>>>>>>>> ________________________________________
>>>>>>>>>> From: Chip Childers [chip.childers@sungard.com]
>>>>>>>>>> Sent: Thursday, November 01, 2012 11:15 PM
>>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>>>> 
>>>>>>>>>> On Wed, Oct 31, 2012 at 2:10 PM, Rohit Yadav 
>>>>>>>>>> <ro...@citrix.com>
>>>>>>>>>> wrote:
>>>>>>>>>>> Hi,
>>>>>>>>>>> 
>>>>>>>>>>> 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:
>>>>>>>>>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudsta
>>>>>>>>>>> ck.gi t; a=c 
>>>>>>>>>>> ommit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
>>>>>>>>>>> 
>>>>>>>>>>> Features:
>>>>>>>>>>> - 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
>>>>>>>>>>> 
>>>>>>>>>>> FIXMEs:
>>>>>>>>>>> - 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 python cloudmonkey.py
>>>>>>>>>>> 
>>>>>>>>>>> If you want to have the terminal tool installed; cd 
>>>>>>>>>>> tools/cli python setup.py 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=8.8.8.8 internaldns1=10.147.28.6
>>>>>>>>>>> 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
>>>>>>>>>>> networkofferingid= create Pod zoneid= name=Pod1
>>>>>>>> gateway=10.147.28.1
>>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.220 
>>>>>>>>>>> endip=10.147.28.235 create VlanIpRange podid= networkid= 
>>>>>>>>>>> gateway=10.147.28.1
>>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.236 
>>>>>>>>>>> endip=10.147.28.250 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=http://10.147.28.60 create StoragePool zoneid= 
>>>>>>>>>>> clusterid= name=NFS1 
>>>>>>>>>>> url=nfs://10.147.28.7/export/home/rohit/primary
>>>>>>>>>>> add SecondaryStorage zoneId= 
>>>>>>>>>>> url=nfs://10.147.28.7/export/home/rohit/secondary
>>>>>>>>>>> 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.
>>>>>>>>>>> 
>>>>>>>>>>> Regards.
>>>>>>>>>>> PS. Marvin the neglected robot and hipster cloudmonkey 
>>>>>>>>>>> should rule the world :D
>>>>>>>>>> 
>>>>>>>>>> Rohit,
>>>>>>>>>> 
>>>>>>>>>> This is really really cool.  It puts the "fun" in managing 
>>>>>>>>>> instances from a command line.  I've been testing it against 
>>>>>>>>>> a production CloudStack environment, and it's working pretty well.
>>>>>>>>>> 
>>>>>>>>>> If you don't mind, I might hack at the code a bit to fill in 
>>>>>>>>>> some gaps that I'm seeing.  First example is that it assumes 
>>>>>>>>>> http, which doesn't work in a public deployment where the endpoint is over https.
>>>>>>>>>> 
>>>>>>>>>> -chip
>> 



RE: CLI for CloudStack: cloudmonkey

Posted by Rohit Yadav <ro...@citrix.com>.
Sebastien, I check the code again now in case there is a HTTP error it won't break and the error is logged in ~/.cloudmonkey_log but we need to show this to user which we can fix in marvin.

Thanks,
Rohit
________________________________________
From: sebgoa [runseb@gmail.com]
Sent: Friday, November 09, 2012 3:21 PM
To: cloudstack-dev@incubator.apache.org
Subject: Re: CLI for CloudStack: cloudmonkey

Using lower case commands solved the issue

thanks, and happy Diwali

-Sebastien

On Nov 8, 2012, at 8:14 PM, Rohit Yadav wrote:

> Oh, forgot to see that. Yes, now all the cmds are lowercase (except for few params liks isAsync=) and tab completion is advised.
>
> Regards.
> ________________________________________
> From: Kishan Kavala [Kishan.Kavala@citrix.com]
> Sent: Thursday, November 08, 2012 11:29 PM
> To: cloudstack-dev@incubator.apache.org
> Cc: cloudstack-dev@incubator.apache.org
> Subject: Re: CLI for CloudStack: cloudmonkey
>
> Sebastian,
>  Try set apikey in lower case. Same with set secretkey.
>
> ~kishan
>
> On 08-Nov-2012, at 10:00 PM, "Sebastien Goasguen" <ru...@gmail.com> wrote:
>
>> Actually it does not work yet.
>>
>> Now I can type 'b' but it does not get passed properly:
>>
>> 🙉 cloudmonkey> set apiKey KEbkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzjRB9UNrBybVr3kcZ6Q
>>
>> Gives:
>>
>> INFO  [cloud.api.ApiServer] (92734721@qtp-1601733969-7:) apiKey does not map to a valid user -- ignoring request, apiKey: KEkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzjRB9UNrByVr3kcZ6Q
>>
>> On Nov 8, 2012, at 5:19 PM, Sebastien Goasguen <ru...@gmail.com> wrote:
>>
>>>
>>> On Nov 8, 2012, at 3:28 PM, Rohit Yadav <ro...@citrix.com> wrote:
>>>
>>>> Hi Sebastien,
>>>>
>>>> Are you using it from pypi/pip, if so do this:
>>>> sudo pip uninstall cloudmonkey
>>>> sudo pip install cloudmonkey
>>>
>>> no, I am doing: sudo python ./setup.py install from the source tree
>>>
>>>> I've had this bug on mac osx, fixed it:
>>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.git;a=commit;h=36e7a7884efef7c41ac369549b7bdb93e5122110
>>>
>>> pulled that and reinstalled…and it works.
>>>
>>> thanks
>>>
>>> -sebastien
>>>
>>>
>>>> If it still persists for you, checkout  http://superuser.com/questions/297527/cant-type-the-b-letter-in-python-shell-in-os-x
>>>>
>>>> Let me know if this still fails then.
>>>>
>>>> Regards.
>>>>
>>>> ________________________________________
>>>> From: Sebastien Goasguen [runseb@gmail.com]
>>>> Sent: Thursday, November 08, 2012 5:37 PM
>>>> To: cloudstack-dev@incubator.apache.org
>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>
>>>> Hi,
>>>>
>>>> I am testing the cli and I have the weirdest issue. When I set the apikey or secretkey, the lower case 'b' letter does not print at the prompt.
>>>> So if my keys contain 'b' they don't work..
>>>>
>>>> I tried all the other letters and they work.
>>>>
>>>> Anyone seeing this,
>>>>
>>>> -Sebastien
>>>>
>>>> On Nov 7, 2012, at 7:25 PM, Rohit Yadav <ro...@citrix.com> wrote:
>>>>
>>>>> yes, I think I'd mentioned in the thread or somewhere. Just use pip or easy_install (apt-get install python-setuptools on ubuntu, install python2.6 or above and pip if you don't have it);
>>>>>
>>>>> sudo pip install cloudmonkey
>>>>>
>>>>> or sudo easy_install cloudmonkey
>>>>>
>>>>> now start cloudmonkey:
>>>>> $ cloudmonkey
>>>>> ...
>>>>>
>>>>> Will post a blog/screencast this weekend and update doc so everyone can get help on its usage, though it's pretty intuitive.
>>>>> ________________________________________
>>>>> From: Musayev, Ilya [imusayev@webmd.net]
>>>>> Sent: Wednesday, November 07, 2012 11:41 PM
>>>>> To: cloudstack-dev@incubator.apache.org
>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>
>>>>> Rohit,
>>>>>
>>>>> Can I get the CLI only without going through the whole source code maven install? Is it part of any RPM?
>>>>>
>>>>> Thanks
>>>>> ilya
>>>>>
>>>>> -----Original Message-----
>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>> Sent: Monday, November 05, 2012 11:35 AM
>>>>> To: cloudstack-dev@incubator.apache.org
>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>
>>>>> Checkout latest code. Few changes to share:
>>>>>
>>>>> - All lowercase now
>>>>> - Tab tab over verbs to see list of params for that api, example list users <tab><tab>
>>>>> - This needs improvement but help string, using --help: list user --help
>>>>> - Caching to speedup runtime
>>>>> - Color and Parsing fixes
>>>>>
>>>>> Last, I'm now able to get the doc strings for each attribute/param, will see this tomorrow.
>>>>>
>>>>> Need your help, just incase you want to contribute, these are the TODOs:
>>>>>
>>>>> - search over history
>>>>> - fix parsing
>>>>> - doc strings for parameters
>>>>> - testing for various kinds of apis (I'm able to deploy a zone with this, but needs testing)
>>>>> - unicode char monkey, used in prompt may mess up history searching and text display
>>>>>
>>>>>
>>>>> Regards.
>>>>>
>>>>> On 02-Nov-2012, at 4:58 AM, Edison Su <Ed...@citrix.com> wrote:
>>>>>
>>>>>>
>>>>>>
>>>>>>> -----Original Message-----
>>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>>> Sent: Thursday, November 01, 2012 2:23 PM
>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>>
>>>>>>> After you install the tool, so that cloudmonkey is in your
>>>>>>> /usr/local/bin or in $PATH...
>>>>>>>
>>>>>>> Two ways;
>>>>>>> 1. As command line tool, on bash/zsh, use the BNF grammar; <command
>>>>>>> line tool
>>>>>>> name>:<separator>:<verb>:<separator>:<action>:<separator>:<params>
>>>>>>> <command line tool name>={'cloudmonkey'} <separator>={' '}
>>>>>>> <verb>={'list', 'create', 'delete', 'update'.... etc.}
>>>>>>> <action>={'Users'... etc.} <params>={'listall=#'... etc.} So; $
>>>>>>> cloudmonkey list Users
>>>>>>
>>>>>>
>>>>>> Got it, thanks!
>>>>>>
>>>>>>>
>>>>>>> 2. file redirector:
>>>>>>>
>>>>>>> $ cat test-file:
>>>>>>> list Users
>>>>>>> list <some other action>
>>>>>>> <some verb> <some action>
>>>>>>>
>>>>>>> $ cloudmonkey < test-file
>>>>>>>
>>>>>>> Note, I'll change the actions (Users, VirtualMachine etc.) to
>>>>>>> lowercase (users, virtualmachine etc.) if that's okay?
>>>>>>
>>>>>> Please do, nobody wants to type extra keystroke, if it's not necessary.
>>>>>>>
>>>>>>> Regards.
>>>>>>>
>>>>>>> ________________________________________
>>>>>>> From: Edison Su [Edison.su@citrix.com]
>>>>>>> Sent: Friday, November 02, 2012 1:55 AM
>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>>
>>>>>>> Oh, it reminds me that how to use the CLI on the bash command line?
>>>>>>> I think admin may want to call cloudstack API in a bash script, how
>>>>>>> can I do that?
>>>>>>>
>>>>>>>> -----Original Message-----
>>>>>>>> From: Marcus Sorensen [mailto:shadowsor@gmail.com]
>>>>>>>> Sent: Thursday, November 01, 2012 1:11 PM
>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>>
>>>>>>>> Yes, I look forward to using it instead of local curl calls on the
>>>>>>>> command line :-)
>>>>>>>>
>>>>>>>> On Thu, Nov 1, 2012 at 2:02 PM, Edison Su <Ed...@citrix.com> wrote:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> -----Original Message-----
>>>>>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>>>>>> Sent: Thursday, November 01, 2012 11:45 AM
>>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>>>>>
>>>>>>>>>> Hi Chip, please go ahead if we can fix the http/s issue. The
>>>>>>>>>> connection is based on marvin, I'm sure using CLI we'll find out
>>>>>>>>>> more bugs and fix anything in marvin thereby help maintain
>>>>>>>>>> marvin->tests and
>>>>>>>> CLI.
>>>>>>>>>> Please hack that up on tools/marvin/marvin/cloudstackConnection.py
>>>>>>>>>>
>>>>>>>>>> Edison, yes I'm working on the completedefault, I've figured a
>>>>>>>>>> solution to the parsing and tabbing issue to show params for any
>>>>>>>>>> api and added more verbs to the grammar like deploy, start etc.
>>>>>>>>>> In the new approach doc strings and params needed for an api are
>>>>>>>>>> fetched and cached in the class locally to speed up the loading process.
>>>>>>>>>> Till it gets committed, cloudmonkey (now) will keep telling the
>>>>>>>>>> user what params they are missing until it gets all the required ones.
>>>>>>>>>
>>>>>>>>> Great! Thanks for your awesome CLI, people will like it.
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> One more thing, for people who may not have unicode support the
>>>>>>>>>> prompt may appear weird and history search (up, down ) can mess up
>>>>>>>>>> the visuals. For example on Mac it appears as a colorful emoji,
>>>>>>>>>> but I found that it looks weird on other platforms. Will probably
>>>>>>>>>> remove it, or the user can custom set their prompt, using: set
>>>>>>>>>> prompt
>>>>>>>>>> myprompt>
>>>>>>>>>>
>>>>>>>>>> Regards.
>>>>>>>>>> PS. the set command is full of (fun :)  hacks because of
>>>>>>>>>> funtional/generic programming, it basically can set any attribute
>>>>>>>>>> on the class, so one can do something like creating something
>>>>>>>>>> (var, func). For example set ruler # (so instead of - you will
>>>>>>>>>> have a #
>>>>>>>>>> separator)
>>>>>>>>>>
>>>>>>>>>> ________________________________________
>>>>>>>>>> From: Chip Childers [chip.childers@sungard.com]
>>>>>>>>>> Sent: Thursday, November 01, 2012 11:15 PM
>>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>>>>
>>>>>>>>>> On Wed, Oct 31, 2012 at 2:10 PM, Rohit Yadav
>>>>>>>>>> <ro...@citrix.com>
>>>>>>>>>> wrote:
>>>>>>>>>>> Hi,
>>>>>>>>>>>
>>>>>>>>>>> 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:
>>>>>>>>>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.gi
>>>>>>>>>>> t; a=c ommit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
>>>>>>>>>>>
>>>>>>>>>>> Features:
>>>>>>>>>>> - 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
>>>>>>>>>>>
>>>>>>>>>>> FIXMEs:
>>>>>>>>>>> - 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 python
>>>>>>>>>>> cloudmonkey.py
>>>>>>>>>>>
>>>>>>>>>>> If you want to have the terminal tool installed; cd tools/cli
>>>>>>>>>>> python setup.py 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=8.8.8.8 internaldns1=10.147.28.6
>>>>>>>>>>> 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
>>>>>>>>>>> networkofferingid= create Pod zoneid= name=Pod1
>>>>>>>> gateway=10.147.28.1
>>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.220 endip=10.147.28.235
>>>>>>>>>>> create VlanIpRange podid= networkid= gateway=10.147.28.1
>>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.236 endip=10.147.28.250
>>>>>>>>>>> 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=http://10.147.28.60 create
>>>>>>>>>>> StoragePool zoneid= clusterid= name=NFS1
>>>>>>>>>>> url=nfs://10.147.28.7/export/home/rohit/primary
>>>>>>>>>>> add SecondaryStorage zoneId=
>>>>>>>>>>> url=nfs://10.147.28.7/export/home/rohit/secondary
>>>>>>>>>>> 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.
>>>>>>>>>>>
>>>>>>>>>>> Regards.
>>>>>>>>>>> PS. Marvin the neglected robot and hipster cloudmonkey should
>>>>>>>>>>> rule the world :D
>>>>>>>>>>
>>>>>>>>>> Rohit,
>>>>>>>>>>
>>>>>>>>>> This is really really cool.  It puts the "fun" in managing
>>>>>>>>>> instances from a command line.  I've been testing it against a
>>>>>>>>>> production CloudStack environment, and it's working pretty well.
>>>>>>>>>>
>>>>>>>>>> If you don't mind, I might hack at the code a bit to fill in some
>>>>>>>>>> gaps that I'm seeing.  First example is that it assumes http,
>>>>>>>>>> which doesn't work in a public deployment where the endpoint is over https.
>>>>>>>>>>
>>>>>>>>>> -chip
>>


Re: CLI for CloudStack: cloudmonkey

Posted by sebgoa <ru...@gmail.com>.
Using lower case commands solved the issue

thanks, and happy Diwali

-Sebastien

On Nov 8, 2012, at 8:14 PM, Rohit Yadav wrote:

> Oh, forgot to see that. Yes, now all the cmds are lowercase (except for few params liks isAsync=) and tab completion is advised.
> 
> Regards.
> ________________________________________
> From: Kishan Kavala [Kishan.Kavala@citrix.com]
> Sent: Thursday, November 08, 2012 11:29 PM
> To: cloudstack-dev@incubator.apache.org
> Cc: cloudstack-dev@incubator.apache.org
> Subject: Re: CLI for CloudStack: cloudmonkey
> 
> Sebastian,
>  Try set apikey in lower case. Same with set secretkey.
> 
> ~kishan
> 
> On 08-Nov-2012, at 10:00 PM, "Sebastien Goasguen" <ru...@gmail.com> wrote:
> 
>> Actually it does not work yet.
>> 
>> Now I can type 'b' but it does not get passed properly:
>> 
>> 🙉 cloudmonkey> set apiKey KEbkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzjRB9UNrBybVr3kcZ6Q
>> 
>> Gives:
>> 
>> INFO  [cloud.api.ApiServer] (92734721@qtp-1601733969-7:) apiKey does not map to a valid user -- ignoring request, apiKey: KEkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzjRB9UNrByVr3kcZ6Q
>> 
>> On Nov 8, 2012, at 5:19 PM, Sebastien Goasguen <ru...@gmail.com> wrote:
>> 
>>> 
>>> On Nov 8, 2012, at 3:28 PM, Rohit Yadav <ro...@citrix.com> wrote:
>>> 
>>>> Hi Sebastien,
>>>> 
>>>> Are you using it from pypi/pip, if so do this:
>>>> sudo pip uninstall cloudmonkey
>>>> sudo pip install cloudmonkey
>>> 
>>> no, I am doing: sudo python ./setup.py install from the source tree
>>> 
>>>> I've had this bug on mac osx, fixed it:
>>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.git;a=commit;h=36e7a7884efef7c41ac369549b7bdb93e5122110
>>> 
>>> pulled that and reinstalled…and it works.
>>> 
>>> thanks
>>> 
>>> -sebastien
>>> 
>>> 
>>>> If it still persists for you, checkout  http://superuser.com/questions/297527/cant-type-the-b-letter-in-python-shell-in-os-x
>>>> 
>>>> Let me know if this still fails then.
>>>> 
>>>> Regards.
>>>> 
>>>> ________________________________________
>>>> From: Sebastien Goasguen [runseb@gmail.com]
>>>> Sent: Thursday, November 08, 2012 5:37 PM
>>>> To: cloudstack-dev@incubator.apache.org
>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>> 
>>>> Hi,
>>>> 
>>>> I am testing the cli and I have the weirdest issue. When I set the apikey or secretkey, the lower case 'b' letter does not print at the prompt.
>>>> So if my keys contain 'b' they don't work..
>>>> 
>>>> I tried all the other letters and they work.
>>>> 
>>>> Anyone seeing this,
>>>> 
>>>> -Sebastien
>>>> 
>>>> On Nov 7, 2012, at 7:25 PM, Rohit Yadav <ro...@citrix.com> wrote:
>>>> 
>>>>> yes, I think I'd mentioned in the thread or somewhere. Just use pip or easy_install (apt-get install python-setuptools on ubuntu, install python2.6 or above and pip if you don't have it);
>>>>> 
>>>>> sudo pip install cloudmonkey
>>>>> 
>>>>> or sudo easy_install cloudmonkey
>>>>> 
>>>>> now start cloudmonkey:
>>>>> $ cloudmonkey
>>>>> ...
>>>>> 
>>>>> Will post a blog/screencast this weekend and update doc so everyone can get help on its usage, though it's pretty intuitive.
>>>>> ________________________________________
>>>>> From: Musayev, Ilya [imusayev@webmd.net]
>>>>> Sent: Wednesday, November 07, 2012 11:41 PM
>>>>> To: cloudstack-dev@incubator.apache.org
>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>> 
>>>>> Rohit,
>>>>> 
>>>>> Can I get the CLI only without going through the whole source code maven install? Is it part of any RPM?
>>>>> 
>>>>> Thanks
>>>>> ilya
>>>>> 
>>>>> -----Original Message-----
>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>> Sent: Monday, November 05, 2012 11:35 AM
>>>>> To: cloudstack-dev@incubator.apache.org
>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>> 
>>>>> Checkout latest code. Few changes to share:
>>>>> 
>>>>> - All lowercase now
>>>>> - Tab tab over verbs to see list of params for that api, example list users <tab><tab>
>>>>> - This needs improvement but help string, using --help: list user --help
>>>>> - Caching to speedup runtime
>>>>> - Color and Parsing fixes
>>>>> 
>>>>> Last, I'm now able to get the doc strings for each attribute/param, will see this tomorrow.
>>>>> 
>>>>> Need your help, just incase you want to contribute, these are the TODOs:
>>>>> 
>>>>> - search over history
>>>>> - fix parsing
>>>>> - doc strings for parameters
>>>>> - testing for various kinds of apis (I'm able to deploy a zone with this, but needs testing)
>>>>> - unicode char monkey, used in prompt may mess up history searching and text display
>>>>> 
>>>>> 
>>>>> Regards.
>>>>> 
>>>>> On 02-Nov-2012, at 4:58 AM, Edison Su <Ed...@citrix.com> wrote:
>>>>> 
>>>>>> 
>>>>>> 
>>>>>>> -----Original Message-----
>>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>>> Sent: Thursday, November 01, 2012 2:23 PM
>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>> 
>>>>>>> After you install the tool, so that cloudmonkey is in your
>>>>>>> /usr/local/bin or in $PATH...
>>>>>>> 
>>>>>>> Two ways;
>>>>>>> 1. As command line tool, on bash/zsh, use the BNF grammar; <command
>>>>>>> line tool
>>>>>>> name>:<separator>:<verb>:<separator>:<action>:<separator>:<params>
>>>>>>> <command line tool name>={'cloudmonkey'} <separator>={' '}
>>>>>>> <verb>={'list', 'create', 'delete', 'update'.... etc.}
>>>>>>> <action>={'Users'... etc.} <params>={'listall=#'... etc.} So; $
>>>>>>> cloudmonkey list Users
>>>>>> 
>>>>>> 
>>>>>> Got it, thanks!
>>>>>> 
>>>>>>> 
>>>>>>> 2. file redirector:
>>>>>>> 
>>>>>>> $ cat test-file:
>>>>>>> list Users
>>>>>>> list <some other action>
>>>>>>> <some verb> <some action>
>>>>>>> 
>>>>>>> $ cloudmonkey < test-file
>>>>>>> 
>>>>>>> Note, I'll change the actions (Users, VirtualMachine etc.) to
>>>>>>> lowercase (users, virtualmachine etc.) if that's okay?
>>>>>> 
>>>>>> Please do, nobody wants to type extra keystroke, if it's not necessary.
>>>>>>> 
>>>>>>> Regards.
>>>>>>> 
>>>>>>> ________________________________________
>>>>>>> From: Edison Su [Edison.su@citrix.com]
>>>>>>> Sent: Friday, November 02, 2012 1:55 AM
>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>> 
>>>>>>> Oh, it reminds me that how to use the CLI on the bash command line?
>>>>>>> I think admin may want to call cloudstack API in a bash script, how
>>>>>>> can I do that?
>>>>>>> 
>>>>>>>> -----Original Message-----
>>>>>>>> From: Marcus Sorensen [mailto:shadowsor@gmail.com]
>>>>>>>> Sent: Thursday, November 01, 2012 1:11 PM
>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>> 
>>>>>>>> Yes, I look forward to using it instead of local curl calls on the
>>>>>>>> command line :-)
>>>>>>>> 
>>>>>>>> On Thu, Nov 1, 2012 at 2:02 PM, Edison Su <Ed...@citrix.com> wrote:
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>>> -----Original Message-----
>>>>>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>>>>>> Sent: Thursday, November 01, 2012 11:45 AM
>>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>>>>> 
>>>>>>>>>> Hi Chip, please go ahead if we can fix the http/s issue. The
>>>>>>>>>> connection is based on marvin, I'm sure using CLI we'll find out
>>>>>>>>>> more bugs and fix anything in marvin thereby help maintain
>>>>>>>>>> marvin->tests and
>>>>>>>> CLI.
>>>>>>>>>> Please hack that up on tools/marvin/marvin/cloudstackConnection.py
>>>>>>>>>> 
>>>>>>>>>> Edison, yes I'm working on the completedefault, I've figured a
>>>>>>>>>> solution to the parsing and tabbing issue to show params for any
>>>>>>>>>> api and added more verbs to the grammar like deploy, start etc.
>>>>>>>>>> In the new approach doc strings and params needed for an api are
>>>>>>>>>> fetched and cached in the class locally to speed up the loading process.
>>>>>>>>>> Till it gets committed, cloudmonkey (now) will keep telling the
>>>>>>>>>> user what params they are missing until it gets all the required ones.
>>>>>>>>> 
>>>>>>>>> Great! Thanks for your awesome CLI, people will like it.
>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> One more thing, for people who may not have unicode support the
>>>>>>>>>> prompt may appear weird and history search (up, down ) can mess up
>>>>>>>>>> the visuals. For example on Mac it appears as a colorful emoji,
>>>>>>>>>> but I found that it looks weird on other platforms. Will probably
>>>>>>>>>> remove it, or the user can custom set their prompt, using: set
>>>>>>>>>> prompt
>>>>>>>>>> myprompt>
>>>>>>>>>> 
>>>>>>>>>> Regards.
>>>>>>>>>> PS. the set command is full of (fun :)  hacks because of
>>>>>>>>>> funtional/generic programming, it basically can set any attribute
>>>>>>>>>> on the class, so one can do something like creating something
>>>>>>>>>> (var, func). For example set ruler # (so instead of - you will
>>>>>>>>>> have a #
>>>>>>>>>> separator)
>>>>>>>>>> 
>>>>>>>>>> ________________________________________
>>>>>>>>>> From: Chip Childers [chip.childers@sungard.com]
>>>>>>>>>> Sent: Thursday, November 01, 2012 11:15 PM
>>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>>>> 
>>>>>>>>>> On Wed, Oct 31, 2012 at 2:10 PM, Rohit Yadav
>>>>>>>>>> <ro...@citrix.com>
>>>>>>>>>> wrote:
>>>>>>>>>>> Hi,
>>>>>>>>>>> 
>>>>>>>>>>> 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:
>>>>>>>>>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.gi
>>>>>>>>>>> t; a=c ommit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
>>>>>>>>>>> 
>>>>>>>>>>> Features:
>>>>>>>>>>> - 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
>>>>>>>>>>> 
>>>>>>>>>>> FIXMEs:
>>>>>>>>>>> - 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 python
>>>>>>>>>>> cloudmonkey.py
>>>>>>>>>>> 
>>>>>>>>>>> If you want to have the terminal tool installed; cd tools/cli
>>>>>>>>>>> python setup.py 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=8.8.8.8 internaldns1=10.147.28.6
>>>>>>>>>>> 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
>>>>>>>>>>> networkofferingid= create Pod zoneid= name=Pod1
>>>>>>>> gateway=10.147.28.1
>>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.220 endip=10.147.28.235
>>>>>>>>>>> create VlanIpRange podid= networkid= gateway=10.147.28.1
>>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.236 endip=10.147.28.250
>>>>>>>>>>> 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=http://10.147.28.60 create
>>>>>>>>>>> StoragePool zoneid= clusterid= name=NFS1
>>>>>>>>>>> url=nfs://10.147.28.7/export/home/rohit/primary
>>>>>>>>>>> add SecondaryStorage zoneId=
>>>>>>>>>>> url=nfs://10.147.28.7/export/home/rohit/secondary
>>>>>>>>>>> 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.
>>>>>>>>>>> 
>>>>>>>>>>> Regards.
>>>>>>>>>>> PS. Marvin the neglected robot and hipster cloudmonkey should
>>>>>>>>>>> rule the world :D
>>>>>>>>>> 
>>>>>>>>>> Rohit,
>>>>>>>>>> 
>>>>>>>>>> This is really really cool.  It puts the "fun" in managing
>>>>>>>>>> instances from a command line.  I've been testing it against a
>>>>>>>>>> production CloudStack environment, and it's working pretty well.
>>>>>>>>>> 
>>>>>>>>>> If you don't mind, I might hack at the code a bit to fill in some
>>>>>>>>>> gaps that I'm seeing.  First example is that it assumes http,
>>>>>>>>>> which doesn't work in a public deployment where the endpoint is over https.
>>>>>>>>>> 
>>>>>>>>>> -chip
>> 


RE: CLI for CloudStack: cloudmonkey

Posted by Rohit Yadav <ro...@citrix.com>.
Oh, forgot to see that. Yes, now all the cmds are lowercase (except for few params liks isAsync=) and tab completion is advised.

Regards.
________________________________________
From: Kishan Kavala [Kishan.Kavala@citrix.com]
Sent: Thursday, November 08, 2012 11:29 PM
To: cloudstack-dev@incubator.apache.org
Cc: cloudstack-dev@incubator.apache.org
Subject: Re: CLI for CloudStack: cloudmonkey

Sebastian,
  Try set apikey in lower case. Same with set secretkey.

~kishan

On 08-Nov-2012, at 10:00 PM, "Sebastien Goasguen" <ru...@gmail.com> wrote:

> Actually it does not work yet.
>
> Now I can type 'b' but it does not get passed properly:
>
> 🙉 cloudmonkey> set apiKey KEbkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzjRB9UNrBybVr3kcZ6Q
>
> Gives:
>
> INFO  [cloud.api.ApiServer] (92734721@qtp-1601733969-7:) apiKey does not map to a valid user -- ignoring request, apiKey: KEkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzjRB9UNrByVr3kcZ6Q
>
> On Nov 8, 2012, at 5:19 PM, Sebastien Goasguen <ru...@gmail.com> wrote:
>
>>
>> On Nov 8, 2012, at 3:28 PM, Rohit Yadav <ro...@citrix.com> wrote:
>>
>>> Hi Sebastien,
>>>
>>> Are you using it from pypi/pip, if so do this:
>>> sudo pip uninstall cloudmonkey
>>> sudo pip install cloudmonkey
>>
>> no, I am doing: sudo python ./setup.py install from the source tree
>>
>>> I've had this bug on mac osx, fixed it:
>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.git;a=commit;h=36e7a7884efef7c41ac369549b7bdb93e5122110
>>
>> pulled that and reinstalled…and it works.
>>
>> thanks
>>
>> -sebastien
>>
>>
>>> If it still persists for you, checkout  http://superuser.com/questions/297527/cant-type-the-b-letter-in-python-shell-in-os-x
>>>
>>> Let me know if this still fails then.
>>>
>>> Regards.
>>>
>>> ________________________________________
>>> From: Sebastien Goasguen [runseb@gmail.com]
>>> Sent: Thursday, November 08, 2012 5:37 PM
>>> To: cloudstack-dev@incubator.apache.org
>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>
>>> Hi,
>>>
>>> I am testing the cli and I have the weirdest issue. When I set the apikey or secretkey, the lower case 'b' letter does not print at the prompt.
>>> So if my keys contain 'b' they don't work..
>>>
>>> I tried all the other letters and they work.
>>>
>>> Anyone seeing this,
>>>
>>> -Sebastien
>>>
>>> On Nov 7, 2012, at 7:25 PM, Rohit Yadav <ro...@citrix.com> wrote:
>>>
>>>> yes, I think I'd mentioned in the thread or somewhere. Just use pip or easy_install (apt-get install python-setuptools on ubuntu, install python2.6 or above and pip if you don't have it);
>>>>
>>>> sudo pip install cloudmonkey
>>>>
>>>> or sudo easy_install cloudmonkey
>>>>
>>>> now start cloudmonkey:
>>>> $ cloudmonkey
>>>> ...
>>>>
>>>> Will post a blog/screencast this weekend and update doc so everyone can get help on its usage, though it's pretty intuitive.
>>>> ________________________________________
>>>> From: Musayev, Ilya [imusayev@webmd.net]
>>>> Sent: Wednesday, November 07, 2012 11:41 PM
>>>> To: cloudstack-dev@incubator.apache.org
>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>
>>>> Rohit,
>>>>
>>>> Can I get the CLI only without going through the whole source code maven install? Is it part of any RPM?
>>>>
>>>> Thanks
>>>> ilya
>>>>
>>>> -----Original Message-----
>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>> Sent: Monday, November 05, 2012 11:35 AM
>>>> To: cloudstack-dev@incubator.apache.org
>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>
>>>> Checkout latest code. Few changes to share:
>>>>
>>>> - All lowercase now
>>>> - Tab tab over verbs to see list of params for that api, example list users <tab><tab>
>>>> - This needs improvement but help string, using --help: list user --help
>>>> - Caching to speedup runtime
>>>> - Color and Parsing fixes
>>>>
>>>> Last, I'm now able to get the doc strings for each attribute/param, will see this tomorrow.
>>>>
>>>> Need your help, just incase you want to contribute, these are the TODOs:
>>>>
>>>> - search over history
>>>> - fix parsing
>>>> - doc strings for parameters
>>>> - testing for various kinds of apis (I'm able to deploy a zone with this, but needs testing)
>>>> - unicode char monkey, used in prompt may mess up history searching and text display
>>>>
>>>>
>>>> Regards.
>>>>
>>>> On 02-Nov-2012, at 4:58 AM, Edison Su <Ed...@citrix.com> wrote:
>>>>
>>>>>
>>>>>
>>>>>> -----Original Message-----
>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>> Sent: Thursday, November 01, 2012 2:23 PM
>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>
>>>>>> After you install the tool, so that cloudmonkey is in your
>>>>>> /usr/local/bin or in $PATH...
>>>>>>
>>>>>> Two ways;
>>>>>> 1. As command line tool, on bash/zsh, use the BNF grammar; <command
>>>>>> line tool
>>>>>> name>:<separator>:<verb>:<separator>:<action>:<separator>:<params>
>>>>>> <command line tool name>={'cloudmonkey'} <separator>={' '}
>>>>>> <verb>={'list', 'create', 'delete', 'update'.... etc.}
>>>>>> <action>={'Users'... etc.} <params>={'listall=#'... etc.} So; $
>>>>>> cloudmonkey list Users
>>>>>
>>>>>
>>>>> Got it, thanks!
>>>>>
>>>>>>
>>>>>> 2. file redirector:
>>>>>>
>>>>>> $ cat test-file:
>>>>>> list Users
>>>>>> list <some other action>
>>>>>> <some verb> <some action>
>>>>>>
>>>>>> $ cloudmonkey < test-file
>>>>>>
>>>>>> Note, I'll change the actions (Users, VirtualMachine etc.) to
>>>>>> lowercase (users, virtualmachine etc.) if that's okay?
>>>>>
>>>>> Please do, nobody wants to type extra keystroke, if it's not necessary.
>>>>>>
>>>>>> Regards.
>>>>>>
>>>>>> ________________________________________
>>>>>> From: Edison Su [Edison.su@citrix.com]
>>>>>> Sent: Friday, November 02, 2012 1:55 AM
>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>
>>>>>> Oh, it reminds me that how to use the CLI on the bash command line?
>>>>>> I think admin may want to call cloudstack API in a bash script, how
>>>>>> can I do that?
>>>>>>
>>>>>>> -----Original Message-----
>>>>>>> From: Marcus Sorensen [mailto:shadowsor@gmail.com]
>>>>>>> Sent: Thursday, November 01, 2012 1:11 PM
>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>
>>>>>>> Yes, I look forward to using it instead of local curl calls on the
>>>>>>> command line :-)
>>>>>>>
>>>>>>> On Thu, Nov 1, 2012 at 2:02 PM, Edison Su <Ed...@citrix.com> wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>> -----Original Message-----
>>>>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>>>>> Sent: Thursday, November 01, 2012 11:45 AM
>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>>>>
>>>>>>>>> Hi Chip, please go ahead if we can fix the http/s issue. The
>>>>>>>>> connection is based on marvin, I'm sure using CLI we'll find out
>>>>>>>>> more bugs and fix anything in marvin thereby help maintain
>>>>>>>>> marvin->tests and
>>>>>>> CLI.
>>>>>>>>> Please hack that up on tools/marvin/marvin/cloudstackConnection.py
>>>>>>>>>
>>>>>>>>> Edison, yes I'm working on the completedefault, I've figured a
>>>>>>>>> solution to the parsing and tabbing issue to show params for any
>>>>>>>>> api and added more verbs to the grammar like deploy, start etc.
>>>>>>>>> In the new approach doc strings and params needed for an api are
>>>>>>>>> fetched and cached in the class locally to speed up the loading process.
>>>>>>>>> Till it gets committed, cloudmonkey (now) will keep telling the
>>>>>>>>> user what params they are missing until it gets all the required ones.
>>>>>>>>
>>>>>>>> Great! Thanks for your awesome CLI, people will like it.
>>>>>>>>
>>>>>>>>>
>>>>>>>>> One more thing, for people who may not have unicode support the
>>>>>>>>> prompt may appear weird and history search (up, down ) can mess up
>>>>>>>>> the visuals. For example on Mac it appears as a colorful emoji,
>>>>>>>>> but I found that it looks weird on other platforms. Will probably
>>>>>>>>> remove it, or the user can custom set their prompt, using: set
>>>>>>>>> prompt
>>>>>>>>> myprompt>
>>>>>>>>>
>>>>>>>>> Regards.
>>>>>>>>> PS. the set command is full of (fun :)  hacks because of
>>>>>>>>> funtional/generic programming, it basically can set any attribute
>>>>>>>>> on the class, so one can do something like creating something
>>>>>>>>> (var, func). For example set ruler # (so instead of - you will
>>>>>>>>> have a #
>>>>>>>>> separator)
>>>>>>>>>
>>>>>>>>> ________________________________________
>>>>>>>>> From: Chip Childers [chip.childers@sungard.com]
>>>>>>>>> Sent: Thursday, November 01, 2012 11:15 PM
>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>>>
>>>>>>>>> On Wed, Oct 31, 2012 at 2:10 PM, Rohit Yadav
>>>>>>>>> <ro...@citrix.com>
>>>>>>>>> wrote:
>>>>>>>>>> Hi,
>>>>>>>>>>
>>>>>>>>>> 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:
>>>>>>>>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.gi
>>>>>>>>>> t; a=c ommit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
>>>>>>>>>>
>>>>>>>>>> Features:
>>>>>>>>>> - 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
>>>>>>>>>>
>>>>>>>>>> FIXMEs:
>>>>>>>>>> - 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 python
>>>>>>>>>> cloudmonkey.py
>>>>>>>>>>
>>>>>>>>>> If you want to have the terminal tool installed; cd tools/cli
>>>>>>>>>> python setup.py 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=8.8.8.8 internaldns1=10.147.28.6
>>>>>>>>>> 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
>>>>>>>>>> networkofferingid= create Pod zoneid= name=Pod1
>>>>>>> gateway=10.147.28.1
>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.220 endip=10.147.28.235
>>>>>>>>>> create VlanIpRange podid= networkid= gateway=10.147.28.1
>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.236 endip=10.147.28.250
>>>>>>>>>> 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=http://10.147.28.60 create
>>>>>>>>>> StoragePool zoneid= clusterid= name=NFS1
>>>>>>>>>> url=nfs://10.147.28.7/export/home/rohit/primary
>>>>>>>>>> add SecondaryStorage zoneId=
>>>>>>>>>> url=nfs://10.147.28.7/export/home/rohit/secondary
>>>>>>>>>> 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.
>>>>>>>>>>
>>>>>>>>>> Regards.
>>>>>>>>>> PS. Marvin the neglected robot and hipster cloudmonkey should
>>>>>>>>>> rule the world :D
>>>>>>>>>
>>>>>>>>> Rohit,
>>>>>>>>>
>>>>>>>>> This is really really cool.  It puts the "fun" in managing
>>>>>>>>> instances from a command line.  I've been testing it against a
>>>>>>>>> production CloudStack environment, and it's working pretty well.
>>>>>>>>>
>>>>>>>>> If you don't mind, I might hack at the code a bit to fill in some
>>>>>>>>> gaps that I'm seeing.  First example is that it assumes http,
>>>>>>>>> which doesn't work in a public deployment where the endpoint is over https.
>>>>>>>>>
>>>>>>>>> -chip
>

Re: CLI for CloudStack: cloudmonkey

Posted by Kishan Kavala <Ki...@citrix.com>.
Sebastian,
  Try set apikey in lower case. Same with set secretkey.

~kishan

On 08-Nov-2012, at 10:00 PM, "Sebastien Goasguen" <ru...@gmail.com> wrote:

> Actually it does not work yet.
>
> Now I can type 'b' but it does not get passed properly:
>
> 🙉 cloudmonkey> set apiKey KEbkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzjRB9UNrBybVr3kcZ6Q
>
> Gives:
>
> INFO  [cloud.api.ApiServer] (92734721@qtp-1601733969-7:) apiKey does not map to a valid user -- ignoring request, apiKey: KEkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzjRB9UNrByVr3kcZ6Q
>
> On Nov 8, 2012, at 5:19 PM, Sebastien Goasguen <ru...@gmail.com> wrote:
>
>>
>> On Nov 8, 2012, at 3:28 PM, Rohit Yadav <ro...@citrix.com> wrote:
>>
>>> Hi Sebastien,
>>>
>>> Are you using it from pypi/pip, if so do this:
>>> sudo pip uninstall cloudmonkey
>>> sudo pip install cloudmonkey
>>
>> no, I am doing: sudo python ./setup.py install from the source tree
>>
>>> I've had this bug on mac osx, fixed it:
>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.git;a=commit;h=36e7a7884efef7c41ac369549b7bdb93e5122110
>>
>> pulled that and reinstalled…and it works.
>>
>> thanks
>>
>> -sebastien
>>
>>
>>> If it still persists for you, checkout  http://superuser.com/questions/297527/cant-type-the-b-letter-in-python-shell-in-os-x
>>>
>>> Let me know if this still fails then.
>>>
>>> Regards.
>>>
>>> ________________________________________
>>> From: Sebastien Goasguen [runseb@gmail.com]
>>> Sent: Thursday, November 08, 2012 5:37 PM
>>> To: cloudstack-dev@incubator.apache.org
>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>
>>> Hi,
>>>
>>> I am testing the cli and I have the weirdest issue. When I set the apikey or secretkey, the lower case 'b' letter does not print at the prompt.
>>> So if my keys contain 'b' they don't work..
>>>
>>> I tried all the other letters and they work.
>>>
>>> Anyone seeing this,
>>>
>>> -Sebastien
>>>
>>> On Nov 7, 2012, at 7:25 PM, Rohit Yadav <ro...@citrix.com> wrote:
>>>
>>>> yes, I think I'd mentioned in the thread or somewhere. Just use pip or easy_install (apt-get install python-setuptools on ubuntu, install python2.6 or above and pip if you don't have it);
>>>>
>>>> sudo pip install cloudmonkey
>>>>
>>>> or sudo easy_install cloudmonkey
>>>>
>>>> now start cloudmonkey:
>>>> $ cloudmonkey
>>>> ...
>>>>
>>>> Will post a blog/screencast this weekend and update doc so everyone can get help on its usage, though it's pretty intuitive.
>>>> ________________________________________
>>>> From: Musayev, Ilya [imusayev@webmd.net]
>>>> Sent: Wednesday, November 07, 2012 11:41 PM
>>>> To: cloudstack-dev@incubator.apache.org
>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>
>>>> Rohit,
>>>>
>>>> Can I get the CLI only without going through the whole source code maven install? Is it part of any RPM?
>>>>
>>>> Thanks
>>>> ilya
>>>>
>>>> -----Original Message-----
>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>> Sent: Monday, November 05, 2012 11:35 AM
>>>> To: cloudstack-dev@incubator.apache.org
>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>
>>>> Checkout latest code. Few changes to share:
>>>>
>>>> - All lowercase now
>>>> - Tab tab over verbs to see list of params for that api, example list users <tab><tab>
>>>> - This needs improvement but help string, using --help: list user --help
>>>> - Caching to speedup runtime
>>>> - Color and Parsing fixes
>>>>
>>>> Last, I'm now able to get the doc strings for each attribute/param, will see this tomorrow.
>>>>
>>>> Need your help, just incase you want to contribute, these are the TODOs:
>>>>
>>>> - search over history
>>>> - fix parsing
>>>> - doc strings for parameters
>>>> - testing for various kinds of apis (I'm able to deploy a zone with this, but needs testing)
>>>> - unicode char monkey, used in prompt may mess up history searching and text display
>>>>
>>>>
>>>> Regards.
>>>>
>>>> On 02-Nov-2012, at 4:58 AM, Edison Su <Ed...@citrix.com> wrote:
>>>>
>>>>>
>>>>>
>>>>>> -----Original Message-----
>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>> Sent: Thursday, November 01, 2012 2:23 PM
>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>
>>>>>> After you install the tool, so that cloudmonkey is in your
>>>>>> /usr/local/bin or in $PATH...
>>>>>>
>>>>>> Two ways;
>>>>>> 1. As command line tool, on bash/zsh, use the BNF grammar; <command
>>>>>> line tool
>>>>>> name>:<separator>:<verb>:<separator>:<action>:<separator>:<params>
>>>>>> <command line tool name>={'cloudmonkey'} <separator>={' '}
>>>>>> <verb>={'list', 'create', 'delete', 'update'.... etc.}
>>>>>> <action>={'Users'... etc.} <params>={'listall=#'... etc.} So; $
>>>>>> cloudmonkey list Users
>>>>>
>>>>>
>>>>> Got it, thanks!
>>>>>
>>>>>>
>>>>>> 2. file redirector:
>>>>>>
>>>>>> $ cat test-file:
>>>>>> list Users
>>>>>> list <some other action>
>>>>>> <some verb> <some action>
>>>>>>
>>>>>> $ cloudmonkey < test-file
>>>>>>
>>>>>> Note, I'll change the actions (Users, VirtualMachine etc.) to
>>>>>> lowercase (users, virtualmachine etc.) if that's okay?
>>>>>
>>>>> Please do, nobody wants to type extra keystroke, if it's not necessary.
>>>>>>
>>>>>> Regards.
>>>>>>
>>>>>> ________________________________________
>>>>>> From: Edison Su [Edison.su@citrix.com]
>>>>>> Sent: Friday, November 02, 2012 1:55 AM
>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>
>>>>>> Oh, it reminds me that how to use the CLI on the bash command line?
>>>>>> I think admin may want to call cloudstack API in a bash script, how
>>>>>> can I do that?
>>>>>>
>>>>>>> -----Original Message-----
>>>>>>> From: Marcus Sorensen [mailto:shadowsor@gmail.com]
>>>>>>> Sent: Thursday, November 01, 2012 1:11 PM
>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>
>>>>>>> Yes, I look forward to using it instead of local curl calls on the
>>>>>>> command line :-)
>>>>>>>
>>>>>>> On Thu, Nov 1, 2012 at 2:02 PM, Edison Su <Ed...@citrix.com> wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>> -----Original Message-----
>>>>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>>>>> Sent: Thursday, November 01, 2012 11:45 AM
>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>>>>
>>>>>>>>> Hi Chip, please go ahead if we can fix the http/s issue. The
>>>>>>>>> connection is based on marvin, I'm sure using CLI we'll find out
>>>>>>>>> more bugs and fix anything in marvin thereby help maintain
>>>>>>>>> marvin->tests and
>>>>>>> CLI.
>>>>>>>>> Please hack that up on tools/marvin/marvin/cloudstackConnection.py
>>>>>>>>>
>>>>>>>>> Edison, yes I'm working on the completedefault, I've figured a
>>>>>>>>> solution to the parsing and tabbing issue to show params for any
>>>>>>>>> api and added more verbs to the grammar like deploy, start etc.
>>>>>>>>> In the new approach doc strings and params needed for an api are
>>>>>>>>> fetched and cached in the class locally to speed up the loading process.
>>>>>>>>> Till it gets committed, cloudmonkey (now) will keep telling the
>>>>>>>>> user what params they are missing until it gets all the required ones.
>>>>>>>>
>>>>>>>> Great! Thanks for your awesome CLI, people will like it.
>>>>>>>>
>>>>>>>>>
>>>>>>>>> One more thing, for people who may not have unicode support the
>>>>>>>>> prompt may appear weird and history search (up, down ) can mess up
>>>>>>>>> the visuals. For example on Mac it appears as a colorful emoji,
>>>>>>>>> but I found that it looks weird on other platforms. Will probably
>>>>>>>>> remove it, or the user can custom set their prompt, using: set
>>>>>>>>> prompt
>>>>>>>>> myprompt>
>>>>>>>>>
>>>>>>>>> Regards.
>>>>>>>>> PS. the set command is full of (fun :)  hacks because of
>>>>>>>>> funtional/generic programming, it basically can set any attribute
>>>>>>>>> on the class, so one can do something like creating something
>>>>>>>>> (var, func). For example set ruler # (so instead of - you will
>>>>>>>>> have a #
>>>>>>>>> separator)
>>>>>>>>>
>>>>>>>>> ________________________________________
>>>>>>>>> From: Chip Childers [chip.childers@sungard.com]
>>>>>>>>> Sent: Thursday, November 01, 2012 11:15 PM
>>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>>>
>>>>>>>>> On Wed, Oct 31, 2012 at 2:10 PM, Rohit Yadav
>>>>>>>>> <ro...@citrix.com>
>>>>>>>>> wrote:
>>>>>>>>>> Hi,
>>>>>>>>>>
>>>>>>>>>> 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:
>>>>>>>>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.gi
>>>>>>>>>> t; a=c ommit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
>>>>>>>>>>
>>>>>>>>>> Features:
>>>>>>>>>> - 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
>>>>>>>>>>
>>>>>>>>>> FIXMEs:
>>>>>>>>>> - 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 python
>>>>>>>>>> cloudmonkey.py
>>>>>>>>>>
>>>>>>>>>> If you want to have the terminal tool installed; cd tools/cli
>>>>>>>>>> python setup.py 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=8.8.8.8 internaldns1=10.147.28.6
>>>>>>>>>> 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
>>>>>>>>>> networkofferingid= create Pod zoneid= name=Pod1
>>>>>>> gateway=10.147.28.1
>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.220 endip=10.147.28.235
>>>>>>>>>> create VlanIpRange podid= networkid= gateway=10.147.28.1
>>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.236 endip=10.147.28.250
>>>>>>>>>> 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=http://10.147.28.60 create
>>>>>>>>>> StoragePool zoneid= clusterid= name=NFS1
>>>>>>>>>> url=nfs://10.147.28.7/export/home/rohit/primary
>>>>>>>>>> add SecondaryStorage zoneId=
>>>>>>>>>> url=nfs://10.147.28.7/export/home/rohit/secondary
>>>>>>>>>> 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.
>>>>>>>>>>
>>>>>>>>>> Regards.
>>>>>>>>>> PS. Marvin the neglected robot and hipster cloudmonkey should
>>>>>>>>>> rule the world :D
>>>>>>>>>
>>>>>>>>> Rohit,
>>>>>>>>>
>>>>>>>>> This is really really cool.  It puts the "fun" in managing
>>>>>>>>> instances from a command line.  I've been testing it against a
>>>>>>>>> production CloudStack environment, and it's working pretty well.
>>>>>>>>>
>>>>>>>>> If you don't mind, I might hack at the code a bit to fill in some
>>>>>>>>> gaps that I'm seeing.  First example is that it assumes http,
>>>>>>>>> which doesn't work in a public deployment where the endpoint is over https.
>>>>>>>>>
>>>>>>>>> -chip
>

Re: CLI for CloudStack: cloudmonkey

Posted by Sebastien Goasguen <ru...@gmail.com>.
Actually it does not work yet.

Now I can type 'b' but it does not get passed properly:

🙉 cloudmonkey> set apiKey KEbkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzjRB9UNrBybVr3kcZ6Q

Gives:

INFO  [cloud.api.ApiServer] (92734721@qtp-1601733969-7:) apiKey does not map to a valid user -- ignoring request, apiKey: KEkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzjRB9UNrByVr3kcZ6Q

On Nov 8, 2012, at 5:19 PM, Sebastien Goasguen <ru...@gmail.com> wrote:

> 
> On Nov 8, 2012, at 3:28 PM, Rohit Yadav <ro...@citrix.com> wrote:
> 
>> Hi Sebastien,
>> 
>> Are you using it from pypi/pip, if so do this:
>> sudo pip uninstall cloudmonkey
>> sudo pip install cloudmonkey
>> 
> 
> no, I am doing: sudo python ./setup.py install from the source tree
> 
>> I've had this bug on mac osx, fixed it:
>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.git;a=commit;h=36e7a7884efef7c41ac369549b7bdb93e5122110
>> 
> 
> pulled that and reinstalled…and it works.
> 
> thanks
> 
> -sebastien
> 
> 
>> If it still persists for you, checkout  http://superuser.com/questions/297527/cant-type-the-b-letter-in-python-shell-in-os-x
>> 
>> Let me know if this still fails then.
>> 
>> Regards.
>> 
>> ________________________________________
>> From: Sebastien Goasguen [runseb@gmail.com]
>> Sent: Thursday, November 08, 2012 5:37 PM
>> To: cloudstack-dev@incubator.apache.org
>> Subject: Re: CLI for CloudStack: cloudmonkey
>> 
>> Hi,
>> 
>> I am testing the cli and I have the weirdest issue. When I set the apikey or secretkey, the lower case 'b' letter does not print at the prompt.
>> So if my keys contain 'b' they don't work..
>> 
>> I tried all the other letters and they work.
>> 
>> Anyone seeing this,
>> 
>> -Sebastien
>> 
>> On Nov 7, 2012, at 7:25 PM, Rohit Yadav <ro...@citrix.com> wrote:
>> 
>>> yes, I think I'd mentioned in the thread or somewhere. Just use pip or easy_install (apt-get install python-setuptools on ubuntu, install python2.6 or above and pip if you don't have it);
>>> 
>>> sudo pip install cloudmonkey
>>> 
>>> or sudo easy_install cloudmonkey
>>> 
>>> now start cloudmonkey:
>>> $ cloudmonkey
>>> ...
>>> 
>>> Will post a blog/screencast this weekend and update doc so everyone can get help on its usage, though it's pretty intuitive.
>>> ________________________________________
>>> From: Musayev, Ilya [imusayev@webmd.net]
>>> Sent: Wednesday, November 07, 2012 11:41 PM
>>> To: cloudstack-dev@incubator.apache.org
>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>> 
>>> Rohit,
>>> 
>>> Can I get the CLI only without going through the whole source code maven install? Is it part of any RPM?
>>> 
>>> Thanks
>>> ilya
>>> 
>>> -----Original Message-----
>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>> Sent: Monday, November 05, 2012 11:35 AM
>>> To: cloudstack-dev@incubator.apache.org
>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>> 
>>> Checkout latest code. Few changes to share:
>>> 
>>> - All lowercase now
>>> - Tab tab over verbs to see list of params for that api, example list users <tab><tab>
>>> - This needs improvement but help string, using --help: list user --help
>>> - Caching to speedup runtime
>>> - Color and Parsing fixes
>>> 
>>> Last, I'm now able to get the doc strings for each attribute/param, will see this tomorrow.
>>> 
>>> Need your help, just incase you want to contribute, these are the TODOs:
>>> 
>>> - search over history
>>> - fix parsing
>>> - doc strings for parameters
>>> - testing for various kinds of apis (I'm able to deploy a zone with this, but needs testing)
>>> - unicode char monkey, used in prompt may mess up history searching and text display
>>> 
>>> 
>>> Regards.
>>> 
>>> On 02-Nov-2012, at 4:58 AM, Edison Su <Ed...@citrix.com> wrote:
>>> 
>>>> 
>>>> 
>>>>> -----Original Message-----
>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>> Sent: Thursday, November 01, 2012 2:23 PM
>>>>> To: cloudstack-dev@incubator.apache.org
>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>> 
>>>>> After you install the tool, so that cloudmonkey is in your
>>>>> /usr/local/bin or in $PATH...
>>>>> 
>>>>> Two ways;
>>>>> 1. As command line tool, on bash/zsh, use the BNF grammar; <command
>>>>> line tool
>>>>> name>:<separator>:<verb>:<separator>:<action>:<separator>:<params>
>>>>> <command line tool name>={'cloudmonkey'} <separator>={' '}
>>>>> <verb>={'list', 'create', 'delete', 'update'.... etc.}
>>>>> <action>={'Users'... etc.} <params>={'listall=#'... etc.} So; $
>>>>> cloudmonkey list Users
>>>> 
>>>> 
>>>> Got it, thanks!
>>>> 
>>>>> 
>>>>> 2. file redirector:
>>>>> 
>>>>> $ cat test-file:
>>>>> list Users
>>>>> list <some other action>
>>>>> <some verb> <some action>
>>>>> 
>>>>> $ cloudmonkey < test-file
>>>>> 
>>>>> Note, I'll change the actions (Users, VirtualMachine etc.) to
>>>>> lowercase (users, virtualmachine etc.) if that's okay?
>>>> 
>>>> Please do, nobody wants to type extra keystroke, if it's not necessary.
>>>>> 
>>>>> Regards.
>>>>> 
>>>>> ________________________________________
>>>>> From: Edison Su [Edison.su@citrix.com]
>>>>> Sent: Friday, November 02, 2012 1:55 AM
>>>>> To: cloudstack-dev@incubator.apache.org
>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>> 
>>>>> Oh, it reminds me that how to use the CLI on the bash command line?
>>>>> I think admin may want to call cloudstack API in a bash script, how
>>>>> can I do that?
>>>>> 
>>>>>> -----Original Message-----
>>>>>> From: Marcus Sorensen [mailto:shadowsor@gmail.com]
>>>>>> Sent: Thursday, November 01, 2012 1:11 PM
>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>> 
>>>>>> Yes, I look forward to using it instead of local curl calls on the
>>>>>> command line :-)
>>>>>> 
>>>>>> On Thu, Nov 1, 2012 at 2:02 PM, Edison Su <Ed...@citrix.com> wrote:
>>>>>>> 
>>>>>>> 
>>>>>>>> -----Original Message-----
>>>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>>>> Sent: Thursday, November 01, 2012 11:45 AM
>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>>> 
>>>>>>>> Hi Chip, please go ahead if we can fix the http/s issue. The
>>>>>>>> connection is based on marvin, I'm sure using CLI we'll find out
>>>>>>>> more bugs and fix anything in marvin thereby help maintain
>>>>>>>> marvin->tests and
>>>>>> CLI.
>>>>>>>> Please hack that up on tools/marvin/marvin/cloudstackConnection.py
>>>>>>>> 
>>>>>>>> Edison, yes I'm working on the completedefault, I've figured a
>>>>>>>> solution to the parsing and tabbing issue to show params for any
>>>>>>>> api and added more verbs to the grammar like deploy, start etc.
>>>>>>>> In the new approach doc strings and params needed for an api are
>>>>>>>> fetched and cached in the class locally to speed up the loading process.
>>>>>>>> Till it gets committed, cloudmonkey (now) will keep telling the
>>>>>>>> user what params they are missing until it gets all the required ones.
>>>>>>> 
>>>>>>> Great! Thanks for your awesome CLI, people will like it.
>>>>>>> 
>>>>>>>> 
>>>>>>>> One more thing, for people who may not have unicode support the
>>>>>>>> prompt may appear weird and history search (up, down ) can mess up
>>>>>>>> the visuals. For example on Mac it appears as a colorful emoji,
>>>>>>>> but I found that it looks weird on other platforms. Will probably
>>>>>>>> remove it, or the user can custom set their prompt, using: set
>>>>>>>> prompt
>>>>>>>> myprompt>
>>>>>>>> 
>>>>>>>> Regards.
>>>>>>>> PS. the set command is full of (fun :)  hacks because of
>>>>>>>> funtional/generic programming, it basically can set any attribute
>>>>>>>> on the class, so one can do something like creating something
>>>>>>>> (var, func). For example set ruler # (so instead of - you will
>>>>>>>> have a #
>>>>>>>> separator)
>>>>>>>> 
>>>>>>>> ________________________________________
>>>>>>>> From: Chip Childers [chip.childers@sungard.com]
>>>>>>>> Sent: Thursday, November 01, 2012 11:15 PM
>>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>>> 
>>>>>>>> On Wed, Oct 31, 2012 at 2:10 PM, Rohit Yadav
>>>>>>>> <ro...@citrix.com>
>>>>>>>> wrote:
>>>>>>>>> Hi,
>>>>>>>>> 
>>>>>>>>> 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:
>>>>>>>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.gi
>>>>>>>>> t; a=c ommit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
>>>>>>>>> 
>>>>>>>>> Features:
>>>>>>>>> - 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
>>>>>>>>> 
>>>>>>>>> FIXMEs:
>>>>>>>>> - 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 python
>>>>>>>>> cloudmonkey.py
>>>>>>>>> 
>>>>>>>>> If you want to have the terminal tool installed; cd tools/cli
>>>>>>>>> python setup.py 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=8.8.8.8 internaldns1=10.147.28.6
>>>>>>>>> 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
>>>>>>>>> networkofferingid= create Pod zoneid= name=Pod1
>>>>>> gateway=10.147.28.1
>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.220 endip=10.147.28.235
>>>>>>>>> create VlanIpRange podid= networkid= gateway=10.147.28.1
>>>>>>>>> netmask=255.255.255.0 startip=10.147.28.236 endip=10.147.28.250
>>>>>>>>> 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=http://10.147.28.60 create
>>>>>>>>> StoragePool zoneid= clusterid= name=NFS1
>>>>>>>>> url=nfs://10.147.28.7/export/home/rohit/primary
>>>>>>>>> add SecondaryStorage zoneId=
>>>>>>>>> url=nfs://10.147.28.7/export/home/rohit/secondary
>>>>>>>>> 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.
>>>>>>>>> 
>>>>>>>>> Regards.
>>>>>>>>> PS. Marvin the neglected robot and hipster cloudmonkey should
>>>>>>>>> rule the world :D
>>>>>>>> 
>>>>>>>> Rohit,
>>>>>>>> 
>>>>>>>> This is really really cool.  It puts the "fun" in managing
>>>>>>>> instances from a command line.  I've been testing it against a
>>>>>>>> production CloudStack environment, and it's working pretty well.
>>>>>>>> 
>>>>>>>> If you don't mind, I might hack at the code a bit to fill in some
>>>>>>>> gaps that I'm seeing.  First example is that it assumes http,
>>>>>>>> which doesn't work in a public deployment where the endpoint is over https.
>>>>>>>> 
>>>>>>>> -chip
>>> 
>> 
> 


Re: CLI for CloudStack: cloudmonkey

Posted by Sebastien Goasguen <ru...@gmail.com>.
On Nov 8, 2012, at 3:28 PM, Rohit Yadav <ro...@citrix.com> wrote:

> Hi Sebastien,
> 
> Are you using it from pypi/pip, if so do this:
> sudo pip uninstall cloudmonkey
> sudo pip install cloudmonkey
> 

no, I am doing: sudo python ./setup.py install from the source tree

> I've had this bug on mac osx, fixed it:
> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.git;a=commit;h=36e7a7884efef7c41ac369549b7bdb93e5122110
> 

pulled that and reinstalled…and it works.

thanks

-sebastien


> If it still persists for you, checkout  http://superuser.com/questions/297527/cant-type-the-b-letter-in-python-shell-in-os-x
> 
> Let me know if this still fails then.
> 
> Regards.
> 
> ________________________________________
> From: Sebastien Goasguen [runseb@gmail.com]
> Sent: Thursday, November 08, 2012 5:37 PM
> To: cloudstack-dev@incubator.apache.org
> Subject: Re: CLI for CloudStack: cloudmonkey
> 
> Hi,
> 
> I am testing the cli and I have the weirdest issue. When I set the apikey or secretkey, the lower case 'b' letter does not print at the prompt.
> So if my keys contain 'b' they don't work..
> 
> I tried all the other letters and they work.
> 
> Anyone seeing this,
> 
> -Sebastien
> 
> On Nov 7, 2012, at 7:25 PM, Rohit Yadav <ro...@citrix.com> wrote:
> 
>> yes, I think I'd mentioned in the thread or somewhere. Just use pip or easy_install (apt-get install python-setuptools on ubuntu, install python2.6 or above and pip if you don't have it);
>> 
>> sudo pip install cloudmonkey
>> 
>> or sudo easy_install cloudmonkey
>> 
>> now start cloudmonkey:
>> $ cloudmonkey
>> ...
>> 
>> Will post a blog/screencast this weekend and update doc so everyone can get help on its usage, though it's pretty intuitive.
>> ________________________________________
>> From: Musayev, Ilya [imusayev@webmd.net]
>> Sent: Wednesday, November 07, 2012 11:41 PM
>> To: cloudstack-dev@incubator.apache.org
>> Subject: RE: CLI for CloudStack: cloudmonkey
>> 
>> Rohit,
>> 
>> Can I get the CLI only without going through the whole source code maven install? Is it part of any RPM?
>> 
>> Thanks
>> ilya
>> 
>> -----Original Message-----
>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>> Sent: Monday, November 05, 2012 11:35 AM
>> To: cloudstack-dev@incubator.apache.org
>> Subject: Re: CLI for CloudStack: cloudmonkey
>> 
>> Checkout latest code. Few changes to share:
>> 
>> - All lowercase now
>> - Tab tab over verbs to see list of params for that api, example list users <tab><tab>
>> - This needs improvement but help string, using --help: list user --help
>> - Caching to speedup runtime
>> - Color and Parsing fixes
>> 
>> Last, I'm now able to get the doc strings for each attribute/param, will see this tomorrow.
>> 
>> Need your help, just incase you want to contribute, these are the TODOs:
>> 
>> - search over history
>> - fix parsing
>> - doc strings for parameters
>> - testing for various kinds of apis (I'm able to deploy a zone with this, but needs testing)
>> - unicode char monkey, used in prompt may mess up history searching and text display
>> 
>> 
>> Regards.
>> 
>> On 02-Nov-2012, at 4:58 AM, Edison Su <Ed...@citrix.com> wrote:
>> 
>>> 
>>> 
>>>> -----Original Message-----
>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>> Sent: Thursday, November 01, 2012 2:23 PM
>>>> To: cloudstack-dev@incubator.apache.org
>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>> 
>>>> After you install the tool, so that cloudmonkey is in your
>>>> /usr/local/bin or in $PATH...
>>>> 
>>>> Two ways;
>>>> 1. As command line tool, on bash/zsh, use the BNF grammar; <command
>>>> line tool
>>>> name>:<separator>:<verb>:<separator>:<action>:<separator>:<params>
>>>> <command line tool name>={'cloudmonkey'} <separator>={' '}
>>>> <verb>={'list', 'create', 'delete', 'update'.... etc.}
>>>> <action>={'Users'... etc.} <params>={'listall=#'... etc.} So; $
>>>> cloudmonkey list Users
>>> 
>>> 
>>> Got it, thanks!
>>> 
>>>> 
>>>> 2. file redirector:
>>>> 
>>>> $ cat test-file:
>>>> list Users
>>>> list <some other action>
>>>> <some verb> <some action>
>>>> 
>>>> $ cloudmonkey < test-file
>>>> 
>>>> Note, I'll change the actions (Users, VirtualMachine etc.) to
>>>> lowercase (users, virtualmachine etc.) if that's okay?
>>> 
>>> Please do, nobody wants to type extra keystroke, if it's not necessary.
>>>> 
>>>> Regards.
>>>> 
>>>> ________________________________________
>>>> From: Edison Su [Edison.su@citrix.com]
>>>> Sent: Friday, November 02, 2012 1:55 AM
>>>> To: cloudstack-dev@incubator.apache.org
>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>> 
>>>> Oh, it reminds me that how to use the CLI on the bash command line?
>>>> I think admin may want to call cloudstack API in a bash script, how
>>>> can I do that?
>>>> 
>>>>> -----Original Message-----
>>>>> From: Marcus Sorensen [mailto:shadowsor@gmail.com]
>>>>> Sent: Thursday, November 01, 2012 1:11 PM
>>>>> To: cloudstack-dev@incubator.apache.org
>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>> 
>>>>> Yes, I look forward to using it instead of local curl calls on the
>>>>> command line :-)
>>>>> 
>>>>> On Thu, Nov 1, 2012 at 2:02 PM, Edison Su <Ed...@citrix.com> wrote:
>>>>>> 
>>>>>> 
>>>>>>> -----Original Message-----
>>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>>> Sent: Thursday, November 01, 2012 11:45 AM
>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>> 
>>>>>>> Hi Chip, please go ahead if we can fix the http/s issue. The
>>>>>>> connection is based on marvin, I'm sure using CLI we'll find out
>>>>>>> more bugs and fix anything in marvin thereby help maintain
>>>>>>> marvin->tests and
>>>>> CLI.
>>>>>>> Please hack that up on tools/marvin/marvin/cloudstackConnection.py
>>>>>>> 
>>>>>>> Edison, yes I'm working on the completedefault, I've figured a
>>>>>>> solution to the parsing and tabbing issue to show params for any
>>>>>>> api and added more verbs to the grammar like deploy, start etc.
>>>>>>> In the new approach doc strings and params needed for an api are
>>>>>>> fetched and cached in the class locally to speed up the loading process.
>>>>>>> Till it gets committed, cloudmonkey (now) will keep telling the
>>>>>>> user what params they are missing until it gets all the required ones.
>>>>>> 
>>>>>> Great! Thanks for your awesome CLI, people will like it.
>>>>>> 
>>>>>>> 
>>>>>>> One more thing, for people who may not have unicode support the
>>>>>>> prompt may appear weird and history search (up, down ) can mess up
>>>>>>> the visuals. For example on Mac it appears as a colorful emoji,
>>>>>>> but I found that it looks weird on other platforms. Will probably
>>>>>>> remove it, or the user can custom set their prompt, using: set
>>>>>>> prompt
>>>>>>> myprompt>
>>>>>>> 
>>>>>>> Regards.
>>>>>>> PS. the set command is full of (fun :)  hacks because of
>>>>>>> funtional/generic programming, it basically can set any attribute
>>>>>>> on the class, so one can do something like creating something
>>>>>>> (var, func). For example set ruler # (so instead of - you will
>>>>>>> have a #
>>>>>>> separator)
>>>>>>> 
>>>>>>> ________________________________________
>>>>>>> From: Chip Childers [chip.childers@sungard.com]
>>>>>>> Sent: Thursday, November 01, 2012 11:15 PM
>>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>> 
>>>>>>> On Wed, Oct 31, 2012 at 2:10 PM, Rohit Yadav
>>>>>>> <ro...@citrix.com>
>>>>>>> wrote:
>>>>>>>> Hi,
>>>>>>>> 
>>>>>>>> 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:
>>>>>>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.gi
>>>>>>>> t; a=c ommit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
>>>>>>>> 
>>>>>>>> Features:
>>>>>>>> - 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
>>>>>>>> 
>>>>>>>> FIXMEs:
>>>>>>>> - 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 python
>>>>>>>> cloudmonkey.py
>>>>>>>> 
>>>>>>>> If you want to have the terminal tool installed; cd tools/cli
>>>>>>>> python setup.py 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=8.8.8.8 internaldns1=10.147.28.6
>>>>>>>> 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
>>>>>>>> networkofferingid= create Pod zoneid= name=Pod1
>>>>> gateway=10.147.28.1
>>>>>>>> netmask=255.255.255.0 startip=10.147.28.220 endip=10.147.28.235
>>>>>>>> create VlanIpRange podid= networkid= gateway=10.147.28.1
>>>>>>>> netmask=255.255.255.0 startip=10.147.28.236 endip=10.147.28.250
>>>>>>>> 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=http://10.147.28.60 create
>>>>>>>> StoragePool zoneid= clusterid= name=NFS1
>>>>>>>> url=nfs://10.147.28.7/export/home/rohit/primary
>>>>>>>> add SecondaryStorage zoneId=
>>>>>>>> url=nfs://10.147.28.7/export/home/rohit/secondary
>>>>>>>> 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.
>>>>>>>> 
>>>>>>>> Regards.
>>>>>>>> PS. Marvin the neglected robot and hipster cloudmonkey should
>>>>>>>> rule the world :D
>>>>>>> 
>>>>>>> Rohit,
>>>>>>> 
>>>>>>> This is really really cool.  It puts the "fun" in managing
>>>>>>> instances from a command line.  I've been testing it against a
>>>>>>> production CloudStack environment, and it's working pretty well.
>>>>>>> 
>>>>>>> If you don't mind, I might hack at the code a bit to fill in some
>>>>>>> gaps that I'm seeing.  First example is that it assumes http,
>>>>>>> which doesn't work in a public deployment where the endpoint is over https.
>>>>>>> 
>>>>>>> -chip
>> 
> 


RE: CLI for CloudStack: cloudmonkey

Posted by Rohit Yadav <ro...@citrix.com>.
Hi Sebastien,

Are you using it from pypi/pip, if so do this:
sudo pip uninstall cloudmonkey
sudo pip install cloudmonkey

I've had this bug on mac osx, fixed it:
https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.git;a=commit;h=36e7a7884efef7c41ac369549b7bdb93e5122110

If it still persists for you, checkout  http://superuser.com/questions/297527/cant-type-the-b-letter-in-python-shell-in-os-x

Let me know if this still fails then.

Regards.

________________________________________
From: Sebastien Goasguen [runseb@gmail.com]
Sent: Thursday, November 08, 2012 5:37 PM
To: cloudstack-dev@incubator.apache.org
Subject: Re: CLI for CloudStack: cloudmonkey

Hi,

I am testing the cli and I have the weirdest issue. When I set the apikey or secretkey, the lower case 'b' letter does not print at the prompt.
So if my keys contain 'b' they don't work..

I tried all the other letters and they work.

Anyone seeing this,

-Sebastien

On Nov 7, 2012, at 7:25 PM, Rohit Yadav <ro...@citrix.com> wrote:

> yes, I think I'd mentioned in the thread or somewhere. Just use pip or easy_install (apt-get install python-setuptools on ubuntu, install python2.6 or above and pip if you don't have it);
>
> sudo pip install cloudmonkey
>
> or sudo easy_install cloudmonkey
>
> now start cloudmonkey:
> $ cloudmonkey
> ...
>
> Will post a blog/screencast this weekend and update doc so everyone can get help on its usage, though it's pretty intuitive.
> ________________________________________
> From: Musayev, Ilya [imusayev@webmd.net]
> Sent: Wednesday, November 07, 2012 11:41 PM
> To: cloudstack-dev@incubator.apache.org
> Subject: RE: CLI for CloudStack: cloudmonkey
>
> Rohit,
>
> Can I get the CLI only without going through the whole source code maven install? Is it part of any RPM?
>
> Thanks
> ilya
>
> -----Original Message-----
> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
> Sent: Monday, November 05, 2012 11:35 AM
> To: cloudstack-dev@incubator.apache.org
> Subject: Re: CLI for CloudStack: cloudmonkey
>
> Checkout latest code. Few changes to share:
>
> - All lowercase now
> - Tab tab over verbs to see list of params for that api, example list users <tab><tab>
> - This needs improvement but help string, using --help: list user --help
> - Caching to speedup runtime
> - Color and Parsing fixes
>
> Last, I'm now able to get the doc strings for each attribute/param, will see this tomorrow.
>
> Need your help, just incase you want to contribute, these are the TODOs:
>
> - search over history
> - fix parsing
> - doc strings for parameters
> - testing for various kinds of apis (I'm able to deploy a zone with this, but needs testing)
> - unicode char monkey, used in prompt may mess up history searching and text display
>
>
> Regards.
>
> On 02-Nov-2012, at 4:58 AM, Edison Su <Ed...@citrix.com> wrote:
>
>>
>>
>>> -----Original Message-----
>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>> Sent: Thursday, November 01, 2012 2:23 PM
>>> To: cloudstack-dev@incubator.apache.org
>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>
>>> After you install the tool, so that cloudmonkey is in your
>>> /usr/local/bin or in $PATH...
>>>
>>> Two ways;
>>> 1. As command line tool, on bash/zsh, use the BNF grammar; <command
>>> line tool
>>> name>:<separator>:<verb>:<separator>:<action>:<separator>:<params>
>>> <command line tool name>={'cloudmonkey'} <separator>={' '}
>>> <verb>={'list', 'create', 'delete', 'update'.... etc.}
>>> <action>={'Users'... etc.} <params>={'listall=#'... etc.} So; $
>>> cloudmonkey list Users
>>
>>
>> Got it, thanks!
>>
>>>
>>> 2. file redirector:
>>>
>>> $ cat test-file:
>>> list Users
>>> list <some other action>
>>> <some verb> <some action>
>>>
>>> $ cloudmonkey < test-file
>>>
>>> Note, I'll change the actions (Users, VirtualMachine etc.) to
>>> lowercase (users, virtualmachine etc.) if that's okay?
>>
>> Please do, nobody wants to type extra keystroke, if it's not necessary.
>>>
>>> Regards.
>>>
>>> ________________________________________
>>> From: Edison Su [Edison.su@citrix.com]
>>> Sent: Friday, November 02, 2012 1:55 AM
>>> To: cloudstack-dev@incubator.apache.org
>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>
>>> Oh, it reminds me that how to use the CLI on the bash command line?
>>> I think admin may want to call cloudstack API in a bash script, how
>>> can I do that?
>>>
>>>> -----Original Message-----
>>>> From: Marcus Sorensen [mailto:shadowsor@gmail.com]
>>>> Sent: Thursday, November 01, 2012 1:11 PM
>>>> To: cloudstack-dev@incubator.apache.org
>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>
>>>> Yes, I look forward to using it instead of local curl calls on the
>>>> command line :-)
>>>>
>>>> On Thu, Nov 1, 2012 at 2:02 PM, Edison Su <Ed...@citrix.com> wrote:
>>>>>
>>>>>
>>>>>> -----Original Message-----
>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>> Sent: Thursday, November 01, 2012 11:45 AM
>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>>
>>>>>> Hi Chip, please go ahead if we can fix the http/s issue. The
>>>>>> connection is based on marvin, I'm sure using CLI we'll find out
>>>>>> more bugs and fix anything in marvin thereby help maintain
>>>>>> marvin->tests and
>>>> CLI.
>>>>>> Please hack that up on tools/marvin/marvin/cloudstackConnection.py
>>>>>>
>>>>>> Edison, yes I'm working on the completedefault, I've figured a
>>>>>> solution to the parsing and tabbing issue to show params for any
>>>>>> api and added more verbs to the grammar like deploy, start etc.
>>>>>> In the new approach doc strings and params needed for an api are
>>>>>> fetched and cached in the class locally to speed up the loading process.
>>>>>> Till it gets committed, cloudmonkey (now) will keep telling the
>>>>>> user what params they are missing until it gets all the required ones.
>>>>>
>>>>> Great! Thanks for your awesome CLI, people will like it.
>>>>>
>>>>>>
>>>>>> One more thing, for people who may not have unicode support the
>>>>>> prompt may appear weird and history search (up, down ) can mess up
>>>>>> the visuals. For example on Mac it appears as a colorful emoji,
>>>>>> but I found that it looks weird on other platforms. Will probably
>>>>>> remove it, or the user can custom set their prompt, using: set
>>>>>> prompt
>>>>>> myprompt>
>>>>>>
>>>>>> Regards.
>>>>>> PS. the set command is full of (fun :)  hacks because of
>>>>>> funtional/generic programming, it basically can set any attribute
>>>>>> on the class, so one can do something like creating something
>>>>>> (var, func). For example set ruler # (so instead of - you will
>>>>>> have a #
>>>>>> separator)
>>>>>>
>>>>>> ________________________________________
>>>>>> From: Chip Childers [chip.childers@sungard.com]
>>>>>> Sent: Thursday, November 01, 2012 11:15 PM
>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>>
>>>>>> On Wed, Oct 31, 2012 at 2:10 PM, Rohit Yadav
>>>>>> <ro...@citrix.com>
>>>>>> wrote:
>>>>>>> Hi,
>>>>>>>
>>>>>>> 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:
>>>>>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.gi
>>>>>>> t; a=c ommit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
>>>>>>>
>>>>>>> Features:
>>>>>>> - 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
>>>>>>>
>>>>>>> FIXMEs:
>>>>>>> - 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 python
>>>>>>> cloudmonkey.py
>>>>>>>
>>>>>>> If you want to have the terminal tool installed; cd tools/cli
>>>>>>> python setup.py 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=8.8.8.8 internaldns1=10.147.28.6
>>>>>>> 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
>>>>>>> networkofferingid= create Pod zoneid= name=Pod1
>>>> gateway=10.147.28.1
>>>>>>> netmask=255.255.255.0 startip=10.147.28.220 endip=10.147.28.235
>>>>>>> create VlanIpRange podid= networkid= gateway=10.147.28.1
>>>>>>> netmask=255.255.255.0 startip=10.147.28.236 endip=10.147.28.250
>>>>>>> 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=http://10.147.28.60 create
>>>>>>> StoragePool zoneid= clusterid= name=NFS1
>>>>>>> url=nfs://10.147.28.7/export/home/rohit/primary
>>>>>>> add SecondaryStorage zoneId=
>>>>>>> url=nfs://10.147.28.7/export/home/rohit/secondary
>>>>>>> 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.
>>>>>>>
>>>>>>> Regards.
>>>>>>> PS. Marvin the neglected robot and hipster cloudmonkey should
>>>>>>> rule the world :D
>>>>>>
>>>>>> Rohit,
>>>>>>
>>>>>> This is really really cool.  It puts the "fun" in managing
>>>>>> instances from a command line.  I've been testing it against a
>>>>>> production CloudStack environment, and it's working pretty well.
>>>>>>
>>>>>> If you don't mind, I might hack at the code a bit to fill in some
>>>>>> gaps that I'm seeing.  First example is that it assumes http,
>>>>>> which doesn't work in a public deployment where the endpoint is over https.
>>>>>>
>>>>>> -chip
>


Re: CLI for CloudStack: cloudmonkey

Posted by Sebastien Goasguen <ru...@gmail.com>.
Hi,

I am testing the cli and I have the weirdest issue. When I set the apikey or secretkey, the lower case 'b' letter does not print at the prompt.
So if my keys contain 'b' they don't work..

I tried all the other letters and they work.

Anyone seeing this,

-Sebastien

On Nov 7, 2012, at 7:25 PM, Rohit Yadav <ro...@citrix.com> wrote:

> yes, I think I'd mentioned in the thread or somewhere. Just use pip or easy_install (apt-get install python-setuptools on ubuntu, install python2.6 or above and pip if you don't have it);
> 
> sudo pip install cloudmonkey
> 
> or sudo easy_install cloudmonkey
> 
> now start cloudmonkey:
> $ cloudmonkey
> ...
> 
> Will post a blog/screencast this weekend and update doc so everyone can get help on its usage, though it's pretty intuitive.
> ________________________________________
> From: Musayev, Ilya [imusayev@webmd.net]
> Sent: Wednesday, November 07, 2012 11:41 PM
> To: cloudstack-dev@incubator.apache.org
> Subject: RE: CLI for CloudStack: cloudmonkey
> 
> Rohit,
> 
> Can I get the CLI only without going through the whole source code maven install? Is it part of any RPM?
> 
> Thanks
> ilya
> 
> -----Original Message-----
> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
> Sent: Monday, November 05, 2012 11:35 AM
> To: cloudstack-dev@incubator.apache.org
> Subject: Re: CLI for CloudStack: cloudmonkey
> 
> Checkout latest code. Few changes to share:
> 
> - All lowercase now
> - Tab tab over verbs to see list of params for that api, example list users <tab><tab>
> - This needs improvement but help string, using --help: list user --help
> - Caching to speedup runtime
> - Color and Parsing fixes
> 
> Last, I'm now able to get the doc strings for each attribute/param, will see this tomorrow.
> 
> Need your help, just incase you want to contribute, these are the TODOs:
> 
> - search over history
> - fix parsing
> - doc strings for parameters
> - testing for various kinds of apis (I'm able to deploy a zone with this, but needs testing)
> - unicode char monkey, used in prompt may mess up history searching and text display
> 
> 
> Regards.
> 
> On 02-Nov-2012, at 4:58 AM, Edison Su <Ed...@citrix.com> wrote:
> 
>> 
>> 
>>> -----Original Message-----
>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>> Sent: Thursday, November 01, 2012 2:23 PM
>>> To: cloudstack-dev@incubator.apache.org
>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>> 
>>> After you install the tool, so that cloudmonkey is in your
>>> /usr/local/bin or in $PATH...
>>> 
>>> Two ways;
>>> 1. As command line tool, on bash/zsh, use the BNF grammar; <command
>>> line tool
>>> name>:<separator>:<verb>:<separator>:<action>:<separator>:<params>
>>> <command line tool name>={'cloudmonkey'} <separator>={' '}
>>> <verb>={'list', 'create', 'delete', 'update'.... etc.}
>>> <action>={'Users'... etc.} <params>={'listall=#'... etc.} So; $
>>> cloudmonkey list Users
>> 
>> 
>> Got it, thanks!
>> 
>>> 
>>> 2. file redirector:
>>> 
>>> $ cat test-file:
>>> list Users
>>> list <some other action>
>>> <some verb> <some action>
>>> 
>>> $ cloudmonkey < test-file
>>> 
>>> Note, I'll change the actions (Users, VirtualMachine etc.) to
>>> lowercase (users, virtualmachine etc.) if that's okay?
>> 
>> Please do, nobody wants to type extra keystroke, if it's not necessary.
>>> 
>>> Regards.
>>> 
>>> ________________________________________
>>> From: Edison Su [Edison.su@citrix.com]
>>> Sent: Friday, November 02, 2012 1:55 AM
>>> To: cloudstack-dev@incubator.apache.org
>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>> 
>>> Oh, it reminds me that how to use the CLI on the bash command line?
>>> I think admin may want to call cloudstack API in a bash script, how
>>> can I do that?
>>> 
>>>> -----Original Message-----
>>>> From: Marcus Sorensen [mailto:shadowsor@gmail.com]
>>>> Sent: Thursday, November 01, 2012 1:11 PM
>>>> To: cloudstack-dev@incubator.apache.org
>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>> 
>>>> Yes, I look forward to using it instead of local curl calls on the
>>>> command line :-)
>>>> 
>>>> On Thu, Nov 1, 2012 at 2:02 PM, Edison Su <Ed...@citrix.com> wrote:
>>>>> 
>>>>> 
>>>>>> -----Original Message-----
>>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>>> Sent: Thursday, November 01, 2012 11:45 AM
>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>> 
>>>>>> Hi Chip, please go ahead if we can fix the http/s issue. The
>>>>>> connection is based on marvin, I'm sure using CLI we'll find out
>>>>>> more bugs and fix anything in marvin thereby help maintain
>>>>>> marvin->tests and
>>>> CLI.
>>>>>> Please hack that up on tools/marvin/marvin/cloudstackConnection.py
>>>>>> 
>>>>>> Edison, yes I'm working on the completedefault, I've figured a
>>>>>> solution to the parsing and tabbing issue to show params for any
>>>>>> api and added more verbs to the grammar like deploy, start etc.
>>>>>> In the new approach doc strings and params needed for an api are
>>>>>> fetched and cached in the class locally to speed up the loading process.
>>>>>> Till it gets committed, cloudmonkey (now) will keep telling the
>>>>>> user what params they are missing until it gets all the required ones.
>>>>> 
>>>>> Great! Thanks for your awesome CLI, people will like it.
>>>>> 
>>>>>> 
>>>>>> One more thing, for people who may not have unicode support the
>>>>>> prompt may appear weird and history search (up, down ) can mess up
>>>>>> the visuals. For example on Mac it appears as a colorful emoji,
>>>>>> but I found that it looks weird on other platforms. Will probably
>>>>>> remove it, or the user can custom set their prompt, using: set
>>>>>> prompt
>>>>>> myprompt>
>>>>>> 
>>>>>> Regards.
>>>>>> PS. the set command is full of (fun :)  hacks because of
>>>>>> funtional/generic programming, it basically can set any attribute
>>>>>> on the class, so one can do something like creating something
>>>>>> (var, func). For example set ruler # (so instead of - you will
>>>>>> have a #
>>>>>> separator)
>>>>>> 
>>>>>> ________________________________________
>>>>>> From: Chip Childers [chip.childers@sungard.com]
>>>>>> Sent: Thursday, November 01, 2012 11:15 PM
>>>>>> To: cloudstack-dev@incubator.apache.org
>>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>> 
>>>>>> On Wed, Oct 31, 2012 at 2:10 PM, Rohit Yadav
>>>>>> <ro...@citrix.com>
>>>>>> wrote:
>>>>>>> Hi,
>>>>>>> 
>>>>>>> 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:
>>>>>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.gi
>>>>>>> t; a=c ommit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
>>>>>>> 
>>>>>>> Features:
>>>>>>> - 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
>>>>>>> 
>>>>>>> FIXMEs:
>>>>>>> - 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 python
>>>>>>> cloudmonkey.py
>>>>>>> 
>>>>>>> If you want to have the terminal tool installed; cd tools/cli
>>>>>>> python setup.py 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=8.8.8.8 internaldns1=10.147.28.6
>>>>>>> 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
>>>>>>> networkofferingid= create Pod zoneid= name=Pod1
>>>> gateway=10.147.28.1
>>>>>>> netmask=255.255.255.0 startip=10.147.28.220 endip=10.147.28.235
>>>>>>> create VlanIpRange podid= networkid= gateway=10.147.28.1
>>>>>>> netmask=255.255.255.0 startip=10.147.28.236 endip=10.147.28.250
>>>>>>> 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=http://10.147.28.60 create
>>>>>>> StoragePool zoneid= clusterid= name=NFS1
>>>>>>> url=nfs://10.147.28.7/export/home/rohit/primary
>>>>>>> add SecondaryStorage zoneId=
>>>>>>> url=nfs://10.147.28.7/export/home/rohit/secondary
>>>>>>> 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.
>>>>>>> 
>>>>>>> Regards.
>>>>>>> PS. Marvin the neglected robot and hipster cloudmonkey should
>>>>>>> rule the world :D
>>>>>> 
>>>>>> Rohit,
>>>>>> 
>>>>>> This is really really cool.  It puts the "fun" in managing
>>>>>> instances from a command line.  I've been testing it against a
>>>>>> production CloudStack environment, and it's working pretty well.
>>>>>> 
>>>>>> If you don't mind, I might hack at the code a bit to fill in some
>>>>>> gaps that I'm seeing.  First example is that it assumes http,
>>>>>> which doesn't work in a public deployment where the endpoint is over https.
>>>>>> 
>>>>>> -chip
> 


RE: CLI for CloudStack: cloudmonkey

Posted by Rohit Yadav <ro...@citrix.com>.
yes, I think I'd mentioned in the thread or somewhere. Just use pip or easy_install (apt-get install python-setuptools on ubuntu, install python2.6 or above and pip if you don't have it);

sudo pip install cloudmonkey

or sudo easy_install cloudmonkey

now start cloudmonkey:
$ cloudmonkey
...

Will post a blog/screencast this weekend and update doc so everyone can get help on its usage, though it's pretty intuitive.
________________________________________
From: Musayev, Ilya [imusayev@webmd.net]
Sent: Wednesday, November 07, 2012 11:41 PM
To: cloudstack-dev@incubator.apache.org
Subject: RE: CLI for CloudStack: cloudmonkey

Rohit,

Can I get the CLI only without going through the whole source code maven install? Is it part of any RPM?

Thanks
ilya

-----Original Message-----
From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
Sent: Monday, November 05, 2012 11:35 AM
To: cloudstack-dev@incubator.apache.org
Subject: Re: CLI for CloudStack: cloudmonkey

Checkout latest code. Few changes to share:

- All lowercase now
- Tab tab over verbs to see list of params for that api, example list users <tab><tab>
- This needs improvement but help string, using --help: list user --help
- Caching to speedup runtime
- Color and Parsing fixes

Last, I'm now able to get the doc strings for each attribute/param, will see this tomorrow.

Need your help, just incase you want to contribute, these are the TODOs:

- search over history
- fix parsing
- doc strings for parameters
- testing for various kinds of apis (I'm able to deploy a zone with this, but needs testing)
- unicode char monkey, used in prompt may mess up history searching and text display


Regards.

On 02-Nov-2012, at 4:58 AM, Edison Su <Ed...@citrix.com> wrote:

>
>
>> -----Original Message-----
>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>> Sent: Thursday, November 01, 2012 2:23 PM
>> To: cloudstack-dev@incubator.apache.org
>> Subject: RE: CLI for CloudStack: cloudmonkey
>>
>> After you install the tool, so that cloudmonkey is in your
>> /usr/local/bin or in $PATH...
>>
>> Two ways;
>> 1. As command line tool, on bash/zsh, use the BNF grammar; <command
>> line tool
>> name>:<separator>:<verb>:<separator>:<action>:<separator>:<params>
>> <command line tool name>={'cloudmonkey'} <separator>={' '}
>> <verb>={'list', 'create', 'delete', 'update'.... etc.}
>> <action>={'Users'... etc.} <params>={'listall=#'... etc.} So; $
>> cloudmonkey list Users
>
>
> Got it, thanks!
>
>>
>> 2. file redirector:
>>
>> $ cat test-file:
>> list Users
>> list <some other action>
>> <some verb> <some action>
>>
>> $ cloudmonkey < test-file
>>
>> Note, I'll change the actions (Users, VirtualMachine etc.) to
>> lowercase (users, virtualmachine etc.) if that's okay?
>
> Please do, nobody wants to type extra keystroke, if it's not necessary.
>>
>> Regards.
>>
>> ________________________________________
>> From: Edison Su [Edison.su@citrix.com]
>> Sent: Friday, November 02, 2012 1:55 AM
>> To: cloudstack-dev@incubator.apache.org
>> Subject: RE: CLI for CloudStack: cloudmonkey
>>
>> Oh, it reminds me that how to use the CLI on the bash command line?
>> I think admin may want to call cloudstack API in a bash script, how
>> can I do that?
>>
>>> -----Original Message-----
>>> From: Marcus Sorensen [mailto:shadowsor@gmail.com]
>>> Sent: Thursday, November 01, 2012 1:11 PM
>>> To: cloudstack-dev@incubator.apache.org
>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>
>>> Yes, I look forward to using it instead of local curl calls on the
>>> command line :-)
>>>
>>> On Thu, Nov 1, 2012 at 2:02 PM, Edison Su <Ed...@citrix.com> wrote:
>>>>
>>>>
>>>>> -----Original Message-----
>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>> Sent: Thursday, November 01, 2012 11:45 AM
>>>>> To: cloudstack-dev@incubator.apache.org
>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>>
>>>>> Hi Chip, please go ahead if we can fix the http/s issue. The
>>>>> connection is based on marvin, I'm sure using CLI we'll find out
>>>>> more bugs and fix anything in marvin thereby help maintain
>>>>> marvin->tests and
>>> CLI.
>>>>> Please hack that up on tools/marvin/marvin/cloudstackConnection.py
>>>>>
>>>>> Edison, yes I'm working on the completedefault, I've figured a
>>>>> solution to the parsing and tabbing issue to show params for any
>>>>> api and added more verbs to the grammar like deploy, start etc.
>>>>> In the new approach doc strings and params needed for an api are
>>>>> fetched and cached in the class locally to speed up the loading process.
>>>>> Till it gets committed, cloudmonkey (now) will keep telling the
>>>>> user what params they are missing until it gets all the required ones.
>>>>
>>>> Great! Thanks for your awesome CLI, people will like it.
>>>>
>>>>>
>>>>> One more thing, for people who may not have unicode support the
>>>>> prompt may appear weird and history search (up, down ) can mess up
>>>>> the visuals. For example on Mac it appears as a colorful emoji,
>>>>> but I found that it looks weird on other platforms. Will probably
>>>>> remove it, or the user can custom set their prompt, using: set
>>>>> prompt
>>>>> myprompt>
>>>>>
>>>>> Regards.
>>>>> PS. the set command is full of (fun :)  hacks because of
>>>>> funtional/generic programming, it basically can set any attribute
>>>>> on the class, so one can do something like creating something
>>>>> (var, func). For example set ruler # (so instead of - you will
>>>>> have a #
>>>>> separator)
>>>>>
>>>>> ________________________________________
>>>>> From: Chip Childers [chip.childers@sungard.com]
>>>>> Sent: Thursday, November 01, 2012 11:15 PM
>>>>> To: cloudstack-dev@incubator.apache.org
>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>>
>>>>> On Wed, Oct 31, 2012 at 2:10 PM, Rohit Yadav
>>>>> <ro...@citrix.com>
>>>>> wrote:
>>>>>> Hi,
>>>>>>
>>>>>> 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:
>>>>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.gi
>>>>>> t; a=c ommit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
>>>>>>
>>>>>> Features:
>>>>>> - 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
>>>>>>
>>>>>> FIXMEs:
>>>>>> - 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 python
>>>>>> cloudmonkey.py
>>>>>>
>>>>>> If you want to have the terminal tool installed; cd tools/cli
>>>>>> python setup.py 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=8.8.8.8 internaldns1=10.147.28.6
>>>>>> 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
>>>>>> networkofferingid= create Pod zoneid= name=Pod1
>>> gateway=10.147.28.1
>>>>>> netmask=255.255.255.0 startip=10.147.28.220 endip=10.147.28.235
>>>>>> create VlanIpRange podid= networkid= gateway=10.147.28.1
>>>>>> netmask=255.255.255.0 startip=10.147.28.236 endip=10.147.28.250
>>>>>> 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=http://10.147.28.60 create
>>>>>> StoragePool zoneid= clusterid= name=NFS1
>>>>>> url=nfs://10.147.28.7/export/home/rohit/primary
>>>>>> add SecondaryStorage zoneId=
>>>>>> url=nfs://10.147.28.7/export/home/rohit/secondary
>>>>>> 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.
>>>>>>
>>>>>> Regards.
>>>>>> PS. Marvin the neglected robot and hipster cloudmonkey should
>>>>>> rule the world :D
>>>>>
>>>>> Rohit,
>>>>>
>>>>> This is really really cool.  It puts the "fun" in managing
>>>>> instances from a command line.  I've been testing it against a
>>>>> production CloudStack environment, and it's working pretty well.
>>>>>
>>>>> If you don't mind, I might hack at the code a bit to fill in some
>>>>> gaps that I'm seeing.  First example is that it assumes http,
>>>>> which doesn't work in a public deployment where the endpoint is over https.
>>>>>
>>>>> -chip


RE: CLI for CloudStack: cloudmonkey

Posted by "Musayev, Ilya" <im...@webmd.net>.
Rohit,

Can I get the CLI only without going through the whole source code maven install? Is it part of any RPM?

Thanks
ilya

-----Original Message-----
From: Rohit Yadav [mailto:rohit.yadav@citrix.com] 
Sent: Monday, November 05, 2012 11:35 AM
To: cloudstack-dev@incubator.apache.org
Subject: Re: CLI for CloudStack: cloudmonkey

Checkout latest code. Few changes to share:

- All lowercase now
- Tab tab over verbs to see list of params for that api, example list users <tab><tab>
- This needs improvement but help string, using --help: list user --help
- Caching to speedup runtime
- Color and Parsing fixes

Last, I'm now able to get the doc strings for each attribute/param, will see this tomorrow.

Need your help, just incase you want to contribute, these are the TODOs:

- search over history
- fix parsing
- doc strings for parameters
- testing for various kinds of apis (I'm able to deploy a zone with this, but needs testing)
- unicode char monkey, used in prompt may mess up history searching and text display


Regards.

On 02-Nov-2012, at 4:58 AM, Edison Su <Ed...@citrix.com> wrote:

> 
> 
>> -----Original Message-----
>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>> Sent: Thursday, November 01, 2012 2:23 PM
>> To: cloudstack-dev@incubator.apache.org
>> Subject: RE: CLI for CloudStack: cloudmonkey
>> 
>> After you install the tool, so that cloudmonkey is in your 
>> /usr/local/bin or in $PATH...
>> 
>> Two ways;
>> 1. As command line tool, on bash/zsh, use the BNF grammar; <command 
>> line tool
>> name>:<separator>:<verb>:<separator>:<action>:<separator>:<params>
>> <command line tool name>={'cloudmonkey'} <separator>={' '} 
>> <verb>={'list', 'create', 'delete', 'update'.... etc.} 
>> <action>={'Users'... etc.} <params>={'listall=#'... etc.} So; $ 
>> cloudmonkey list Users
> 
> 
> Got it, thanks!
> 
>> 
>> 2. file redirector:
>> 
>> $ cat test-file:
>> list Users
>> list <some other action>
>> <some verb> <some action>
>> 
>> $ cloudmonkey < test-file
>> 
>> Note, I'll change the actions (Users, VirtualMachine etc.) to 
>> lowercase (users, virtualmachine etc.) if that's okay?
> 
> Please do, nobody wants to type extra keystroke, if it's not necessary.
>> 
>> Regards.
>> 
>> ________________________________________
>> From: Edison Su [Edison.su@citrix.com]
>> Sent: Friday, November 02, 2012 1:55 AM
>> To: cloudstack-dev@incubator.apache.org
>> Subject: RE: CLI for CloudStack: cloudmonkey
>> 
>> Oh, it reminds me that how to use the CLI on the bash command line?
>> I think admin may want to call cloudstack API in a bash script, how 
>> can I do that?
>> 
>>> -----Original Message-----
>>> From: Marcus Sorensen [mailto:shadowsor@gmail.com]
>>> Sent: Thursday, November 01, 2012 1:11 PM
>>> To: cloudstack-dev@incubator.apache.org
>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>> 
>>> Yes, I look forward to using it instead of local curl calls on the 
>>> command line :-)
>>> 
>>> On Thu, Nov 1, 2012 at 2:02 PM, Edison Su <Ed...@citrix.com> wrote:
>>>> 
>>>> 
>>>>> -----Original Message-----
>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>> Sent: Thursday, November 01, 2012 11:45 AM
>>>>> To: cloudstack-dev@incubator.apache.org
>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>> 
>>>>> Hi Chip, please go ahead if we can fix the http/s issue. The 
>>>>> connection is based on marvin, I'm sure using CLI we'll find out 
>>>>> more bugs and fix anything in marvin thereby help maintain
>>>>> marvin->tests and
>>> CLI.
>>>>> Please hack that up on tools/marvin/marvin/cloudstackConnection.py
>>>>> 
>>>>> Edison, yes I'm working on the completedefault, I've figured a 
>>>>> solution to the parsing and tabbing issue to show params for any 
>>>>> api and added more verbs to the grammar like deploy, start etc.
>>>>> In the new approach doc strings and params needed for an api are 
>>>>> fetched and cached in the class locally to speed up the loading process.
>>>>> Till it gets committed, cloudmonkey (now) will keep telling the 
>>>>> user what params they are missing until it gets all the required ones.
>>>> 
>>>> Great! Thanks for your awesome CLI, people will like it.
>>>> 
>>>>> 
>>>>> One more thing, for people who may not have unicode support the 
>>>>> prompt may appear weird and history search (up, down ) can mess up 
>>>>> the visuals. For example on Mac it appears as a colorful emoji, 
>>>>> but I found that it looks weird on other platforms. Will probably 
>>>>> remove it, or the user can custom set their prompt, using: set 
>>>>> prompt
>>>>> myprompt>
>>>>> 
>>>>> Regards.
>>>>> PS. the set command is full of (fun :)  hacks because of 
>>>>> funtional/generic programming, it basically can set any attribute 
>>>>> on the class, so one can do something like creating something 
>>>>> (var, func). For example set ruler # (so instead of - you will 
>>>>> have a #
>>>>> separator)
>>>>> 
>>>>> ________________________________________
>>>>> From: Chip Childers [chip.childers@sungard.com]
>>>>> Sent: Thursday, November 01, 2012 11:15 PM
>>>>> To: cloudstack-dev@incubator.apache.org
>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>> 
>>>>> On Wed, Oct 31, 2012 at 2:10 PM, Rohit Yadav 
>>>>> <ro...@citrix.com>
>>>>> wrote:
>>>>>> Hi,
>>>>>> 
>>>>>> 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:
>>>>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.gi
>>>>>> t; a=c ommit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
>>>>>> 
>>>>>> Features:
>>>>>> - 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
>>>>>> 
>>>>>> FIXMEs:
>>>>>> - 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 python 
>>>>>> cloudmonkey.py
>>>>>> 
>>>>>> If you want to have the terminal tool installed; cd tools/cli 
>>>>>> python setup.py 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=8.8.8.8 internaldns1=10.147.28.6
>>>>>> 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
>>>>>> networkofferingid= create Pod zoneid= name=Pod1
>>> gateway=10.147.28.1
>>>>>> netmask=255.255.255.0 startip=10.147.28.220 endip=10.147.28.235 
>>>>>> create VlanIpRange podid= networkid= gateway=10.147.28.1
>>>>>> netmask=255.255.255.0 startip=10.147.28.236 endip=10.147.28.250 
>>>>>> 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=http://10.147.28.60 create 
>>>>>> StoragePool zoneid= clusterid= name=NFS1 
>>>>>> url=nfs://10.147.28.7/export/home/rohit/primary
>>>>>> add SecondaryStorage zoneId=
>>>>>> url=nfs://10.147.28.7/export/home/rohit/secondary
>>>>>> 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.
>>>>>> 
>>>>>> Regards.
>>>>>> PS. Marvin the neglected robot and hipster cloudmonkey should 
>>>>>> rule the world :D
>>>>> 
>>>>> Rohit,
>>>>> 
>>>>> This is really really cool.  It puts the "fun" in managing 
>>>>> instances from a command line.  I've been testing it against a 
>>>>> production CloudStack environment, and it's working pretty well.
>>>>> 
>>>>> If you don't mind, I might hack at the code a bit to fill in some 
>>>>> gaps that I'm seeing.  First example is that it assumes http, 
>>>>> which doesn't work in a public deployment where the endpoint is over https.
>>>>> 
>>>>> -chip


Re: CLI for CloudStack: cloudmonkey

Posted by Rohit Yadav <ro...@citrix.com>.
Checkout latest code. Few changes to share:

- All lowercase now
- Tab tab over verbs to see list of params for that api, example list users <tab><tab>
- This needs improvement but help string, using --help: list user --help
- Caching to speedup runtime
- Color and Parsing fixes

Last, I'm now able to get the doc strings for each attribute/param, will see this tomorrow.

Need your help, just incase you want to contribute, these are the TODOs:

- search over history
- fix parsing
- doc strings for parameters
- testing for various kinds of apis (I'm able to deploy a zone with this, but needs testing)
- unicode char monkey, used in prompt may mess up history searching and text display


Regards.

On 02-Nov-2012, at 4:58 AM, Edison Su <Ed...@citrix.com> wrote:

> 
> 
>> -----Original Message-----
>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>> Sent: Thursday, November 01, 2012 2:23 PM
>> To: cloudstack-dev@incubator.apache.org
>> Subject: RE: CLI for CloudStack: cloudmonkey
>> 
>> After you install the tool, so that cloudmonkey is in your /usr/local/bin or in
>> $PATH...
>> 
>> Two ways;
>> 1. As command line tool, on bash/zsh, use the BNF grammar; <command line
>> tool
>> name>:<separator>:<verb>:<separator>:<action>:<separator>:<params>
>> <command line tool name>={'cloudmonkey'} <separator>={' '} <verb>={'list',
>> 'create', 'delete', 'update'.... etc.} <action>={'Users'... etc.}
>> <params>={'listall=#'... etc.} So; $ cloudmonkey list Users
> 
> 
> Got it, thanks!
> 
>> 
>> 2. file redirector:
>> 
>> $ cat test-file:
>> list Users
>> list <some other action>
>> <some verb> <some action>
>> 
>> $ cloudmonkey < test-file
>> 
>> Note, I'll change the actions (Users, VirtualMachine etc.) to lowercase (users,
>> virtualmachine etc.) if that's okay?
> 
> Please do, nobody wants to type extra keystroke, if it's not necessary.
>> 
>> Regards.
>> 
>> ________________________________________
>> From: Edison Su [Edison.su@citrix.com]
>> Sent: Friday, November 02, 2012 1:55 AM
>> To: cloudstack-dev@incubator.apache.org
>> Subject: RE: CLI for CloudStack: cloudmonkey
>> 
>> Oh, it reminds me that how to use the CLI on the bash command line?
>> I think admin may want to call cloudstack API in a bash script, how can I do
>> that?
>> 
>>> -----Original Message-----
>>> From: Marcus Sorensen [mailto:shadowsor@gmail.com]
>>> Sent: Thursday, November 01, 2012 1:11 PM
>>> To: cloudstack-dev@incubator.apache.org
>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>> 
>>> Yes, I look forward to using it instead of local curl calls on the
>>> command line :-)
>>> 
>>> On Thu, Nov 1, 2012 at 2:02 PM, Edison Su <Ed...@citrix.com> wrote:
>>>> 
>>>> 
>>>>> -----Original Message-----
>>>>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>>>>> Sent: Thursday, November 01, 2012 11:45 AM
>>>>> To: cloudstack-dev@incubator.apache.org
>>>>> Subject: RE: CLI for CloudStack: cloudmonkey
>>>>> 
>>>>> Hi Chip, please go ahead if we can fix the http/s issue. The
>>>>> connection is based on marvin, I'm sure using CLI we'll find out
>>>>> more bugs and fix anything in marvin thereby help maintain
>>>>> marvin->tests and
>>> CLI.
>>>>> Please hack that up on tools/marvin/marvin/cloudstackConnection.py
>>>>> 
>>>>> Edison, yes I'm working on the completedefault, I've figured a
>>>>> solution to the parsing and tabbing issue to show params for any
>>>>> api and added more verbs to the grammar like deploy, start etc.
>>>>> In the new approach doc strings and params needed for an api are
>>>>> fetched and cached in the class locally to speed up the loading process.
>>>>> Till it gets committed, cloudmonkey (now) will keep telling the
>>>>> user what params they are missing until it gets all the required ones.
>>>> 
>>>> Great! Thanks for your awesome CLI, people will like it.
>>>> 
>>>>> 
>>>>> One more thing, for people who may not have unicode support the
>>>>> prompt may appear weird and history search (up, down ) can mess up
>>>>> the visuals. For example on Mac it appears as a colorful emoji, but
>>>>> I found that it looks weird on other platforms. Will probably
>>>>> remove it, or the user can custom set their prompt, using: set
>>>>> prompt
>>>>> myprompt>
>>>>> 
>>>>> Regards.
>>>>> PS. the set command is full of (fun :)  hacks because of
>>>>> funtional/generic programming, it basically can set any attribute
>>>>> on the class, so one can do something like creating something (var,
>>>>> func). For example set ruler # (so instead of - you will have a #
>>>>> separator)
>>>>> 
>>>>> ________________________________________
>>>>> From: Chip Childers [chip.childers@sungard.com]
>>>>> Sent: Thursday, November 01, 2012 11:15 PM
>>>>> To: cloudstack-dev@incubator.apache.org
>>>>> Subject: Re: CLI for CloudStack: cloudmonkey
>>>>> 
>>>>> On Wed, Oct 31, 2012 at 2:10 PM, Rohit Yadav
>>>>> <ro...@citrix.com>
>>>>> wrote:
>>>>>> Hi,
>>>>>> 
>>>>>> 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:
>>>>>> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.gi
>>>>>> t; a=c ommit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
>>>>>> 
>>>>>> Features:
>>>>>> - 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
>>>>>> 
>>>>>> FIXMEs:
>>>>>> - 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 python
>>>>>> cloudmonkey.py
>>>>>> 
>>>>>> If you want to have the terminal tool installed; cd tools/cli
>>>>>> python setup.py 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=8.8.8.8 internaldns1=10.147.28.6
>>>>>> 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
>>>>>> networkofferingid= create Pod zoneid= name=Pod1
>>> gateway=10.147.28.1
>>>>>> netmask=255.255.255.0 startip=10.147.28.220 endip=10.147.28.235
>>>>>> create VlanIpRange podid= networkid= gateway=10.147.28.1
>>>>>> netmask=255.255.255.0 startip=10.147.28.236 endip=10.147.28.250
>>>>>> 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=http://10.147.28.60 create
>>>>>> StoragePool zoneid= clusterid= name=NFS1
>>>>>> url=nfs://10.147.28.7/export/home/rohit/primary
>>>>>> add SecondaryStorage zoneId=
>>>>>> url=nfs://10.147.28.7/export/home/rohit/secondary
>>>>>> 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.
>>>>>> 
>>>>>> Regards.
>>>>>> PS. Marvin the neglected robot and hipster cloudmonkey should
>>>>>> rule the world :D
>>>>> 
>>>>> Rohit,
>>>>> 
>>>>> This is really really cool.  It puts the "fun" in managing
>>>>> instances from a command line.  I've been testing it against a
>>>>> production CloudStack environment, and it's working pretty well.
>>>>> 
>>>>> If you don't mind, I might hack at the code a bit to fill in some
>>>>> gaps that I'm seeing.  First example is that it assumes http, which
>>>>> doesn't work in a public deployment where the endpoint is over https.
>>>>> 
>>>>> -chip


RE: CLI for CloudStack: cloudmonkey

Posted by Edison Su <Ed...@citrix.com>.

> -----Original Message-----
> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
> Sent: Thursday, November 01, 2012 2:23 PM
> To: cloudstack-dev@incubator.apache.org
> Subject: RE: CLI for CloudStack: cloudmonkey
> 
> After you install the tool, so that cloudmonkey is in your /usr/local/bin or in
> $PATH...
> 
> Two ways;
> 1. As command line tool, on bash/zsh, use the BNF grammar; <command line
> tool
> name>:<separator>:<verb>:<separator>:<action>:<separator>:<params>
> <command line tool name>={'cloudmonkey'} <separator>={' '} <verb>={'list',
> 'create', 'delete', 'update'.... etc.} <action>={'Users'... etc.}
> <params>={'listall=#'... etc.} So; $ cloudmonkey list Users


Got it, thanks!

> 
> 2. file redirector:
> 
> $ cat test-file:
> list Users
> list <some other action>
> <some verb> <some action>
> 
> $ cloudmonkey < test-file
> 
> Note, I'll change the actions (Users, VirtualMachine etc.) to lowercase (users,
> virtualmachine etc.) if that's okay?

Please do, nobody wants to type extra keystroke, if it's not necessary. 
> 
> Regards.
> 
> ________________________________________
> From: Edison Su [Edison.su@citrix.com]
> Sent: Friday, November 02, 2012 1:55 AM
> To: cloudstack-dev@incubator.apache.org
> Subject: RE: CLI for CloudStack: cloudmonkey
> 
> Oh, it reminds me that how to use the CLI on the bash command line?
> I think admin may want to call cloudstack API in a bash script, how can I do
> that?
> 
> > -----Original Message-----
> > From: Marcus Sorensen [mailto:shadowsor@gmail.com]
> > Sent: Thursday, November 01, 2012 1:11 PM
> > To: cloudstack-dev@incubator.apache.org
> > Subject: Re: CLI for CloudStack: cloudmonkey
> >
> > Yes, I look forward to using it instead of local curl calls on the
> > command line :-)
> >
> > On Thu, Nov 1, 2012 at 2:02 PM, Edison Su <Ed...@citrix.com> wrote:
> > >
> > >
> > >> -----Original Message-----
> > >> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
> > >> Sent: Thursday, November 01, 2012 11:45 AM
> > >> To: cloudstack-dev@incubator.apache.org
> > >> Subject: RE: CLI for CloudStack: cloudmonkey
> > >>
> > >> Hi Chip, please go ahead if we can fix the http/s issue. The
> > >> connection is based on marvin, I'm sure using CLI we'll find out
> > >> more bugs and fix anything in marvin thereby help maintain
> > >> marvin->tests and
> > CLI.
> > >> Please hack that up on tools/marvin/marvin/cloudstackConnection.py
> > >>
> > >> Edison, yes I'm working on the completedefault, I've figured a
> > >> solution to the parsing and tabbing issue to show params for any
> > >> api and added more verbs to the grammar like deploy, start etc.
> > >> In the new approach doc strings and params needed for an api are
> > >> fetched and cached in the class locally to speed up the loading process.
> > >> Till it gets committed, cloudmonkey (now) will keep telling the
> > >> user what params they are missing until it gets all the required ones.
> > >
> > > Great! Thanks for your awesome CLI, people will like it.
> > >
> > >>
> > >> One more thing, for people who may not have unicode support the
> > >> prompt may appear weird and history search (up, down ) can mess up
> > >> the visuals. For example on Mac it appears as a colorful emoji, but
> > >> I found that it looks weird on other platforms. Will probably
> > >> remove it, or the user can custom set their prompt, using: set
> > >> prompt
> > >> myprompt>
> > >>
> > >> Regards.
> > >> PS. the set command is full of (fun :)  hacks because of
> > >> funtional/generic programming, it basically can set any attribute
> > >> on the class, so one can do something like creating something (var,
> > >> func). For example set ruler # (so instead of - you will have a #
> > >> separator)
> > >>
> > >> ________________________________________
> > >> From: Chip Childers [chip.childers@sungard.com]
> > >> Sent: Thursday, November 01, 2012 11:15 PM
> > >> To: cloudstack-dev@incubator.apache.org
> > >> Subject: Re: CLI for CloudStack: cloudmonkey
> > >>
> > >> On Wed, Oct 31, 2012 at 2:10 PM, Rohit Yadav
> > >> <ro...@citrix.com>
> > >> wrote:
> > >> > Hi,
> > >> >
> > >> > 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:
> > >> > https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.gi
> > >> > t; a=c ommit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
> > >> >
> > >> > Features:
> > >> > - 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
> > >> >
> > >> > FIXMEs:
> > >> > - 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 python
> > >> > cloudmonkey.py
> > >> >
> > >> > If you want to have the terminal tool installed; cd tools/cli
> > >> > python setup.py 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=8.8.8.8 internaldns1=10.147.28.6
> > >> > 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
> > >> > networkofferingid= create Pod zoneid= name=Pod1
> > gateway=10.147.28.1
> > >> > netmask=255.255.255.0 startip=10.147.28.220 endip=10.147.28.235
> > >> > create VlanIpRange podid= networkid= gateway=10.147.28.1
> > >> > netmask=255.255.255.0 startip=10.147.28.236 endip=10.147.28.250
> > >> > 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=http://10.147.28.60 create
> > >> > StoragePool zoneid= clusterid= name=NFS1
> > >> > url=nfs://10.147.28.7/export/home/rohit/primary
> > >> > add SecondaryStorage zoneId=
> > >> > url=nfs://10.147.28.7/export/home/rohit/secondary
> > >> > 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.
> > >> >
> > >> > Regards.
> > >> > PS. Marvin the neglected robot and hipster cloudmonkey should
> > >> > rule the world :D
> > >>
> > >> Rohit,
> > >>
> > >> This is really really cool.  It puts the "fun" in managing
> > >> instances from a command line.  I've been testing it against a
> > >> production CloudStack environment, and it's working pretty well.
> > >>
> > >> If you don't mind, I might hack at the code a bit to fill in some
> > >> gaps that I'm seeing.  First example is that it assumes http, which
> > >> doesn't work in a public deployment where the endpoint is over https.
> > >>
> > >> -chip

RE: CLI for CloudStack: cloudmonkey

Posted by Rohit Yadav <ro...@citrix.com>.
After you install the tool, so that cloudmonkey is in your /usr/local/bin or in $PATH...

Two ways;
1. As command line tool, on bash/zsh, use the BNF grammar;
<command line tool name>:<separator>:<verb>:<separator>:<action>:<separator>:<params>
<command line tool name>={'cloudmonkey'}
<separator>={' '}
<verb>={'list', 'create', 'delete', 'update'.... etc.}
<action>={'Users'... etc.}
<params>={'listall=#'... etc.}
So;
$ cloudmonkey list Users

2. file redirector:

$ cat test-file:
list Users
list <some other action>
<some verb> <some action>

$ cloudmonkey < test-file

Note, I'll change the actions (Users, VirtualMachine etc.) to lowercase (users, virtualmachine etc.) if that's okay?

Regards.

________________________________________
From: Edison Su [Edison.su@citrix.com]
Sent: Friday, November 02, 2012 1:55 AM
To: cloudstack-dev@incubator.apache.org
Subject: RE: CLI for CloudStack: cloudmonkey

Oh, it reminds me that how to use the CLI on the bash command line?
I think admin may want to call cloudstack API in a bash script, how can I do that?

> -----Original Message-----
> From: Marcus Sorensen [mailto:shadowsor@gmail.com]
> Sent: Thursday, November 01, 2012 1:11 PM
> To: cloudstack-dev@incubator.apache.org
> Subject: Re: CLI for CloudStack: cloudmonkey
>
> Yes, I look forward to using it instead of local curl calls on the command line :-)
>
> On Thu, Nov 1, 2012 at 2:02 PM, Edison Su <Ed...@citrix.com> wrote:
> >
> >
> >> -----Original Message-----
> >> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
> >> Sent: Thursday, November 01, 2012 11:45 AM
> >> To: cloudstack-dev@incubator.apache.org
> >> Subject: RE: CLI for CloudStack: cloudmonkey
> >>
> >> Hi Chip, please go ahead if we can fix the http/s issue. The
> >> connection is based on marvin, I'm sure using CLI we'll find out more
> >> bugs and fix anything in marvin thereby help maintain marvin->tests and
> CLI.
> >> Please hack that up on tools/marvin/marvin/cloudstackConnection.py
> >>
> >> Edison, yes I'm working on the completedefault, I've figured a
> >> solution to the parsing and tabbing issue to show params for any api
> >> and added more verbs to the grammar like deploy, start etc.
> >> In the new approach doc strings and params needed for an api are
> >> fetched and cached in the class locally to speed up the loading process.
> >> Till it gets committed, cloudmonkey (now) will keep telling the user
> >> what params they are missing until it gets all the required ones.
> >
> > Great! Thanks for your awesome CLI, people will like it.
> >
> >>
> >> One more thing, for people who may not have unicode support the
> >> prompt may appear weird and history search (up, down ) can mess up
> >> the visuals. For example on Mac it appears as a colorful emoji, but I
> >> found that it looks weird on other platforms. Will probably remove
> >> it, or the user can custom set their prompt, using: set prompt
> >> myprompt>
> >>
> >> Regards.
> >> PS. the set command is full of (fun :)  hacks because of
> >> funtional/generic programming, it basically can set any attribute on
> >> the class, so one can do something like creating something (var,
> >> func). For example set ruler # (so instead of - you will have a #
> >> separator)
> >>
> >> ________________________________________
> >> From: Chip Childers [chip.childers@sungard.com]
> >> Sent: Thursday, November 01, 2012 11:15 PM
> >> To: cloudstack-dev@incubator.apache.org
> >> Subject: Re: CLI for CloudStack: cloudmonkey
> >>
> >> On Wed, Oct 31, 2012 at 2:10 PM, Rohit Yadav <ro...@citrix.com>
> >> wrote:
> >> > Hi,
> >> >
> >> > 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:
> >> > https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.git;
> >> > a=c ommit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
> >> >
> >> > Features:
> >> > - 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
> >> >
> >> > FIXMEs:
> >> > - 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 python cloudmonkey.py
> >> >
> >> > If you want to have the terminal tool installed; cd tools/cli
> >> > python setup.py 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=8.8.8.8 internaldns1=10.147.28.6 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
> >> > networkofferingid= create Pod zoneid= name=Pod1
> gateway=10.147.28.1
> >> > netmask=255.255.255.0 startip=10.147.28.220 endip=10.147.28.235
> >> > create VlanIpRange podid= networkid= gateway=10.147.28.1
> >> > netmask=255.255.255.0 startip=10.147.28.236 endip=10.147.28.250
> >> > 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=http://10.147.28.60 create
> >> > StoragePool zoneid= clusterid= name=NFS1
> >> > url=nfs://10.147.28.7/export/home/rohit/primary
> >> > add SecondaryStorage zoneId=
> >> > url=nfs://10.147.28.7/export/home/rohit/secondary
> >> > 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.
> >> >
> >> > Regards.
> >> > PS. Marvin the neglected robot and hipster cloudmonkey should rule
> >> > the world :D
> >>
> >> Rohit,
> >>
> >> This is really really cool.  It puts the "fun" in managing instances
> >> from a command line.  I've been testing it against a production
> >> CloudStack environment, and it's working pretty well.
> >>
> >> If you don't mind, I might hack at the code a bit to fill in some
> >> gaps that I'm seeing.  First example is that it assumes http, which
> >> doesn't work in a public deployment where the endpoint is over https.
> >>
> >> -chip

RE: CLI for CloudStack: cloudmonkey

Posted by Edison Su <Ed...@citrix.com>.
Oh, it reminds me that how to use the CLI on the bash command line?
I think admin may want to call cloudstack API in a bash script, how can I do that?

> -----Original Message-----
> From: Marcus Sorensen [mailto:shadowsor@gmail.com]
> Sent: Thursday, November 01, 2012 1:11 PM
> To: cloudstack-dev@incubator.apache.org
> Subject: Re: CLI for CloudStack: cloudmonkey
> 
> Yes, I look forward to using it instead of local curl calls on the command line :-)
> 
> On Thu, Nov 1, 2012 at 2:02 PM, Edison Su <Ed...@citrix.com> wrote:
> >
> >
> >> -----Original Message-----
> >> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
> >> Sent: Thursday, November 01, 2012 11:45 AM
> >> To: cloudstack-dev@incubator.apache.org
> >> Subject: RE: CLI for CloudStack: cloudmonkey
> >>
> >> Hi Chip, please go ahead if we can fix the http/s issue. The
> >> connection is based on marvin, I'm sure using CLI we'll find out more
> >> bugs and fix anything in marvin thereby help maintain marvin->tests and
> CLI.
> >> Please hack that up on tools/marvin/marvin/cloudstackConnection.py
> >>
> >> Edison, yes I'm working on the completedefault, I've figured a
> >> solution to the parsing and tabbing issue to show params for any api
> >> and added more verbs to the grammar like deploy, start etc.
> >> In the new approach doc strings and params needed for an api are
> >> fetched and cached in the class locally to speed up the loading process.
> >> Till it gets committed, cloudmonkey (now) will keep telling the user
> >> what params they are missing until it gets all the required ones.
> >
> > Great! Thanks for your awesome CLI, people will like it.
> >
> >>
> >> One more thing, for people who may not have unicode support the
> >> prompt may appear weird and history search (up, down ) can mess up
> >> the visuals. For example on Mac it appears as a colorful emoji, but I
> >> found that it looks weird on other platforms. Will probably remove
> >> it, or the user can custom set their prompt, using: set prompt
> >> myprompt>
> >>
> >> Regards.
> >> PS. the set command is full of (fun :)  hacks because of
> >> funtional/generic programming, it basically can set any attribute on
> >> the class, so one can do something like creating something (var,
> >> func). For example set ruler # (so instead of - you will have a #
> >> separator)
> >>
> >> ________________________________________
> >> From: Chip Childers [chip.childers@sungard.com]
> >> Sent: Thursday, November 01, 2012 11:15 PM
> >> To: cloudstack-dev@incubator.apache.org
> >> Subject: Re: CLI for CloudStack: cloudmonkey
> >>
> >> On Wed, Oct 31, 2012 at 2:10 PM, Rohit Yadav <ro...@citrix.com>
> >> wrote:
> >> > Hi,
> >> >
> >> > 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:
> >> > https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.git;
> >> > a=c ommit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
> >> >
> >> > Features:
> >> > - 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
> >> >
> >> > FIXMEs:
> >> > - 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 python cloudmonkey.py
> >> >
> >> > If you want to have the terminal tool installed; cd tools/cli
> >> > python setup.py 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=8.8.8.8 internaldns1=10.147.28.6 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
> >> > networkofferingid= create Pod zoneid= name=Pod1
> gateway=10.147.28.1
> >> > netmask=255.255.255.0 startip=10.147.28.220 endip=10.147.28.235
> >> > create VlanIpRange podid= networkid= gateway=10.147.28.1
> >> > netmask=255.255.255.0 startip=10.147.28.236 endip=10.147.28.250
> >> > 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=http://10.147.28.60 create
> >> > StoragePool zoneid= clusterid= name=NFS1
> >> > url=nfs://10.147.28.7/export/home/rohit/primary
> >> > add SecondaryStorage zoneId=
> >> > url=nfs://10.147.28.7/export/home/rohit/secondary
> >> > 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.
> >> >
> >> > Regards.
> >> > PS. Marvin the neglected robot and hipster cloudmonkey should rule
> >> > the world :D
> >>
> >> Rohit,
> >>
> >> This is really really cool.  It puts the "fun" in managing instances
> >> from a command line.  I've been testing it against a production
> >> CloudStack environment, and it's working pretty well.
> >>
> >> If you don't mind, I might hack at the code a bit to fill in some
> >> gaps that I'm seeing.  First example is that it assumes http, which
> >> doesn't work in a public deployment where the endpoint is over https.
> >>
> >> -chip

Re: CLI for CloudStack: cloudmonkey

Posted by Marcus Sorensen <sh...@gmail.com>.
Yes, I look forward to using it instead of local curl calls on the
command line :-)

On Thu, Nov 1, 2012 at 2:02 PM, Edison Su <Ed...@citrix.com> wrote:
>
>
>> -----Original Message-----
>> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
>> Sent: Thursday, November 01, 2012 11:45 AM
>> To: cloudstack-dev@incubator.apache.org
>> Subject: RE: CLI for CloudStack: cloudmonkey
>>
>> Hi Chip, please go ahead if we can fix the http/s issue. The connection is
>> based on marvin, I'm sure using CLI we'll find out more bugs and fix anything
>> in marvin thereby help maintain marvin->tests and CLI.
>> Please hack that up on tools/marvin/marvin/cloudstackConnection.py
>>
>> Edison, yes I'm working on the completedefault, I've figured a solution to the
>> parsing and tabbing issue to show params for any api and added more verbs
>> to the grammar like deploy, start etc.
>> In the new approach doc strings and params needed for an api are fetched
>> and cached in the class locally to speed up the loading process.
>> Till it gets committed, cloudmonkey (now) will keep telling the user what
>> params they are missing until it gets all the required ones.
>
> Great! Thanks for your awesome CLI, people will like it.
>
>>
>> One more thing, for people who may not have unicode support the prompt
>> may appear weird and history search (up, down ) can mess up the visuals. For
>> example on Mac it appears as a colorful emoji, but I found that it looks weird
>> on other platforms. Will probably remove it, or the user can custom set their
>> prompt, using: set prompt myprompt>
>>
>> Regards.
>> PS. the set command is full of (fun :)  hacks because of funtional/generic
>> programming, it basically can set any attribute on the class, so one can do
>> something like creating something (var, func). For example set ruler # (so
>> instead of - you will have a # separator)
>>
>> ________________________________________
>> From: Chip Childers [chip.childers@sungard.com]
>> Sent: Thursday, November 01, 2012 11:15 PM
>> To: cloudstack-dev@incubator.apache.org
>> Subject: Re: CLI for CloudStack: cloudmonkey
>>
>> On Wed, Oct 31, 2012 at 2:10 PM, Rohit Yadav <ro...@citrix.com>
>> wrote:
>> > Hi,
>> >
>> > 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:
>> > https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.git;a=c
>> > ommit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
>> >
>> > Features:
>> > - 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
>> >
>> > FIXMEs:
>> > - 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 python cloudmonkey.py
>> >
>> > If you want to have the terminal tool installed; cd tools/cli python
>> > setup.py 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=8.8.8.8 internaldns1=10.147.28.6 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
>> > networkofferingid= create Pod zoneid= name=Pod1 gateway=10.147.28.1
>> > netmask=255.255.255.0 startip=10.147.28.220 endip=10.147.28.235 create
>> > VlanIpRange podid= networkid= gateway=10.147.28.1
>> > netmask=255.255.255.0 startip=10.147.28.236 endip=10.147.28.250
>> > 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=http://10.147.28.60 create
>> > StoragePool zoneid= clusterid= name=NFS1
>> > url=nfs://10.147.28.7/export/home/rohit/primary
>> > add SecondaryStorage zoneId=
>> > url=nfs://10.147.28.7/export/home/rohit/secondary
>> > 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.
>> >
>> > Regards.
>> > PS. Marvin the neglected robot and hipster cloudmonkey should rule the
>> > world :D
>>
>> Rohit,
>>
>> This is really really cool.  It puts the "fun" in managing instances from a
>> command line.  I've been testing it against a production CloudStack
>> environment, and it's working pretty well.
>>
>> If you don't mind, I might hack at the code a bit to fill in some gaps that I'm
>> seeing.  First example is that it assumes http, which doesn't work in a public
>> deployment where the endpoint is over https.
>>
>> -chip

RE: CLI for CloudStack: cloudmonkey

Posted by Edison Su <Ed...@citrix.com>.

> -----Original Message-----
> From: Rohit Yadav [mailto:rohit.yadav@citrix.com]
> Sent: Thursday, November 01, 2012 11:45 AM
> To: cloudstack-dev@incubator.apache.org
> Subject: RE: CLI for CloudStack: cloudmonkey
> 
> Hi Chip, please go ahead if we can fix the http/s issue. The connection is
> based on marvin, I'm sure using CLI we'll find out more bugs and fix anything
> in marvin thereby help maintain marvin->tests and CLI.
> Please hack that up on tools/marvin/marvin/cloudstackConnection.py
> 
> Edison, yes I'm working on the completedefault, I've figured a solution to the
> parsing and tabbing issue to show params for any api and added more verbs
> to the grammar like deploy, start etc.
> In the new approach doc strings and params needed for an api are fetched
> and cached in the class locally to speed up the loading process.
> Till it gets committed, cloudmonkey (now) will keep telling the user what
> params they are missing until it gets all the required ones.

Great! Thanks for your awesome CLI, people will like it.

> 
> One more thing, for people who may not have unicode support the prompt
> may appear weird and history search (up, down ) can mess up the visuals. For
> example on Mac it appears as a colorful emoji, but I found that it looks weird
> on other platforms. Will probably remove it, or the user can custom set their
> prompt, using: set prompt myprompt>
> 
> Regards.
> PS. the set command is full of (fun :)  hacks because of funtional/generic
> programming, it basically can set any attribute on the class, so one can do
> something like creating something (var, func). For example set ruler # (so
> instead of - you will have a # separator)
> 
> ________________________________________
> From: Chip Childers [chip.childers@sungard.com]
> Sent: Thursday, November 01, 2012 11:15 PM
> To: cloudstack-dev@incubator.apache.org
> Subject: Re: CLI for CloudStack: cloudmonkey
> 
> On Wed, Oct 31, 2012 at 2:10 PM, Rohit Yadav <ro...@citrix.com>
> wrote:
> > Hi,
> >
> > 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:
> > https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.git;a=c
> > ommit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
> >
> > Features:
> > - 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
> >
> > FIXMEs:
> > - 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 python cloudmonkey.py
> >
> > If you want to have the terminal tool installed; cd tools/cli python
> > setup.py 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=8.8.8.8 internaldns1=10.147.28.6 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
> > networkofferingid= create Pod zoneid= name=Pod1 gateway=10.147.28.1
> > netmask=255.255.255.0 startip=10.147.28.220 endip=10.147.28.235 create
> > VlanIpRange podid= networkid= gateway=10.147.28.1
> > netmask=255.255.255.0 startip=10.147.28.236 endip=10.147.28.250
> > 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=http://10.147.28.60 create
> > StoragePool zoneid= clusterid= name=NFS1
> > url=nfs://10.147.28.7/export/home/rohit/primary
> > add SecondaryStorage zoneId=
> > url=nfs://10.147.28.7/export/home/rohit/secondary
> > 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.
> >
> > Regards.
> > PS. Marvin the neglected robot and hipster cloudmonkey should rule the
> > world :D
> 
> Rohit,
> 
> This is really really cool.  It puts the "fun" in managing instances from a
> command line.  I've been testing it against a production CloudStack
> environment, and it's working pretty well.
> 
> If you don't mind, I might hack at the code a bit to fill in some gaps that I'm
> seeing.  First example is that it assumes http, which doesn't work in a public
> deployment where the endpoint is over https.
> 
> -chip

RE: CLI for CloudStack: cloudmonkey

Posted by Rohit Yadav <ro...@citrix.com>.
Hi Chip, please go ahead if we can fix the http/s issue. The connection is based on marvin, I'm sure using CLI we'll find out more bugs and fix anything in marvin thereby help maintain marvin->tests and CLI.
Please hack that up on tools/marvin/marvin/cloudstackConnection.py

Edison, yes I'm working on the completedefault, I've figured a solution to the parsing and tabbing issue to show params for any api and added more verbs to the grammar like deploy, start etc.
In the new approach doc strings and params needed for an api are fetched and cached in the class locally to speed up the loading process.
Till it gets committed, cloudmonkey (now) will keep telling the user what params they are missing until it gets all the required ones.

One more thing, for people who may not have unicode support the prompt may appear weird and history search (up, down ) can mess up the visuals. For example on Mac it appears as a colorful emoji, but I found that it looks weird on other platforms. Will probably remove it, or the user can custom set their prompt, using: set prompt myprompt>

Regards.
PS. the set command is full of (fun :)  hacks because of funtional/generic programming, it basically can set any attribute on the class, so one can do something like creating something (var, func). For example set ruler # (so instead of - you will have a # separator)

________________________________________
From: Chip Childers [chip.childers@sungard.com]
Sent: Thursday, November 01, 2012 11:15 PM
To: cloudstack-dev@incubator.apache.org
Subject: Re: CLI for CloudStack: cloudmonkey

On Wed, Oct 31, 2012 at 2:10 PM, Rohit Yadav <ro...@citrix.com> wrote:
> Hi,
>
> 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:
> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.git;a=commit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
>
> Features:
> - 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
>
> FIXMEs:
> - 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
> python cloudmonkey.py
>
> If you want to have the terminal tool installed;
> cd tools/cli
> python setup.py 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=8.8.8.8 internaldns1=10.147.28.6 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 networkofferingid=
> create Pod zoneid= name=Pod1 gateway=10.147.28.1 netmask=255.255.255.0 startip=10.147.28.220 endip=10.147.28.235
> create VlanIpRange podid= networkid= gateway=10.147.28.1 netmask=255.255.255.0 startip=10.147.28.236 endip=10.147.28.250 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=http://10.147.28.60
> create StoragePool zoneid= clusterid= name=NFS1 url=nfs://10.147.28.7/export/home/rohit/primary
> add SecondaryStorage zoneId= url=nfs://10.147.28.7/export/home/rohit/secondary
> 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.
>
> Regards.
> PS. Marvin the neglected robot and hipster cloudmonkey should rule the world :D

Rohit,

This is really really cool.  It puts the "fun" in managing instances
from a command line.  I've been testing it against a production
CloudStack environment, and it's working pretty well.

If you don't mind, I might hack at the code a bit to fill in some gaps
that I'm seeing.  First example is that it assumes http, which doesn't
work in a public deployment where the endpoint is over https.

-chip

Re: CLI for CloudStack: cloudmonkey

Posted by Chip Childers <ch...@sungard.com>.
On Wed, Oct 31, 2012 at 2:10 PM, Rohit Yadav <ro...@citrix.com> wrote:
> Hi,
>
> 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:
> https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.git;a=commit;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
>
> Features:
> - 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
>
> FIXMEs:
> - 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
> python cloudmonkey.py
>
> If you want to have the terminal tool installed;
> cd tools/cli
> python setup.py 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=8.8.8.8 internaldns1=10.147.28.6 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 networkofferingid=
> create Pod zoneid= name=Pod1 gateway=10.147.28.1 netmask=255.255.255.0 startip=10.147.28.220 endip=10.147.28.235
> create VlanIpRange podid= networkid= gateway=10.147.28.1 netmask=255.255.255.0 startip=10.147.28.236 endip=10.147.28.250 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=http://10.147.28.60
> create StoragePool zoneid= clusterid= name=NFS1 url=nfs://10.147.28.7/export/home/rohit/primary
> add SecondaryStorage zoneId= url=nfs://10.147.28.7/export/home/rohit/secondary
> 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.
>
> Regards.
> PS. Marvin the neglected robot and hipster cloudmonkey should rule the world :D

Rohit,

This is really really cool.  It puts the "fun" in managing instances
from a command line.  I've been testing it against a production
CloudStack environment, and it's working pretty well.

If you don't mind, I might hack at the code a bit to fill in some gaps
that I'm seeing.  First example is that it assumes http, which doesn't
work in a public deployment where the endpoint is over https.

-chip

Re: CLI for CloudStack: cloudmonkey

Posted by Ahmad Emneina <Ah...@citrix.com>.
I welcome our new overlords! :p

On 10/31/12 11:10 AM, "Rohit Yadav" <ro...@citrix.com> wrote:

>Hi,
>
>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:
>https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.git;a=commi
>t;h=2ceaa3911e792dbeb6c40dfb70961008a01f7e3c
>
>Features:
>- 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
>
>FIXMEs:
>- 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
>python cloudmonkey.py
>
>If you want to have the terminal tool installed;
>cd tools/cli
>python setup.py 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=8.8.8.8 internaldns1=10.147.28.6 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 networkofferingid=
>create Pod zoneid= name=Pod1 gateway=10.147.28.1 netmask=255.255.255.0
>startip=10.147.28.220 endip=10.147.28.235
>create VlanIpRange podid= networkid= gateway=10.147.28.1
>netmask=255.255.255.0 startip=10.147.28.236 endip=10.147.28.250
>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=http://10.147.28.60
>create StoragePool zoneid= clusterid= name=NFS1
>url=nfs://10.147.28.7/export/home/rohit/primary
>add SecondaryStorage zoneId=
>url=nfs://10.147.28.7/export/home/rohit/secondary
>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.
>
>Regards.
>PS. Marvin the neglected robot and hipster cloudmonkey should rule the
>world :D


-- 
Æ