aboutsummaryrefslogtreecommitdiffstats
path: root/uni/unibase/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'uni/unibase/src/main/java')
-rw-r--r--uni/unibase/src/main/java/com/cablelabs/vcpe/uni/unibase/client/EvcPathClient.java180
-rw-r--r--uni/unibase/src/main/java/com/cablelabs/vcpe/uni/unibase/client/UniClient.java188
-rw-r--r--uni/unibase/src/main/java/com/cablelabs/vcpe/uni/unibase/model/EvcPath.java112
-rw-r--r--uni/unibase/src/main/java/com/cablelabs/vcpe/uni/unibase/model/Uni.java230
4 files changed, 710 insertions, 0 deletions
diff --git a/uni/unibase/src/main/java/com/cablelabs/vcpe/uni/unibase/client/EvcPathClient.java b/uni/unibase/src/main/java/com/cablelabs/vcpe/uni/unibase/client/EvcPathClient.java
new file mode 100644
index 0000000..1bc41b5
--- /dev/null
+++ b/uni/unibase/src/main/java/com/cablelabs/vcpe/uni/unibase/client/EvcPathClient.java
@@ -0,0 +1,180 @@
+package com.cablelabs.vcpe.uni.unibase.client;
+
+import com.cablelabs.vcpe.common.Dbg;
+import com.cablelabs.vcpe.uni.unibase.model.EvcPath;
+import com.cablelabs.vcpe.uni.unibase.model.Uni;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.GenericType;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.xml.bind.DatatypeConverter;
+import java.util.List;
+
+/**
+ * Created by steve on 5/28/15.
+ */
+
+public class EvcPathClient {
+
+ private String evcMgrServer = "localhost";
+ private String evcMgrPort = "8181";
+ private String evcMgrCfgRESTPath = "/restconf/config/cl-vcpe-mef:evcs/";
+
+ private Client client; // provided by Jersey
+
+ public EvcPathClient() {
+ client = ClientBuilder.newClient();
+ }
+
+ //--------------------------------------------------------
+ public Response create(EvcPath evcPath )
+ //--------------------------------------------------------
+ {
+ WebTarget target =client.target("http://"+evcMgrServer+":" + evcMgrPort + evcMgrCfgRESTPath);
+
+ String json = evcPath.toJson();
+ Dbg.p("\nEVC Create JSON:");
+ Dbg.p(json);
+
+ Response response = target.path("evc")
+ .request(MediaType.APPLICATION_JSON)
+ .post(Entity.entity(json, MediaType.APPLICATION_JSON));
+
+ if (response.getStatus() != 200 ) // figure out how to use Status.OK
+ {
+ // in production you can be more specific based on reponse code, id, etc
+ throw new RuntimeException(response.getStatus() + ": there was an error on the server.");
+ }
+ //return response.readEntity(EvcPath.class);
+ return response;
+ }
+
+ //--------------------------------------------------------
+ public Response update(EvcPath evcPath) throws Exception
+ //--------------------------------------------------------
+ {
+ WebTarget target =client.target("http://"+evcMgrServer+":" + evcMgrPort + evcMgrCfgRESTPath);
+
+ String json = evcPath.toJson();
+ String unamepass = "admin:admin";
+ String authorizationHeaderValue = "Basic " + DatatypeConverter.printBase64Binary(unamepass.getBytes("UTF-8"));
+ Dbg.p("\nEVC Create/Update JSON:");
+ Dbg.p(json);
+
+ Response response = target.path("evc/"+evcPath.getId())
+ .request(MediaType.APPLICATION_JSON)
+ .header("Authorization", authorizationHeaderValue)
+ .put(Entity.entity(json, MediaType.APPLICATION_JSON));
+
+ if (response.getStatus() != 200 ) // figure out how to use Status.OK
+ {
+ // in production you can be more specific based on reponse code, id, etc
+ throw new RuntimeException(response.getStatus() + ": there was an error on the server.");
+ }
+ return response;
+ }
+ //--------------------------------------------------------
+ public void delete(String evcPathId) throws Exception
+ //--------------------------------------------------------
+ // delete EvcPath of specified ID
+ {
+ WebTarget target =client.target("http://"+evcMgrServer+":" + evcMgrPort + evcMgrCfgRESTPath);
+
+ String uNameAndPass = "admin:admin";
+ String authorizationHeaderValue = "Basic " +
+ DatatypeConverter.printBase64Binary(uNameAndPass.getBytes("UTF-8"));
+
+ Response response = target.path("evc/" + evcPathId)
+ .request(MediaType.APPLICATION_JSON)
+ .header("Authorization", authorizationHeaderValue)
+ .delete();
+ if (response.getStatus() != 200) // figure out how to use Status.OK
+ {
+ // in production you can be more specific based on reponse code, id, etc
+ throw new RuntimeException(response.getStatus() + ": there was an error on the server.");
+ }
+ }
+
+ //
+ // Code from here below requires work in order to work with ODL
+ //
+
+ //--------------------------------------------------------
+ public EvcPath get(String evcPathId)
+ //--------------------------------------------------------
+ // get EvcPath of specified ID
+ {
+ WebTarget target = client.target("http://localhost:9090/evcmgr/webapi/");
+
+ Response response = target.path("evc/"+evcPathId).request(MediaType.APPLICATION_JSON).get(Response.class);
+ if (response.getStatus() != 200) // figure out how to use Status.OK
+ {
+ // in production you can be more specific based on reponse code, id, etc
+ throw new RuntimeException(response.getStatus() + ": there was an error on the server.");
+ }
+
+ return response.readEntity(EvcPath.class);
+ }
+
+ //--------------------------------------------------------
+ public List<EvcPath> getAll()
+ //--------------------------------------------------------
+ // get a list of all EvcPath instances
+ {
+
+ WebTarget target = client.target("http://localhost:9090/evcmgr/webapi/");
+
+ // Can I do this with a Response, so that I can check for errors
+ List<EvcPath> response = target.path("evc/list")
+ .request(MediaType.APPLICATION_JSON)
+ .get(new GenericType<List<EvcPath>>() {
+ });
+ if (response == null) // figure out how to use Status.OK
+ {
+ // in production you can be more specific based on reponse code, id, etc
+ throw new RuntimeException("there was an error on the server.");
+ }
+ return response;
+ }
+
+ //--------------------------------------------------------
+ public EvcPath testGet()
+ //--------------------------------------------------------
+ // test marshaling of EvcPath class from server json
+ {
+ WebTarget target = client.target("http://localhost:9090/evcmgr/webapi/");
+
+ Response response = target.path("evc").request(MediaType.APPLICATION_JSON).get(Response.class);
+ if (response.getStatus() != 200) // figure out how to use Status.OK
+ {
+ // in production you can be more specific based on reponse code, id, etc
+ throw new RuntimeException(response.getStatus() + ": there was an error on the server.");
+ }
+
+ //return response;
+ return response.readEntity(EvcPath.class);
+ }
+
+ //--------------------------------------------------------
+ public String ping()
+ //--------------------------------------------------------
+ // test connectivity
+ {
+
+ WebTarget target = client.target("http://localhost:9090/evcmgr/webapi/");
+
+ Response response = target.path("evc").request(MediaType.TEXT_PLAIN).get();
+ if (response.getStatus() != 200) // figure out how to use Status.OK
+ {
+ // in production you can be more specific based on reponse code, id, etc
+ throw new RuntimeException(response.getStatus() + ": there was an error on the server.");
+ }
+
+
+ return response.readEntity(String.class);
+ }
+}
diff --git a/uni/unibase/src/main/java/com/cablelabs/vcpe/uni/unibase/client/UniClient.java b/uni/unibase/src/main/java/com/cablelabs/vcpe/uni/unibase/client/UniClient.java
new file mode 100644
index 0000000..a1dcff4
--- /dev/null
+++ b/uni/unibase/src/main/java/com/cablelabs/vcpe/uni/unibase/client/UniClient.java
@@ -0,0 +1,188 @@
+package com.cablelabs.vcpe.uni.unibase.client;
+
+import com.cablelabs.vcpe.common.Dbg;
+import com.cablelabs.vcpe.uni.unibase.model.Uni;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.GenericType;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.util.List;
+import javax.xml.bind.DatatypeConverter;
+
+/**
+ * Created by steve on 5/28/15.
+ */
+
+public class UniClient {
+
+ private String uniMgrServer = "localhost";
+ private String uniMgrPort = "8181";
+ private String uniMgrCfgRESTPath = "/restconf/config/cl-vcpe-mef:unis/";
+
+ private Client client; // provided by Jersey
+
+ public UniClient() {
+ client = ClientBuilder.newClient();
+ }
+
+ //--------------------------------------------------------
+ public Response create(Uni uni ) throws Exception
+ //--------------------------------------------------------
+ // create Uni
+ {
+ WebTarget target =client.target("http://"+uniMgrServer+":" + uniMgrPort + uniMgrCfgRESTPath);
+
+ String json = uni.toJson();
+ Dbg.p("\nUNI Create JSON:");
+ Dbg.p(json);
+
+ String uNameAndPass = "admin:admin";
+ String authorizationHeaderValue = "Basic " +
+ DatatypeConverter.printBase64Binary(uNameAndPass.getBytes("UTF-8"));
+ Response response = target.path("uni")
+ .request(MediaType.APPLICATION_JSON)
+ .header("Authorization", authorizationHeaderValue)
+ .post(Entity.entity(json, MediaType.APPLICATION_JSON));
+
+ if (response.getStatus() != 200 ) // figure out how to use Status.OK
+ {
+ // in production you can be more specific based on reponse code, id, etc
+ throw new RuntimeException(response.getStatus() + ": there was an error on the server.");
+ }
+ //return response.readEntity(Uni.class);
+ return response;
+ }
+
+ //--------------------------------------------------------
+ public Response update(Uni uni) throws Exception
+ //--------------------------------------------------------
+ // create/update Uni. This seems to be how OLD expects uni creation
+ {
+ WebTarget target =client.target("http://"+uniMgrServer+":" + uniMgrPort + uniMgrCfgRESTPath);
+
+ String json = uni.toJson();
+ Dbg.p("\nUNI Create/Update JSON:");
+ Dbg.p(json);
+
+ String uNameAndPass = "admin:admin";
+ String authorizationHeaderValue = "Basic " +
+ DatatypeConverter.printBase64Binary(uNameAndPass.getBytes("UTF-8"));
+ Response response = target.path("uni/"+uni.getId())
+ .request(MediaType.APPLICATION_JSON)
+ .header("Authorization", authorizationHeaderValue)
+ .put(Entity.entity(json, MediaType.APPLICATION_JSON));
+
+ if (response.getStatus() != 200 ) // figure out how to use Status.OK
+ {
+ // in production you can be more specific based on reponse code, id, etc
+ throw new RuntimeException(response.getStatus() + ": there was an error on the server.");
+ }
+ return response;
+ }
+
+ //--------------------------------------------------------
+ public void delete(String uniId) throws Exception
+ //--------------------------------------------------------
+ // delete Uni of specified ID
+ {
+ WebTarget target =client.target("http://"+uniMgrServer+":" + uniMgrPort + uniMgrCfgRESTPath);
+
+ String uNameAndPass = "admin:admin";
+ String authorizationHeaderValue = "Basic " +
+ DatatypeConverter.printBase64Binary(uNameAndPass.getBytes("UTF-8"));
+
+ Response response = target.path("uni/" + uniId)
+ .request(MediaType.APPLICATION_JSON)
+ .header("Authorization", authorizationHeaderValue)
+ .delete();
+ if (response.getStatus() != 200) // figure out how to use Status.OK
+ {
+ // in production you can be more specific based on reponse code, id, etc
+ throw new RuntimeException(response.getStatus() + ": there was an error on the server.");
+ }
+ }
+
+ //
+ // Code from here below requires work in order to work with ODL
+ //
+
+ //--------------------------------------------------------
+ public Uni get(String uniId)
+ //--------------------------------------------------------
+ // get Uni of specified ID
+ {
+ WebTarget target = client.target("http://localhost:9090/unimgr/webapi/");
+
+ Response response = target.path("uni/"+uniId).request(MediaType.APPLICATION_JSON).get(Response.class);
+ if (response.getStatus() != 200) // figure out how to use Status.OK
+ {
+ // in production you can be more specific based on reponse code, id, etc
+ throw new RuntimeException(response.getStatus() + ": there was an error on the server.");
+ }
+
+ //return response;
+ return response.readEntity(Uni.class);
+ }
+
+ //--------------------------------------------------------
+ public List<Uni> getAll()
+ //--------------------------------------------------------
+ // get a list of all Uni instances
+ {
+
+ WebTarget target = client.target("http://localhost:9090/unimgr/webapi/");
+
+ // Can I do this with a Response, so that I can check for errors
+ List<Uni> response = target.path("uni/list")
+ .request(MediaType.APPLICATION_JSON)
+ .get(new GenericType<List<Uni>>() {
+ });
+ if (response == null) // figure out how to use Status.OK
+ {
+ // in production you can be more specific based on reponse code, id, etc
+ throw new RuntimeException("there was an error on the server.");
+ }
+ return response;
+ }
+
+ //--------------------------------------------------------
+ public Uni testGet()
+ //--------------------------------------------------------
+ // test marshaling of Uni class from server json
+ {
+ WebTarget target = client.target("http://localhost:9090/unimgr/webapi/");
+
+ Response response = target.path("uni").request(MediaType.APPLICATION_JSON).get(Response.class);
+ if (response.getStatus() != 200) // figure out how to use Status.OK
+ {
+ // in production you can be more specific based on reponse code, id, etc
+ throw new RuntimeException(response.getStatus() + ": there was an error on the server.");
+ }
+
+ //return response;
+ return response.readEntity(Uni.class);
+ }
+
+ //--------------------------------------------------------
+ public String ping()
+ //--------------------------------------------------------
+ // test connectivity
+ {
+
+ WebTarget target = client.target("http://localhost:9090/unimgr/webapi/");
+
+ Response response = target.path("uni").request(MediaType.TEXT_PLAIN).get();
+ if (response.getStatus() != 200) // figure out how to use Status.OK
+ {
+ // in production you can be more specific based on reponse code, id, etc
+ throw new RuntimeException(response.getStatus() + ": there was an error on the server.");
+ }
+
+
+ return response.readEntity(String.class);
+ }
+}
diff --git a/uni/unibase/src/main/java/com/cablelabs/vcpe/uni/unibase/model/EvcPath.java b/uni/unibase/src/main/java/com/cablelabs/vcpe/uni/unibase/model/EvcPath.java
new file mode 100644
index 0000000..6556fbb
--- /dev/null
+++ b/uni/unibase/src/main/java/com/cablelabs/vcpe/uni/unibase/model/EvcPath.java
@@ -0,0 +1,112 @@
+package com.cablelabs.vcpe.uni.unibase.model;
+
+/**
+ * Created by steve on 7/24/15.
+ */
+public class EvcPath {
+
+ String id = "unset";
+ Uni uni1 = null;
+ Uni uni2 = null;
+ String cos;
+ Uni.SvcSpeed ingressBW = Uni.SvcSpeed.UNASSIGNED;
+ Uni.SvcSpeed egressBW = Uni.SvcSpeed.UNASSIGNED;
+
+ public EvcPath(String id, Uni uni1, Uni uni2,
+ Uni.SvcSpeed ingressBW,
+ Uni.SvcSpeed egressBW,
+ String cos)
+ {
+ this.id = id;
+ this.uni1 = uni1;
+ this.uni2 = uni2;
+ this.cos = cos;
+ this.ingressBW = ingressBW;
+ this.egressBW = egressBW;
+ }
+
+ public String toJson() {
+
+//{
+// "evc":
+// {
+// "evc:id": "822f8284-2b35-11e5-b345-feff819cdc9f",
+// "evc:uni-dest":
+// [
+// {
+// "order": 0,
+// "uni": "822f7eec-2b35-11e5-b345-feff819cdc9f"
+// }
+// ],
+// "evc:uni-source":
+// [
+// {
+// "order": 0,
+// "uni": "111f7eec-2c35-11e5-b345-feff819cdc9f"
+// }
+// ],
+// "evc:cos-id": "string",
+// "evc:ingress-bw":
+// {
+// "speed-1G": {}
+// },
+// "evc:egress-bw":
+// {
+// "speed-1G": {}
+// }
+// }
+//}
+
+ String json = "{\n"+
+ " \"evc\":\n"+
+ " {\n"+
+ " \"evc:id\": \""+ this.getId() +"\",\n"+
+ " \"evc:uni-dest\":\n"+
+ " [\n"+
+ " {\n"+
+ " \"order\": 0,\n"+
+ " \"uni\": \""+ this.uni1.getId() +"\"\n"+
+ " }\n"+
+ " ],\n"+
+ " \"evc:uni-source\":\n"+
+ " [\n"+
+ " {\n"+
+ " \"order\": 0,\n"+
+ " \"uni\": \""+ this.uni2.getId() +"\"\n"+
+ " }\n"+
+ " ],\n"+
+ " \"evc:cos-id\": \""+ this.getCos() +"\",\n"+
+ " \"evc:ingress-bw\":\n"+
+ " {\n"+
+// " \"speed-1G\": {}\n"+
+ " \"" + this.getIngressBW() + "\": {}\n"+
+ " },\n"+
+ " \"evc:egress-bw\":\n"+
+ " {\n"+
+// " \"speed-1G\": {}\n"+
+ " \"" + this.getEgressBW() + "\": {}\n"+
+ " }\n"+
+ " }\n"+
+ "}";
+ return json;
+ }
+
+
+ public String getId() { return id; }
+ public void setId(String id) { this.id = id; }
+
+ public Uni getUn1() { return uni1; }
+ public void setUn1(Uni uni1) { this.uni1 = uni1; }
+
+ public Uni getUn2() { return uni2; }
+ public void setUn2(Uni uni2) { this.uni2 = uni2; }
+
+ public String getCos() { return cos; }
+ public void setCos(String cos) { this.cos = cos; }
+
+ public Uni.SvcSpeed getIngressBW() { return ingressBW; }
+ public void setIngressBW(Uni.SvcSpeed ingressBW) { this.ingressBW = ingressBW; }
+
+ public Uni.SvcSpeed getEgressBW() { return egressBW; }
+ public void setEgressBW(Uni.SvcSpeed egressBW) { this.egressBW = egressBW; }
+}
diff --git a/uni/unibase/src/main/java/com/cablelabs/vcpe/uni/unibase/model/Uni.java b/uni/unibase/src/main/java/com/cablelabs/vcpe/uni/unibase/model/Uni.java
new file mode 100644
index 0000000..6d1b9c0
--- /dev/null
+++ b/uni/unibase/src/main/java/com/cablelabs/vcpe/uni/unibase/model/Uni.java
@@ -0,0 +1,230 @@
+package com.cablelabs.vcpe.uni.unibase.model;
+
+import com.cablelabs.vcpe.common.Dbg;
+
+import javax.xml.bind.annotation.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Created by steve on 5/24/15.
+ */
+
+@XmlRootElement
+public class Uni
+{
+
+ public enum SvcSpeed {
+ UNASSIGNED ("UNASSIGNED"),
+ TEN_MEG ("speed-10M"),
+ HUNDRED_MEG ("speed-100M"),
+ ONE_GIG ("speed-1G"),
+ TEN_GIG ("speed-10G");
+ private final String s;
+ private SvcSpeed(final String s) {this.s = s;}
+ @Override public String toString() { return s; }
+ }
+
+ public enum PhysMedium { // just a sampling of 802.3 phys layers
+ UNASSIGNED ("UNASSIGNED"),
+ TEN_BASE_T ("10BASE‑T"),
+ HUNDERED_BASE_T("100BASE‑T"),
+ GIG_BASE_T ("1000BASE‑T"),
+ TEN_GIG_BASE_T ("10GBASE‑T");
+ private final String s;
+ private PhysMedium(final String s) {this.s = s;}
+ @Override public String toString() { return s; }
+ }
+
+ public enum MacLayer {
+ UNASSIGNED ("UNASSIGNED"),
+ IEEE_802_3 ("IEEE 802.3-2005");
+ private final String s;
+ private MacLayer(final String s) {this.s = s;}
+ @Override public String toString() { return s; }
+ }
+
+ public enum SyncMode {
+ UNASSIGNED ("UNASSIGNED"),
+ ENABLED ("syncEnabled"),
+ DISABLED ("syncDisabled");
+ private final String s;
+ private SyncMode(final String s) {this.s = s;}
+ @Override public String toString() { return s; }
+ }
+
+ public enum Type { // not sure what this is
+ UNASSIGNED ("UNASSIGNED"),
+ UNITYPE ("UNITYPE");
+ private final String s;
+ private Type(final String s) {this.s = s;}
+ @Override public String toString() { return s; }
+ }
+
+ @XmlElement(name="id")
+ private String id;
+
+ @XmlTransient // This does not get written to JSON body
+ private SvcSpeed speed;
+
+ @XmlElement(name="ip-address")
+ private String ipAddress;
+
+ @XmlElement(name="mac-address")
+ private String macAddress;
+
+ @XmlElement(name="physical-medium")
+ private PhysMedium physicalMedium;
+
+ @XmlElement(name="mac-layer")
+ private MacLayer macLayer;
+
+ @XmlElement(name="mode")
+ private SyncMode mode;
+
+ @XmlElement(name="type")
+ private Type type;
+
+ @XmlElement(name="mtu-size")
+ private long mtuSize;
+
+ // no argument constructor required for JAX-RS
+ public Uni() {
+ this.id = "unset";
+ this.speed = SvcSpeed.UNASSIGNED;
+ this.ipAddress = "unset";
+ this.macAddress = "unset";
+ this.physicalMedium = PhysMedium.UNASSIGNED;
+ this.macLayer = MacLayer.UNASSIGNED;
+ this.mode = SyncMode.UNASSIGNED;
+ this.type = Type.UNASSIGNED;
+ this.mtuSize = -1;
+ }
+
+ public void setAllProps (String id, SvcSpeed speed, String ipAddress,
+ String macAddress, PhysMedium physicalMedium,
+ MacLayer macLayer, SyncMode mode, Type type, long mtuSize) {
+ this.id = id;
+ this.speed = speed;
+ this.ipAddress = ipAddress;
+ this.macAddress = macAddress;
+ this.physicalMedium = physicalMedium;
+ this.macLayer = macLayer;
+ this.mode = mode;
+ this.type = type;
+ this.mtuSize = mtuSize;
+ }
+
+ public void dump() { dump(0); }
+ public void dump(int tab) {
+ Dbg.p(tab, "id: " + this.id);
+ Dbg.p(tab, "speed: " + this.speed);
+ Dbg.p(tab, "ipAddress: " + this.ipAddress);
+ Dbg.p(tab, "macAddress: " + this.macAddress);
+ Dbg.p(tab, "physicalMedium: " + this.physicalMedium);
+ Dbg.p(tab, "macLayer: " + this.macLayer);
+ Dbg.p(tab, "mode: " + this.mode);
+ Dbg.p(tab, "type: " + this.type);
+ Dbg.p(tab, "mtuSize: " + this.mtuSize);
+ }
+
+ public String toJson() {
+
+ String json = "{\n"+
+ " \"uni\":\n"+
+ " {\n"+
+ " \"uni:id\": \""+ this.getId() +"\",\n"+
+ " \"speed\":\n" +
+ " {\n" +
+ " \"" + this.getSpeed() + "\": "+"\"1\"\n"+
+ " },\n"+
+ " \"uni:mac-layer\": \""+ this.getMacLayer() +"\",\n"+
+ " \"uni:physical-medium\": \""+ this.getPhysicalMedium() +"\",\n"+
+ " \"uni:mtu-size\": \""+ this.getMtuSize() +"\",\n"+
+ " \"uni:type\": \"\",\n"+
+ " \"uni:mac-address\": \""+ this.getMacAddress() +"\",\n"+
+ " \"uni:ip-address\": \""+ this.getIpAddress() +"\",\n"+
+ " \"uni:mode\": \""+ this.getMode() +"\"\n"+
+ " }\n"+
+ "}";
+
+ return json;
+ }
+
+
+ public static SvcSpeed cirToSvcSpeed (long cir) {
+
+ // find closest
+ SvcSpeed svcSpeed = SvcSpeed.UNASSIGNED;
+ if ( cir <= 10000 )
+ svcSpeed = SvcSpeed.TEN_MEG;
+ else if ( cir <= 100000 )
+ svcSpeed = SvcSpeed.HUNDRED_MEG;
+ else if ( cir <= 1000000 )
+ svcSpeed = SvcSpeed.ONE_GIG;
+ else
+ svcSpeed = SvcSpeed.TEN_GIG;
+
+ return svcSpeed;
+ }
+
+ public static PhysMedium svcSpeedToPhysMedium (SvcSpeed svcSpeed) {
+
+
+ // just for demo, this really needs to come from host, when hosts are modeled
+ switch (svcSpeed) {
+ case TEN_MEG:
+ return PhysMedium.TEN_BASE_T;
+ case HUNDRED_MEG:
+ return PhysMedium.HUNDERED_BASE_T;
+ case ONE_GIG:
+ return PhysMedium.GIG_BASE_T;
+ case TEN_GIG:
+ return PhysMedium.TEN_GIG_BASE_T;
+ default:
+ return PhysMedium.UNASSIGNED;
+ }
+ }
+
+ public static void dumpList(List<Uni> uniList) { dumpList(0, uniList); }
+ public static void dumpList(int tab, List<Uni> uniList) {
+ int numUni = 0;
+ Dbg.p("----- Uni List : [" + uniList.size() + "] elements");
+ for (Uni curUni : uniList) {
+ numUni++;
+ Dbg.p(tab+1, "<Entry " + numUni+">");
+ curUni.dump(tab+2);
+ }
+ }
+
+ // getters & setters
+
+ public String getId() { return id; }
+ public void setId(String id) { this.id = id; }
+
+ public SvcSpeed getSpeed() { return speed; }
+ public void setSpeed(SvcSpeed speed) { this.speed = speed; }
+
+ public String getIpAddress() { return ipAddress; }
+ public void setIpAddress(String ipAddress) { this.ipAddress = ipAddress; }
+
+ public String getMacAddress() { return macAddress; }
+ public void setMacAddress(String macAddress) { this.macAddress = macAddress; }
+
+ public PhysMedium getPhysicalMedium() { return physicalMedium; }
+ public void setPhysicalMedium(PhysMedium physicalMedium) { this.physicalMedium = physicalMedium; }
+
+ public MacLayer getMacLayer() { return macLayer; }
+ public void setMacLayer(MacLayer macLayer) { this.macLayer = macLayer; }
+
+ public SyncMode getMode() { return mode; }
+ public void setMode(SyncMode mode) { this.mode = mode; }
+
+ public Type getType() { return type; }
+ public void setType(Type type) { this.type = type; }
+
+ public long getMtuSize() { return mtuSize; }
+ public void setMtuSize(long mtuSize) { this.mtuSize = mtuSize; }
+}