Skip to content

Instantly share code, notes, and snippets.

@itaifrenkel
Last active December 31, 2015 12:18
Show Gist options
  • Save itaifrenkel/7984834 to your computer and use it in GitHub Desktop.
Save itaifrenkel/7984834 to your computer and use it in GitHub Desktop.
Cloudify cloud driver access from recipe
// The following recipe snippet shows custom commands that forward the requests to the network cloud driver
// See also:
// https://github.com/CloudifySource/Cloudify-iTests/blob/master/src/main/resources/apps/USM/usm/networks/openstack/floatingips/floatingips-service.groovy
customCommands ([
"getMachineIp" : { return context.getPrivateAddress() },
"getPublicAddress" : { return context.getPublicAddress() },
"getFloatingIp" : { return context.attributes.thisInstance["floatingIp"] },
"getApplicationNetworkIp" : { return System.getenv()['CLOUDIFY_APPLICATION_NETWORK_IP'] },
"assignFloatingIp" : {
// allocate and assigning new floating ip
def floatingIp = context.getNetwork().allocateFloatingIP("network_ext", null)
def machineIp = context.getPrivateAddress()
context.getNetwork().assignFloatingIP(machineIp, floatingIp, null)
context.attributes.thisInstance["floatingIp"] = "${floatingIp}"
return floatingIp
}
])
// The following recipe snippet shows a call to the storage cloud driver from the postStart hook
// See also:
// https://github.com/CloudifySource/Cloudify-iTests/blob/master/src/main/resources/apps/USM/usm/dynamicstorage/create-and-attach/groovy-service.groovy
postStart {
//Create, attach, format and mount a new storage volume
volumeId = context.storage.createVolume("SMALL_BLOCK")
context.storage.attachVolume(volumeId, device)
context.storage.format(device, fs)
context.storage.mount(device, path)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment