|
86 | 86 | import org.apache.cloudstack.acl.SecurityChecker; |
87 | 87 | import org.apache.cloudstack.acl.SecurityChecker.AccessType; |
88 | 88 | import org.apache.cloudstack.api.command.admin.usage.ListTrafficTypeImplementorsCmd; |
89 | | -import org.apache.cloudstack.api.command.user.network.CreateNetworkCmd; |
90 | | -import org.apache.cloudstack.api.command.user.network.ListNetworksCmd; |
91 | | -import org.apache.cloudstack.api.command.user.network.RestartNetworkCmd; |
| 89 | +import org.apache.cloudstack.api.command.user.network.*; |
92 | 90 | import org.apache.cloudstack.api.command.user.vm.ListNicsCmd; |
93 | 91 | import org.apache.log4j.Logger; |
94 | 92 | import org.springframework.stereotype.Component; |
@@ -203,6 +201,8 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { |
203 | 201 | HostPodDao _hostPodDao; |
204 | 202 | @Inject |
205 | 203 | DataCenterVnetDao _datacneter_vnet; |
| 204 | + @Inject |
| 205 | + NicDetailDao _nicDetailDao = null; |
206 | 206 |
|
207 | 207 | int _cidrLimit; |
208 | 208 | boolean _allowSubdomainNetworkAccess; |
@@ -817,6 +817,7 @@ public Network createGuestNetwork(CreateNetworkCmd cmd) throws InsufficientCapac |
817 | 817 | String endIPv6 = cmd.getEndIpv6(); |
818 | 818 | String ip6Gateway = cmd.getIp6Gateway(); |
819 | 819 | String ip6Cidr = cmd.getIp6Cidr(); |
| 820 | + Boolean isDisplayNetworkEnabled = cmd.getDisplayNetwork(); |
820 | 821 |
|
821 | 822 | // Validate network offering |
822 | 823 | NetworkOfferingVO ntwkOff = _networkOfferingDao.findById(networkOfferingId); |
@@ -1098,13 +1099,13 @@ && areServicesSupportedByNetworkOffering(ntwkOff.getId(), Service.SourceNat))) { |
1098 | 1099 | throw new InvalidParameterValueException("Network offering can't be used for VPC networks"); |
1099 | 1100 | } |
1100 | 1101 | network = _vpcMgr.createVpcGuestNetwork(networkOfferingId, name, displayText, gateway, cidr, vlanId, |
1101 | | - networkDomain, owner, sharedDomainId, pNtwk, zoneId, aclType, subdomainAccess, vpcId, caller); |
| 1102 | + networkDomain, owner, sharedDomainId, pNtwk, zoneId, aclType, subdomainAccess, vpcId, caller, isDisplayNetworkEnabled); |
1102 | 1103 | } else { |
1103 | 1104 | if (_configMgr.isOfferingForVpc(ntwkOff)){ |
1104 | 1105 | throw new InvalidParameterValueException("Network offering can be used for VPC networks only"); |
1105 | 1106 | } |
1106 | 1107 | network = _networkMgr.createGuestNetwork(networkOfferingId, name, displayText, gateway, cidr, vlanId, |
1107 | | - networkDomain, owner, sharedDomainId, pNtwk, zoneId, aclType, subdomainAccess, vpcId, ip6Gateway, ip6Cidr); |
| 1108 | + networkDomain, owner, sharedDomainId, pNtwk, zoneId, aclType, subdomainAccess, vpcId, ip6Gateway, ip6Cidr, isDisplayNetworkEnabled); |
1108 | 1109 | } |
1109 | 1110 |
|
1110 | 1111 | if (caller.getType() == Account.ACCOUNT_TYPE_ADMIN && createVlan) { |
@@ -3347,7 +3348,7 @@ public Network createPrivateNetwork(String networkName, String displayText, long |
3347 | 3348 | if (privateNetwork == null) { |
3348 | 3349 | //create Guest network |
3349 | 3350 | privateNetwork = _networkMgr.createGuestNetwork(ntwkOff.getId(), networkName, displayText, gateway, cidr, vlan, |
3350 | | - null, owner, null, pNtwk, pNtwk.getDataCenterId(), ACLType.Account, null, null, null, null); |
| 3351 | + null, owner, null, pNtwk, pNtwk.getDataCenterId(), ACLType.Account, null, null, null, null, true); |
3351 | 3352 | s_logger.debug("Created private network " + privateNetwork); |
3352 | 3353 | } else { |
3353 | 3354 | s_logger.debug("Private network already exists: " + privateNetwork); |
@@ -3407,4 +3408,57 @@ public List<? extends Nic> listNics(ListNicsCmd cmd) { |
3407 | 3408 | _accountMgr.checkAccess(caller, null, true, userVm); |
3408 | 3409 | return _networkMgr.listVmNics(vmId, nicId); |
3409 | 3410 | } |
| 3411 | + |
| 3412 | + @Override |
| 3413 | + public void addNicDetail(AddNicDetailCmd cmd){ |
| 3414 | + UserContext.current().setEventDetails("Nic Id: " + cmd.getId()); |
| 3415 | + Account caller = UserContext.current().getCaller(); |
| 3416 | + Long nicId = cmd.getId(); |
| 3417 | + String name = cmd.getName(); |
| 3418 | + String value = cmd.getValue(); |
| 3419 | + |
| 3420 | + NicVO nic = _nicDao.findById(nicId); |
| 3421 | + |
| 3422 | + //_accountMgr.checkAccess(caller, null, true, nic); |
| 3423 | + NicDetailVO nicDetail = new NicDetailVO(nicId, name, value); |
| 3424 | + _nicDetailDao.persist(nicDetail); |
| 3425 | + } |
| 3426 | + |
| 3427 | + @Override |
| 3428 | + public void updateNicDetail(UpdateNicDetailCmd cmd){ |
| 3429 | + UserContext.current().setEventDetails("Nic Id: " + cmd.getId()); |
| 3430 | + Account caller = UserContext.current().getCaller(); |
| 3431 | + Long nicId = cmd.getId(); |
| 3432 | + String name = cmd.getName(); |
| 3433 | + String value = cmd.getValue(); |
| 3434 | + |
| 3435 | + NicVO nic = _nicDao.findById(nicId); |
| 3436 | + // _accountMgr.checkAccess(caller, null, true, nic); |
| 3437 | + NicDetailVO nicDetail = _nicDetailDao.findDetail(nicId, name); |
| 3438 | + if(nicDetail != null){ |
| 3439 | + nicDetail.setValue(value); |
| 3440 | + _nicDetailDao.update(nicDetail.getId(), nicDetail); |
| 3441 | + }else{ |
| 3442 | + throw new InvalidParameterValueException("This detail doesnt exist for the nic"); |
| 3443 | + } |
| 3444 | + |
| 3445 | + } |
| 3446 | + |
| 3447 | + @Override |
| 3448 | + public void removeNicDetail(RemoveNicDetailCmd cmd){ |
| 3449 | + Account caller = UserContext.current().getCaller(); |
| 3450 | + Long nicId = cmd.getId(); |
| 3451 | + String name = cmd.getName(); |
| 3452 | + |
| 3453 | + NicVO nic = _nicDao.findById(nicId); |
| 3454 | + //_accountMgr.checkAccess(caller, null, true, nic); |
| 3455 | + NicDetailVO nicDetail = _nicDetailDao.findDetail(nicId, name); |
| 3456 | + if(nicDetail != null){ |
| 3457 | + _nicDetailDao.remove(nicDetail.getId()); |
| 3458 | + }else{ |
| 3459 | + throw new InvalidParameterValueException("This detail doesnt exist for the nic "); |
| 3460 | + } |
| 3461 | + |
| 3462 | + } |
| 3463 | + |
3410 | 3464 | } |
0 commit comments