Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No networks shown in LXDUI, even though it can create one with no problems #330

Closed
UserXYZ opened this issue Nov 15, 2020 · 5 comments
Closed

Comments

@UserXYZ
Copy link

UserXYZ commented Nov 15, 2020

When opening Networks page in LXDUI, I always get an empty table, even though LXDUI can create new bridged network just fine. Even after that, the newly created network is not present and table stays empty.
I have been digging through the code and found out that LXCNetwork.py does actually get a list of networks from LXD API call, and populates the JSON that is then passed on to blueprint.py which should dynamically fill the network.html page with proper content - but that content is not injected into the html page and Network page stays with just an empty table.
Here's a part of the generated JSON:
res=[{'config': {'ipv4.address': '192.168.192.1/24', 'ipv4.dhcp.ranges': '192.168.192.2-192.168.192.250', 'ipv4.nat': 'true', 'ipv6.address': 'fd42:1a24:382f:2ece::1/64', 'ipv6.nat': 'true'}, 'description': '', 'name': 'lxdbr0', 'type': 'bridge', 'used_by': ['/1.0/profiles/NATed'], 'managed': True, 'status': 'Created', 'locations': ['none']}, {'config': {'ipv4.address': '10.20.30.1/24', 'ipv4.dhcp.ranges': '10.20.30.2-10.20.30.254', 'ipv4.nat': 'true', 'ipv6.address': 'fd42:411d:6e00:d25f::1/64', 'ipv6.nat': 'true'}, 'description': '', 'name': 't0', 'type': 'bridge', 'used_by': None, 'managed': True, 'status': 'Created', 'locations': ['none']},...

t0 in here is the test network that LXDUI generated fine, and lxdbr0 is the one I created directly with lxc command.

HTML template is in /usr/local/lib/python3.6/dist-packages/app/ui/templates/network.html (I installed LXDUI with pip3 on Ubuntu 18.04) and this is the table definition that does not get populated:

        <table class="table table-bordered" id="tableNetworks">
            <thead>
                <th><input type="checkbox" id="selectAllNetworks"/></th>
                <th>Name</th>
                <th>Type</th>
                <th>Config</th>
                <th>Used by</th>
                <th>Action</th>
            </thead>
            <tbody>
            {% for net in network %}
            {% if net.type == 'bridge' %}
            <tr id="{{net.name}}">
                <td></td>
                <td>{{ net.name }}</td>
                <td>{{ net.type }}</td>
                <td>
                    <ul>
                        <h5>Config:</h5>
                        {% for key, value in net.config.items() %}

                        <li>{{key}}: {{value}}</li>
                        {% endfor %}
                    </ul>
                </td>
                <td>
                 {% for used in net.used_by %}
                    <li>{{used.split('/')[-1]}}</li>
                 {% endfor %}
                </td>
                <td>
                    <button class="btn btn-default" id="{{net.name}}" name="updateBridge" onClick="$.proxy(App.network.showUpdateNetwork('{{net.name}}'));">
                        <span class="glyphicon"> </span> Update Bridge
                    </button>
                </td>
            </tr>
            {% endif %}
            {% endfor %}
            </tbody>
        </table>

So, for loop obviously does nothing and elements get no content.
Funny thing is that even if I change the network.html directly and put some chars into elements, they do not get shown.
Also funny thing is that JSON button on Networks page gives quite the correct output for all the networks that exist on the system.

Does anyone have a clue how this can be fixed? Is there some special prerequisite, permission, group ownership or anything that would make it work?

Finally, is this project still alive at all and being maintained, at least a bit? I like it because it's quite lightweight and quick to install and does most of the things for daily click-click operations, but not having any output for networks is just too big of a bug for such a simple project.

Thank you.

@mopo3ilo
Copy link

mopo3ilo commented Feb 6, 2021

try this

--- network.html.backup	2021-02-06 17:36:10.163546370 +0300
+++ network.html	2021-02-06 17:32:47.572897768 +0300
@@ -21,7 +21,7 @@
         <br>
         <br>
         <br>
-        <div class="">
+        <div class="col-lg-12">
             <table class="table table-bordered" id="tableNetworks">
                 <thead>
                     <th><input type="checkbox" id="selectAllNetworks"/></th>
@@ -40,17 +40,20 @@
                     <td>{{ net.type }}</td>
                     <td>
                         <ul>
+                            {% if net.config != {} %}
                             <h5>Config:</h5>
                             {% for key, value in net.config.items() %}
-
                             <li>{{key}}: {{value}}</li>
                             {% endfor %}
+                            {% endif %}
                         </ul>
                     </td>
                     <td>
+                     {% if net.used_by != None %}
                      {% for used in net.used_by %}
                         <li>{{used.split('/')[-1]}}</li>
                      {% endfor %}
+                     {% endif %}
                     </td>
                     <td>
                         <button class="btn btn-default" id="{{net.name}}" name="updateBridge" onClick="$.proxy(App.network.showUpdateNetwork('{{net.name}}'));">

@UserXYZ
Copy link
Author

UserXYZ commented Feb 25, 2021

Thank you for responding @mopo3ilo , but unfortunately, your patch did not help...I still do not see anything shown in my network page - only when I click on JSON button there I get my network config.
I applied the patch and restarted whole LXDUI to be safe - is there maybe some sort of cache that might need to be cleaned or something in order for the new page to be rebuilt and perhaps shown correctly?

Thank you.

@mopo3ilo
Copy link

Thank you for responding @mopo3ilo , but unfortunately, your patch did not help...I still do not see anything shown in my network page - only when I click on JSON button there I get my network config.
I applied the patch and restarted whole LXDUI to be safe - is there maybe some sort of cache that might need to be cleaned or something in order for the new page to be rebuilt and perhaps shown correctly?

Thank you.

Restart service, ctrl+shift+r page?

@UserXYZ
Copy link
Author

UserXYZ commented Mar 4, 2021

Well, like I said, I restarted the whole VM with LXDUI and it did not help. Not sure what 'ctrl+shift+r' would be in this case...

The thing is that I was able to debug the page and code up to the point and I see that I can get a list of networks internally but the for loop does not seem to parse it properly, and so it fails to create the table (basically the the section where your patch is applied).
That is why I was hoping that some sort of cache exists that can be cleared so the page (or template for it) gets rebuilt.

@UserXYZ
Copy link
Author

UserXYZ commented Mar 4, 2021

It seems I spoke too soon...after revisiting your patch and my changed files, I realized that I had a bad character in one place, and html file would not render completely, essentially breaking the display of networks.
After re-applying your patch to a fresh copy from git repo, it started to work and I can see my network page as it should be.

So, thank you very much Oleg, appreciate the help.

Cheers, Andrea

@jetroni jetroni closed this as completed Feb 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants