def migrate_datastore():
    key_value_items = KeyValuePair.get_all()

    try:
        for kvp in key_value_items:
            kvp_id = getattr(kvp, 'id', None)
            secret = getattr(kvp, 'secret', False)
            scope = getattr(kvp, 'scope', SYSTEM_SCOPE)

            if scope == USER_SCOPE:
                scope = FULL_USER_SCOPE

            if scope == SYSTEM_SCOPE:
                scope = FULL_SYSTEM_SCOPE

            new_kvp_db = KeyValuePairDB(id=kvp_id,
                                        name=kvp.name,
                                        expire_timestamp=kvp.expire_timestamp,
                                        value=kvp.value,
                                        secret=secret,
                                        scope=scope)
            KeyValuePair.add_or_update(new_kvp_db)
    except:
        print('ERROR: Failed migrating datastore item with name: %s' %
              kvp.name)
        tb.print_exc()
        raise
def migrate_datastore():
    key_value_items = KeyValuePair.get_all()

    try:
        for kvp in key_value_items:
            kvp_id = getattr(kvp, 'id', None)
            secret = getattr(kvp, 'secret', False)
            scope = getattr(kvp, 'scope', SYSTEM_SCOPE)
            new_kvp_db = KeyValuePairDB(id=kvp_id, name=kvp.name,
                                        expire_timestamp=kvp.expire_timestamp,
                                        value=kvp.value, secret=secret,
                                        scope=scope)
            KeyValuePair.add_or_update(new_kvp_db)
    except:
        print('ERROR: Failed migrating datastore item with name: %s' % kvp.name)
        tb.print_exc()
        raise
Пример #3
0
    def get_all(self, **kw):
        """
            List all keys.

            Handles requests:
                GET /keys/
        """
        # Prefix filtering
        prefix_filter = kw.get('prefix', None)

        if prefix_filter:
            kw['name__startswith'] = prefix_filter
            del kw['prefix']

        kvp_dbs = KeyValuePair.get_all(**kw)
        kvps = [KeyValuePairAPI.from_model(kvp_db) for kvp_db in kvp_dbs]

        return kvps
Пример #4
0
def migrate_datastore():
    key_value_items = KeyValuePair.get_all()

    try:
        for kvp in key_value_items:
            kvp_id = getattr(kvp, 'id', None)
            secret = getattr(kvp, 'secret', False)
            encrypted = getattr(kvp, 'encrypted', False)
            scope = getattr(kvp, 'scope', SYSTEM_SCOPE)
            new_kvp_db = KeyValuePairDB(id=kvp_id,
                                        name=kvp.name,
                                        expire_timestamp=kvp.expire_timestamp,
                                        value=kvp.value,
                                        secret=secret,
                                        encrypted=encrypted,
                                        scope=scope)
            KeyValuePair.add_or_update(new_kvp_db)
    except:
        print('Error trying to migrate KeyValuePair item with name: %s' %
              kvp.name)
        tb.print_exc()
Пример #5
0
def migrate_datastore():
    key_value_items = KeyValuePair.get_all()

    try:
        for kvp in key_value_items:
            kvp_id = getattr(kvp, "id", None)
            secret = getattr(kvp, "secret", False)
            scope = getattr(kvp, "scope", SYSTEM_SCOPE)
            new_kvp_db = KeyValuePairDB(
                id=kvp_id,
                name=kvp.name,
                expire_timestamp=kvp.expire_timestamp,
                value=kvp.value,
                secret=secret,
                scope=scope,
            )
            KeyValuePair.add_or_update(new_kvp_db)
    except:
        print("ERROR: Failed migrating datastore item with name: %s" %
              kvp.name)
        tb.print_exc()
        raise
def migrate_datastore():
    key_value_items = KeyValuePair.get_all()

    try:
        for kvp in key_value_items:
            kvp_id = getattr(kvp, "id", None)
            secret = getattr(kvp, "secret", False)
            encrypted = getattr(kvp, "encrypted", False)
            scope = getattr(kvp, "scope", SYSTEM_SCOPE)
            new_kvp_db = KeyValuePairDB(
                id=kvp_id,
                name=kvp.name,
                expire_timestamp=kvp.expire_timestamp,
                value=kvp.value,
                secret=secret,
                encrypted=encrypted,
                scope=scope,
            )
            KeyValuePair.add_or_update(new_kvp_db)
    except:
        print("ERROR: Failed migrating datastore item with name: %s" % kvp.name)
        tb.print_exc()
        raise