Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions src/main/java/net/netshot/netshot/rest/RestService.java
Original file line number Diff line number Diff line change
Expand Up @@ -1584,6 +1584,13 @@ public static class RsLightDevice {
@Setter
protected Boolean configCompliant;

/** The serial number. */
@Getter(onMethod = @__({
@XmlElement, @JsonView(DefaultView.class)
}))
@Setter
protected String serialNumber;

/** The software level. */
@Getter(onMethod = @__({
@XmlElement, @JsonView(DefaultView.class)
Expand Down Expand Up @@ -1629,6 +1636,7 @@ public List<RsLightDevice> getDevices(
+ "case when (d.eolDate < current_date()) then true else false end, "
+ "case when (d.eosDate < current_date()) then true else false end, "
+ "case when (select count(cr) from CheckResult cr where cr.key.device = d and cr.result = :nonConforming) = 0 then true else false end, "
+ "d.serialNumber, "
+ "d.softwareLevel "
+ ") from Device d";
if (groupId != null) {
Expand Down Expand Up @@ -3021,6 +3029,7 @@ public RsSearchResults searchDevices(RsSearchCriteria criteria)
+ "case when (d.eolDate < current_date()) then true else false end, "
+ "case when (d.eosDate < current_date()) then true else false end, "
+ "case when (select count(cr) from CheckResult cr where cr.key.device = d and cr.result = :nonConforming) = 0 then true else false end, "
+ "d.serialNumber, "
+ "d.softwareLevel) " + finder.getHql(), RsLightDevice.class);
finder.setVariables(query);
query.setParameter("nonConforming", CheckResult.ResultOption.NONCONFORMING);
Expand Down Expand Up @@ -5304,9 +5313,9 @@ public static class RsLightExemptedDevice extends RsLightDevice {
private Date expirationDate;

public RsLightExemptedDevice(long id, String name, String family, Network4Address mgmtAddress, Status status,
String driver, Boolean eol, Boolean eos, Boolean configCompliant, ConformanceLevel softwareLevel,
String driver, Boolean eol, Boolean eos, Boolean configCompliant, String serialNumber, ConformanceLevel softwareLevel,
Date expirationDate) {
super(id, name, family, mgmtAddress, status, driver, eol, eos, configCompliant, softwareLevel);
super(id, name, family, mgmtAddress, status, driver, eol, eos, configCompliant, serialNumber, softwareLevel);
this.expirationDate = expirationDate;
}

Expand Down Expand Up @@ -5346,6 +5355,7 @@ public List<RsLightExemptedDevice> getExemptedDevices(@BeanParam PaginationParam
+ "case when (d.eolDate < current_date()) then true else false end, "
+ "case when (d.eosDate < current_date()) then true else false end, "
+ "case when (select count(cr) from CheckResult cr where cr.key.device = d and cr.result = :nonConforming) = 0 then true else false end, "
+ "d.serialNumber, "
+ "d.softwareLevel, "
+ "e.expirationDate as expirationDate "
+ ") from Exemption e join e.key.device d where e.key.rule.id = :id",
Expand Down Expand Up @@ -5917,9 +5927,9 @@ public static class RsLightPolicyRuleDevice extends RsLightDevice {
private ResultOption result;

public RsLightPolicyRuleDevice(long id, String name, String family, Network4Address mgmtAddress, Status status,
String driver, Boolean eol, Boolean eos, Boolean configCompliant, ConformanceLevel softwareLevel,
String driver, Boolean eol, Boolean eos, Boolean configCompliant, String serialNumber, ConformanceLevel softwareLevel,
String policyName, String ruleName, Date checkDate, ResultOption result) {
super(id, name, family, mgmtAddress, status, driver, eol, eos, configCompliant, softwareLevel);
super(id, name, family, mgmtAddress, status, driver, eol, eos, configCompliant, serialNumber, softwareLevel);
this.ruleName = ruleName;
this.policyName = policyName;
this.checkDate = checkDate;
Expand Down Expand Up @@ -5970,6 +5980,7 @@ public List<RsLightPolicyRuleDevice> getConfigComplianceDeviceStatuses(
+ "case when (d.eolDate < current_date()) then true else false end, "
+ "case when (d.eosDate < current_date()) then true else false end, "
+ "case when (select count(cr) from CheckResult cr where cr.key.device = d and cr.result = :nonConforming) = 0 then true else false end, "
+ "d.serialNumber, "
+ "d.softwareLevel, "
+ "p.name as policyName, "
+ "r.name as ruleName, "
Expand Down Expand Up @@ -6066,6 +6077,7 @@ public List<RsLightPolicyRuleDevice> getGroupConfigNonCompliantDevices(
+ "case when (d.eolDate < current_date()) then true else false end, "
+ "case when (d.eosDate < current_date()) then true else false end, "
+ "case when (select count(cr) from CheckResult cr where cr.key.device = d and cr.result = :nonConforming) = 0 then true else false end, "
+ "d.serialNumber, "
+ "d.softwareLevel, "
+ "p.name as policyName, "
+ "r.name as ruleName, "
Expand Down Expand Up @@ -6133,6 +6145,7 @@ public List<RsLightDevice> getHardwareStatusDevices(
+ "case when (d.eolDate < current_date()) then true else false end, "
+ "case when (d.eosDate < current_date()) then true else false end, "
+ "case when (select count(cr) from CheckResult cr where cr.key.device = d and cr.result = :nonConforming) = 0 then true else false end, "
+ "d.serialNumber, "
+ "d.softwareLevel "
+ ") from Device d where d." + type + "Date is null and d.status = :enabled",
RsLightDevice.class)
Expand All @@ -6154,6 +6167,7 @@ public List<RsLightDevice> getHardwareStatusDevices(
+ "case when (d.eolDate < current_date()) then true else false end, "
+ "case when (d.eosDate < current_date()) then true else false end, "
+ "case when (select count(cr) from CheckResult cr where cr.key.device = d and cr.result = :nonConforming) = 0 then true else false end, "
+ "d.serialNumber, "
+ "d.softwareLevel "
+ ") from Device d where date(d." + type + "Date) = :eoxDate and d.status = :enabled",
RsLightDevice.class)
Expand Down Expand Up @@ -6901,6 +6915,7 @@ public List<RsLightDevice> getGroupDevicesBySoftwareLevel(
+ "case when (d.eolDate < current_date()) then true else false end, "
+ "case when (d.eosDate < current_date()) then true else false end, "
+ "case when (select count(cr) from CheckResult cr where cr.key.device = d and cr.result = :nonConforming) = 0 then true else false end, "
+ "d.serialNumber, "
+ "d.softwareLevel "
+ ") from Device d join d.groupMemberships gm where gm.key.group.id = :id and d.softwareLevel = :level and d.status = :enabled" + domainFilter,
RsLightDevice.class)
Expand Down Expand Up @@ -6945,9 +6960,9 @@ public static class RsLightAccessFailureDevice extends RsLightDevice {
private Date lastFailure;

public RsLightAccessFailureDevice(long id, String name, String family, Network4Address mgmtAddress, Status status,
String driver, Boolean eol, Boolean eos, Boolean configCompliant, ConformanceLevel softwareLevel,
String driver, Boolean eol, Boolean eos, Boolean configCompliant, String serialNumber, ConformanceLevel softwareLevel,
Date lastSuccess, Date lastFailure) {
super(id, name, family, mgmtAddress, status, driver, eol, eos, configCompliant, softwareLevel);
super(id, name, family, mgmtAddress, status, driver, eol, eos, configCompliant, serialNumber, softwareLevel);
this.lastSuccess = lastSuccess;
this.lastFailure = lastFailure;
}
Expand Down Expand Up @@ -7005,6 +7020,7 @@ public List<RsLightAccessFailureDevice> getAccessFailureDevices(
+ "case when (d.eolDate < current_date()) then true else false end, "
+ "case when (d.eosDate < current_date()) then true else false end, "
+ "case when (select count(cr) from CheckResult cr where cr.key.device = d and cr.result = :nonConforming) = 0 then true else false end, "
+ "d.serialNumber, "
+ "d.softwareLevel, "
+ "(select max(t.executionDate) from TakeSnapshotTask t where t.device = d and t.status = :success) as lastSuccess, "
+ "(select max(t.executionDate) from TakeSnapshotTask t where t.device = d and t.status = :failure) as lastFailure "
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/net/netshot/netshot/RestServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1408,6 +1408,7 @@ void listDevices() throws IOException, InterruptedException {
.put("eol", device1.isEndOfLife())
.put("eos", device1.isEndOfSale())
.put("configCompliant", device1.isCompliant())
.put("serialNumber", device1.getSerialNumber())
.put("softwareLevel", device1.getSoftwareLevel().toString()),
deviceNode1,
"Retrieved device doesn't match expected object");
Expand Down Expand Up @@ -1636,6 +1637,7 @@ void deleteDevice() throws IOException, InterruptedException {
.put("mgmtAddress", device2.getMgmtAddress().getIp())
.put("status", device2.getStatus().toString())
.put("driver", device2.getDriver())
.put("serialNumber", device2.getSerialNumber())
.put("eol", device2.isEndOfLife())
.put("eos", device2.isEndOfSale())
.put("configCompliant", device2.isCompliant())
Expand Down