fmaximus commented on a change in pull request #2193: CLOUDSTACK-10007
Isolation methods
URL: https://github.com/apache/cloudstack/pull/2193#discussion_r129041647
##########
File path: api/src/com/cloud/network/PhysicalNetwork.java
##########
@@ -32,8 +35,82 @@
Disabled, Enabled;
}
- public enum IsolationMethod {
- VLAN, L3, GRE, STT, BCF_SEGMENT, MIDO, SSP, VXLAN, ODL, L3VPN, VSP,
VCS;
+ public class IsolationMethod {
+ protected static final String UNKNOWN_PROVIDER = "Unknown";
+ private static Set<IsolationMethod> registeredIsolationMethods = new
HashSet<>();
+
+ /**
+ * gets a IsolationMethod object that defines this prefix and if any
it returns the first one found that has a known provider. If none has a known
provider
+ * it will return the one with the unknown provider. if none is found
it return null.
+ *
+ * @param prfx
+ * @return
+ */
+ public static IsolationMethod getIsolationMethod(String prfx) {
+ IsolationMethod rc = null;
+ for (IsolationMethod method: registeredIsolationMethods) {
+ if (method.provider.equals(prfx)) {
+ rc = method;
+ if(! rc.getProvider().equals(UNKNOWN_PROVIDER)) {
+ break;
+ }
+ }
+ }
+ return rc;
+ }
+
+ public String getMethodPrefix() {
+ return methodPrefix;
+ }
+
+ public String getProvider() {
+ return provider;
+ }
+
+ String methodPrefix;
+ String provider;
+
+ // VLAN, L3, GRE, STT, BCF_SEGMENT, MIDO, SSP, VXLAN, ODL, L3VPN, VSP,
VCS;
+
+ public IsolationMethod(String prfx) {
+ this(prfx, UNKNOWN_PROVIDER);
+ }
+
+ public IsolationMethod(String prfx, String prvdr) {
+ methodPrefix = prfx;
+ provider = StringUtils.isNotBlank(prvdr)? prvdr : UNKNOWN_PROVIDER;
+ registeredIsolationMethods.add(this);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+ IsolationMethod that = (IsolationMethod)o;
+ return Objects.equals(methodPrefix, that.methodPrefix) &&
Objects.equals(provider, that.provider);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(methodPrefix, provider);
+ }
+
+ @Override
+ public String toString() {
+ return methodPrefix.toString();
Review comment:
'methodPrefix.toString()' is redundant
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services