Repository: airavata Updated Branches: refs/heads/AIRAVATA-2500 0e97713b0 -> fcf8c471f
http://git-wip-us.apache.org/repos/asf/airavata/blob/fcf8c471/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/appcatalog/accountprovisioning/SSHAccountProvisioner.java ---------------------------------------------------------------------- diff --git a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/appcatalog/accountprovisioning/SSHAccountProvisioner.java b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/appcatalog/accountprovisioning/SSHAccountProvisioner.java new file mode 100644 index 0000000..45b157d --- /dev/null +++ b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/appcatalog/accountprovisioning/SSHAccountProvisioner.java @@ -0,0 +1,406 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ + +/** + * Autogenerated by Thrift Compiler (0.9.3) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package org.apache.airavata.model.appcatalog.accountprovisioning; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)") +public class SSHAccountProvisioner implements org.apache.thrift.TBase<SSHAccountProvisioner, SSHAccountProvisioner._Fields>, java.io.Serializable, Cloneable, Comparable<SSHAccountProvisioner> { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("SSHAccountProvisioner"); + + private static final org.apache.thrift.protocol.TField NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("name", org.apache.thrift.protocol.TType.STRING, (short)1); + + private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new SSHAccountProvisionerStandardSchemeFactory()); + schemes.put(TupleScheme.class, new SSHAccountProvisionerTupleSchemeFactory()); + } + + private String name; // 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 { + NAME((short)1, "name"); + + private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // NAME + return NAME; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + 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.NAME, new org.apache.thrift.meta_data.FieldMetaData("name", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(SSHAccountProvisioner.class, metaDataMap); + } + + public SSHAccountProvisioner() { + } + + public SSHAccountProvisioner( + String name) + { + this(); + this.name = name; + } + + /** + * Performs a deep copy on <i>other</i>. + */ + public SSHAccountProvisioner(SSHAccountProvisioner other) { + if (other.isSetName()) { + this.name = other.name; + } + } + + public SSHAccountProvisioner deepCopy() { + return new SSHAccountProvisioner(this); + } + + @Override + public void clear() { + this.name = null; + } + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + + public void unsetName() { + this.name = null; + } + + /** Returns true if field name is set (has been assigned a value) and false otherwise */ + public boolean isSetName() { + return this.name != null; + } + + public void setNameIsSet(boolean value) { + if (!value) { + this.name = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case NAME: + if (value == null) { + unsetName(); + } else { + setName((String)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case NAME: + return getName(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case NAME: + return isSetName(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof SSHAccountProvisioner) + return this.equals((SSHAccountProvisioner)that); + return false; + } + + public boolean equals(SSHAccountProvisioner that) { + if (that == null) + return false; + + boolean this_present_name = true && this.isSetName(); + boolean that_present_name = true && that.isSetName(); + if (this_present_name || that_present_name) { + if (!(this_present_name && that_present_name)) + return false; + if (!this.name.equals(that.name)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List<Object> list = new ArrayList<Object>(); + + boolean present_name = true && (isSetName()); + list.add(present_name); + if (present_name) + list.add(name); + + return list.hashCode(); + } + + @Override + public int compareTo(SSHAccountProvisioner other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetName()).compareTo(other.isSetName()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetName()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.name, other.name); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("SSHAccountProvisioner("); + boolean first = true; + + sb.append("name:"); + if (this.name == null) { + sb.append("null"); + } else { + sb.append(this.name); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (!isSetName()) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'name' is unset! Struct:" + toString()); + } + + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class SSHAccountProvisionerStandardSchemeFactory implements SchemeFactory { + public SSHAccountProvisionerStandardScheme getScheme() { + return new SSHAccountProvisionerStandardScheme(); + } + } + + private static class SSHAccountProvisionerStandardScheme extends StandardScheme<SSHAccountProvisioner> { + + public void read(org.apache.thrift.protocol.TProtocol iprot, SSHAccountProvisioner struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // NAME + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.name = iprot.readString(); + struct.setNameIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, SSHAccountProvisioner struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.name != null) { + oprot.writeFieldBegin(NAME_FIELD_DESC); + oprot.writeString(struct.name); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class SSHAccountProvisionerTupleSchemeFactory implements SchemeFactory { + public SSHAccountProvisionerTupleScheme getScheme() { + return new SSHAccountProvisionerTupleScheme(); + } + } + + private static class SSHAccountProvisionerTupleScheme extends TupleScheme<SSHAccountProvisioner> { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, SSHAccountProvisioner struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + oprot.writeString(struct.name); + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, SSHAccountProvisioner struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + struct.name = iprot.readString(); + struct.setNameIsSet(true); + } + } + +} + http://git-wip-us.apache.org/repos/asf/airavata/blob/fcf8c471/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/appcatalog/accountprovisioning/SSHAccountProvisionerConfigParam.java ---------------------------------------------------------------------- diff --git a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/appcatalog/accountprovisioning/SSHAccountProvisionerConfigParam.java b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/appcatalog/accountprovisioning/SSHAccountProvisionerConfigParam.java new file mode 100644 index 0000000..11b6613 --- /dev/null +++ b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/appcatalog/accountprovisioning/SSHAccountProvisionerConfigParam.java @@ -0,0 +1,733 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ + +/** + * Autogenerated by Thrift Compiler (0.9.3) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package org.apache.airavata.model.appcatalog.accountprovisioning; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)") +public class SSHAccountProvisionerConfigParam implements org.apache.thrift.TBase<SSHAccountProvisionerConfigParam, SSHAccountProvisionerConfigParam._Fields>, java.io.Serializable, Cloneable, Comparable<SSHAccountProvisionerConfigParam> { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("SSHAccountProvisionerConfigParam"); + + private static final org.apache.thrift.protocol.TField NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("name", org.apache.thrift.protocol.TType.STRING, (short)1); + private static final org.apache.thrift.protocol.TField TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("type", org.apache.thrift.protocol.TType.I32, (short)2); + private static final org.apache.thrift.protocol.TField IS_OPTIONAL_FIELD_DESC = new org.apache.thrift.protocol.TField("isOptional", org.apache.thrift.protocol.TType.BOOL, (short)3); + private static final org.apache.thrift.protocol.TField DESCRIPTION_FIELD_DESC = new org.apache.thrift.protocol.TField("description", org.apache.thrift.protocol.TType.STRING, (short)4); + + private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new SSHAccountProvisionerConfigParamStandardSchemeFactory()); + schemes.put(TupleScheme.class, new SSHAccountProvisionerConfigParamTupleSchemeFactory()); + } + + private String name; // required + private SSHAccountProvisionerConfigParamType type; // required + private boolean isOptional; // required + private String description; // optional + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + NAME((short)1, "name"), + /** + * + * @see SSHAccountProvisionerConfigParamType + */ + TYPE((short)2, "type"), + IS_OPTIONAL((short)3, "isOptional"), + DESCRIPTION((short)4, "description"); + + private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // NAME + return NAME; + case 2: // TYPE + return TYPE; + case 3: // IS_OPTIONAL + return IS_OPTIONAL; + case 4: // DESCRIPTION + return DESCRIPTION; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + private static final int __ISOPTIONAL_ISSET_ID = 0; + private byte __isset_bitfield = 0; + private static final _Fields optionals[] = {_Fields.DESCRIPTION}; + 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.NAME, new org.apache.thrift.meta_data.FieldMetaData("name", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.TYPE, new org.apache.thrift.meta_data.FieldMetaData("type", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, SSHAccountProvisionerConfigParamType.class))); + tmpMap.put(_Fields.IS_OPTIONAL, new org.apache.thrift.meta_data.FieldMetaData("isOptional", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); + tmpMap.put(_Fields.DESCRIPTION, new org.apache.thrift.meta_data.FieldMetaData("description", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(SSHAccountProvisionerConfigParam.class, metaDataMap); + } + + public SSHAccountProvisionerConfigParam() { + this.type = org.apache.airavata.model.appcatalog.accountprovisioning.SSHAccountProvisionerConfigParamType.STRING; + + this.isOptional = false; + + } + + public SSHAccountProvisionerConfigParam( + String name, + SSHAccountProvisionerConfigParamType type, + boolean isOptional) + { + this(); + this.name = name; + this.type = type; + this.isOptional = isOptional; + setIsOptionalIsSet(true); + } + + /** + * Performs a deep copy on <i>other</i>. + */ + public SSHAccountProvisionerConfigParam(SSHAccountProvisionerConfigParam other) { + __isset_bitfield = other.__isset_bitfield; + if (other.isSetName()) { + this.name = other.name; + } + if (other.isSetType()) { + this.type = other.type; + } + this.isOptional = other.isOptional; + if (other.isSetDescription()) { + this.description = other.description; + } + } + + public SSHAccountProvisionerConfigParam deepCopy() { + return new SSHAccountProvisionerConfigParam(this); + } + + @Override + public void clear() { + this.name = null; + this.type = org.apache.airavata.model.appcatalog.accountprovisioning.SSHAccountProvisionerConfigParamType.STRING; + + this.isOptional = false; + + this.description = null; + } + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + + public void unsetName() { + this.name = null; + } + + /** Returns true if field name is set (has been assigned a value) and false otherwise */ + public boolean isSetName() { + return this.name != null; + } + + public void setNameIsSet(boolean value) { + if (!value) { + this.name = null; + } + } + + /** + * + * @see SSHAccountProvisionerConfigParamType + */ + public SSHAccountProvisionerConfigParamType getType() { + return this.type; + } + + /** + * + * @see SSHAccountProvisionerConfigParamType + */ + public void setType(SSHAccountProvisionerConfigParamType type) { + this.type = type; + } + + public void unsetType() { + this.type = null; + } + + /** Returns true if field type is set (has been assigned a value) and false otherwise */ + public boolean isSetType() { + return this.type != null; + } + + public void setTypeIsSet(boolean value) { + if (!value) { + this.type = null; + } + } + + public boolean isIsOptional() { + return this.isOptional; + } + + public void setIsOptional(boolean isOptional) { + this.isOptional = isOptional; + setIsOptionalIsSet(true); + } + + public void unsetIsOptional() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __ISOPTIONAL_ISSET_ID); + } + + /** Returns true if field isOptional is set (has been assigned a value) and false otherwise */ + public boolean isSetIsOptional() { + return EncodingUtils.testBit(__isset_bitfield, __ISOPTIONAL_ISSET_ID); + } + + public void setIsOptionalIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __ISOPTIONAL_ISSET_ID, value); + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + + public void unsetDescription() { + this.description = null; + } + + /** Returns true if field description is set (has been assigned a value) and false otherwise */ + public boolean isSetDescription() { + return this.description != null; + } + + public void setDescriptionIsSet(boolean value) { + if (!value) { + this.description = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case NAME: + if (value == null) { + unsetName(); + } else { + setName((String)value); + } + break; + + case TYPE: + if (value == null) { + unsetType(); + } else { + setType((SSHAccountProvisionerConfigParamType)value); + } + break; + + case IS_OPTIONAL: + if (value == null) { + unsetIsOptional(); + } else { + setIsOptional((Boolean)value); + } + break; + + case DESCRIPTION: + if (value == null) { + unsetDescription(); + } else { + setDescription((String)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case NAME: + return getName(); + + case TYPE: + return getType(); + + case IS_OPTIONAL: + return isIsOptional(); + + case DESCRIPTION: + return getDescription(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case NAME: + return isSetName(); + case TYPE: + return isSetType(); + case IS_OPTIONAL: + return isSetIsOptional(); + case DESCRIPTION: + return isSetDescription(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof SSHAccountProvisionerConfigParam) + return this.equals((SSHAccountProvisionerConfigParam)that); + return false; + } + + public boolean equals(SSHAccountProvisionerConfigParam that) { + if (that == null) + return false; + + boolean this_present_name = true && this.isSetName(); + boolean that_present_name = true && that.isSetName(); + if (this_present_name || that_present_name) { + if (!(this_present_name && that_present_name)) + return false; + if (!this.name.equals(that.name)) + return false; + } + + boolean this_present_type = true && this.isSetType(); + boolean that_present_type = true && that.isSetType(); + if (this_present_type || that_present_type) { + if (!(this_present_type && that_present_type)) + return false; + if (!this.type.equals(that.type)) + return false; + } + + boolean this_present_isOptional = true; + boolean that_present_isOptional = true; + if (this_present_isOptional || that_present_isOptional) { + if (!(this_present_isOptional && that_present_isOptional)) + return false; + if (this.isOptional != that.isOptional) + return false; + } + + boolean this_present_description = true && this.isSetDescription(); + boolean that_present_description = true && that.isSetDescription(); + if (this_present_description || that_present_description) { + if (!(this_present_description && that_present_description)) + return false; + if (!this.description.equals(that.description)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List<Object> list = new ArrayList<Object>(); + + boolean present_name = true && (isSetName()); + list.add(present_name); + if (present_name) + list.add(name); + + boolean present_type = true && (isSetType()); + list.add(present_type); + if (present_type) + list.add(type.getValue()); + + boolean present_isOptional = true; + list.add(present_isOptional); + if (present_isOptional) + list.add(isOptional); + + boolean present_description = true && (isSetDescription()); + list.add(present_description); + if (present_description) + list.add(description); + + return list.hashCode(); + } + + @Override + public int compareTo(SSHAccountProvisionerConfigParam other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetName()).compareTo(other.isSetName()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetName()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.name, other.name); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetType()).compareTo(other.isSetType()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetType()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.type, other.type); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetIsOptional()).compareTo(other.isSetIsOptional()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetIsOptional()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.isOptional, other.isOptional); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetDescription()).compareTo(other.isSetDescription()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetDescription()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.description, other.description); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("SSHAccountProvisionerConfigParam("); + boolean first = true; + + sb.append("name:"); + if (this.name == null) { + sb.append("null"); + } else { + sb.append(this.name); + } + first = false; + if (!first) sb.append(", "); + sb.append("type:"); + if (this.type == null) { + sb.append("null"); + } else { + sb.append(this.type); + } + first = false; + if (!first) sb.append(", "); + sb.append("isOptional:"); + sb.append(this.isOptional); + first = false; + if (isSetDescription()) { + if (!first) sb.append(", "); + sb.append("description:"); + if (this.description == null) { + sb.append("null"); + } else { + sb.append(this.description); + } + first = false; + } + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (!isSetName()) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'name' is unset! Struct:" + toString()); + } + + if (!isSetType()) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'type' is unset! Struct:" + toString()); + } + + if (!isSetIsOptional()) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'isOptional' is unset! Struct:" + toString()); + } + + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. + __isset_bitfield = 0; + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class SSHAccountProvisionerConfigParamStandardSchemeFactory implements SchemeFactory { + public SSHAccountProvisionerConfigParamStandardScheme getScheme() { + return new SSHAccountProvisionerConfigParamStandardScheme(); + } + } + + private static class SSHAccountProvisionerConfigParamStandardScheme extends StandardScheme<SSHAccountProvisionerConfigParam> { + + public void read(org.apache.thrift.protocol.TProtocol iprot, SSHAccountProvisionerConfigParam struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // NAME + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.name = iprot.readString(); + struct.setNameIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // TYPE + if (schemeField.type == org.apache.thrift.protocol.TType.I32) { + struct.type = org.apache.airavata.model.appcatalog.accountprovisioning.SSHAccountProvisionerConfigParamType.findByValue(iprot.readI32()); + struct.setTypeIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 3: // IS_OPTIONAL + if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) { + struct.isOptional = iprot.readBool(); + struct.setIsOptionalIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 4: // DESCRIPTION + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.description = iprot.readString(); + struct.setDescriptionIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, SSHAccountProvisionerConfigParam struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.name != null) { + oprot.writeFieldBegin(NAME_FIELD_DESC); + oprot.writeString(struct.name); + oprot.writeFieldEnd(); + } + if (struct.type != null) { + oprot.writeFieldBegin(TYPE_FIELD_DESC); + oprot.writeI32(struct.type.getValue()); + oprot.writeFieldEnd(); + } + oprot.writeFieldBegin(IS_OPTIONAL_FIELD_DESC); + oprot.writeBool(struct.isOptional); + oprot.writeFieldEnd(); + if (struct.description != null) { + if (struct.isSetDescription()) { + oprot.writeFieldBegin(DESCRIPTION_FIELD_DESC); + oprot.writeString(struct.description); + oprot.writeFieldEnd(); + } + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class SSHAccountProvisionerConfigParamTupleSchemeFactory implements SchemeFactory { + public SSHAccountProvisionerConfigParamTupleScheme getScheme() { + return new SSHAccountProvisionerConfigParamTupleScheme(); + } + } + + private static class SSHAccountProvisionerConfigParamTupleScheme extends TupleScheme<SSHAccountProvisionerConfigParam> { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, SSHAccountProvisionerConfigParam struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + oprot.writeString(struct.name); + oprot.writeI32(struct.type.getValue()); + oprot.writeBool(struct.isOptional); + BitSet optionals = new BitSet(); + if (struct.isSetDescription()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetDescription()) { + oprot.writeString(struct.description); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, SSHAccountProvisionerConfigParam struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + struct.name = iprot.readString(); + struct.setNameIsSet(true); + struct.type = org.apache.airavata.model.appcatalog.accountprovisioning.SSHAccountProvisionerConfigParamType.findByValue(iprot.readI32()); + struct.setTypeIsSet(true); + struct.isOptional = iprot.readBool(); + struct.setIsOptionalIsSet(true); + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.description = iprot.readString(); + struct.setDescriptionIsSet(true); + } + } + } + +} + http://git-wip-us.apache.org/repos/asf/airavata/blob/fcf8c471/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/appcatalog/accountprovisioning/SSHAccountProvisionerConfigParamType.java ---------------------------------------------------------------------- diff --git a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/appcatalog/accountprovisioning/SSHAccountProvisionerConfigParamType.java b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/appcatalog/accountprovisioning/SSHAccountProvisionerConfigParamType.java new file mode 100644 index 0000000..a6bde9a --- /dev/null +++ b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/appcatalog/accountprovisioning/SSHAccountProvisionerConfigParamType.java @@ -0,0 +1,62 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ + +/** + * Autogenerated by Thrift Compiler (0.9.3) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package org.apache.airavata.model.appcatalog.accountprovisioning; + + +import java.util.Map; +import java.util.HashMap; +import org.apache.thrift.TEnum; + +public enum SSHAccountProvisionerConfigParamType implements org.apache.thrift.TEnum { + STRING(0), + CRED_STORE_PASSWORD_TOKEN(1); + + private final int value; + + private SSHAccountProvisionerConfigParamType(int value) { + this.value = value; + } + + /** + * Get the integer value of this enum value, as defined in the Thrift IDL. + */ + public int getValue() { + return value; + } + + /** + * Find a the enum type by its integer value, as defined in the Thrift IDL. + * @return null if the value is not found. + */ + public static SSHAccountProvisionerConfigParamType findByValue(int value) { + switch (value) { + case 0: + return STRING; + case 1: + return CRED_STORE_PASSWORD_TOKEN; + default: + return null; + } + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/fcf8c471/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/appcatalog/gatewayprofile/ComputeResourcePreference.java ---------------------------------------------------------------------- diff --git a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/appcatalog/gatewayprofile/ComputeResourcePreference.java b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/appcatalog/gatewayprofile/ComputeResourcePreference.java index b1c092b..0d52abb 100644 --- a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/appcatalog/gatewayprofile/ComputeResourcePreference.java +++ b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/appcatalog/gatewayprofile/ComputeResourcePreference.java @@ -103,6 +103,8 @@ public class ComputeResourcePreference implements org.apache.thrift.TBase<Comput private static final org.apache.thrift.protocol.TField RESERVATION_FIELD_DESC = new org.apache.thrift.protocol.TField("reservation", org.apache.thrift.protocol.TType.STRING, (short)12); private static final org.apache.thrift.protocol.TField RESERVATION_START_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("reservationStartTime", org.apache.thrift.protocol.TType.I64, (short)13); private static final org.apache.thrift.protocol.TField RESERVATION_END_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("reservationEndTime", org.apache.thrift.protocol.TType.I64, (short)14); + private static final org.apache.thrift.protocol.TField SSH_ACCOUNT_PROVISIONER_FIELD_DESC = new org.apache.thrift.protocol.TField("sshAccountProvisioner", org.apache.thrift.protocol.TType.STRING, (short)15); + private static final org.apache.thrift.protocol.TField SSH_ACCOUNT_PROVISIONER_CONFIG_FIELD_DESC = new org.apache.thrift.protocol.TField("sshAccountProvisionerConfig", org.apache.thrift.protocol.TType.MAP, (short)16); private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); static { @@ -124,6 +126,8 @@ public class ComputeResourcePreference implements org.apache.thrift.TBase<Comput private String reservation; // optional private long reservationStartTime; // optional private long reservationEndTime; // optional + private String sshAccountProvisioner; // optional + private Map<org.apache.airavata.model.appcatalog.accountprovisioning.SSHAccountProvisionerConfigParam,String> sshAccountProvisionerConfig; // optional /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { @@ -148,7 +152,9 @@ public class ComputeResourcePreference implements org.apache.thrift.TBase<Comput QUALITY_OF_SERVICE((short)11, "qualityOfService"), RESERVATION((short)12, "reservation"), RESERVATION_START_TIME((short)13, "reservationStartTime"), - RESERVATION_END_TIME((short)14, "reservationEndTime"); + RESERVATION_END_TIME((short)14, "reservationEndTime"), + SSH_ACCOUNT_PROVISIONER((short)15, "sshAccountProvisioner"), + SSH_ACCOUNT_PROVISIONER_CONFIG((short)16, "sshAccountProvisionerConfig"); private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); @@ -191,6 +197,10 @@ public class ComputeResourcePreference implements org.apache.thrift.TBase<Comput return RESERVATION_START_TIME; case 14: // RESERVATION_END_TIME return RESERVATION_END_TIME; + case 15: // SSH_ACCOUNT_PROVISIONER + return SSH_ACCOUNT_PROVISIONER; + case 16: // SSH_ACCOUNT_PROVISIONER_CONFIG + return SSH_ACCOUNT_PROVISIONER_CONFIG; default: return null; } @@ -235,7 +245,7 @@ public class ComputeResourcePreference implements org.apache.thrift.TBase<Comput private static final int __RESERVATIONSTARTTIME_ISSET_ID = 1; private static final int __RESERVATIONENDTIME_ISSET_ID = 2; private byte __isset_bitfield = 0; - private static final _Fields optionals[] = {_Fields.LOGIN_USER_NAME,_Fields.PREFERRED_JOB_SUBMISSION_PROTOCOL,_Fields.PREFERRED_DATA_MOVEMENT_PROTOCOL,_Fields.PREFERRED_BATCH_QUEUE,_Fields.SCRATCH_LOCATION,_Fields.ALLOCATION_PROJECT_NUMBER,_Fields.RESOURCE_SPECIFIC_CREDENTIAL_STORE_TOKEN,_Fields.USAGE_REPORTING_GATEWAY_ID,_Fields.QUALITY_OF_SERVICE,_Fields.RESERVATION,_Fields.RESERVATION_START_TIME,_Fields.RESERVATION_END_TIME}; + private static final _Fields optionals[] = {_Fields.LOGIN_USER_NAME,_Fields.PREFERRED_JOB_SUBMISSION_PROTOCOL,_Fields.PREFERRED_DATA_MOVEMENT_PROTOCOL,_Fields.PREFERRED_BATCH_QUEUE,_Fields.SCRATCH_LOCATION,_Fields.ALLOCATION_PROJECT_NUMBER,_Fields.RESOURCE_SPECIFIC_CREDENTIAL_STORE_TOKEN,_Fields.USAGE_REPORTING_GATEWAY_ID,_Fields.QUALITY_OF_SERVICE,_Fields.RESERVATION,_Fields.RESERVATION_START_TIME,_Fields.RESERVATION_END_TIME,_Fields.SSH_ACCOUNT_PROVISIONER,_Fields.SSH_ACCOUNT_PROVISIONER_CONFIG}; 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); @@ -267,6 +277,12 @@ public class ComputeResourcePreference implements org.apache.thrift.TBase<Comput new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); tmpMap.put(_Fields.RESERVATION_END_TIME, new org.apache.thrift.meta_data.FieldMetaData("reservationEndTime", org.apache.thrift.TFieldRequirementType.OPTIONAL, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); + tmpMap.put(_Fields.SSH_ACCOUNT_PROVISIONER, new org.apache.thrift.meta_data.FieldMetaData("sshAccountProvisioner", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.SSH_ACCOUNT_PROVISIONER_CONFIG, new org.apache.thrift.meta_data.FieldMetaData("sshAccountProvisionerConfig", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.airavata.model.appcatalog.accountprovisioning.SSHAccountProvisionerConfigParam.class), + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)))); metaDataMap = Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(ComputeResourcePreference.class, metaDataMap); } @@ -327,6 +343,24 @@ public class ComputeResourcePreference implements org.apache.thrift.TBase<Comput } this.reservationStartTime = other.reservationStartTime; this.reservationEndTime = other.reservationEndTime; + if (other.isSetSshAccountProvisioner()) { + this.sshAccountProvisioner = other.sshAccountProvisioner; + } + if (other.isSetSshAccountProvisionerConfig()) { + Map<org.apache.airavata.model.appcatalog.accountprovisioning.SSHAccountProvisionerConfigParam,String> __this__sshAccountProvisionerConfig = new HashMap<org.apache.airavata.model.appcatalog.accountprovisioning.SSHAccountProvisionerConfigParam,String>(other.sshAccountProvisionerConfig.size()); + for (Map.Entry<org.apache.airavata.model.appcatalog.accountprovisioning.SSHAccountProvisionerConfigParam, String> other_element : other.sshAccountProvisionerConfig.entrySet()) { + + org.apache.airavata.model.appcatalog.accountprovisioning.SSHAccountProvisionerConfigParam other_element_key = other_element.getKey(); + String other_element_value = other_element.getValue(); + + org.apache.airavata.model.appcatalog.accountprovisioning.SSHAccountProvisionerConfigParam __this__sshAccountProvisionerConfig_copy_key = new org.apache.airavata.model.appcatalog.accountprovisioning.SSHAccountProvisionerConfigParam(other_element_key); + + String __this__sshAccountProvisionerConfig_copy_value = other_element_value; + + __this__sshAccountProvisionerConfig.put(__this__sshAccountProvisionerConfig_copy_key, __this__sshAccountProvisionerConfig_copy_value); + } + this.sshAccountProvisionerConfig = __this__sshAccountProvisionerConfig; + } } public ComputeResourcePreference deepCopy() { @@ -352,6 +386,8 @@ public class ComputeResourcePreference implements org.apache.thrift.TBase<Comput this.reservationStartTime = 0; setReservationEndTimeIsSet(false); this.reservationEndTime = 0; + this.sshAccountProvisioner = null; + this.sshAccountProvisionerConfig = null; } public String getComputeResourceId() { @@ -689,6 +725,63 @@ public class ComputeResourcePreference implements org.apache.thrift.TBase<Comput __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __RESERVATIONENDTIME_ISSET_ID, value); } + public String getSshAccountProvisioner() { + return this.sshAccountProvisioner; + } + + public void setSshAccountProvisioner(String sshAccountProvisioner) { + this.sshAccountProvisioner = sshAccountProvisioner; + } + + public void unsetSshAccountProvisioner() { + this.sshAccountProvisioner = null; + } + + /** Returns true if field sshAccountProvisioner is set (has been assigned a value) and false otherwise */ + public boolean isSetSshAccountProvisioner() { + return this.sshAccountProvisioner != null; + } + + public void setSshAccountProvisionerIsSet(boolean value) { + if (!value) { + this.sshAccountProvisioner = null; + } + } + + public int getSshAccountProvisionerConfigSize() { + return (this.sshAccountProvisionerConfig == null) ? 0 : this.sshAccountProvisionerConfig.size(); + } + + public void putToSshAccountProvisionerConfig(org.apache.airavata.model.appcatalog.accountprovisioning.SSHAccountProvisionerConfigParam key, String val) { + if (this.sshAccountProvisionerConfig == null) { + this.sshAccountProvisionerConfig = new HashMap<org.apache.airavata.model.appcatalog.accountprovisioning.SSHAccountProvisionerConfigParam,String>(); + } + this.sshAccountProvisionerConfig.put(key, val); + } + + public Map<org.apache.airavata.model.appcatalog.accountprovisioning.SSHAccountProvisionerConfigParam,String> getSshAccountProvisionerConfig() { + return this.sshAccountProvisionerConfig; + } + + public void setSshAccountProvisionerConfig(Map<org.apache.airavata.model.appcatalog.accountprovisioning.SSHAccountProvisionerConfigParam,String> sshAccountProvisionerConfig) { + this.sshAccountProvisionerConfig = sshAccountProvisionerConfig; + } + + public void unsetSshAccountProvisionerConfig() { + this.sshAccountProvisionerConfig = null; + } + + /** Returns true if field sshAccountProvisionerConfig is set (has been assigned a value) and false otherwise */ + public boolean isSetSshAccountProvisionerConfig() { + return this.sshAccountProvisionerConfig != null; + } + + public void setSshAccountProvisionerConfigIsSet(boolean value) { + if (!value) { + this.sshAccountProvisionerConfig = null; + } + } + public void setFieldValue(_Fields field, Object value) { switch (field) { case COMPUTE_RESOURCE_ID: @@ -803,6 +896,22 @@ public class ComputeResourcePreference implements org.apache.thrift.TBase<Comput } break; + case SSH_ACCOUNT_PROVISIONER: + if (value == null) { + unsetSshAccountProvisioner(); + } else { + setSshAccountProvisioner((String)value); + } + break; + + case SSH_ACCOUNT_PROVISIONER_CONFIG: + if (value == null) { + unsetSshAccountProvisionerConfig(); + } else { + setSshAccountProvisionerConfig((Map<org.apache.airavata.model.appcatalog.accountprovisioning.SSHAccountProvisionerConfigParam,String>)value); + } + break; + } } @@ -850,6 +959,12 @@ public class ComputeResourcePreference implements org.apache.thrift.TBase<Comput case RESERVATION_END_TIME: return getReservationEndTime(); + case SSH_ACCOUNT_PROVISIONER: + return getSshAccountProvisioner(); + + case SSH_ACCOUNT_PROVISIONER_CONFIG: + return getSshAccountProvisionerConfig(); + } throw new IllegalStateException(); } @@ -889,6 +1004,10 @@ public class ComputeResourcePreference implements org.apache.thrift.TBase<Comput return isSetReservationStartTime(); case RESERVATION_END_TIME: return isSetReservationEndTime(); + case SSH_ACCOUNT_PROVISIONER: + return isSetSshAccountProvisioner(); + case SSH_ACCOUNT_PROVISIONER_CONFIG: + return isSetSshAccountProvisionerConfig(); } throw new IllegalStateException(); } @@ -1032,6 +1151,24 @@ public class ComputeResourcePreference implements org.apache.thrift.TBase<Comput return false; } + boolean this_present_sshAccountProvisioner = true && this.isSetSshAccountProvisioner(); + boolean that_present_sshAccountProvisioner = true && that.isSetSshAccountProvisioner(); + if (this_present_sshAccountProvisioner || that_present_sshAccountProvisioner) { + if (!(this_present_sshAccountProvisioner && that_present_sshAccountProvisioner)) + return false; + if (!this.sshAccountProvisioner.equals(that.sshAccountProvisioner)) + return false; + } + + boolean this_present_sshAccountProvisionerConfig = true && this.isSetSshAccountProvisionerConfig(); + boolean that_present_sshAccountProvisionerConfig = true && that.isSetSshAccountProvisionerConfig(); + if (this_present_sshAccountProvisionerConfig || that_present_sshAccountProvisionerConfig) { + if (!(this_present_sshAccountProvisionerConfig && that_present_sshAccountProvisionerConfig)) + return false; + if (!this.sshAccountProvisionerConfig.equals(that.sshAccountProvisionerConfig)) + return false; + } + return true; } @@ -1109,6 +1246,16 @@ public class ComputeResourcePreference implements org.apache.thrift.TBase<Comput if (present_reservationEndTime) list.add(reservationEndTime); + boolean present_sshAccountProvisioner = true && (isSetSshAccountProvisioner()); + list.add(present_sshAccountProvisioner); + if (present_sshAccountProvisioner) + list.add(sshAccountProvisioner); + + boolean present_sshAccountProvisionerConfig = true && (isSetSshAccountProvisionerConfig()); + list.add(present_sshAccountProvisionerConfig); + if (present_sshAccountProvisionerConfig) + list.add(sshAccountProvisionerConfig); + return list.hashCode(); } @@ -1260,6 +1407,26 @@ public class ComputeResourcePreference implements org.apache.thrift.TBase<Comput return lastComparison; } } + lastComparison = Boolean.valueOf(isSetSshAccountProvisioner()).compareTo(other.isSetSshAccountProvisioner()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSshAccountProvisioner()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.sshAccountProvisioner, other.sshAccountProvisioner); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetSshAccountProvisionerConfig()).compareTo(other.isSetSshAccountProvisionerConfig()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSshAccountProvisionerConfig()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.sshAccountProvisionerConfig, other.sshAccountProvisionerConfig); + if (lastComparison != 0) { + return lastComparison; + } + } return 0; } @@ -1403,6 +1570,26 @@ public class ComputeResourcePreference implements org.apache.thrift.TBase<Comput sb.append(this.reservationEndTime); first = false; } + if (isSetSshAccountProvisioner()) { + if (!first) sb.append(", "); + sb.append("sshAccountProvisioner:"); + if (this.sshAccountProvisioner == null) { + sb.append("null"); + } else { + sb.append(this.sshAccountProvisioner); + } + first = false; + } + if (isSetSshAccountProvisionerConfig()) { + if (!first) sb.append(", "); + sb.append("sshAccountProvisionerConfig:"); + if (this.sshAccountProvisionerConfig == null) { + sb.append("null"); + } else { + sb.append(this.sshAccountProvisionerConfig); + } + first = false; + } sb.append(")"); return sb.toString(); } @@ -1568,6 +1755,35 @@ public class ComputeResourcePreference implements org.apache.thrift.TBase<Comput org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; + case 15: // SSH_ACCOUNT_PROVISIONER + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.sshAccountProvisioner = iprot.readString(); + struct.setSshAccountProvisionerIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 16: // SSH_ACCOUNT_PROVISIONER_CONFIG + if (schemeField.type == org.apache.thrift.protocol.TType.MAP) { + { + org.apache.thrift.protocol.TMap _map0 = iprot.readMapBegin(); + struct.sshAccountProvisionerConfig = new HashMap<org.apache.airavata.model.appcatalog.accountprovisioning.SSHAccountProvisionerConfigParam,String>(2*_map0.size); + org.apache.airavata.model.appcatalog.accountprovisioning.SSHAccountProvisionerConfigParam _key1; + String _val2; + for (int _i3 = 0; _i3 < _map0.size; ++_i3) + { + _key1 = new org.apache.airavata.model.appcatalog.accountprovisioning.SSHAccountProvisionerConfigParam(); + _key1.read(iprot); + _val2 = iprot.readString(); + struct.sshAccountProvisionerConfig.put(_key1, _val2); + } + iprot.readMapEnd(); + } + struct.setSshAccountProvisionerConfigIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } @@ -1669,6 +1885,28 @@ public class ComputeResourcePreference implements org.apache.thrift.TBase<Comput oprot.writeI64(struct.reservationEndTime); oprot.writeFieldEnd(); } + if (struct.sshAccountProvisioner != null) { + if (struct.isSetSshAccountProvisioner()) { + oprot.writeFieldBegin(SSH_ACCOUNT_PROVISIONER_FIELD_DESC); + oprot.writeString(struct.sshAccountProvisioner); + oprot.writeFieldEnd(); + } + } + if (struct.sshAccountProvisionerConfig != null) { + if (struct.isSetSshAccountProvisionerConfig()) { + oprot.writeFieldBegin(SSH_ACCOUNT_PROVISIONER_CONFIG_FIELD_DESC); + { + oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRUCT, org.apache.thrift.protocol.TType.STRING, struct.sshAccountProvisionerConfig.size())); + for (Map.Entry<org.apache.airavata.model.appcatalog.accountprovisioning.SSHAccountProvisionerConfigParam, String> _iter4 : struct.sshAccountProvisionerConfig.entrySet()) + { + _iter4.getKey().write(oprot); + oprot.writeString(_iter4.getValue()); + } + oprot.writeMapEnd(); + } + oprot.writeFieldEnd(); + } + } oprot.writeFieldStop(); oprot.writeStructEnd(); } @@ -1725,7 +1963,13 @@ public class ComputeResourcePreference implements org.apache.thrift.TBase<Comput if (struct.isSetReservationEndTime()) { optionals.set(11); } - oprot.writeBitSet(optionals, 12); + if (struct.isSetSshAccountProvisioner()) { + optionals.set(12); + } + if (struct.isSetSshAccountProvisionerConfig()) { + optionals.set(13); + } + oprot.writeBitSet(optionals, 14); if (struct.isSetLoginUserName()) { oprot.writeString(struct.loginUserName); } @@ -1762,6 +2006,19 @@ public class ComputeResourcePreference implements org.apache.thrift.TBase<Comput if (struct.isSetReservationEndTime()) { oprot.writeI64(struct.reservationEndTime); } + if (struct.isSetSshAccountProvisioner()) { + oprot.writeString(struct.sshAccountProvisioner); + } + if (struct.isSetSshAccountProvisionerConfig()) { + { + oprot.writeI32(struct.sshAccountProvisionerConfig.size()); + for (Map.Entry<org.apache.airavata.model.appcatalog.accountprovisioning.SSHAccountProvisionerConfigParam, String> _iter5 : struct.sshAccountProvisionerConfig.entrySet()) + { + _iter5.getKey().write(oprot); + oprot.writeString(_iter5.getValue()); + } + } + } } @Override @@ -1771,7 +2028,7 @@ public class ComputeResourcePreference implements org.apache.thrift.TBase<Comput struct.setComputeResourceIdIsSet(true); struct.overridebyAiravata = iprot.readBool(); struct.setOverridebyAiravataIsSet(true); - BitSet incoming = iprot.readBitSet(12); + BitSet incoming = iprot.readBitSet(14); if (incoming.get(0)) { struct.loginUserName = iprot.readString(); struct.setLoginUserNameIsSet(true); @@ -1820,6 +2077,26 @@ public class ComputeResourcePreference implements org.apache.thrift.TBase<Comput struct.reservationEndTime = iprot.readI64(); struct.setReservationEndTimeIsSet(true); } + if (incoming.get(12)) { + struct.sshAccountProvisioner = iprot.readString(); + struct.setSshAccountProvisionerIsSet(true); + } + if (incoming.get(13)) { + { + org.apache.thrift.protocol.TMap _map6 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRUCT, org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.sshAccountProvisionerConfig = new HashMap<org.apache.airavata.model.appcatalog.accountprovisioning.SSHAccountProvisionerConfigParam,String>(2*_map6.size); + org.apache.airavata.model.appcatalog.accountprovisioning.SSHAccountProvisionerConfigParam _key7; + String _val8; + for (int _i9 = 0; _i9 < _map6.size; ++_i9) + { + _key7 = new org.apache.airavata.model.appcatalog.accountprovisioning.SSHAccountProvisionerConfigParam(); + _key7.read(iprot); + _val8 = iprot.readString(); + struct.sshAccountProvisionerConfig.put(_key7, _val8); + } + } + struct.setSshAccountProvisionerConfigIsSet(true); + } } } http://git-wip-us.apache.org/repos/asf/airavata/blob/fcf8c471/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/appcatalog/gatewayprofile/GatewayResourceProfile.java ---------------------------------------------------------------------- diff --git a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/appcatalog/gatewayprofile/GatewayResourceProfile.java b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/appcatalog/gatewayprofile/GatewayResourceProfile.java index 31f33f6..725bf43 100644 --- a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/appcatalog/gatewayprofile/GatewayResourceProfile.java +++ b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/appcatalog/gatewayprofile/GatewayResourceProfile.java @@ -830,14 +830,14 @@ public class GatewayResourceProfile implements org.apache.thrift.TBase<GatewayRe case 3: // COMPUTE_RESOURCE_PREFERENCES if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list0 = iprot.readListBegin(); - struct.computeResourcePreferences = new ArrayList<ComputeResourcePreference>(_list0.size); - ComputeResourcePreference _elem1; - for (int _i2 = 0; _i2 < _list0.size; ++_i2) + org.apache.thrift.protocol.TList _list10 = iprot.readListBegin(); + struct.computeResourcePreferences = new ArrayList<ComputeResourcePreference>(_list10.size); + ComputeResourcePreference _elem11; + for (int _i12 = 0; _i12 < _list10.size; ++_i12) { - _elem1 = new ComputeResourcePreference(); - _elem1.read(iprot); - struct.computeResourcePreferences.add(_elem1); + _elem11 = new ComputeResourcePreference(); + _elem11.read(iprot); + struct.computeResourcePreferences.add(_elem11); } iprot.readListEnd(); } @@ -849,14 +849,14 @@ public class GatewayResourceProfile implements org.apache.thrift.TBase<GatewayRe case 4: // STORAGE_PREFERENCES if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list3 = iprot.readListBegin(); - struct.storagePreferences = new ArrayList<StoragePreference>(_list3.size); - StoragePreference _elem4; - for (int _i5 = 0; _i5 < _list3.size; ++_i5) + org.apache.thrift.protocol.TList _list13 = iprot.readListBegin(); + struct.storagePreferences = new ArrayList<StoragePreference>(_list13.size); + StoragePreference _elem14; + for (int _i15 = 0; _i15 < _list13.size; ++_i15) { - _elem4 = new StoragePreference(); - _elem4.read(iprot); - struct.storagePreferences.add(_elem4); + _elem14 = new StoragePreference(); + _elem14.read(iprot); + struct.storagePreferences.add(_elem14); } iprot.readListEnd(); } @@ -911,9 +911,9 @@ public class GatewayResourceProfile implements org.apache.thrift.TBase<GatewayRe oprot.writeFieldBegin(COMPUTE_RESOURCE_PREFERENCES_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.computeResourcePreferences.size())); - for (ComputeResourcePreference _iter6 : struct.computeResourcePreferences) + for (ComputeResourcePreference _iter16 : struct.computeResourcePreferences) { - _iter6.write(oprot); + _iter16.write(oprot); } oprot.writeListEnd(); } @@ -925,9 +925,9 @@ public class GatewayResourceProfile implements org.apache.thrift.TBase<GatewayRe oprot.writeFieldBegin(STORAGE_PREFERENCES_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.storagePreferences.size())); - for (StoragePreference _iter7 : struct.storagePreferences) + for (StoragePreference _iter17 : struct.storagePreferences) { - _iter7.write(oprot); + _iter17.write(oprot); } oprot.writeListEnd(); } @@ -989,18 +989,18 @@ public class GatewayResourceProfile implements org.apache.thrift.TBase<GatewayRe if (struct.isSetComputeResourcePreferences()) { { oprot.writeI32(struct.computeResourcePreferences.size()); - for (ComputeResourcePreference _iter8 : struct.computeResourcePreferences) + for (ComputeResourcePreference _iter18 : struct.computeResourcePreferences) { - _iter8.write(oprot); + _iter18.write(oprot); } } } if (struct.isSetStoragePreferences()) { { oprot.writeI32(struct.storagePreferences.size()); - for (StoragePreference _iter9 : struct.storagePreferences) + for (StoragePreference _iter19 : struct.storagePreferences) { - _iter9.write(oprot); + _iter19.write(oprot); } } } @@ -1024,28 +1024,28 @@ public class GatewayResourceProfile implements org.apache.thrift.TBase<GatewayRe } if (incoming.get(1)) { { - org.apache.thrift.protocol.TList _list10 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.computeResourcePreferences = new ArrayList<ComputeResourcePreference>(_list10.size); - ComputeResourcePreference _elem11; - for (int _i12 = 0; _i12 < _list10.size; ++_i12) + org.apache.thrift.protocol.TList _list20 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.computeResourcePreferences = new ArrayList<ComputeResourcePreference>(_list20.size); + ComputeResourcePreference _elem21; + for (int _i22 = 0; _i22 < _list20.size; ++_i22) { - _elem11 = new ComputeResourcePreference(); - _elem11.read(iprot); - struct.computeResourcePreferences.add(_elem11); + _elem21 = new ComputeResourcePreference(); + _elem21.read(iprot); + struct.computeResourcePreferences.add(_elem21); } } struct.setComputeResourcePreferencesIsSet(true); } if (incoming.get(2)) { { - org.apache.thrift.protocol.TList _list13 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.storagePreferences = new ArrayList<StoragePreference>(_list13.size); - StoragePreference _elem14; - for (int _i15 = 0; _i15 < _list13.size; ++_i15) + org.apache.thrift.protocol.TList _list23 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.storagePreferences = new ArrayList<StoragePreference>(_list23.size); + StoragePreference _elem24; + for (int _i25 = 0; _i25 < _list23.size; ++_i25) { - _elem14 = new StoragePreference(); - _elem14.read(iprot); - struct.storagePreferences.add(_elem14); + _elem24 = new StoragePreference(); + _elem24.read(iprot); + struct.storagePreferences.add(_elem24); } } struct.setStoragePreferencesIsSet(true); http://git-wip-us.apache.org/repos/asf/airavata/blob/fcf8c471/modules/compute-account-provisioning/src/main/java/org/apache/airavata/accountprovisioning/SSHAccountManager.java ---------------------------------------------------------------------- diff --git a/modules/compute-account-provisioning/src/main/java/org/apache/airavata/accountprovisioning/SSHAccountManager.java b/modules/compute-account-provisioning/src/main/java/org/apache/airavata/accountprovisioning/SSHAccountManager.java index dcb819b..86bf8c1 100644 --- a/modules/compute-account-provisioning/src/main/java/org/apache/airavata/accountprovisioning/SSHAccountManager.java +++ b/modules/compute-account-provisioning/src/main/java/org/apache/airavata/accountprovisioning/SSHAccountManager.java @@ -25,6 +25,8 @@ import org.apache.airavata.common.utils.ServerSettings; import org.apache.airavata.credential.store.client.CredentialStoreClientFactory; import org.apache.airavata.credential.store.cpi.CredentialStoreService; import org.apache.airavata.credential.store.exception.CredentialStoreException; +import org.apache.airavata.model.appcatalog.accountprovisioning.SSHAccountProvisionerConfigParam; +import org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference; import org.apache.airavata.model.credential.store.PasswordCredential; import org.apache.airavata.registry.api.RegistryService; import org.apache.airavata.registry.api.client.RegistryServiceClientFactory; @@ -32,36 +34,30 @@ import org.apache.airavata.registry.api.exception.RegistryServiceException; import org.apache.thrift.TException; import java.util.HashMap; +import java.util.List; import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; public class SSHAccountManager { // TODO: need private key too to verify - public static void setupSSHAccount(String gatewayId, String hostname, String username, String sshPublicKey) { - - // TODO: finish implementing + public static void setupSSHAccount(String gatewayId, String computeResourceId, String username, String sshPublicKey) { // get compute resource preferences for the gateway and hostname + // TODO: close the registry service client transport when done with it + RegistryService.Client registryServiceClient = getRegistryServiceClient(); + ComputeResourcePreference computeResourcePreference = registryServiceClient.getGatewayComputeResourcePreference(gatewayId, computeResourceId); // get the account provisioner and config values for the preferences - String provisionerName = null; - Map<ConfigParam,String> provisionerConfig = null; - - CredentialStoreService.Client credentialStoreServiceClient = getCredentialStoreClient(); - // Resolve any CRED_STORE_PASSWORD_TOKEN config parameters to passwords - Map<ConfigParam,String> resolvedConfig = new HashMap<>(); - for (Map.Entry<ConfigParam,String> configEntry : provisionerConfig.entrySet() ) { - if (configEntry.getKey().getType() == ConfigParam.ConfigParamType.CRED_STORE_PASSWORD_TOKEN) { - try { - PasswordCredential password = credentialStoreServiceClient.getPasswordCredential(configEntry.getValue(), gatewayId); - resolvedConfig.put(configEntry.getKey(), password.getPassword()); - } catch (TException e) { - throw new RuntimeException("Failed to get password needed to configure " + provisionerName); - } - } else { - resolvedConfig.put(configEntry.getKey(), configEntry.getValue()); - } + if (!computeResourcePreference.isSetSshAccountProvisioner()) { + // TODO: provide better exception? + throw new RuntimeException("Compute resource [" + computeResourceId + "] does not have an SSH Account Provisioner configured for it."); } + String provisionerName = computeResourcePreference.getSshAccountProvisioner(); + Map<ConfigParam,String> provisionerConfig = convertConfigParams(provisionerName, computeResourcePreference.getSshAccountProvisionerConfig()); + + Map<ConfigParam, String> resolvedConfig = resolveProvisionerConfig(gatewayId, provisionerName, provisionerConfig); // instantiate and init the account provisioner SSHAccountProvisioner sshAccountProvisioner = SSHAccountProvisionerFactory.createSSHAccountProvisioner(provisionerName, resolvedConfig); @@ -70,12 +66,14 @@ public class SSHAccountManager { boolean hasAccount = sshAccountProvisioner.hasAccount(username); if (!hasAccount && !sshAccountProvisioner.canCreateAccount()) { - // TODO: throw an exception + // TODO: provide better exception + throw new RuntimeException("User [" + username + "] doesn't have account and [" + provisionerName + "] doesn't support creating account."); } // TODO: first check if SSH key is already installed, or do we care? // Install SSH key + sshAccountProvisioner.installSSHKey(username, sshPublicKey); // Verify can authenticate to host @@ -83,10 +81,50 @@ public class SSHAccountManager { String scratchLocation = sshAccountProvisioner.getScratchLocation(username); } - private static RegistryService.Client getRegistryServiceClient() throws RegistryServiceException { + private static Map<ConfigParam, String> resolveProvisionerConfig(String gatewayId, String provisionerName, Map<ConfigParam, String> provisionerConfig) { + CredentialStoreService.Client credentialStoreServiceClient = null; + try { + credentialStoreServiceClient = getCredentialStoreClient(); + // Resolve any CRED_STORE_PASSWORD_TOKEN config parameters to passwords + Map<ConfigParam, String> resolvedConfig = new HashMap<>(); + for (Map.Entry<ConfigParam, String> configEntry : provisionerConfig.entrySet()) { + if (configEntry.getKey().getType() == ConfigParam.ConfigParamType.CRED_STORE_PASSWORD_TOKEN) { + try { + PasswordCredential password = credentialStoreServiceClient.getPasswordCredential(configEntry.getValue(), gatewayId); + resolvedConfig.put(configEntry.getKey(), password.getPassword()); + } catch (TException e) { + throw new RuntimeException("Failed to get password needed to configure " + provisionerName); + } + } else { + resolvedConfig.put(configEntry.getKey(), configEntry.getValue()); + } + } + return resolvedConfig; + } finally { + if (credentialStoreServiceClient != null) { + if (credentialStoreServiceClient.getInputProtocol().getTransport().isOpen()) { + credentialStoreServiceClient.getInputProtocol().getTransport().close(); + } + } + } + } + + private static Map<ConfigParam, String> convertConfigParams(String provisionerName, Map<SSHAccountProvisionerConfigParam, String> thriftConfigParams) { + List<ConfigParam> configParams = SSHAccountProvisionerFactory.getSSHAccountProvisionerConfigParams(provisionerName); + Map<String, ConfigParam> configParamMap = configParams.stream().collect(Collectors.toMap(ConfigParam::getName, Function.identity())); + + return thriftConfigParams.entrySet().stream().collect(Collectors.toMap(entry -> configParamMap.get(entry.getKey().getName()), entry -> entry.getValue())); + } + + private static RegistryService.Client getRegistryServiceClient() { - // TODO: finish implementing - return RegistryServiceClientFactory.createRegistryClient(null, 0); + try { + String registryServerHost = ServerSettings.getRegistryServerHost(); + int registryServerPort = Integer.valueOf(ServerSettings.getRegistryServerPort()); + return RegistryServiceClientFactory.createRegistryClient(registryServerHost, registryServerPort); + } catch (ApplicationSettingsException|RegistryServiceException e) { + throw new RuntimeException("Failed to create registry service client", e); + } } private static CredentialStoreService.Client getCredentialStoreClient() { http://git-wip-us.apache.org/repos/asf/airavata/blob/fcf8c471/thrift-interface-descriptions/data-models/resource-catalog-models/account_provisioning_model.thrift ---------------------------------------------------------------------- diff --git a/thrift-interface-descriptions/data-models/resource-catalog-models/account_provisioning_model.thrift b/thrift-interface-descriptions/data-models/resource-catalog-models/account_provisioning_model.thrift index 627116e..a6c6ab9 100644 --- a/thrift-interface-descriptions/data-models/resource-catalog-models/account_provisioning_model.thrift +++ b/thrift-interface-descriptions/data-models/resource-catalog-models/account_provisioning_model.thrift @@ -35,6 +35,6 @@ struct SSHAccountProvisioner { struct SSHAccountProvisionerConfigParam { 1: required string name; 2: required SSHAccountProvisionerConfigParamType type = SSHAccountProvisionerConfigParamType.STRING; - 3: required bool optional = false; + 3: required bool isOptional = false; 4: optional string description; } http://git-wip-us.apache.org/repos/asf/airavata/blob/fcf8c471/thrift-interface-descriptions/data-models/resource-catalog-models/gateway_resource_profile_model.thrift ---------------------------------------------------------------------- diff --git a/thrift-interface-descriptions/data-models/resource-catalog-models/gateway_resource_profile_model.thrift b/thrift-interface-descriptions/data-models/resource-catalog-models/gateway_resource_profile_model.thrift index 6244c28..060442b 100644 --- a/thrift-interface-descriptions/data-models/resource-catalog-models/gateway_resource_profile_model.thrift +++ b/thrift-interface-descriptions/data-models/resource-catalog-models/gateway_resource_profile_model.thrift @@ -77,7 +77,7 @@ struct ComputeResourcePreference { 13: optional i64 reservationStartTime, 14: optional i64 reservationEndTime, 15: optional string sshAccountProvisioner, - 16: optional map<account_provisioning_model.SSHAccountProvisionerConfigParam, String> sshAccountProvisionerConfig + 16: optional map<account_provisioning_model.SSHAccountProvisionerConfigParam, string> sshAccountProvisionerConfig } struct StoragePreference {
