Пример #1
0
def init_datastoreCache(force=False):
    """
    Initializes the datastore cache with the list of datastores accessible
    from local ESX host. force=True will force it to ignore current cache
    and force init
    """
    with lockManager.get_lock("init_datastoreCache"):
        global datastores
        logging.debug("init_datastoreCache:  %s", datastores)
        if datastores and not force:
            return

        si = vmdk_ops.get_si()

        #  We are connected to ESX so childEntity[0] is current DC/Host
        ds_objects = si.content.rootFolder.childEntity[
            0].datastoreFolder.childEntity
        tmp_ds = []

        for datastore in ds_objects:
            dockvols_path, err = vmdk_ops.get_vol_path(
                datastore=datastore.info.name, create=False)
            if err:
                logging.error(
                    " datastore %s is being ignored as the dockvol path can't be created on it",
                    datastore.info.name)
                continue
            tmp_ds.append(
                (datastore.info.name, datastore.info.url, dockvols_path))
        datastores = tmp_ds
Пример #2
0
def init_datastoreCache(force=False):
    """
    Initializes the datastore cache with the list of datastores accessible
    from local ESX host. force=True will force it to ignore current cache
    and force init
    """
    with lockManager.get_lock("init_datastoreCache"):
        global datastores
        logging.debug("init_datastoreCache:  %s", datastores)
        if datastores and not force:
            return

        si = vmdk_ops.get_si()

        #  We are connected to ESX so childEntity[0] is current DC/Host
        ds_objects = si.content.rootFolder.childEntity[0].datastoreFolder.childEntity
        tmp_ds = []

        for datastore in ds_objects:
            dockvols_path, err = vmdk_ops.get_vol_path(datastore=datastore.info.name, create=False)
            if err:
                logging.error(" datastore %s is being ignored as the dockvol path can't be created on it", datastore.info.name)
                continue
            tmp_ds.append((datastore.info.name,
                           datastore.info.url,
                           dockvols_path))
        datastores = tmp_ds
Пример #3
0
def get_vsan_dockvols_path():
    """
    Return the VSAN datastore dockvols path for a given cluster. Default to the
    first datastore for now, so we can test without VSAN.
    """
    datastore = get_vsan_datastore()
    if datastore:
        path, err = vmdk_ops.get_vol_path(datastore.info.name)
        if not err:
            return path
    else:
        return None
Пример #4
0
def get_vsan_dockvols_path():
    """
    Return the VSAN datastore dockvols path for a given cluster. Default to the
    first datastore for now, so we can test without VSAN.
    """
    datastore = get_vsan_datastore()
    if datastore:
        path, err = vmdk_ops.get_vol_path(datastore.info.name)
        if not err:
            return path
    else:
        return None
def init_datastoreCache():
    """
    Initializes the datastore cache with the list of datastores accessible from local ESX host.
    """
    global datastores
    logging.debug("init_datastoreCache: %s", datastores)

    si = vmdk_ops.get_si()

    #  We are connected to ESX so childEntity[0] is current DC/Host
    ds_objects = \
      si.content.rootFolder.childEntity[0].datastoreFolder.childEntity
    datastores = []

    for datastore in ds_objects:
        dockvols_path, err = vmdk_ops.get_vol_path(datastore.info.name)
        if err:
            continue
        datastores.append(
            (datastore.info.name, datastore.info.url, dockvols_path))