Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Dashboard link directs to localhost (127.0.0.1) #10

Open
bubthegreat opened this issue Feb 22, 2018 · 1 comment
Open

Dashboard link directs to localhost (127.0.0.1) #10

bubthegreat opened this issue Feb 22, 2018 · 1 comment

Comments

@bubthegreat
Copy link
Contributor

When clicking the link for a dashboard, it forwards to localhost, which is not correct if you've set up everything on a remote VM.

@Callidin
Copy link

Callidin commented Oct 2, 2018

This seems to be linked with the following logic from FlashStache/flasharray/views.py:

ip_addr = socket.gethostbyname(socket.gethostname())
...
'grafana': 'http://{}:3000'.format(ip_addr),

For VMs that have internet connectivity, I was able to solve it with the following code:

def index(request):
    """Generate a list of FlashArray objects ordered by hostname for the base page."""
    # pylint: disable=no-member
    def get_address():
        try:
                address = socket.gethostbyname(socket.gethostname())
                # On my system, this always gives me 127.0.0.1. Hence...
        except:
                address = ''
        if not address or address.startswith('127.'):
                # ...the hard way.
                s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
                s.connect(('4.2.2.1', 0))
                address = s.getsockname()[0]
        return address
    ip_addr = get_address()

    context = {
        'arrays': models.FlashArray.objects.distinct(),
        'remote_assist': models.RemoteAssist.objects.distinct(),
        'array_status': models.ArrayStatus.objects.distinct(),
        'url': 'http://{}'.format(ip_addr),
        'grafana': 'http://{}:3000'.format(ip_addr),
    }

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants