~openstack-charmers-next/charms/xenial/neutron-gateway/trunk

« back to all changes in this revision

Viewing changes to hooks/charmhelpers/contrib/network/ip.py

  • Committer: James Page
  • Date: 2016-03-02 11:06:34 UTC
  • Revision ID: james.page@ubuntu.com-20160302110634-05v54wbliqkprlog
Resync charm-helpers

Change-Id: Iced6305e239114371518831a1e2c450e630152b4

Show diffs side-by-side

added added

removed removed

Lines of Context:
456
456
            return result
457
457
    else:
458
458
        return result.split('.')[0]
 
459
 
 
460
 
 
461
def port_has_listener(address, port):
 
462
    """
 
463
    Returns True if the address:port is open and being listened to,
 
464
    else False.
 
465
 
 
466
    @param address: an IP address or hostname
 
467
    @param port: integer port
 
468
 
 
469
    Note calls 'zc' via a subprocess shell
 
470
    """
 
471
    cmd = ['nc', '-z', address, str(port)]
 
472
    result = subprocess.call(cmd)
 
473
    return not(bool(result))