Package org.globus.workspace.service.binding.vm

Examples of org.globus.workspace.service.binding.vm.VirtualMachinePartition


                    uri.getHost() + "' which is not in allowed.http.hosts";
                throw new CreationException(err);
            }
        }

        final VirtualMachinePartition partition = new VirtualMachinePartition();

        if (propagationEnabled && !local) {
            vm.setPropagateRequired(true);
            partition.setPropRequired(true);
            if (vm.getDeployment().getRequestedShutdown() ==
                               WorkspaceConstants.DEFAULT_SHUTDOWN_TRASH) {
                vm.setUnPropagateRequired(false);
                partition.setUnPropRequired(false);
            }
            vm.setUnPropagateRequired(true);
            partition.setUnPropRequired(true);
        }

        partition.setImage(uri.toASCIIString());
        partition.setImagemount(mountAs);
        partition.setRootdisk(true);
        partition.setBlankspace(0);

        final String perms = file.getDiskPerms();
        if (VMFile.DISKPERMS_ReadOnly.equals(perms)) {
            partition.setReadwrite(false);
        } else if (VMFile.DISKPERMS_ReadWrite.equals(perms)) {
            partition.setReadwrite(true);
        }

        // only applicable to rootPartition currently
        // waiting on generalization of disk and propagation (both in
        // messaging layers and file movement tools)
        final URI unpropURI = file.getUnpropURI();
        if (unpropURI != null) {
            partition.setAlternateUnpropTarget(unpropURI.toASCIIString());
        }

        return partition;
    }
View Full Code Here


    protected VirtualMachinePartition regularPartition(VMFile file,
                                                       String vmName)
            throws CreationException {
       
        final VirtualMachinePartition partition = new VirtualMachinePartition();

        // see root partition comments
        partition.setPropRequired(false);
        partition.setUnPropRequired(false);

        final URI uri = file.getURI();

        if (!uri.getScheme().equals("file")) {
            final String err = "request for '" + vmName + "' contains " +
                    "partition that is not root disk or a blank space " +
                    "creation request but it is not a cache reference " +
                    "(currently no propagate support for these)";
            throw new CreationException(err);
        }

        partition.setImage(uri.toASCIIString());
        partition.setImagemount(file.getMountAs());
        partition.setRootdisk(false);
        partition.setBlankspace(0);

        final String perms = file.getDiskPerms();
        if (VMFile.DISKPERMS_ReadOnly.equals(perms)) {
            partition.setReadwrite(false);
        } else if (VMFile.DISKPERMS_ReadWrite.equals(perms)) {
            partition.setReadwrite(true);
        }

        return partition;
    }
View Full Code Here

            final String err = "blank space request under 1 megabyte in " +
                    "request for '" + vmName + "'";
            throw new CreationException(err);
        }

        final VirtualMachinePartition partition = new VirtualMachinePartition();
        partition.setPropRequired(false);
        partition.setUnPropRequired(false);
        partition.setImage("file://fake");
        partition.setImagemount(file.getMountAs());
        partition.setRootdisk(false);
        partition.setReadwrite(true);
        partition.setBlankspace(megabytes);

        return partition;
    }
View Full Code Here

        }

        final ArrayList<VirtualMachinePartition> partitions = new ArrayList<VirtualMachinePartition>(8);

        do {
            final VirtualMachinePartition partition =
                    new VirtualMachinePartition();
            partition.setImage(rs.getString("image"));
            partition.setImagemount(rs.getString("imagemount"));
            partition.setReadwrite(rs.getBoolean("readwrite"));
            partition.setRootdisk(rs.getBoolean("rootdisk"));
            partition.setBlankspace(rs.getInt("blankspace"));
            partition.setPropRequired(rs.getBoolean("prop_required"));
            partition.setUnPropRequired(rs.getBoolean("unprop_required"));
            partition.setAlternateUnpropTarget(rs.getString("alternate_unprop"));

            partitions.add(partition);
        } while (rs.next());

        VirtualMachinePartition[] final_partitions = partitions.toArray(new VirtualMachinePartition[partitions.size()]);
View Full Code Here

            final String net = "'" + hackStatic(vm.getNetwork()) + "'";
            cmd.add(net);
        }

        // sources:
        VirtualMachinePartition rootdisk = null;
        final ArrayList regularPartitions = new ArrayList();
        final ArrayList blankPartitions = new ArrayList();

        // results to send:
        final ArrayList images = new ArrayList();
        final ArrayList imagemounts = new ArrayList();

        final VirtualMachinePartition[] partitions = vm.getPartitions();

        if (partitions == null || partitions.length == 0) {
            final String err = "should be at least one partition, Binding " +
                    "should have caught at the outset";
            logger.error(err);
            throw new WorkspaceException(err);
        } else {
            for (int i = 0; i < partitions.length; i++) {
                if (partitions[i].isRootdisk()) {
                    rootdisk = partitions[i];
                } else if (partitions[i].getBlankspace() > 0) {
                    blankPartitions.add(partitions[i]);
                } else {
                    regularPartitions.add(partitions[i]);
                }
            }
        }


        // todo: generalize when propagating more than just rootdisk
        if (rootdisk != null) {
           
            String rootImageURI = rootdisk.getImage();

            // We know that if Propagate was required and notificationInfo
            // is null that this is a create command following a successful
            // Propagate-only command, so we let the backend know it can
            // find the file in its workspace-specific secureimage directory
            // by setting this file URL to a relative path -- relative paths
            // hitting the backend always cause the workspace-specific
            // secureimage directory to be consulted first

            if (vm.isPropagateRequired() && notificationInfo == null) {
                final String newURI = convertToAlreadyPropagated(rootImageURI, vm);

                logger.debug("turned '" + rootImageURI + "' into '" +
                            newURI + "' because file was already propagated");

                // not handling readonly root partition yet
                images.add(newURI);
            } else {
                // not handling readonly root partition yet
                images.add(rootImageURI);
            }
            imagemounts.add(rootdisk.getImagemount());
        }

        if (!blankPartitions.isEmpty()) {
            int blankNum = 0;
            final Iterator iter = blankPartitions.iterator();

            while (iter.hasNext()) {
                final VirtualMachinePartition blank =
                                (VirtualMachinePartition) iter.next();
                final int megs = blank.getBlankspace();
                //When unpropagate support is added for blank partitions,
                // this file will likely be unpropagated to the image node
                // with the originally supplied filename as target -- and
                // perhaps some schema change will allow the user to specify
                // whether or not it should be saved at all (when serializing
                // it would have to be)
                images.add("blankcreate://blankpartition" + blankNum
                                                            + "-size-" + megs);
                imagemounts.add(blank.getImagemount());
                blankNum += 1;

                // (assuming blank partition will always be readwrite)
            }
        }
       
        if (!regularPartitions.isEmpty()) {
            final Iterator iter = regularPartitions.iterator();
            while (iter.hasNext()) {
                final VirtualMachinePartition regular =
                                (VirtualMachinePartition) iter.next();
                String imgStr = regular.getImage();
                if (!regular.isReadwrite()) {
                    imgStr += WC_FIELD_SEPARATOR + "ro";
                }
                images.add(imgStr);
                imagemounts.add(regular.getImagemount());
            }
        }

        if (images.isEmpty()) {
            final String err = "should be at least one image here...";
View Full Code Here

    }

    public static VirtualMachinePartition getPartition(ResultSet rs)
                                                        throws SQLException {

        final VirtualMachinePartition partition =
                new VirtualMachinePartition();
       
        partition.setImage(rs.getString(1));
        partition.setImagemount(rs.getString(2));
        partition.setReadwrite(rs.getBoolean(3));
        partition.setRootdisk(rs.getBoolean(4));
        partition.setBlankspace(rs.getInt(5));
        partition.setPropRequired(rs.getBoolean(6));
        partition.setUnPropRequired(rs.getBoolean(7));
        partition.setAlternateUnpropTarget(rs.getString(8));
        return partition;
    }
View Full Code Here

TOP

Related Classes of org.globus.workspace.service.binding.vm.VirtualMachinePartition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.