Пример #1
0
def update_gateway(g_name_or_id, **fields):
    # NOTE: the UpdateAPIGuard ensures that the caller user exists,
    # and that the user is either admin or the owner of this gateway.
    # We only need to read the volume and gateway to call Volume.Reversion

    # gateway must exist...(defensive check)
    gateway = read_gateway(g_name_or_id)

    if gateway == None:
        raise Exception("No such Gateway '%s'" % g_name_or_id)

    volume = read_volume(gateway.volume_id)

    # volume must exist...(defensive check)
    if volume == None or volume.deleted:
        raise Exception("No volume with ID '%s'" % gateway.volume_id)

    rc = Gateway.Update(g_name_or_id, **fields)

    if rc:
        storagetypes.deferred.defer(Volume.Reversion, volume.volume_id)

    return rc
Пример #2
0
    if gateway_cert.version < gateway.cert_version:
        raise Exception("Stale cert version (%s < %s)" %
                        (gateway_cert.version, gateway.cert_version))

    # if given a new cert bundle, put it in place
    if new_cert_bundle:
        rc = VolumeCertBundle.Put(volume.volume_id, cert_bundle_bin)
        if not rc:
            raise Exception("Invalid volume cert bundle")

    # do the update
    new_driver = kw.get('driver_text', None)
    if new_driver is not None:
        new_driver = str(new_driver)

    gw_key = Gateway.Update(gateway_cert, new_driver=new_driver)
    return {"result": True}


# ----------------------------------
def list_gateways(attrs=None, **q_opts):
    return Gateway.ListAll(attrs, **q_opts)


# ----------------------------------
def list_gateways_by_volume(volume_name_or_id, **q_opts):
    caller_user = _check_authenticated(q_opts)

    # volume must exist
    volume = read_volume(volume_name_or_id)
    if volume == None or volume.deleted: