• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package autotest.moblab.rpc;
2 
3 import com.google.gwt.json.client.JSONArray;
4 import com.google.gwt.json.client.JSONObject;
5 import java.util.ArrayList;
6 import java.util.List;
7 import java.util.Map;
8 import java.util.TreeMap;
9 
10 /**
11  * The connected DUT information RPC entity.
12  */
13 public class ConnectedDutInfo extends JsonRpcEntity {
14 
15   private Map<String, String> connectedIpsToMacAddresses;
16   private Map<String, String> configuredIpsToLabels;
17 
ConnectedDutInfo()18   public ConnectedDutInfo() {
19     connectedIpsToMacAddresses = new TreeMap<String, String>();
20     configuredIpsToLabels = new TreeMap<String, String>();
21   }
22 
getConnectedIpsToMacAddress()23   public Map<String, String> getConnectedIpsToMacAddress() { return connectedIpsToMacAddresses; }
getConfiguredIpsToLabels()24   public Map<String, String> getConfiguredIpsToLabels() { return configuredIpsToLabels; }
25 
26   @Override
fromJson(JSONObject object)27   public void fromJson(JSONObject object) {
28     JSONObject leases = object.get("connected_duts").isObject();
29     for (String lease : leases.keySet()) {
30       connectedIpsToMacAddresses.put(lease, leases.get(lease).isString().stringValue());
31     }
32     JSONObject configuredDuts = object.get("configured_duts").isObject();
33     for (String ipAddress : configuredDuts.keySet()) {
34       configuredIpsToLabels.put(ipAddress, configuredDuts.get(ipAddress).isString().stringValue());
35     }
36   }
37 
38   @Override
toJson()39   public JSONObject toJson() {
40     // This is a read only RPC call so nothing to be submitted back to the
41     // server from the UI.
42     return null;
43   }
44 }
45