-
Install sbt
-
Clone the repository
git clone git@gist.github.com:09a5faacc5936089231f.git
- Fire it
sbt console
or
sbt -Dabiquo.endpoint=http://10.60.1.223/api console
Wait for internet complet download (considere removing thie .ivy cache if some dep problem), at the end you get the scala> prompt, now you can start using AbiquoContext from context or the AbiquoApi from abiquo, current Enterprise fetched from enter value. dc will get an existing datacenter or setup one by default (127.0.0.1)
Check sprawl.scala file to see the different possibilities when using the jclouds API
- Domain objects
scala> enter.listVirtualMachines
- Sprawl utils
scala> machine("10.60.1.223")
scala> vm("testVm", template("Core").get, vapp("testVapp", vdc("testVdc")))
- Context Services
scala> context.getCloudService.listVirtualMachines.filter(vm => vm.getState.name == "UNKNOWN").foreach(vm => vm.delete)
- API binding
scala> abiquo.getVirtualMachineTemplateApi.listVirtualMachineTemplates(enter.getId,dc.getId)
- Dtos manipulation
scala> val enterDto = enter.unwrap
enterDto: com.abiquo.server.core.enterprise.EnterpriseDto = com.abiquo.server.core.enterprise.EnterpriseDto@4e61d0f4
scala> println(marshal(enterDto))
scala> val enter2 = unmarshal[EnterpriseDto]("""<enterprise></enterprise>""")
- Going restful
scala> val myenter = get[EnterpriseDto]("http://10.60.1.223:80/api/admin/enterprises/1")
scala> myenter.setName("foo")
scala> val modified = put(myenter)
scala> delete(modified)