Skip to content

Commit 61afb4c

Browse files
abh1sarDaan Hoogland
authored andcommitted
fix identation
1 parent 23b19a9 commit 61afb4c

File tree

10 files changed

+930
-939
lines changed

10 files changed

+930
-939
lines changed

engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java

Lines changed: 289 additions & 290 deletions
Large diffs are not rendered by default.

server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5430,19 +5430,17 @@ public Vlan updateVlanAndPublicIpRange(final long id, String startIp,
54305430
}
54315431

54325432
try (CheckedReservation publicIpReservation = new CheckedReservation(account, ResourceType.public_ip, null, null, null, newIpAddressAmount, existingIpAddressAmount, reservationDao, _resourceLimitMgr)) {
5433-
5434-
updateVlanAndIpv4Range(id, vlanRange, startIp, endIp, gateway, netmask, isRangeForSystemVM, forSystemVms);
5435-
5436-
if (account != null) {
5437-
long countDiff = newIpAddressAmount - existingIpAddressAmount;
5438-
if (countDiff > 0) {
5439-
_resourceLimitMgr.incrementResourceCount(account.getId(), ResourceType.public_ip, countDiff);
5440-
} else if (countDiff < 0) {
5441-
_resourceLimitMgr.decrementResourceCount(account.getId(), ResourceType.public_ip, Math.abs(countDiff));
5433+
updateVlanAndIpv4Range(id, vlanRange, startIp, endIp, gateway, netmask, isRangeForSystemVM, forSystemVms);
5434+
5435+
if (account != null) {
5436+
long countDiff = newIpAddressAmount - existingIpAddressAmount;
5437+
if (countDiff > 0) {
5438+
_resourceLimitMgr.incrementResourceCount(account.getId(), ResourceType.public_ip, countDiff);
5439+
} else if (countDiff < 0) {
5440+
_resourceLimitMgr.decrementResourceCount(account.getId(), ResourceType.public_ip, Math.abs(countDiff));
5441+
}
54425442
}
54435443
}
5444-
5445-
}
54465444
}
54475445
if (ipv6) {
54485446
updateVlanAndIpv6Range(id, vlanRange, startIpv6, endIpv6, ip6Gateway, ip6Cidr, isRangeForSystemVM, forSystemVms);
@@ -5852,31 +5850,29 @@ public Vlan dedicatePublicIpRange(final DedicatePublicIpRangeCmd cmd) throws Res
58525850
// Check Public IP resource limits
58535851
long reservedIpAddressesAmount = vlanOwner != null ? _publicIpAddressDao.countIPs(zoneId, vlanDbId, false) : 0L;
58545852
try (CheckedReservation publicIpReservation = new CheckedReservation(vlanOwner, ResourceType.public_ip, null, null, null, reservedIpAddressesAmount, null, reservationDao, _resourceLimitMgr)) {
5853+
if (vlanOwner != null) {
5854+
// Create an AccountVlanMapVO entry
5855+
final AccountVlanMapVO accountVlanMapVO = new AccountVlanMapVO(vlanOwner.getId(), vlan.getId());
5856+
_accountVlanMapDao.persist(accountVlanMapVO);
58555857

5856-
if (vlanOwner != null) {
5857-
// Create an AccountVlanMapVO entry
5858-
final AccountVlanMapVO accountVlanMapVO = new AccountVlanMapVO(vlanOwner.getId(), vlan.getId());
5859-
_accountVlanMapDao.persist(accountVlanMapVO);
5860-
5861-
// generate usage event for dedication of every ip address in the range
5862-
for (final IPAddressVO ip : ips) {
5863-
final boolean usageHidden = _ipAddrMgr.isUsageHidden(ip);
5864-
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_NET_IP_ASSIGN, vlanOwner.getId(), ip.getDataCenterId(), ip.getId(), ip.getAddress().toString(), ip.isSourceNat(),
5865-
vlan.getVlanType().toString(), ip.getSystem(), usageHidden, ip.getClass().getName(), ip.getUuid());
5858+
// generate usage event for dedication of every ip address in the range
5859+
for (final IPAddressVO ip : ips) {
5860+
final boolean usageHidden = _ipAddrMgr.isUsageHidden(ip);
5861+
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_NET_IP_ASSIGN, vlanOwner.getId(), ip.getDataCenterId(), ip.getId(), ip.getAddress().toString(), ip.isSourceNat(),
5862+
vlan.getVlanType().toString(), ip.getSystem(), usageHidden, ip.getClass().getName(), ip.getUuid());
5863+
}
5864+
} else if (domain != null) {
5865+
// Create an DomainVlanMapVO entry
5866+
DomainVlanMapVO domainVlanMapVO = new DomainVlanMapVO(domain.getId(), vlan.getId());
5867+
_domainVlanMapDao.persist(domainVlanMapVO);
58665868
}
5867-
} else if (domain != null) {
5868-
// Create an DomainVlanMapVO entry
5869-
DomainVlanMapVO domainVlanMapVO = new DomainVlanMapVO(domain.getId(), vlan.getId());
5870-
_domainVlanMapDao.persist(domainVlanMapVO);
5871-
}
5872-
5873-
// increment resource count for dedicated public ip's
5874-
if (vlanOwner != null) {
5875-
_resourceLimitMgr.incrementResourceCount(vlanOwner.getId(), ResourceType.public_ip, new Long(ips.size()));
5876-
}
58775869

5878-
return vlan;
5870+
// increment resource count for dedicated public ip's
5871+
if (vlanOwner != null) {
5872+
_resourceLimitMgr.incrementResourceCount(vlanOwner.getId(), ResourceType.public_ip, new Long(ips.size()));
5873+
}
58795874

5875+
return vlan;
58805876
}
58815877
}
58825878

server/src/main/java/com/cloud/network/NetworkServiceImpl.java

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,21 +1150,19 @@ public IpAddress reserveIpAddress(Account account, Boolean displayIp, Long ipAdd
11501150

11511151
long reservedIpAddressesAmount = ipDedicatedAccountId == null ? 1L : 0L;
11521152
try (CheckedReservation publicIpAddressReservation = new CheckedReservation(account, Resource.ResourceType.public_ip, reservedIpAddressesAmount, reservationDao, _resourceLimitMgr)) {
1153-
1154-
List<AccountVlanMapVO> maps = _accountVlanMapDao.listAccountVlanMapsByVlan(ipVO.getVlanId());
1155-
ipVO.setAllocatedTime(new Date());
1156-
ipVO.setAllocatedToAccountId(account.getAccountId());
1157-
ipVO.setAllocatedInDomainId(account.getDomainId());
1158-
ipVO.setState(State.Reserved);
1159-
if (displayIp != null) {
1160-
ipVO.setDisplay(displayIp);
1161-
}
1162-
ipVO = _ipAddressDao.persist(ipVO);
1163-
if (reservedIpAddressesAmount > 0) {
1164-
_resourceLimitMgr.incrementResourceCount(account.getId(), Resource.ResourceType.public_ip);
1165-
}
1166-
return ipVO;
1167-
1153+
List<AccountVlanMapVO> maps = _accountVlanMapDao.listAccountVlanMapsByVlan(ipVO.getVlanId());
1154+
ipVO.setAllocatedTime(new Date());
1155+
ipVO.setAllocatedToAccountId(account.getAccountId());
1156+
ipVO.setAllocatedInDomainId(account.getDomainId());
1157+
ipVO.setState(State.Reserved);
1158+
if (displayIp != null) {
1159+
ipVO.setDisplay(displayIp);
1160+
}
1161+
ipVO = _ipAddressDao.persist(ipVO);
1162+
if (reservedIpAddressesAmount > 0) {
1163+
_resourceLimitMgr.incrementResourceCount(account.getId(), Resource.ResourceType.public_ip);
1164+
}
1165+
return ipVO;
11681166
} catch (ResourceAllocationException ex) {
11691167
logger.warn("Failed to allocate resource of type " + ex.getResourceType() + " for account " + account);
11701168
throw new AccountLimitException("Maximum number of public IP addresses for account: " + account.getAccountName() + " has been exceeded.");

server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,25 +1248,25 @@ public Vpc createVpc(final long zoneId, final long vpcOffId, final long vpcOwner
12481248
vpc.setDisplay(Boolean.TRUE.equals(displayVpc));
12491249

12501250
try (CheckedReservation vpcReservation = new CheckedReservation(owner, ResourceType.vpc, null, null, 1L, reservationDao, _resourceLimitMgr)) {
1251-
if (vpc.getCidr() == null && cidrSize != null) {
1252-
// Allocate a CIDR for VPC
1253-
Ipv4GuestSubnetNetworkMap subnet = routedIpv4Manager.getOrCreateIpv4SubnetForVpc(vpc, cidrSize);
1254-
if (subnet != null) {
1255-
vpc.setCidr(subnet.getSubnet());
1256-
} else {
1257-
throw new CloudRuntimeException("Failed to allocate a CIDR with requested size for VPC.");
1251+
if (vpc.getCidr() == null && cidrSize != null) {
1252+
// Allocate a CIDR for VPC
1253+
Ipv4GuestSubnetNetworkMap subnet = routedIpv4Manager.getOrCreateIpv4SubnetForVpc(vpc, cidrSize);
1254+
if (subnet != null) {
1255+
vpc.setCidr(subnet.getSubnet());
1256+
} else {
1257+
throw new CloudRuntimeException("Failed to allocate a CIDR with requested size for VPC.");
1258+
}
12581259
}
1259-
}
12601260

1261-
Vpc newVpc = createVpc(displayVpc, vpc);
1262-
// assign Ipv4 subnet to Routed VPC
1263-
if (routedIpv4Manager.isRoutedVpc(vpc)) {
1264-
routedIpv4Manager.assignIpv4SubnetToVpc(newVpc);
1265-
}
1266-
if (CollectionUtils.isNotEmpty(bgpPeerIds)) {
1267-
routedIpv4Manager.persistBgpPeersForVpc(newVpc.getId(), bgpPeerIds);
1268-
}
1269-
return newVpc;
1261+
Vpc newVpc = createVpc(displayVpc, vpc);
1262+
// assign Ipv4 subnet to Routed VPC
1263+
if (routedIpv4Manager.isRoutedVpc(vpc)) {
1264+
routedIpv4Manager.assignIpv4SubnetToVpc(newVpc);
1265+
}
1266+
if (CollectionUtils.isNotEmpty(bgpPeerIds)) {
1267+
routedIpv4Manager.persistBgpPeersForVpc(newVpc.getId(), bgpPeerIds);
1268+
}
1269+
return newVpc;
12701270
}
12711271
}
12721272

server/src/main/java/com/cloud/projects/ProjectManagerImpl.java

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -277,40 +277,39 @@ public Project createProject(final String name, final String displayText, String
277277
}
278278

279279
try (CheckedReservation projectReservation = new CheckedReservation(owner, ResourceType.project, null, null, 1L, reservationDao, _resourceLimitMgr)) {
280+
final Account ownerFinal = owner;
281+
User finalUser = user;
282+
Project project = Transaction.execute(new TransactionCallback<Project>() {
283+
@Override
284+
public Project doInTransaction(TransactionStatus status) {
280285

281-
final Account ownerFinal = owner;
282-
User finalUser = user;
283-
Project project = Transaction.execute(new TransactionCallback<Project>() {
284-
@Override
285-
public Project doInTransaction(TransactionStatus status) {
286-
287-
//Create an account associated with the project
288-
StringBuilder acctNm = new StringBuilder("PrjAcct-");
289-
acctNm.append(name).append("-").append(ownerFinal.getDomainId());
286+
//Create an account associated with the project
287+
StringBuilder acctNm = new StringBuilder("PrjAcct-");
288+
acctNm.append(name).append("-").append(ownerFinal.getDomainId());
290289

291-
Account projectAccount = _accountMgr.createAccount(acctNm.toString(), Account.Type.PROJECT, null, domainId, null, null, UUID.randomUUID().toString());
290+
Account projectAccount = _accountMgr.createAccount(acctNm.toString(), Account.Type.PROJECT, null, domainId, null, null, UUID.randomUUID().toString());
292291

293-
Project project = _projectDao.persist(new ProjectVO(name, displayText, ownerFinal.getDomainId(), projectAccount.getId()));
292+
Project project = _projectDao.persist(new ProjectVO(name, displayText, ownerFinal.getDomainId(), projectAccount.getId()));
294293

295-
//assign owner to the project
296-
assignAccountToProject(project, ownerFinal.getId(), ProjectAccount.Role.Admin,
297-
Optional.ofNullable(finalUser).map(User::getId).orElse(null), null);
294+
//assign owner to the project
295+
assignAccountToProject(project, ownerFinal.getId(), ProjectAccount.Role.Admin,
296+
Optional.ofNullable(finalUser).map(User::getId).orElse(null), null);
298297

299-
if (project != null) {
300-
CallContext.current().setEventDetails("Project id=" + project.getId());
301-
CallContext.current().putContextParameter(Project.class, project.getUuid());
302-
}
298+
if (project != null) {
299+
CallContext.current().setEventDetails("Project id=" + project.getId());
300+
CallContext.current().putContextParameter(Project.class, project.getUuid());
301+
}
303302

304-
//Increment resource count
305-
_resourceLimitMgr.incrementResourceCount(ownerFinal.getId(), ResourceType.project);
303+
//Increment resource count
304+
_resourceLimitMgr.incrementResourceCount(ownerFinal.getId(), ResourceType.project);
306305

307-
return project;
308-
}
309-
});
306+
return project;
307+
}
308+
});
310309

311-
messageBus.publish(_name, ProjectManager.MESSAGE_CREATE_TUNGSTEN_PROJECT_EVENT, PublishScope.LOCAL, project);
310+
messageBus.publish(_name, ProjectManager.MESSAGE_CREATE_TUNGSTEN_PROJECT_EVENT, PublishScope.LOCAL, project);
312311

313-
return project;
312+
return project;
314313
}
315314
}
316315

@@ -671,13 +670,13 @@ private void updateProjectAccount(ProjectAccountVO futureOwner, Role newAccRole,
671670
boolean shouldIncrementResourceCount = Role.Admin == newAccRole;
672671

673672
try (CheckedReservation checkedReservation = new CheckedReservation(account, ResourceType.project, shouldIncrementResourceCount ? 1L : 0L, reservationDao, _resourceLimitMgr)) {
674-
futureOwner.setAccountRole(newAccRole);
675-
_projectAccountDao.update(futureOwner.getId(), futureOwner);
676-
if (shouldIncrementResourceCount) {
677-
_resourceLimitMgr.incrementResourceCount(accountId, ResourceType.project);
678-
} else {
679-
_resourceLimitMgr.decrementResourceCount(accountId, ResourceType.project);
680-
}
673+
futureOwner.setAccountRole(newAccRole);
674+
_projectAccountDao.update(futureOwner.getId(), futureOwner);
675+
if (shouldIncrementResourceCount) {
676+
_resourceLimitMgr.incrementResourceCount(accountId, ResourceType.project);
677+
} else {
678+
_resourceLimitMgr.decrementResourceCount(accountId, ResourceType.project);
679+
}
681680
}
682681
}
683682

@@ -877,16 +876,16 @@ public boolean addAccountToProject(long projectId, String accountName, String em
877876

878877
boolean shouldIncrementResourceCount = projectRoleType != null && Role.Admin == projectRoleType;
879878
try (CheckedReservation cr = new CheckedReservation(account, ResourceType.project, shouldIncrementResourceCount ? 1L : 0L, reservationDao, _resourceLimitMgr)) {
880-
if (assignAccountToProject(project, account.getId(), projectRoleType, null,
881-
Optional.ofNullable(projectRole).map(ProjectRole::getId).orElse(null)) != null) {
882-
if (shouldIncrementResourceCount) {
883-
_resourceLimitMgr.incrementResourceCount(account.getId(), ResourceType.project);
879+
if (assignAccountToProject(project, account.getId(), projectRoleType, null,
880+
Optional.ofNullable(projectRole).map(ProjectRole::getId).orElse(null)) != null) {
881+
if (shouldIncrementResourceCount) {
882+
_resourceLimitMgr.incrementResourceCount(account.getId(), ResourceType.project);
883+
}
884+
return true;
885+
} else {
886+
logger.warn("Failed to add account {} to project {}", accountName, project);
887+
return false;
884888
}
885-
return true;
886-
} else {
887-
logger.warn("Failed to add account {} to project {}", accountName, project);
888-
return false;
889-
}
890889
}
891890
}
892891
}

0 commit comments

Comments
 (0)