Skip to content

Commit

Permalink
add global_config RPC support
Browse files Browse the repository at this point in the history
Signed-off-by: Leo Ma <[email protected]>
  • Loading branch information
leomaatEric committed Apr 25, 2023
1 parent 4be8278 commit 2aca01b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/main/java/com/cisco/trex/ClientBase.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.cisco.trex;

import com.cisco.trex.model.GlobalConfig;
import com.cisco.trex.stateless.TRexCommand;
import com.cisco.trex.stateless.TRexTransport;
import com.cisco.trex.stateless.exception.TRexConnectionException;
Expand Down Expand Up @@ -548,6 +549,29 @@ public SystemInfo getSystemInfo() {
return GSON.fromJson(getResultFromResponse(json), SystemInfo.class);
}

/**
* Get global configuration parameters
*
* @return GlobalConfig
*/
public TRexClientResult<GlobalConfig> getGlobalConfig(int portIdx) {
Map<String, Object> payload = new HashMap<>();
return callMethod("get_global_cfg", null, GlobalConfig.class);
}

/**
* Change global configuration parameter
*
* @param name parameter name
* @param value parameter value in data types of dboule, boolean depending on the parameter type
* @return StubResult
*/
public TRexClientResult<StubResult> setGlobalConfig(String name, Object value) {
Map<String, Object> payload = new HashMap<>();
payload.put(name, value);
return callMethod("set_global_cfg", payload, StubResult.class);
}

protected Map<String, Object> createPayload(int portIndex) {
Map<String, Object> payload = new HashMap<>();
payload.put(PORT_ID, portIndex);
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/com/cisco/trex/model/GlobalConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.cisco.trex.model;

import java.util.HashMap;

/** Global configuration parameters */
public class GlobalConfig extends HashMap<String, Object> {

public boolean getProcessAtCp() {
return (boolean) get("process_at_cp");
}

public double getSchedMaxStretch() {
return (double) get("sched_max_stretch");
}
}

0 comments on commit 2aca01b

Please sign in to comment.