[
https://issues.apache.org/jira/browse/CLOUDSTACK-10013?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16302655#comment-16302655
]
ASF GitHub Bot commented on CLOUDSTACK-10013:
---------------------------------------------
rhtyd commented on a change in pull request #2211: CLOUDSTACK-10013: Migrate
systemvmtemplate to Debian9
URL: https://github.com/apache/cloudstack/pull/2211#discussion_r158593073
##########
File path: server/src/com/cloud/network/IpAddressManagerImpl.java
##########
@@ -799,28 +798,55 @@ public IPAddressVO doInTransaction(TransactionStatus
status) throws Insufficient
throw new AccountLimitException("Maximum number of
public IP addresses for account: " + owner.getAccountName() + " has been
exceeded.");
}
}
- IPAddressVO addr = addrs.get(0);
- addr.setSourceNat(sourceNat);
- addr.setAllocatedTime(new Date());
- addr.setAllocatedInDomainId(owner.getDomainId());
- addr.setAllocatedToAccountId(owner.getId());
- addr.setSystem(isSystem);
-
- if (displayIp != null) {
- addr.setDisplay(displayIp);
+
+ IPAddressVO finalAddr = null;
+ for (final IPAddressVO possibleAddr: addrs) {
+ if (possibleAddr.getState() != IpAddress.State.Free) {
+ continue;
+ }
+ final IPAddressVO addr = possibleAddr;
+ addr.setSourceNat(sourceNat);
+ addr.setAllocatedTime(new Date());
+ addr.setAllocatedInDomainId(owner.getDomainId());
+ addr.setAllocatedToAccountId(owner.getId());
+ addr.setSystem(isSystem);
+
+ if (displayIp != null) {
+ addr.setDisplay(displayIp);
+ }
+
+ if (vlanUse != VlanType.DirectAttached) {
+ addr.setAssociatedWithNetworkId(guestNetworkId);
+ addr.setVpcId(vpcId);
+ }
+ if (_ipAddressDao.lockRow(possibleAddr.getId(), true) !=
null) {
+ final IPAddressVO userIp =
_ipAddressDao.findById(addr.getId());
+ if (userIp.getState() == IpAddress.State.Free) {
+ addr.setState(IpAddress.State.Allocating);
+ if (_ipAddressDao.update(addr.getId(), addr)) {
Review comment:
The current regression fix is a two step process where IPs are first marked
allocating and then marked allocated if assign is true, it's because ips in
both free and allocating state can be allocated. Do you propose we simply mark
free ips to allocated in the loop if assign is true?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Migrate to Debian9 systemvmtemplate
> -----------------------------------
>
> Key: CLOUDSTACK-10013
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10013
> Project: CloudStack
> Issue Type: Bug
> Security Level: Public(Anyone can view this level - this is the
> default.)
> Reporter: Rohit Yadav
> Assignee: Rohit Yadav
> Fix For: Future, 4.11.0.0
>
>
> Migrate to debian9 based systemvmtemplate
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)