[workspace-commit] CVS update: MODIFIED: vm
Tim Freeman
commit at globus.org
Thu Apr 17 10:10:58 CDT 2008
, VirtualMachinePartition.java ...
User: tfreeman
Date: 08/04/17 10:10:58
Modified: vm/service/service/java/source/src/org/globus/workspace/service/binding/vm
VirtualMachinePartition.java VirtualMachine.java
Added: vm/service/service/java/source/src/org/globus/workspace/service/binding/vm
CustomizationNeed.java
Log:
- alternate unpropagation target URL
- bulk status query
- file customizations
- fault can accompany state in RP/notification
- misc changes for new WSDL
- backend VM name prefix moved from "workspace" to "wrksp" (extends ebtables NIC length limit)
Revision Changes Path
1.3 +12 -1 workspace/vm/service/service/java/source/src/org/globus/workspace/service/binding/vm/VirtualMachinePartition.java
http://viewcvs.globus.org/viewcvs.cgi/workspace/vm/service/service/java/source/src/org/globus/workspace/service/binding/vm/VirtualMachinePartition.java.diff?r1=1.2&r2=1.3
(In the diff below, changes in quantity of whitespace are not shown.)
Index: VirtualMachinePartition.java
===================================================================
RCS file: /home/globdev/CVS/globus-packages/workspace/vm/service/service/java/source/src/org/globus/workspace/service/binding/vm/VirtualMachinePartition.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- VirtualMachinePartition.java 2 Nov 2007 14:47:15 -0000 1.2
+++ VirtualMachinePartition.java 17 Apr 2008 15:10:58 -0000 1.3
@@ -24,7 +24,7 @@
private int blankspace;
private boolean propRequired;
private boolean unPropRequired;
-
+ private String alternateUnpropTarget;
public String getImage() {
return this.image;
@@ -82,6 +82,15 @@
this.unPropRequired = unPropRequired;
}
+ public String getAlternateUnpropTarget() {
+ return alternateUnpropTarget;
+ }
+
+ public void setAlternateUnpropTarget(
+ String alternateUnpropTarget) {
+ this.alternateUnpropTarget = alternateUnpropTarget;
+ }
+
public String toString() {
return "VirtualMachinePartition{" +
@@ -92,6 +101,7 @@
", blankspace=" + this.blankspace +
", propRequired=" + this.propRequired +
", unPropRequired=" + this.unPropRequired +
+ ", alternateUnpropTarget='" + this.alternateUnpropTarget + '\'' +
'}';
}
@@ -113,6 +123,7 @@
vmp.readwrite = p.readwrite;
vmp.rootdisk = p.rootdisk;
vmp.unPropRequired = p.unPropRequired;
+ vmp.alternateUnpropTarget = p.alternateUnpropTarget;
return vmp;
}
1.9 +117 -1 workspace/vm/service/service/java/source/src/org/globus/workspace/service/binding/vm/VirtualMachine.java
http://viewcvs.globus.org/viewcvs.cgi/workspace/vm/service/service/java/source/src/org/globus/workspace/service/binding/vm/VirtualMachine.java.diff?r1=1.8&r2=1.9
(In the diff below, changes in quantity of whitespace are not shown.)
Index: VirtualMachine.java
===================================================================
RCS file: /home/globdev/CVS/globus-packages/workspace/vm/service/service/java/source/src/org/globus/workspace/service/binding/vm/VirtualMachine.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- VirtualMachine.java 2 Nov 2007 14:47:15 -0000 1.8
+++ VirtualMachine.java 17 Apr 2008 15:10:58 -0000 1.9
@@ -17,8 +17,11 @@
package org.globus.workspace.service.binding.vm;
import org.globus.workspace.WorkspaceConstants;
+import org.globus.workspace.WorkspaceException;
+import org.globus.workspace.Lager;
import org.globus.workspace.service.binding.WorkspaceInstantiation;
import org.globus.workspace.service.impls.staging.StagingRequest;
+import org.apache.commons.logging.Log;
/**
* Access to this is not synchronized, assumes set once (keeping set
@@ -40,6 +43,8 @@
private VirtualMachinePartition[] partitions;
+ private CustomizationNeed[] customizationNeeds;
+
//requested vmm type
private String vmm;
//requested vmm version
@@ -127,6 +132,101 @@
this.vmmVersion = vmmVersion;
}
+ public synchronized void addCustomizationNeed(CustomizationNeed need) {
+ if (this.customizationNeeds == null) {
+ this.customizationNeeds = new CustomizationNeed[1];
+ this.customizationNeeds[0] = need;
+ } else {
+ final int curlen = this.customizationNeeds.length;
+ final CustomizationNeed[] src = this.customizationNeeds;
+ final CustomizationNeed[] dst = new CustomizationNeed[curlen+1];
+ System.arraycopy(src, 0, dst, 0, curlen);
+ dst[curlen] = need;
+ this.customizationNeeds = dst;
+ }
+ }
+
+ public synchronized CustomizationNeed[] getCustomizationNeeds() {
+ return this.customizationNeeds;
+ }
+
+ public synchronized boolean isCustomizationAllDone() {
+ if (this.customizationNeeds == null) {
+ return true;
+ }
+ for (int i = 0; i < this.customizationNeeds.length; i++) {
+ if (!this.customizationNeeds[i].isSent()) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public synchronized void addUnpropTargetSuffixes()
+
+ throws WorkspaceException {
+
+ if (this.id == null) {
+ throw new IllegalStateException("cannot call if ID is unset");
+ }
+
+ final String suffix = "-" + this.id.toString();
+ this._adjustRootUnpropTarget(null, suffix, null);
+ }
+
+ public synchronized void overrideRootUnpropTarget(String path, Log logger)
+
+ throws WorkspaceException {
+
+ this._adjustRootUnpropTarget(path, null, logger);
+ }
+
+ private void _adjustRootUnpropTarget(String path, String suffix, Log logger)
+
+ throws WorkspaceException {
+
+ if (this.partitions == null || this.partitions.length == 0) {
+ throw new WorkspaceException("partitions do not exist");
+ }
+
+ boolean found = false;
+ for (int i = 0; i < this.partitions.length; i++) {
+ if (this.partitions[i].isRootdisk()) {
+
+ final String old = this.partitions[i].getAlternateUnpropTarget();
+ if (logger != null && old != null) {
+ logger.info(Lager.ev(this.id) + "Overriding previously " +
+ "set alternate unpropagate target: '" + old + "'");
+ } else if (logger != null) {
+ logger.info(Lager.ev(this.id) + "Setting " +
+ "alternate unpropagate target: '" + path + "'");
+ }
+
+ if (path != null) {
+
+ if (suffix != null) {
+ final String newpath = path + suffix;
+ this.partitions[i].setAlternateUnpropTarget(newpath);
+ } else {
+ this.partitions[i].setAlternateUnpropTarget(path);
+ }
+
+ } else if (old != null && suffix != null) {
+ final String newpath = old + suffix;
+ this.partitions[i].setAlternateUnpropTarget(newpath);
+ }
+
+ found = true;
+ break;
+ }
+ }
+
+ if (!found) {
+ throw new WorkspaceException(
+ "could not find root disk to override its target");
+ }
+ }
+
public String toString() {
StringBuffer parts = null;
@@ -144,6 +244,11 @@
deployment.getRequestedShutdown());
}
+ int custLen = 0;
+ if (this.customizationNeeds != null) {
+ custLen = this.customizationNeeds.length;
+ }
+
return "VirtualMachine{" +
"deployment=" + this.deployment +
", network='" + this.network + '\'' +
@@ -159,9 +264,15 @@
", vmmVersion='" + this.vmmVersion + '\'' +
", partitions='" + parts + '\'' +
", associationsNeeded='" + this.associationsNeeded + '\'' +
+ ", customizationsNeeds length='" + custLen + '\'' +
'}';
}
+ public boolean isPropagateStartOK() {
+ return this.customizationNeeds == null ||
+ this.customizationNeeds.length <= 0;
+ }
+
// part of the instantiation interface, nothing about VM deployment
// class is known there
public int getRequestedShutdownMechanism() {
@@ -174,7 +285,9 @@
// don't use clone()
// be sure to differentiate afterwards if that's what is desired...
- public static VirtualMachine cloneOne(final VirtualMachine vm) {
+ public static VirtualMachine cloneOne(final VirtualMachine vm)
+ throws Exception {
+
if (vm == null) {
return null;
}
@@ -217,6 +330,9 @@
VirtualMachineDeployment.cloneOne(vm.deployment);
}
+ newvm.customizationNeeds =
+ CustomizationNeed.cloneArray(vm.customizationNeeds);
+
return newvm;
}
}
1.1 workspace/vm/service/service/java/source/src/org/globus/workspace/service/binding/vm/CustomizationNeed.java
http://viewcvs.globus.org/viewcvs.cgi/workspace/vm/service/service/java/source/src/org/globus/workspace/service/binding/vm/CustomizationNeed.java?rev=1.1&content-type=text/x-cvsweb-markup
Index: CustomizationNeed.java
===================================================================
/*
* Copyright 1999-2008 University of Chicago
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy
* of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package org.globus.workspace.service.binding.vm;
/**
* right now limits are checked before hitting the DB for fail fast, sourcepath
* is 32 chars (UUID), destpath is is 512 chars and is the path ON the VM.
* On the VMM, the file is also the UUID.
*/
public class CustomizationNeed {
public final static int srcMax = 36;
public final static int dstMax = 512;
private final static String legalDestCharsString =
"./_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
public final static char[] legalDestChars =
legalDestCharsString.toCharArray();
public final String sourcePath;
public final String destPath;
boolean wasSent;
public CustomizationNeed(String src, String dst)
throws Exception {
this(src, dst, false);
}
public CustomizationNeed(String src, String dst, boolean sent)
throws Exception {
if (src == null) {
throw new IllegalArgumentException("source path may not be null");
}
if (src.length() > srcMax) {
throw new Exception(
"customization source path is too long: " +
src.length() + " > " + srcMax +
". Path: '" + src + "'");
}
if (dst == null) {
throw new IllegalArgumentException(
"destination path may not be null");
}
if (dst.length() > dstMax) {
throw new Exception(
"customization destination path is too long: " +
dst.length() + " > " + dstMax +
". Path: '" + dst + "'");
}
// the mount tool would catch this too, but failfast
final char[] dstChars = dst.toCharArray();
for (int i = 0; i < dstChars.length; i++) {
if (!legalChar(dstChars[i])) {
throw new Exception(
"customization destination path contains illegal " +
"character '" + dstChars[i] + "'. Path: '" + dst + "'");
}
}
if (dst.indexOf("../") >= 0) {
throw new Exception(
"customization destination path contains illegal " +
"path expansion, for example '../'. Path: '" + dst + "'");
}
this.sourcePath = src;
this.destPath = dst;
this.wasSent = sent;
}
// for clone only
// 'fake' is just there to get around java limitation
private CustomizationNeed(String src, String dst, boolean sent, int fake) {
this.sourcePath = src;
this.destPath = dst;
this.wasSent = sent;
}
public synchronized boolean isSent() {
return this.wasSent;
}
public synchronized void setSent(boolean sent) {
this.wasSent = sent;
}
private static boolean legalChar(char c) {
for (int i = 0; i < legalDestChars.length; i++) {
if (c == legalDestChars[i]) {
return true;
}
}
return false;
}
public static CustomizationNeed[] cloneArray(CustomizationNeed[] cur)
throws Exception {
if (cur == null) {
return null;
}
final CustomizationNeed[] newArr = new CustomizationNeed[cur.length];
for (int i = 0; i < cur.length; i++) {
newArr[i] = cloneOne(cur[i]);
}
return newArr;
}
public static CustomizationNeed cloneOne(CustomizationNeed cur)
throws Exception {
if (cur == null) {
return null;
}
return new CustomizationNeed(
cur.sourcePath, cur.destPath, cur.wasSent, 0);
}
}
More information about the workspace-commit
mailing list