Github user jburwell commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1578#discussion_r77755263
  
    --- Diff: 
plugins/network-elements/nuage-vsp/src/com/cloud/network/guru/NuageVspGuestNetworkGuru.java
 ---
    @@ -242,6 +256,44 @@ public void reserve(NicProfile nic, Network network, 
VirtualMachineProfile vm, D
                     throw new IllegalStateException("The broadcast URI path " 
+ network.getBroadcastUri() + " is empty or in an incorrect format.");
                 }
     
    +            HostVO nuageVspHost = 
getNuageVspHost(network.getPhysicalNetworkId());
    +            VspNetwork vspNetwork = 
_nuageVspEntityBuilder.buildVspNetwork(network, false);
    +
    +            // Set flags for dhcp options
    +            boolean networkHasDns = networkHasDns(network);
    +
    +            Map<Long, Boolean> networkHasDnsCache = Maps.newHashMap();
    +            networkHasDnsCache.put(network.getId(), networkHasDns);
    +
    +            // Determine if dhcp options of the other nics in the network 
need to be updated
    +            if (vm.getType() == VirtualMachine.Type.DomainRouter && 
network.getState() != State.Implementing) {
    +
    +                // Update dhcp options if a VR is added when we are not 
initiating the network
    +                if(s_logger.isDebugEnabled()) {
    +                    s_logger.debug(String.format("DomainRouter is added to 
an existing network: %s in state: %s", network.getName(), network.getState()));
    +                }
    +                List<VspDhcpVMOption> dhcpOptions = Lists.newLinkedList();
    +                for (NicVO userNic 
:_nicDao.listByNetworkId(network.getId())) {
    +                    if (userNic.getVmType() != 
VirtualMachine.Type.DomainRouter) {
    +                        boolean defaultHasDns = 
getDefaultHasDns(networkHasDnsCache, userNic);
    +                        
dhcpOptions.add(_nuageVspEntityBuilder.buildVmDhcpOption(userNic, 
defaultHasDns, networkHasDns));
    +                    }
    +                }
    +
    +                if (!dhcpOptions.isEmpty()) {
    +                    UpdateDhcpOptionVspCommand cmd = new 
UpdateDhcpOptionVspCommand(dhcpOptions, vspNetwork);
    +                    Answer answer = 
_agentMgr.easySend(nuageVspHost.getId(), cmd);
    +
    +                    if (answer == null || !answer.getResult()) {
    +                        s_logger.error("UpdateDhcpOptionVspCommand failed 
at \"reserve\" for network " + vspNetwork.getName());
    +                        if ((null != answer) && (null != 
answer.getDetails())) {
    +                            s_logger.error(answer.getDetails());
    +                        }
    +                        throw new 
InsufficientVirtualNetworkCapacityException("Failed to reserve VM in Nuage 
VSP.", Network.class, network.getId());
    +                    }
    +                }
    +            }
    --- End diff --
    
    Consider extracting lines 262-295 to a separate method such as 
``updateDhcpOptions`` to reduce the size of this method and increase 
readability.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to