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, Boolean> connectedIpsToSshConnection; 17 private Map<String, String> configuredIpsToLabels; 18 ConnectedDutInfo()19 public ConnectedDutInfo() { 20 connectedIpsToMacAddresses = new TreeMap<String, String>(); 21 connectedIpsToSshConnection = new TreeMap<String, Boolean>(); 22 configuredIpsToLabels = new TreeMap<String, String>(); 23 } 24 getConnectedIpsToMacAddress()25 public Map<String, String> getConnectedIpsToMacAddress() { 26 return connectedIpsToMacAddresses; 27 } 28 getConnectedIpsToSshConnection()29 public Map<String, Boolean> getConnectedIpsToSshConnection() { 30 return connectedIpsToSshConnection; 31 } 32 getConfiguredIpsToLabels()33 public Map<String, String> getConfiguredIpsToLabels() { 34 return configuredIpsToLabels; 35 } 36 37 @Override fromJson(JSONObject object)38 public void fromJson(JSONObject object) { 39 JSONObject leases = object.get("connected_duts").isObject(); 40 for (String lease : leases.keySet()) { 41 JSONObject leaseObject = leases.get(lease).isObject(); 42 connectedIpsToMacAddresses.put(lease, 43 leaseObject.get("mac_address").isString().stringValue()); 44 connectedIpsToSshConnection.put(lease, 45 leaseObject.get("ssh_connection_ok").isBoolean().booleanValue()); 46 } 47 JSONObject configuredDuts = object.get("configured_duts").isObject(); 48 for (String ipAddress : configuredDuts.keySet()) { 49 configuredIpsToLabels.put(ipAddress, configuredDuts.get(ipAddress).isString().stringValue()); 50 } 51 } 52 53 @Override toJson()54 public JSONObject toJson() { 55 // This is a read only RPC call so nothing to be submitted back to the 56 // server from the UI. 57 return null; 58 } 59 } 60