Skip to content
This repository was archived by the owner on Nov 13, 2023. It is now read-only.

Commit 4fffbc1

Browse files
Sumanth SathyanarayanaSumanth Sathyanarayana
authored andcommitted
Added some parameters visible via save-config to get-config api command
1 parent b606b47 commit 4fffbc1

File tree

4 files changed

+271
-5
lines changed

4 files changed

+271
-5
lines changed

src/org/flowvisor/api/handlers/ApiHandler.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,17 @@ public interface ApiHandler<T> {
3131
final static String QUEUE = "queues";
3232
final static String SHOW = "show-disabled";
3333
final static String FSID = "fs-id";
34-
34+
//Additions to get config
35+
public static String APIPORT = "api_webserver_port";
36+
public static String CONFIG = "config_name";
37+
public static String JETTYPORT = "api_jetty_webserver_port";
38+
public static String LOGFACILITY = "log_facility";
39+
public static String LOGGING = "logging";
40+
public static String CHECKPOINT = "checkpointing";
41+
public static String LOGIDENT = "log_ident";
42+
public static String VERSION = "version";
43+
public static String HOST = "host";
44+
public static String DB_VERSION = "db_version";
3545

3646
final static String MSG = "msg";
3747
final static String CURRRATE = "current-rate";

src/org/flowvisor/api/handlers/configuration/GetConfig.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@ public JSONRPC2Response process(Map<String, Object> params) {
3737
configs.put(STATSDESC, FlowvisorImpl.getProxy().getstats_desc_hack());
3838
configs.put(TOPOCTRL, FlowvisorImpl.getProxy().getTopologyServer());
3939
configs.put(FSCACHE, FlowvisorImpl.getProxy().getFlowStatsCache());
40+
configs.put(APIPORT, FlowvisorImpl.getProxy().getAPIWSPort());
41+
configs.put(CONFIG, FlowvisorImpl.getProxy().getConfigName());
42+
configs.put(JETTYPORT, FlowvisorImpl.getProxy().getJettyPort());
43+
configs.put(LOGFACILITY, FlowvisorImpl.getProxy().getLogFacility());
44+
configs.put(LOGGING, FlowvisorImpl.getProxy().getLogging());
45+
configs.put(CHECKPOINT, FlowvisorImpl.getProxy().getCheckPoint());
46+
configs.put(LOGIDENT, FlowvisorImpl.getProxy().getLogIdent());
47+
configs.put(VERSION, FlowvisorImpl.getProxy().getVersion());
48+
configs.put(HOST, FlowvisorImpl.getProxy().getHost());
49+
configs.put(DB_VERSION, FlowvisorImpl.getProxy().getDBVersion());
50+
4051
addFloodPerms(dpidStr, configs);
4152
addFlowmodLimits(sliceName, dpidStr, configs);
4253

src/org/flowvisor/config/Flowvisor.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,14 @@ public interface Flowvisor extends FVAppConfig {
5454
public Boolean getTopologyServer(int id) throws ConfigError;
5555
public Boolean getTopologyServer() throws ConfigError;
5656
public Integer getFlowStatsCache() throws ConfigError;
57-
57+
public String getConfigName(Integer id) throws ConfigError;
58+
public String getConfigName() throws ConfigError;
59+
public String getVersion(Integer id) throws ConfigError;
60+
public String getVersion() throws ConfigError;
61+
public String getHost(Integer id) throws ConfigError;
62+
public String getHost() throws ConfigError;
63+
public String getDBVersion(Integer id) throws ConfigError;
64+
public String getDBVersion() throws ConfigError;
5865

5966
public void settrack_flows(Integer id, Boolean track_flows);
6067
public void settrack_flows(Boolean track_flows);
@@ -77,8 +84,14 @@ public interface Flowvisor extends FVAppConfig {
7784
public void setJettyPort(Integer id, Integer port) throws ConfigError;
7885
public void setJettyPort(Integer port) throws ConfigError;
7986
public void setFlowStatsCache(Integer timer) throws ConfigError;
80-
81-
87+
public void setConfigName(Integer id, String config) throws ConfigError;
88+
public void setConfigName(String config) throws ConfigError;
89+
public void setVersion(Integer id, String version) throws ConfigError;
90+
public void setVersion(String version) throws ConfigError;
91+
public void setDBVersion(Integer id, Integer version) throws ConfigError;
92+
public void setDBVersion(Integer version) throws ConfigError;
93+
public void setHost(Integer id, String version) throws ConfigError;
94+
public void setHost(String version) throws ConfigError;
8295

8396
public int fetchDBVersion();
8497

src/org/flowvisor/config/FlowvisorImpl.java

Lines changed: 233 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ public class FlowvisorImpl implements Flowvisor {
4343
private static String GLOGFACILITY = "SELECT " + LOGFACILITY + " FROM FlowVisor WHERE id = ?";
4444
private static String GTOPO = "SELECT " + TOPO + " FROM Flowvisor WHERE id = ?";
4545
private static String GFSTIME = "SELECT " + FSCACHE + " FROM Flowvisor WHERE id = ?";
46-
46+
private static String GCONFIG = "SELECT " + CONFIG + " FROM Flowvisor WHERE id = ?";
47+
private static String GVERSION = "SELECT " + VERSION + " FROM Flowvisor WHERE id = ?";
48+
private static String GHOST = "SELECT " + HOST + " FROM Flowvisor WHERE id = ?";
49+
private static String GDBVERSION = "SELECT " + DB_VERSION + " FROM Flowvisor WHERE id = ?";
4750

4851
private static String STRACKID = "UPDATE Flowvisor SET " + TRACK + " = ? WHERE id = ?";
4952
private static String SSTATSID = "UPDATE Flowvisor SET " + STATS + " = ? WHERE id = ?";
@@ -56,6 +59,10 @@ public class FlowvisorImpl implements Flowvisor {
5659
private static String SAPIPORT = "UPDATE Flowvisor SET " + APIPORT + " = ? WHERE id = ?";
5760
private static String SJETTYPORT = "UPDATE Flowvisor SET " + JETTYPORT + " = ? WHERE id = ?";
5861
private static String SFSTIME = "UPDATE Flowvisor SET " + FSCACHE + " = ? WHERE id = ?";
62+
private static String SCONFIG = "UPDATE Flowvisor SET " + CONFIG + " = ? WHERE id = ?";
63+
private static String SVERSION = "SELECT " + VERSION + " FROM Flowvisor WHERE id = ?";
64+
private static String SHOST = "SELECT " + HOST + " FROM Flowvisor WHERE id = ?";
65+
private static String SDBVERSION = "SELECT " + DB_VERSION + " FROM Flowvisor WHERE id = ?";
5966

6067
private static String INSERT = "INSERT INTO " + FLOWVISOR + "(" + APIPORT + "," +
6168
JETTYPORT + "," + CHECKPOINT + "," + LISTEN + "," + TRACK + "," +
@@ -218,6 +225,120 @@ public Integer getAPIWSPort(Integer id) throws ConfigError {
218225
public Integer getAPIWSPort() throws ConfigError {
219226
return getAPIWSPort(1);
220227
}
228+
229+
//Additions for get config
230+
231+
public String getConfigName(Integer id) throws ConfigError {
232+
Connection conn = null;
233+
PreparedStatement ps = null;
234+
ResultSet set = null;
235+
try {
236+
conn = settings.getConnection();
237+
ps = conn.prepareStatement(GCONFIG);
238+
ps.setInt(1, id);
239+
set = ps.executeQuery();
240+
if (set.next())
241+
return set.getString(CONFIG);
242+
else
243+
throw new ConfigError("Config Name not found");
244+
} catch (SQLException e) {
245+
FVLog.log(LogLevel.WARN, null, e.getMessage());
246+
} finally {
247+
248+
close(set);
249+
close(ps);
250+
close(conn);
251+
252+
}
253+
return null;
254+
}
255+
public String getConfigName() throws ConfigError {
256+
return getConfigName(1);
257+
}
258+
259+
public String getVersion(Integer id) throws ConfigError {
260+
Connection conn = null;
261+
PreparedStatement ps = null;
262+
ResultSet set = null;
263+
try {
264+
conn = settings.getConnection();
265+
ps = conn.prepareStatement(GVERSION);
266+
ps.setInt(1, id);
267+
set = ps.executeQuery();
268+
if (set.next())
269+
return set.getString(VERSION);
270+
else
271+
throw new ConfigError("Version not found");
272+
} catch (SQLException e) {
273+
FVLog.log(LogLevel.WARN, null, e.getMessage());
274+
} finally {
275+
276+
close(set);
277+
close(ps);
278+
close(conn);
279+
280+
}
281+
return null;
282+
}
283+
public String getVersion() throws ConfigError {
284+
return getVersion(1);
285+
}
286+
287+
public String getDBVersion(Integer id) throws ConfigError {
288+
Connection conn = null;
289+
PreparedStatement ps = null;
290+
ResultSet set = null;
291+
try {
292+
conn = settings.getConnection();
293+
ps = conn.prepareStatement(GDBVERSION);
294+
ps.setInt(1, id);
295+
set = ps.executeQuery();
296+
if (set.next())
297+
return set.getString(DB_VERSION);
298+
else
299+
throw new ConfigError("DBVersion not found");
300+
} catch (SQLException e) {
301+
FVLog.log(LogLevel.WARN, null, e.getMessage());
302+
} finally {
303+
304+
close(set);
305+
close(ps);
306+
close(conn);
307+
308+
}
309+
return null;
310+
}
311+
public String getDBVersion() throws ConfigError {
312+
return getDBVersion(1);
313+
}
314+
315+
public String getHost(Integer id) throws ConfigError {
316+
Connection conn = null;
317+
PreparedStatement ps = null;
318+
ResultSet set = null;
319+
try {
320+
conn = settings.getConnection();
321+
ps = conn.prepareStatement(GHOST);
322+
ps.setInt(1, id);
323+
set = ps.executeQuery();
324+
if (set.next())
325+
return set.getString(HOST);
326+
else
327+
throw new ConfigError("Host not found");
328+
} catch (SQLException e) {
329+
FVLog.log(LogLevel.WARN, null, e.getMessage());
330+
} finally {
331+
332+
close(set);
333+
close(ps);
334+
close(conn);
335+
336+
}
337+
return null;
338+
}
339+
public String getHost() throws ConfigError {
340+
return getHost(1);
341+
}
221342

222343
public Integer getJettyPort(Integer id) throws ConfigError {
223344
Connection conn = null;
@@ -690,6 +811,117 @@ public void setAPIWSPort(Integer id, Integer port) throws ConfigError {
690811
}
691812
}
692813

814+
//Additions for get config
815+
@Override
816+
public void setConfigName(String config) throws ConfigError{
817+
setConfigName(1, config);
818+
}
819+
820+
@Override
821+
public void setConfigName(Integer id, String config) throws ConfigError {
822+
Connection conn = null;
823+
PreparedStatement ps = null;
824+
ResultSet set = null;
825+
try {
826+
conn = settings.getConnection();
827+
ps = conn.prepareStatement(SCONFIG);
828+
ps.setString(1, config);
829+
ps.setInt(2, id);
830+
if (ps.executeUpdate() == 0)
831+
FVLog.log(LogLevel.WARN, null, "Unable to set the config name.");
832+
} catch (SQLException e) {
833+
FVLog.log(LogLevel.WARN, null, e.getMessage());
834+
835+
} finally {
836+
close(set);
837+
close(ps);
838+
close(conn);
839+
}
840+
}
841+
842+
@Override
843+
public void setVersion(String version) throws ConfigError{
844+
setVersion(1, version);
845+
}
846+
847+
@Override
848+
public void setVersion(Integer id, String version) throws ConfigError {
849+
Connection conn = null;
850+
PreparedStatement ps = null;
851+
ResultSet set = null;
852+
try {
853+
conn = settings.getConnection();
854+
ps = conn.prepareStatement(SVERSION);
855+
ps.setString(1, version);
856+
ps.setInt(2, id);
857+
if (ps.executeUpdate() == 0)
858+
FVLog.log(LogLevel.WARN, null, "Unable to set the version.");
859+
} catch (SQLException e) {
860+
FVLog.log(LogLevel.WARN, null, e.getMessage());
861+
862+
} finally {
863+
close(set);
864+
close(ps);
865+
close(conn);
866+
}
867+
}
868+
869+
@Override
870+
public void setHost(String host) throws ConfigError{
871+
setHost(1, host);
872+
}
873+
874+
@Override
875+
public void setHost(Integer id, String host) throws ConfigError {
876+
Connection conn = null;
877+
PreparedStatement ps = null;
878+
ResultSet set = null;
879+
try {
880+
conn = settings.getConnection();
881+
ps = conn.prepareStatement(SHOST);
882+
ps.setString(1, host);
883+
ps.setInt(2, id);
884+
if (ps.executeUpdate() == 0)
885+
FVLog.log(LogLevel.WARN, null, "Unable to set the host.");
886+
} catch (SQLException e) {
887+
FVLog.log(LogLevel.WARN, null, e.getMessage());
888+
889+
} finally {
890+
close(set);
891+
close(ps);
892+
close(conn);
893+
}
894+
}
895+
896+
@Override
897+
public void setDBVersion(Integer dbVersion) throws ConfigError{
898+
setDBVersion(1, dbVersion);
899+
}
900+
901+
@Override
902+
public void setDBVersion(Integer id, Integer dbVersion) throws ConfigError {
903+
Connection conn = null;
904+
PreparedStatement ps = null;
905+
ResultSet set = null;
906+
try {
907+
conn = settings.getConnection();
908+
ps = conn.prepareStatement(SDBVERSION);
909+
ps.setInt(1, dbVersion);
910+
ps.setInt(2, id);
911+
if (ps.executeUpdate() == 0)
912+
FVLog.log(LogLevel.WARN, null, "Unable to set the dbVersion.");
913+
} catch (SQLException e) {
914+
FVLog.log(LogLevel.WARN, null, e.getMessage());
915+
916+
} finally {
917+
close(set);
918+
close(ps);
919+
close(conn);
920+
}
921+
}
922+
923+
924+
693925
@Override
694926
public void setJettyPort(Integer port) throws ConfigError{
695927
setJettyPort(1, port);

0 commit comments

Comments
 (0)