'Searches cells, or a single cell, and maps found hosts.
When a new host is added to a deployment it will add a service entry
to the db it\'s configured to use. This command will check the db for
each cell, or a single one if passed in, and map any hosts which are
not currently mapped. If a host is already mapped nothing will be done.'

@args('--cell_uuid', metavar='<cell_uuid>', dest='cell_uuid', help='If    provided    only    this    cell    will    be    searched    for    new    hosts    to    map.')
@args('--verbose', action='store_true', help=_('Provide    detailed    output    when    discovering    hosts.'))
@args('--strict', action='store_true', help=_('Considered    successful    (exit    code    0)    only    when    an    unmapped    host    is    discovered.    Any    other    outcome    will    be    considered    a    failure    (exit    code    1).'))
def discover_hosts(self, cell_uuid=None, verbose=False, strict=False):

    def status_fn(msg):
        if verbose:
            print(msg)
    ctxt = context.RequestContext()
    hosts = host_mapping_obj.discover_hosts(ctxt, cell_uuid, status_fn)
    if strict:
        return int((not hosts))
