GabrielBrascher opened a new issue #4853:
URL: https://github.com/apache/cloudstack/issues/4853


   <!--
   Verify first that your issue/request is not already reported on GitHub.
   Also test if the latest release and master branch are affected too.
   Always add information AFTER of these HTML comments, but no need to delete 
the comments.
   -->
   
   ##### ISSUE TYPE
   <!-- Pick one below and delete the rest -->
    * Bug Report
    * Improvement Request
   
   ##### COMPONENT NAME
   <!--
   Categorize the issue, e.g. API, VR, VPN, UI, etc.
   -->
   ~~~
   API
   ~~~
   
   ##### CLOUDSTACK VERSION
   <!--
   New line separated list of affected versions, commit ID for issues on master 
branch.
   -->
   
   ~~~
   Since long long time ago ... (10 years)
   ~~~
   
   ##### CONFIGURATION
   <!--
   Information about the configuration if relevant, e.g. basic network, 
advanced networking, etc.  N/A otherwise
   -->
   
   - **Zone Network type:** Advanced network with Security Groups enabled
   - **Network isolation:** VXLAN
   - **Virtualization:** KVM
   
   ##### SUMMARY
   <!-- Explain the problem/feature briefly -->
   
   The API command 
[listPublicIpAddresses](https://cloudstack.apache.org/api/apidocs-4.15/apis/listPublicIpAddresses.html)
 does not list IP addresses for any network with Advanced Networking + Security 
Groups + VLAN / VXLAN.
   
   Command example: `list publicipaddresses 
networkid=a7f6b609-211f-4157-a016-62c5563f8085 listall=True`
   
   The API command lists IP addresses with a select such as:
   ```
   SELECT user_ip_address.id, user_ip_address.account_id, 
user_ip_address.domain_id, user_ip_address.public_ip_address, 
user_ip_address.data_center_id, user_ip_address.source_nat, 
user_ip_address.allocated, user_ip_address.vlan_db_id, 
user_ip_address.one_to_one_nat, user_ip_address.vm_id, user_ip_address.state, 
user_ip_address.mac_address, user_ip_address.source_network_id, 
user_ip_address.network_id, user_ip_address.uuid, 
user_ip_address.physical_network_id, user_ip_address.is_system, 
user_ip_address.vpc_id, user_ip_address.dnat_vmip, user_ip_address.is_portable, 
user_ip_address.display, user_ip_address.rule_state, 
user_ip_address.forsystemvms, user_ip_address.removed, user_ip_address.created
       FROM user_ip_address
           INNER JOIN vlan ON user_ip_address.vlan_db_id=vlan.id
           INNER JOIN account ON user_ip_address.account_id=account.id
       WHERE user_ip_address.source_network_id = 216 AND 
user_ip_address.display=1 AND user_ip_address.forsystemvms=0 AND 
user_ip_address.allocated IS NOT NULL AND user_ip_address.removed IS NULL  AND  
(vlan.vlan_type = 'VirtualNetwork'  AND vlan.removed IS NULL ) AND 
(account.type != 5 ) ORDER BY user_ip_address.public_ip_address DESC  LIMIT 0, 
500
   ```
   
   The problem here is that the _WHERE_ conditional `vlan.vlan_type = 
'VirtualNetwork' ` filters to VLANs of type  'VirtualNetwork'; however, all 
networks of Advanced Network + SG are deployed with VLAN of type  
'DirectAttached' which leads to an empty result.
   
   This is due to the following code at 
[ManagementServerImpl.java](https://github.com/apache/cloudstack/blob/4e90a8c454f4d8ea6c35d9f92ada13325aeecf54/server/src/main/java/com/cloud/server/ManagementServerImpl.java#L2117):
   ```
          VlanType vlanType = null;
           if (forVirtualNetwork != null) {
               vlanType = forVirtualNetwork ? VlanType.VirtualNetwork : 
VlanType.DirectAttached;
           } else {
               vlanType = VlanType.VirtualNetwork;
           }
   ```
   
   When adding the parameter `forVirtualNetwork` at the API Command then it 
lists all the allocated IPs as expected.
   
   ```
   list publicipaddresses networkid=<network-uuid> listall=true 
forvirtualnetwork=true;
   ```
   
   This also affects the UI (both legacy and primate):
   
   
![image](https://user-images.githubusercontent.com/5025148/112076342-09efe900-8b59-11eb-819e-bdc0559bebd7.png)
   
   
![image](https://user-images.githubusercontent.com/5025148/112076284-e7f66680-8b58-11eb-91dc-a60706db0d29.png)
   
   ##### DISCUSSION
   
   Considering the context presented here I see this as a bug, however, I would 
appreciate any feedback.
   
   Is this a bug, or simply the desired behavior? If it is not a bug, we should 
then enhance the UI and API documentation.
   I still don't see the "why" of such behavior in the case of VLAN on Advanced 
networking, as we hold networks with public IPs but none of them are listed on 
UI.
   
   ##### STEPS TO REPRODUCE
   <!--
   For bugs, show exactly how to reproduce the problem, using a minimal 
test-case. Use Screenshots if accurate.
   
   For new features, show how the feature would be used.
   -->
   
   <!-- Paste example playbooks or commands between quotes below -->
   ~~~
    🐱 > list publicipaddresses networkid=<network-uuid> listall=true;
    🐱 > list publicipaddresses networkid=<network-uuid> listall=true 
forvirtualnetwork=true;
   count = 7
      ...
      ...
      ...
   ~~~
   
   <!-- You can also paste gist.github.com links for larger files -->
   
   ##### EXPECTED RESULTS
   <!-- What did you expect to happen when running the steps above? -->
   
   ~~~
    🐱 > list publicipaddresses networkid=<network-uuid> listall=true;
   count = 7
      ...
      ...
      ...
   ~~~
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to