Skip to content

Commit 969f4ca

Browse files
author
Daan Hoogland
committed
co-pilot's remarks addressed
1 parent 8b0ae96 commit 969f4ca

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@
7777
import org.apache.commons.collections4.CollectionUtils;
7878
import org.apache.commons.lang3.ObjectUtils;
7979
import org.apache.commons.lang3.StringUtils;
80-
import org.jetbrains.annotations.NotNull;
8180
import org.springframework.beans.factory.annotation.Autowired;
8281
import org.springframework.beans.factory.annotation.Qualifier;
8382

@@ -540,8 +539,8 @@ public boolean configure(final String name, final Map<String, Object> params) th
540539

541540
final Map<String, String> configs = _configDao.getConfiguration("AgentManager", params);
542541

543-
int _routerRamSize = NumbersUtil.parseInt(configs.get("router.ram.size"), DEFAULT_ROUTER_VM_RAMSIZE);
544-
int _routerCpuMHz = NumbersUtil.parseInt(configs.get("router.cpu.mhz"), DEFAULT_ROUTER_CPU_MHZ);
542+
int routerRamSize = NumbersUtil.parseInt(configs.get("router.ram.size"), DEFAULT_ROUTER_VM_RAMSIZE);
543+
int routerCpuMHz = NumbersUtil.parseInt(configs.get("router.cpu.mhz"), DEFAULT_ROUTER_CPU_MHZ);
545544

546545
_routerExtraPublicNics = NumbersUtil.parseInt(_configDao.getValue(Config.RouterExtraPublicNics.key()), 2);
547546

@@ -578,12 +577,12 @@ public boolean configure(final String name, final Map<String, Object> params) th
578577

579578
_dnsBasicZoneUpdates = String.valueOf(_configDao.getValue(Config.DnsBasicZoneUpdates.key()));
580579

581-
logger.info("Router configurations: " + "ramsize=" + _routerRamSize);
580+
logger.info("Router configurations: " + "ramsize=" + routerRamSize);
582581

583582
_agentMgr.registerForHostEvents(new SshKeysDistriMonitor(_agentMgr, _hostDao, _configDao), true, false, false);
584583

585584
final List<ServiceOfferingVO> offerings = _serviceOfferingDao.createSystemServiceOfferings("System Offering For Software Router",
586-
ServiceOffering.routerDefaultOffUniqueName, 1, _routerRamSize, _routerCpuMHz, null,
585+
ServiceOffering.routerDefaultOffUniqueName, 1, routerRamSize, routerCpuMHz, null,
587586
null, true, null, ProvisioningType.THIN, true, null, true, VirtualMachine.Type.DomainRouter, true);
588587
// this can sometimes happen, if DB is manually or programmatically manipulated
589588
if (offerings == null || offerings.size() < 2) {
@@ -1312,7 +1311,7 @@ private void updateRouterHealthCheckResult(final long routerId, String checkName
13121311
private RouterHealthCheckResultVO parseHealthCheckVOFromJson(final long routerId,
13131312
final String checkName, final String checkType, final Map<String, String> checkData,
13141313
final Map<String, Map<String, RouterHealthCheckResultVO>> checksInDb) {
1315-
RouterHealthStatus success = RouterHealthStatus.valueOf(checkData.get("success"));
1314+
RouterHealthStatus success = getRouterHealthStatus(checkData.get("success"));
13161315
Date lastUpdate = new Date(Long.parseLong(checkData.get("lastUpdate")));
13171316
double lastRunDuration = Double.parseDouble(checkData.get("lastRunDuration"));
13181317
String message = checkData.get("message");
@@ -1340,6 +1339,16 @@ private RouterHealthCheckResultVO parseHealthCheckVOFromJson(final long routerId
13401339
return hcVo;
13411340
}
13421341

1342+
private static RouterHealthStatus getRouterHealthStatus(String status) {
1343+
RouterHealthStatus success;
1344+
try {
1345+
success = RouterHealthStatus.valueOf(status.trim());
1346+
} catch (IllegalArgumentException | NullPointerException e) {
1347+
success = RouterHealthStatus.UNKNOWN;
1348+
}
1349+
return success;
1350+
}
1351+
13431352
/**
13441353
*
13451354
* @param checksJson JSON expected is
@@ -1851,7 +1860,6 @@ protected void getRouterAlerts() {
18511860
}
18521861
}
18531862

1854-
@NotNull
18551863
private static GetRouterAlertsCommand getGetRouterAlertsCommand(OpRouterMonitorServiceVO opRouterMonitorServiceVO, String controlIP) {
18561864
GetRouterAlertsCommand command;
18571865
if (opRouterMonitorServiceVO == null) {
@@ -2277,7 +2285,7 @@ public boolean finalizeCommandsOnStart(final Commands cmds, final VirtualMachine
22772285

22782286
// restart network if restartNetwork = false is not specified in profile
22792287
// parameters
2280-
boolean reprogramGuestNtwks = ! Boolean.FALSE.equals(profile.getParameter(Param.ReProgramGuestNetworks));
2288+
boolean reprogramGuestNtwks = !Boolean.FALSE.equals(profile.getParameter(Param.ReProgramGuestNetworks));
22812289

22822290
final Provider provider = getVrProvider(router);
22832291

@@ -2624,7 +2632,6 @@ private void createDefaultEgressFirewallRule(final List<FirewallRule> rules, fin
26242632
}
26252633
}
26262634

2627-
@NotNull
26282635
private static FirewallRule getFirewallRule(String cidr, String allIp4Cidrs, long networkId, NetworkVO network, Purpose firewall) {
26292636
final List<String> sourceCidr = new ArrayList<>();
26302637
final List<String> destCidr = new ArrayList<>();

0 commit comments

Comments
 (0)