Missing private address property from unit.info

Bug #1293831 reported by Charles Butler
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Amulet
New
Wishlist
Unassigned

Bug Description

The output of what i can receive from a unit does not contain private-address as a callable property.

When introspecting with ipdb, i see the following:

p d.sentry.unit['nagios/0'].info

{'public-address': '10.0.3.47', 'service': 'nagios', 'subordinates': {'nagios-sentry/0': {'public-address': '10.0.3.47', 'agent-state': 'started', 'agent-version': '1.17.5.1', 'upgrading-from': 'local:precise/nagios-sentry-0', 'open-ports': ['9001/tcp']}}, 'unit': '0', 'agent-state': 'started', 'agent-version': '1.17.5.1', 'machine': '4', 'open-ports': ['80/tcp']}

Even though there is no "private address" persay, perhaps amulet could alias this on the local provider?

and on clouds, missing private-address is a far larger problem, as several charms reference the private address during the relationship lifecycle.

description: updated
description: updated
summary: - Missing private address property when testing on local provider
+ Missing private address property from unit.info
description: updated
Revision history for this message
Matt Bruzek (mbruzek) wrote :

When I juju ssh to tomcat/1 I was able to find a command that gives the private address:
ubuntu@juju-hp-mbruzek-machine-5:~$ juju-run tomcat/1 "unit-get private-address"
10.4.189.86

However the equivalent command in Amulet does not produce the same output:
addr, rc = d.sentry.unit['tomcat/1'].run('juju-run tomcat/1 "unit-get private-address"')

Revision history for this message
Matt Bruzek (mbruzek) wrote :

Just to follow up, I did find a way to work around this problem from the amulet test perspective. I wanted to leave this information here in case it helps someone else. Warning, the workaround is ugly python code but it works.

# The command must contain the double quotes around "unit-get private address"
# Other ways of writing the command, got the quotes escaped.
cmd = 'juju run --unit tomcat/1 "unit-get private-address"
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)

Marco Ceppi (marcoceppi)
Changed in amulet:
importance: Undecided → Wishlist
Revision history for this message
Francesco Banconi (frankban) wrote :

FWIW, a function like the following seems to work:

def get_private_address(unit):
    """Return the private address of the given sentry unit."""
    address, retcode = unit.run('unit-get private-address')
    assert retcode == 0, 'error retrieving unit private address'
    return address

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.