Esempio n. 1
0
def init(internal_services, enable_security):

    if enable_security:
        icom = get_instance_from_services(internal_services, 'irods')
        graph = get_instance_from_services(internal_services, 'neo4j')

        users = graph.User.nodes.all()

        # Only available one user, the default one?
        if len(users) == 1:
            userobj = users.pop()
            associated = userobj.associated.all()

            # Link default user to default irods users
            if len(associated) < 2:
                irodsusers = graph.IrodsUser.get_or_create(
                    {'username': icom.get_current_user(),
                        'default_user': False},
                    {'username': icom.get_default_user(),
                        'default_user': True},
                )
                for irodsuser in irodsusers:
                    if irodsuser not in associated:
                        userobj.associated.connect(irodsuser)

            logger.info("Mixed irods and graph users")
    else:
        pass
Esempio n. 2
0
    def global_get_service(self,
                           service_name, object_name='services', **kwargs):

        from commons.services import get_instance_from_services
        return get_instance_from_services(
            self.global_get(object_name),   # services
            service_name,
            **kwargs)
Esempio n. 3
0
 def get_service(service_name):
     from commons.globals import mem
     from commons.services import get_instance_from_services
     return get_instance_from_services(mem.services, service_name)