summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Bauer2016-09-02 15:04:51 +0200
committerJonathan Bauer2016-09-02 15:04:51 +0200
commit7a975667e311d11ae520f146de8d32b5b29f151f (patch)
tree2c934484621d53b77ddddaa85826838f2ee18e85
parentnew API version (diff)
downloadmaster-sync-shared-7a975667e311d11ae520f146de8d32b5b29f151f.tar.gz
master-sync-shared-7a975667e311d11ae520f146de8d32b5b29f151f.tar.xz
master-sync-shared-7a975667e311d11ae520f146de8d32b5b29f151f.zip
vmx editor stuff
-rw-r--r--src/main/java/org/openslx/bwlp/thrift/iface/SatelliteServer.java161
-rw-r--r--src/main/java/org/openslx/util/ThriftUtil.java21
-rw-r--r--src/main/java/org/openslx/util/vm/VmwareConfig.java9
-rw-r--r--src/main/java/org/openslx/util/vm/VmwareMetaData.java14
-rw-r--r--src/main/thrift/bwlp.thrift2
5 files changed, 62 insertions, 145 deletions
diff --git a/src/main/java/org/openslx/bwlp/thrift/iface/SatelliteServer.java b/src/main/java/org/openslx/bwlp/thrift/iface/SatelliteServer.java
index 98559f7..5acedf9 100644
--- a/src/main/java/org/openslx/bwlp/thrift/iface/SatelliteServer.java
+++ b/src/main/java/org/openslx/bwlp/thrift/iface/SatelliteServer.java
@@ -34,7 +34,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
-@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2016-08-31")
+@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2016-09-02")
public class SatelliteServer {
public interface Iface {
@@ -101,7 +101,7 @@ public class SatelliteServer {
public ByteBuffer getImageVersionVirtConfig(String userToken, String imageVersionId) throws TAuthorizationException, TNotFoundException, TInvocationException, org.apache.thrift.TException;
- public ByteBuffer setImageVersionVirtConfig(String userToken, String imageVersionId, ByteBuffer meta) throws TAuthorizationException, TNotFoundException, TInvocationException, org.apache.thrift.TException;
+ public void setImageVersionVirtConfig(String userToken, String imageVersionId, ByteBuffer meta) throws TAuthorizationException, TNotFoundException, TInvocationException, org.apache.thrift.TException;
public String requestImageReplication(String userToken, String imageVersionId) throws TAuthorizationException, TNotFoundException, TInvocationException, org.apache.thrift.TException;
@@ -1101,10 +1101,10 @@ public class SatelliteServer {
throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getImageVersionVirtConfig failed: unknown result");
}
- public ByteBuffer setImageVersionVirtConfig(String userToken, String imageVersionId, ByteBuffer meta) throws TAuthorizationException, TNotFoundException, TInvocationException, org.apache.thrift.TException
+ public void setImageVersionVirtConfig(String userToken, String imageVersionId, ByteBuffer meta) throws TAuthorizationException, TNotFoundException, TInvocationException, org.apache.thrift.TException
{
send_setImageVersionVirtConfig(userToken, imageVersionId, meta);
- return recv_setImageVersionVirtConfig();
+ recv_setImageVersionVirtConfig();
}
public void send_setImageVersionVirtConfig(String userToken, String imageVersionId, ByteBuffer meta) throws org.apache.thrift.TException
@@ -1116,13 +1116,10 @@ public class SatelliteServer {
sendBase("setImageVersionVirtConfig", args);
}
- public ByteBuffer recv_setImageVersionVirtConfig() throws TAuthorizationException, TNotFoundException, TInvocationException, org.apache.thrift.TException
+ public void recv_setImageVersionVirtConfig() throws TAuthorizationException, TNotFoundException, TInvocationException, org.apache.thrift.TException
{
setImageVersionVirtConfig_result result = new setImageVersionVirtConfig_result();
receiveBase(result, "setImageVersionVirtConfig");
- if (result.isSetSuccess()) {
- return result.success;
- }
if (result.authError != null) {
throw result.authError;
}
@@ -1132,7 +1129,7 @@ public class SatelliteServer {
if (result.serverError != null) {
throw result.serverError;
}
- throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "setImageVersionVirtConfig failed: unknown result");
+ return;
}
public String requestImageReplication(String userToken, String imageVersionId) throws TAuthorizationException, TNotFoundException, TInvocationException, org.apache.thrift.TException
@@ -2560,13 +2557,13 @@ public class SatelliteServer {
prot.writeMessageEnd();
}
- public ByteBuffer getResult() throws TAuthorizationException, TNotFoundException, TInvocationException, org.apache.thrift.TException {
+ public void getResult() throws TAuthorizationException, TNotFoundException, TInvocationException, org.apache.thrift.TException {
if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) {
throw new IllegalStateException("Method call not finished!");
}
org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array());
org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport);
- return (new Client(prot)).recv_setImageVersionVirtConfig();
+ (new Client(prot)).recv_setImageVersionVirtConfig();
}
}
@@ -3788,7 +3785,7 @@ public class SatelliteServer {
public setImageVersionVirtConfig_result getResult(I iface, setImageVersionVirtConfig_args args) throws org.apache.thrift.TException {
setImageVersionVirtConfig_result result = new setImageVersionVirtConfig_result();
try {
- result.success = iface.setImageVersionVirtConfig(args.userToken, args.imageVersionId, args.meta);
+ iface.setImageVersionVirtConfig(args.userToken, args.imageVersionId, args.meta);
} catch (TAuthorizationException authError) {
result.authError = authError;
} catch (TNotFoundException notFound) {
@@ -6025,7 +6022,7 @@ public class SatelliteServer {
}
}
- public static class setImageVersionVirtConfig<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, setImageVersionVirtConfig_args, ByteBuffer> {
+ public static class setImageVersionVirtConfig<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, setImageVersionVirtConfig_args, Void> {
public setImageVersionVirtConfig() {
super("setImageVersionVirtConfig");
}
@@ -6034,12 +6031,11 @@ public class SatelliteServer {
return new setImageVersionVirtConfig_args();
}
- public AsyncMethodCallback<ByteBuffer> getResultHandler(final AsyncFrameBuffer fb, final int seqid) {
+ public AsyncMethodCallback<Void> getResultHandler(final AsyncFrameBuffer fb, final int seqid) {
final org.apache.thrift.AsyncProcessFunction fcall = this;
- return new AsyncMethodCallback<ByteBuffer>() {
- public void onComplete(ByteBuffer o) {
+ return new AsyncMethodCallback<Void>() {
+ public void onComplete(Void o) {
setImageVersionVirtConfig_result result = new setImageVersionVirtConfig_result();
- result.success = o;
try {
fcall.sendResponse(fb,result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);
return;
@@ -6087,7 +6083,7 @@ public class SatelliteServer {
return false;
}
- public void start(I iface, setImageVersionVirtConfig_args args, org.apache.thrift.async.AsyncMethodCallback<ByteBuffer> resultHandler) throws TException {
+ public void start(I iface, setImageVersionVirtConfig_args args, org.apache.thrift.async.AsyncMethodCallback<Void> resultHandler) throws TException {
iface.setImageVersionVirtConfig(args.userToken, args.imageVersionId, args.meta,resultHandler);
}
}
@@ -37295,7 +37291,6 @@ public class SatelliteServer {
public static class setImageVersionVirtConfig_result implements org.apache.thrift.TBase<setImageVersionVirtConfig_result, setImageVersionVirtConfig_result._Fields>, java.io.Serializable, Cloneable, Comparable<setImageVersionVirtConfig_result> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("setImageVersionVirtConfig_result");
- private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRING, (short)0);
private static final org.apache.thrift.protocol.TField AUTH_ERROR_FIELD_DESC = new org.apache.thrift.protocol.TField("authError", org.apache.thrift.protocol.TType.STRUCT, (short)1);
private static final org.apache.thrift.protocol.TField NOT_FOUND_FIELD_DESC = new org.apache.thrift.protocol.TField("notFound", org.apache.thrift.protocol.TType.STRUCT, (short)2);
private static final org.apache.thrift.protocol.TField SERVER_ERROR_FIELD_DESC = new org.apache.thrift.protocol.TField("serverError", org.apache.thrift.protocol.TType.STRUCT, (short)3);
@@ -37306,14 +37301,12 @@ public class SatelliteServer {
schemes.put(TupleScheme.class, new setImageVersionVirtConfig_resultTupleSchemeFactory());
}
- public ByteBuffer success; // required
public TAuthorizationException authError; // required
public TNotFoundException notFound; // required
public TInvocationException serverError; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
- SUCCESS((short)0, "success"),
AUTH_ERROR((short)1, "authError"),
NOT_FOUND((short)2, "notFound"),
SERVER_ERROR((short)3, "serverError");
@@ -37331,8 +37324,6 @@ public class SatelliteServer {
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
- case 0: // SUCCESS
- return SUCCESS;
case 1: // AUTH_ERROR
return AUTH_ERROR;
case 2: // NOT_FOUND
@@ -37382,8 +37373,6 @@ public class SatelliteServer {
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
- tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT,
- new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)));
tmpMap.put(_Fields.AUTH_ERROR, new org.apache.thrift.meta_data.FieldMetaData("authError", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT)));
tmpMap.put(_Fields.NOT_FOUND, new org.apache.thrift.meta_data.FieldMetaData("notFound", org.apache.thrift.TFieldRequirementType.DEFAULT,
@@ -37398,13 +37387,11 @@ public class SatelliteServer {
}
public setImageVersionVirtConfig_result(
- ByteBuffer success,
TAuthorizationException authError,
TNotFoundException notFound,
TInvocationException serverError)
{
this();
- this.success = org.apache.thrift.TBaseHelper.copyBinary(success);
this.authError = authError;
this.notFound = notFound;
this.serverError = serverError;
@@ -37414,9 +37401,6 @@ public class SatelliteServer {
* Performs a deep copy on <i>other</i>.
*/
public setImageVersionVirtConfig_result(setImageVersionVirtConfig_result other) {
- if (other.isSetSuccess()) {
- this.success = org.apache.thrift.TBaseHelper.copyBinary(other.success);
- }
if (other.isSetAuthError()) {
this.authError = new TAuthorizationException(other.authError);
}
@@ -37434,46 +37418,11 @@ public class SatelliteServer {
@Override
public void clear() {
- this.success = null;
this.authError = null;
this.notFound = null;
this.serverError = null;
}
- public byte[] getSuccess() {
- setSuccess(org.apache.thrift.TBaseHelper.rightSize(success));
- return success == null ? null : success.array();
- }
-
- public ByteBuffer bufferForSuccess() {
- return org.apache.thrift.TBaseHelper.copyBinary(success);
- }
-
- public setImageVersionVirtConfig_result setSuccess(byte[] success) {
- this.success = success == null ? (ByteBuffer)null : ByteBuffer.wrap(Arrays.copyOf(success, success.length));
- return this;
- }
-
- public setImageVersionVirtConfig_result setSuccess(ByteBuffer success) {
- this.success = org.apache.thrift.TBaseHelper.copyBinary(success);
- return this;
- }
-
- public void unsetSuccess() {
- this.success = null;
- }
-
- /** Returns true if field success is set (has been assigned a value) and false otherwise */
- public boolean isSetSuccess() {
- return this.success != null;
- }
-
- public void setSuccessIsSet(boolean value) {
- if (!value) {
- this.success = null;
- }
- }
-
public TAuthorizationException getAuthError() {
return this.authError;
}
@@ -37548,14 +37497,6 @@ public class SatelliteServer {
public void setFieldValue(_Fields field, Object value) {
switch (field) {
- case SUCCESS:
- if (value == null) {
- unsetSuccess();
- } else {
- setSuccess((ByteBuffer)value);
- }
- break;
-
case AUTH_ERROR:
if (value == null) {
unsetAuthError();
@@ -37585,9 +37526,6 @@ public class SatelliteServer {
public Object getFieldValue(_Fields field) {
switch (field) {
- case SUCCESS:
- return getSuccess();
-
case AUTH_ERROR:
return getAuthError();
@@ -37608,8 +37546,6 @@ public class SatelliteServer {
}
switch (field) {
- case SUCCESS:
- return isSetSuccess();
case AUTH_ERROR:
return isSetAuthError();
case NOT_FOUND:
@@ -37633,15 +37569,6 @@ public class SatelliteServer {
if (that == null)
return false;
- boolean this_present_success = true && this.isSetSuccess();
- boolean that_present_success = true && that.isSetSuccess();
- if (this_present_success || that_present_success) {
- if (!(this_present_success && that_present_success))
- return false;
- if (!this.success.equals(that.success))
- return false;
- }
-
boolean this_present_authError = true && this.isSetAuthError();
boolean that_present_authError = true && that.isSetAuthError();
if (this_present_authError || that_present_authError) {
@@ -37676,11 +37603,6 @@ public class SatelliteServer {
public int hashCode() {
List<Object> list = new ArrayList<Object>();
- boolean present_success = true && (isSetSuccess());
- list.add(present_success);
- if (present_success)
- list.add(success);
-
boolean present_authError = true && (isSetAuthError());
list.add(present_authError);
if (present_authError)
@@ -37707,16 +37629,6 @@ public class SatelliteServer {
int lastComparison = 0;
- lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess());
- if (lastComparison != 0) {
- return lastComparison;
- }
- if (isSetSuccess()) {
- lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success);
- if (lastComparison != 0) {
- return lastComparison;
- }
- }
lastComparison = Boolean.valueOf(isSetAuthError()).compareTo(other.isSetAuthError());
if (lastComparison != 0) {
return lastComparison;
@@ -37767,14 +37679,6 @@ public class SatelliteServer {
StringBuilder sb = new StringBuilder("setImageVersionVirtConfig_result(");
boolean first = true;
- sb.append("success:");
- if (this.success == null) {
- sb.append("null");
- } else {
- org.apache.thrift.TBaseHelper.toString(this.success, sb);
- }
- first = false;
- if (!first) sb.append(", ");
sb.append("authError:");
if (this.authError == null) {
sb.append("null");
@@ -37841,14 +37745,6 @@ public class SatelliteServer {
break;
}
switch (schemeField.id) {
- case 0: // SUCCESS
- if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
- struct.success = iprot.readBinary();
- struct.setSuccessIsSet(true);
- } else {
- org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
- }
- break;
case 1: // AUTH_ERROR
if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
struct.authError = new TAuthorizationException();
@@ -37891,11 +37787,6 @@ public class SatelliteServer {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
- if (struct.success != null) {
- oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
- oprot.writeBinary(struct.success);
- oprot.writeFieldEnd();
- }
if (struct.authError != null) {
oprot.writeFieldBegin(AUTH_ERROR_FIELD_DESC);
struct.authError.write(oprot);
@@ -37929,22 +37820,16 @@ public class SatelliteServer {
public void write(org.apache.thrift.protocol.TProtocol prot, setImageVersionVirtConfig_result struct) throws org.apache.thrift.TException {
TTupleProtocol oprot = (TTupleProtocol) prot;
BitSet optionals = new BitSet();
- if (struct.isSetSuccess()) {
- optionals.set(0);
- }
if (struct.isSetAuthError()) {
- optionals.set(1);
+ optionals.set(0);
}
if (struct.isSetNotFound()) {
- optionals.set(2);
+ optionals.set(1);
}
if (struct.isSetServerError()) {
- optionals.set(3);
- }
- oprot.writeBitSet(optionals, 4);
- if (struct.isSetSuccess()) {
- oprot.writeBinary(struct.success);
+ optionals.set(2);
}
+ oprot.writeBitSet(optionals, 3);
if (struct.isSetAuthError()) {
struct.authError.write(oprot);
}
@@ -37959,22 +37844,18 @@ public class SatelliteServer {
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, setImageVersionVirtConfig_result struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
- BitSet incoming = iprot.readBitSet(4);
+ BitSet incoming = iprot.readBitSet(3);
if (incoming.get(0)) {
- struct.success = iprot.readBinary();
- struct.setSuccessIsSet(true);
- }
- if (incoming.get(1)) {
struct.authError = new TAuthorizationException();
struct.authError.read(iprot);
struct.setAuthErrorIsSet(true);
}
- if (incoming.get(2)) {
+ if (incoming.get(1)) {
struct.notFound = new TNotFoundException();
struct.notFound.read(iprot);
struct.setNotFoundIsSet(true);
}
- if (incoming.get(3)) {
+ if (incoming.get(2)) {
struct.serverError = new TInvocationException();
struct.serverError.read(iprot);
struct.setServerErrorIsSet(true);
diff --git a/src/main/java/org/openslx/util/ThriftUtil.java b/src/main/java/org/openslx/util/ThriftUtil.java
index 58019a7..41449ac 100644
--- a/src/main/java/org/openslx/util/ThriftUtil.java
+++ b/src/main/java/org/openslx/util/ThriftUtil.java
@@ -1,9 +1,13 @@
package org.openslx.util;
+import java.io.BufferedReader;
+import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
+import org.openslx.util.vm.VmwareConfig;
+
public class ThriftUtil {
public static List<byte[]> unwrapByteBufferList(List<ByteBuffer> blockHashes) {
@@ -31,4 +35,21 @@ public class ThriftUtil {
return byteArray;
}
+ public static String byteBufferToString(ByteBuffer buffer) {
+ byte[] bytes = unwrapByteBuffer(buffer);
+ BufferedReader reader;
+ StringBuffer content = new StringBuffer("");
+ try {
+ reader = VmwareConfig.getVmxReader(bytes, bytes.length);
+ String line="";
+ while ((line=reader.readLine()) != null) {
+ content.append(line + System.lineSeparator());
+ }
+ reader.close();
+ } catch (IOException e) {
+ // swallow - shouldn't happen.
+ return null;
+ }
+ return content.toString();
+ }
}
diff --git a/src/main/java/org/openslx/util/vm/VmwareConfig.java b/src/main/java/org/openslx/util/vm/VmwareConfig.java
index aa82419..c0e30f6 100644
--- a/src/main/java/org/openslx/util/vm/VmwareConfig.java
+++ b/src/main/java/org/openslx/util/vm/VmwareConfig.java
@@ -90,6 +90,12 @@ public class VmwareConfig
}
public static BufferedReader getVmxReader( byte[] vmxContent, int length ) throws IOException {
+ Charset cs = getCharset(vmxContent, length);
+ return new BufferedReader( new InputStreamReader( new ByteArrayInputStream( vmxContent, 0, length ), cs ) );
+
+ }
+
+ public static Charset getCharset( byte[] vmxContent, int length ) {
String csName = detectCharset( new ByteArrayInputStream( vmxContent, 0, length ) );
Charset cs = null;
try {
@@ -99,8 +105,7 @@ public class VmwareConfig
}
if ( cs == null )
cs = StandardCharsets.ISO_8859_1;
- return new BufferedReader( new InputStreamReader( new ByteArrayInputStream( vmxContent, 0, length ), cs ) );
-
+ return cs;
}
private String unescape( String value )
diff --git a/src/main/java/org/openslx/util/vm/VmwareMetaData.java b/src/main/java/org/openslx/util/vm/VmwareMetaData.java
index 9192035..fef2b2d 100644
--- a/src/main/java/org/openslx/util/vm/VmwareMetaData.java
+++ b/src/main/java/org/openslx/util/vm/VmwareMetaData.java
@@ -52,8 +52,8 @@ public class VmwareMetaData extends VmMetaData
public VmwareMetaData( List<OperatingSystem> osList, byte[] vmxContent, int length )
{
super( osList );
- this.config = new VmwareConfig( vmxContent, length );
- init();
+ this.config = new VmwareConfig( vmxContent, length ); // still unfiltered
+ init(); // now filtered
}
private void init()
@@ -61,6 +61,10 @@ public class VmwareMetaData extends VmMetaData
for ( Entry<String, ConfigEntry> entry : config.entrySet() ) {
handleLoadEntry( entry );
}
+ // if we find this tag, we already went through the hdd's - so we're done.
+ if ( config.get("#SLX_HDD_BUS" ) != null) {
+ return;
+ }
// Now find the HDDs and add to list
for ( Entry<String, Controller> cEntry : disks.entrySet() ) {
Controller controller = cEntry.getValue();
@@ -84,6 +88,7 @@ public class VmwareMetaData extends VmMetaData
hdds.add( new HardDisk( controller.virtualDev, bus, device.filename ) );
}
}
+
// Add HDD to cleaned vmx
if ( !hdds.isEmpty() ) {
HardDisk hdd = hdds.get( 0 );
@@ -305,6 +310,11 @@ public class VmwareMetaData extends VmMetaData
return config.toString( true, false ).getBytes( StandardCharsets.UTF_8 );
}
+ public byte[] getDefinitionArray()
+ {
+ return config.toString( false, false ).getBytes( StandardCharsets.UTF_8 );
+ }
+
@Override
public Virtualizer getVirtualizer()
{
diff --git a/src/main/thrift/bwlp.thrift b/src/main/thrift/bwlp.thrift
index e60574d..47f0964 100644
--- a/src/main/thrift/bwlp.thrift
+++ b/src/main/thrift/bwlp.thrift
@@ -531,7 +531,7 @@ service SatelliteServer {
throws (1:TAuthorizationException authError, 2:TNotFoundException notFound, 3:TInvocationException serverError),
// Set image's VM metadata for the given version
- binary setImageVersionVirtConfig(1: Token userToken, 2: UUID imageVersionId, 3: binary meta)
+ void setImageVersionVirtConfig(1: Token userToken, 2: UUID imageVersionId, 3: binary meta)
throws (1:TAuthorizationException authError, 2:TNotFoundException notFound, 3:TInvocationException serverError),
// Client asks server to replicate an image from the master server