[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-10013?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16302549#comment-16302549
 ] 

ASF GitHub Bot commented on CLOUDSTACK-10013:
---------------------------------------------

yvsubhash commented on a change in pull request #2211: CLOUDSTACK-10013: 
Migrate systemvmtemplate to Debian9
URL: https://github.com/apache/cloudstack/pull/2211#discussion_r158587630
 
 

 ##########
 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:
   @rhtyd  unlike previous approach, now it seems to be doing an extra update 
operation to DB when assign is true,   can we avoid that?

----------------------------------------------------------------
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)

Reply via email to