예제 #1
0
    def new_class(self, account_id, credential, language, new_classes):

        new_cl = {}

        for klass in new_classes:
            yaml_str = dataclay_yaml_dump(klass)
            new_cl[klass.name] = yaml_str

        request = logicmodule_messages_pb2.NewClassRequest(
            accountID=Utils.get_msg_id(account_id),
            credential=Utils.get_credential(credential),
            language=language,
            newClasses=new_cl)
        lm_function = lambda request: self.lm_stub.newClass.future(
            request=request, metadata=self.metadata_call)
        response = self._call_logicmodule(request, lm_function)
        if response.excInfo.isException:
            raise DataClayException(response.excInfo.exceptionMessage)

        result = dict()

        for k, v in response.newClasses.items():
            result[k] = dataclay_yaml_load(v)

        return result
예제 #2
0
    def ds_new_version(self, session_id, object_id, metadata_info):

        logger.info("This new_version is called somewhere?")

        request = dataservice_messages_pb2.NewVersionRequest(
            sessionID=Utils.get_msg_options['session'](session_id),
            objectID=Utils.get_msg_options['object'](object_id),
            metadataInfo=dataclay_yaml_dump(metadata_info))

        try:
            response = self.ds_stub.newVersion(request)

        except RuntimeError as e:
            raise e

        if response.excInfo.isException:
            raise DataClayException(response.excInfo.exceptionMessage)

        result = dict()
        oid = Utils.get_id(response.objectID)

        for k, v in response.versionedIDs:
            result[Utils.get_id_from_uuid(k)] = Utils.get_id_from_uuid(v)

        t = (oid, result)

        return t
예제 #3
0
    def advise_event(self, new_event):

        request = logicmodule_messages_pb2.AdviseEventRequest(
            eventYaml=dataclay_yaml_dump(new_event))
        lm_function = lambda request: self.lm_stub.adviseEvent.future(
            request=request, metadata=self.metadata_call)
        response = self._call_logicmodule(request, lm_function)
        if response.isException:
            raise DataClayException(response.exceptionMessage)
예제 #4
0
    def register_event_listener_implementation(self, account_id, credential,
                                               new_event_listener):

        request = logicmodule_messages_pb2.RegisterECARequest(
            applicantAccountID=Utils.get_msg_id(account_id),
            credentials=Utils.get_credential(credential),
            eca=dataclay_yaml_dump(new_event_listener))
        lm_function = lambda request: self.lm_stub.registerECA.future(
            request=request, metadata=self.metadata_call)
        response = self._call_logicmodule(request, lm_function)
        if response.excInfo.isException:
            raise DataClayException(response.excInfo.exceptionMessage)
예제 #5
0
    def ds_consolidate_version(self, session_id, version_info):

        request = dataservice_messages_pb2.ConsolidateVersionRequest(
            sessionID=Utils.get_msg_options['session'](session_id),
            versionInfo=dataclay_yaml_dump(version_info))

        try:
            response = self.ds_stub.consolidateVersion(request)

        except RuntimeError as e:
            raise e

        if response.isException:
            raise DataClayException(response.exceptionMessage)
예제 #6
0
    def new_namespace(self, account_id, credential, namespace):

        yaml_dom = dataclay_yaml_dump(namespace)

        request = logicmodule_messages_pb2.NewNamespaceRequest(
            accountID=account_id,
            credential=Utils.get_credential(credential),
            newNamespaceYaml=yaml_dom)
        lm_function = lambda request: self.lm_stub.newNamespace.future(
            request=request, metadata=self.metadata_call)
        response = self._call_logicmodule(request, lm_function)
        if response.excInfo.isException:
            raise DataClayException(response.excInfo.exceptionMessage)

        return Utils.get_id(response.namespaceID)
예제 #7
0
    def new_account(self, admin_account_id, admin_credential, account):

        acc_yaml = dataclay_yaml_dump(account)

        request = logicmodule_messages_pb2.NewAccountRequest(
            adminID=Utils.get_msg_id(admin_account_id),
            admincredential=Utils.get_credential(admin_credential),
            yamlNewAccount=acc_yaml)
        lm_function = lambda request: self.lm_stub.newAccount.future(
            request=request, metadata=self.metadata_call)
        response = self._call_logicmodule(request, lm_function)
        if response.excInfo.isException:
            raise DataClayException(response.excInfo.exceptionMessage)

        return Utils.get_id(response.newAccountID)
예제 #8
0
    def ds_deploy_metaclasses(self, namespace_name, deployment_pack):
        deployment_pack_dict = dict()

        for k, v in deployment_pack.items():
            deployment_pack_dict[k] = dataclay_yaml_dump(v)

        request = dataservice_messages_pb2.DeployMetaClassesRequest(
            namespace=namespace_name, deploymentPack=deployment_pack_dict)

        try:
            response = self.ds_stub.deployMetaClasses(request)

        except RuntimeError as e:
            raise e

        if response.isException:
            raise DataClayException(response.exceptionMessage)
예제 #9
0
    def ds_new_metadata(self, md_infos):

        md_infos_dict = dict()

        for k, v in md_infos.items():

            md_infos_dict[k] = dataclay_yaml_dump(v)

        request = dataservice_messages_pb2.NewMetaDataRequest(
            mdInfos=md_infos_dict)

        try:
            response = self.ds_stub.newMetaData(request)

        except RuntimeError as e:
            raise e

        if response.isException:
            raise DataClayException(response.exceptionMessage)
예제 #10
0
    def ds_migrate_objects_to_backends(self, back_ends):

        back_ends_dict = dict()

        for k, v in back_ends.items():
            back_ends_dict[k] = dataclay_yaml_dump(v)

        request = dataservice_messages_pb2.MigrateObjectsRequest(
            destStorageLocs=back_ends_dict)

        try:
            response = self.ds_stub.migrateObjectsToBackends(request)

        except RuntimeError as e:
            raise e

        if response.excInfo.isException:
            raise DataClayException(response.excInfo.exceptionMessage)

        result = dict()

        for k, v in response.migratedObjs.items():
            m_objs = v
            oids = set()

            for oid in m_objs.getObjsList():
                oids.add(Utils.get_id(oid))

            result[Utils.get_id_from_uuid(k)] = oids

        non_migrated = set()

        for oid in response.nonMigratedObjs.getObjsList():
            non_migrated.add(Utils.get_id(oid))

        t = (result, non_migrated)

        return t