Esempio n. 1
0
 def __init__(self, **kwargs):
     self.name = kwargs['name']
     self.metadata = dict(kwargs.get('metadata', {}))
     self.kind = kwargs.get('engine')
     self.resources = {}
     self.resource_types = {}
     self.relations = {}
     self.timestamp = int(time.time())
     self._reverse_map = None
     self._schema = utils.get_resource_schema(self.kind)
Esempio n. 2
0
 def __init__(self, **kwargs):
     self.name = kwargs['name']
     self.metadata = kwargs.get('metadata', {})
     self.kind = kwargs.get('engine')
     self.base_url = self.metadata['auth_url']
     self.user = self.metadata.get('user', None)
     self.password = self.metadata.get('password', None)
     self.queries = kwargs.get('queries', [])
     self.moment = kwargs.get('moment', None)
     self.start = kwargs.get('start', None)
     self.end = kwargs.get('end', None)
     self.step = kwargs.get('step', None)
     self.verify = False
     self._schema = utils.get_resource_schema(self.kind)
Esempio n. 3
0
 def get_schema(self):
     return utils.get_resource_schema(self.engine)
Esempio n. 4
0
def create_relations(relation_types):
    for relation_name, relation in relation_types.items():
        registry.add(
            type(relation_name, (ResourceRel, ), relation.get('model', {})))


def create_resources(resource_types):
    for resource_name, resource in resource_types.items():
        fields = {
            'uid': StringProperty(unique_index=True),
            'name': StringProperty(required=True),
            'kind': StringProperty(required=True),
            'status': StringProperty(default='Unknown'),
            'metadata': JSONProperty(),
        }
        for field_name, field in resource.get('model', {}).items():
            cls_name = field.pop("type")
            target_cls = field.pop('target')
            model_name = field.pop('model')
            field['model'] = registry.get_type(model_name)
            fields[field_name] = globals().get(utils.to_camel_case(cls_name))(
                target_cls, model_name, **field)
        registry.add(type(resource_name, (StructuredNode, ), fields))


salt_schema = utils.get_resource_schema('saltstack')

create_relations(salt_schema['relation'])
create_resources(salt_schema['resource'])