Search in sources :

Example 1 with ZoneAndId

use of org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndId in project legacy-jclouds-examples by jclouds.

the class DetachVolume method unmountVolume.

/**
    * Make sure you've unmounted the volume first. Failure to do so could result in failure or data loss.
    */
private void unmountVolume(VolumeAttachment volumeAttachment) {
    System.out.println("Unmount Volume");
    String script = new ScriptBuilder().addStatement(exec("umount /mnt")).render(OsFamily.UNIX);
    RunScriptOptions options = RunScriptOptions.Builder.overrideLoginUser(Constants.ROOT).overrideLoginPassword(Constants.PASSWORD).blockOnComplete(true);
    ZoneAndId zoneAndId = ZoneAndId.fromZoneAndId(Constants.ZONE, volumeAttachment.getServerId());
    ExecResponse response = compute.runScriptOnNode(zoneAndId.slashEncode(), script, options);
    if (response.getExitStatus() == 0) {
        System.out.println("  Exit Status: " + response.getExitStatus());
    } else {
        System.out.println("  Error: " + response.getOutput());
    }
}
Also used : RunScriptOptions(org.jclouds.compute.options.RunScriptOptions) ExecResponse(org.jclouds.compute.domain.ExecResponse) ZoneAndId(org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndId) ScriptBuilder(org.jclouds.scriptbuilder.ScriptBuilder)

Aggregations

ExecResponse (org.jclouds.compute.domain.ExecResponse)1 RunScriptOptions (org.jclouds.compute.options.RunScriptOptions)1 ZoneAndId (org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndId)1 ScriptBuilder (org.jclouds.scriptbuilder.ScriptBuilder)1