Thursday, March 31, 2011

prl{*} and the "hidden" parallels command set

I'm a CLI freak - there I said it. Today I was futzing with clovr.org (very cool informatics cluster system) and looking at spinning up their instance under Parallels 6.0. As with all things I got a little distracted, and started to look at the SDK for Parallels. There is an amazing and monster programing guide here - lots of ideas to be had here, more at the end of this post!


Long story short it is very cool, always thought of Parallels as a small desktop VM solution, but with a few CLI options more can be done! Three good commands prlsrvctl, prlctl and prl_disk_tool.

Who can log in?
jcmacbook:files jcuff$ prlsrvctl user list
NAME            MNG_SETTINGS DEF_VM_HOME
root@.          allow        /Users/Shared/Parallels
jcuff@.         allow        /Users/jcuff/Documents/Parallels

What networks do we have?
jcmacbook:files jcuff$ prlsrvctl net list
Network ID        Type      Bound To
Shared            shared    vnic0
Host-Only         host-only vnic1
Ethernet (en0)    bridged   en0
AirPort (en1)     bridged   en1
vnic0 (vnic0)     bridged   vnic0
vnic1 (vnic1)     bridged   vnic1
Default           bridged   FF:FF:FF:FF:FF:FF

Hrrm - can we list the vm's we have?
jcmacbook:~ jcuff$ prlctl list -o name -a
NAME
10.10 64 bit Desktop
Chrome OS
Natty Narwhal Alpha 3
Test Linux
Ubuntu Linux 32bit 10.10
Windows 7
clovr

Let's start up a box:
jcmacbook:~ jcuff$ prlctl start "Natty Narwhal Alpha 3"
Starting the VM...
The VM has been successfully started.

jcmacbook:~ jcuff$ prlctl list -o name,status
NAME                             STATUS
Natty Narwhal Alpha 3            running

Can we ask some stats of the running machine? Sure, here is a snap of the disks while running a "dd" inside the vm:
jcmacbook:~ jcuff$ prl_perf_ctl -s Natty -c sata -l
Performance Counters View Utility v6.0.11994.637263
Copyright 1999-2011 Parallels Holdings, Ltd. and its affiliates.

Natty Narwhal Alpha 3 - 12:02:55
devices.sata-sf0.ext_req                         0
devices.sata-sf0.read_req                        0
devices.sata-sf0.write_req                       0
devices.sata0.flush                              0
devices.sata0.read_pc_hit                        0
devices.sata0.read_requests                      0
devices.sata0.read_total                         0
devices.sata0.write_requests                     0
devices.sata0.write_total                        0

Natty Narwhal Alpha 3 - 12:02:57  +1.108 sec
devices.sata-sf0.ext_req                         0
devices.sata-sf0.read_req                        0
devices.sata-sf0.write_req                       0
devices.sata0.flush                              2
devices.sata0.read_pc_hit                        0
devices.sata0.read_requests                      1
devices.sata0.read_total                         4096
devices.sata0.write_requests                     325
devices.sata0.write_total                        150487040

info --list is neat also:
jcmacbook:~ jcuff$ prlctl list --info "Natty Narwhal Alpha 3" | egrep "cpu|hdd"
Boot order: hdd0 cdrom0 fdd0 net0 hdd1 
  cpu 4 VT-x accl=high mode=32
  hdd0 (+) sata:0 image='/Users/jcuff/Documents/Parallels/Natty Narwhal Alpha 3.pvm/Natty Narwhal Alpha 3-0.hdd' 65536Mb
  hdd1 (+) ide:0 image='/Users/jcuff/Documents/Parallels/Natty Narwhal Alpha 3.pvm/harddisk1.hdd' 65000Mb

Then finally last up some cool disk utils:
jcmacbook:~ jcuff$ prl_disk_tool convert --info --hdd /Users/jcuff/Documents/Parallels/Natty\ Narwhal\ Alpha\ 3.pvm/Natty\ Narwhal\ Alpha\ 3-0.hdd
Disk information:
Type:             expanding, non-split

jcmacbook:~ jcuff$ prl_disk_tool compact --info --hdd /Users/jcuff/Documents/Parallels/Natty\ Narwhal\ Alpha\ 3.pvm/Natty\ Narwhal\ Alpha\ 3-0.hdd
Operation progress 100 %
Disk information:
Block size:                   512
Total blocks:              262144
Allocated blocks:          262134
Used blocks:               262134

Or add a disk:
jcmacbook:~ jcuff$ prlctl set "Natty Narwhal Alpha 3" --device-add hdd --size 65000 --iface ide
Creating hdd1 (+) ide:0 image='/Users/jcuff/Documents/Parallels/Natty Narwhal Alpha 3.pvm/harddisk1.hdd' 65536Mb
Create the expand image file, 65000Mb...

The VM has been successfully configured.

Sure changes my thoughts on what was a gui click, click interface ;-)

So now just need to combine all this lights off no GUI with sshd, a few DSA hostbased keys and a few extensions to openstack and now I can actually start to think of my first OSX cloud based provisioning service based out of a bunch of stacked mac mini's with OSX inside OSX.

*update from the tweetverse!*
Some of this is already close to a product it would seem
[http://www.parallels.com/products/automation/]



[any opinions here are all mine, and have absolutely nothing to do with my employer]
(c) 2011 James Cuff