Esempio n. 1
0
    def metadata_add_asset_to_ipfs(self):
        metadata = load_mpe_service_metadata(self.args.metadata_file)
        asset_file_ipfs_hash_base58 = utils_ipfs.publish_file_in_ipfs(
            self._get_ipfs_client(), self.args.asset_file_path)

        metadata.add_asset(asset_file_ipfs_hash_base58, self.args.asset_type)
        metadata.save_pretty(self.args.metadata_file)
Esempio n. 2
0
    def metadata_add_asset_to_ipfs(self):
        metadata_file = self.args.metadata_file
        org_metadata = OrganizationMetadata.from_file(metadata_file)
        asset_file_ipfs_hash_base58 = utils_ipfs.publish_file_in_ipfs(
            self._get_ipfs_client(), self.args.asset_file_path)

        org_metadata.add_asset(asset_file_ipfs_hash_base58,
                               self.args.asset_type)
        org_metadata.save_pretty(self.args.metadata_file)
Esempio n. 3
0
    def update_metadata(self):
        metadata_file = self.args.metadata_file

        try:
            with open(metadata_file, 'r') as f:
                org_metadata = OrganizationMetadata.from_json(json.load(f))
        except Exception as e:
            print(
                "Organization metadata json file not found ,Please check --metadata-file path "
            )
            raise e
        # validate the metadata before updating

        org_id = self.args.org_id
        existing_registry_org_metadata = self._get_organization_metadata_from_registry(
            org_id)
        org_metadata.validate(existing_registry_org_metadata)

        # Check if Organization already exists
        found = self._getorganizationbyid(org_id)[0]
        if not found:
            raise Exception(
                "\nOrganization with id={} does not  exists!\n".format(org_id))

        ipfs_metatdata_uri = publish_file_in_ipfs(self._get_ipfs_client(),
                                                  metadata_file, False)
        params = [
            type_converter("bytes32")(org_id),
            hash_to_bytesuri(ipfs_metatdata_uri)
        ]
        self._printout(
            "Creating transaction to create organization name={} id={}\n".
            format(org_metadata.org_name, org_id))
        self.transact_contract_command("Registry",
                                       "changeOrganizationMetadataURI", params)
        self._printout("id:\n%s" % org_id)