Exemplo n.º 1
0
def show_query(cloud_name, type_name, qry):
    data = []
    fields = list(model.get_model(type_name).get_schema().fields.keys())
    with model.Session() as session:
        for r in query.Query({type_name: [qry]}).search(session, cloud_name):
            data.append([str(getattr(r, f)) for f in fields])
    return fields, data
Exemplo n.º 2
0
 def test_simple_query2(self):
     q = query.Query({CLASS_FQN: [{
         'field1': ['b'],
         'field2': ['b'],
     }]})
     with model.Session() as session:
         objs = sorted(q.search(session), key=lambda x: x.object_id.id)
         self.assertEqual(1, len(objs))
         self.assertEqual(objs[0].object_id.id, 'id4')
Exemplo n.º 3
0
    def __init__(self, source, destination, objects, migration_flow_factories,
                 **kwargs):
        self.source = source
        self.destination = destination
        self.query = query.Query(objects)
        self.migration_flow_factories = {}

        # Migration logic can be extended through migration_flow_factories
        # migration parameter
        for factory_class in migration_flow_factories:
            migrated_class = factory_class.migrated_class
            self.migration_flow_factories[migrated_class] = factory_class
        super(Migration, self).__init__(objects=objects, **kwargs)
Exemplo n.º 4
0
    def __init__(self, source, destination, objects, migration_flow_factories,
                 overrides, **kwargs):
        self.source = source
        self.destination = destination
        self.query = query.Query(objects)
        self.migration_flow_factories = {}

        # Migration logic can be extended through migration_flow_factories
        # migration parameter
        for factory_class in migration_flow_factories:
            migrated_class = factory_class.migrated_class
            self.migration_flow_factories[migrated_class] = factory_class

        self.overrides = {
            model.get_model(k): v
            for k, v in list(overrides.items())
        }

        super(Migration, self).__init__(objects=objects, **kwargs)
Exemplo n.º 5
0
 def test_jmespath_query(self):
     q = query.Query({CLASS_FQN: ['[? field1 == `b` && field2 == `a` ]']})
     with model.Session() as session:
         objs = sorted(q.search(session), key=lambda x: x.object_id.id)
         self.assertEqual(1, len(objs))
         self.assertEqual(objs[0].object_id.id, 'id3')
Exemplo n.º 6
0
 def __init__(self, source, destination, objects):
     self.source = source
     self.destination = destination
     self.query = query.Query(objects)