This topic describes how to use faascmd commands.

Prerequisites

The faascmd tool is configured. For more information, see Configure faascmd.

The following conditions are met before you use the authorization command:

  1. An Object Storage Service (OSS) bucket is created for FPGA as a Service (FaaS) to upload the originally compiled DCP file.
  2. A folder named compiling_logs is created in the bucket.

Background information

The description of the faascmd command syntax is as follows:

  • All commands and parameters provided by faascmd are case-sensitive.
  • In faascmd commands, extra spaces are not allowed among parameters, equal signs (=), and values.

This topic describes the following faascmd commands:

Authorize RAM users

You can run the faascmd auth command to authorize a RAM user to access your OSS buckets as an FaaS administrator.

The command format:
faascmd auth --bucket=<YourFaasOSSBucketName>
Sample codeAuthorize RAM users
Note If your Alibaba Cloud account has multiple RAM users, we recommend that you have the OSS bucket shared among the RAM users to prevent authorization policies from being repeatedly modified or overwritten.

View an authorization policy

You can run the faascmd list_policy command to check whether the specified OSS bucket is contained in the corresponding authorization policy (faasPolicy).

The command format:
faascmd list_policy
Sample codeView an authorization policy
Note You need to check whether your OSS bucket and the compiling_logs folder in the bucket are displayed in the policy information.

Delete an authorization policy

You can run the faascmd delete_policy command to delete an authorization policy (faasPolicy).

The command format:
faascmd delete_policy
Sample codeDelete an authorization policy
Note If your Alibaba Cloud account has multiple RAM users, we recommend that you perform this operation in the RAM console to avoid unexpected policy deletion.

View all objects in an OSS bucket

You can run the faascmd list_objects command to view all objects in an OSS bucket.

The command format:
faascmd list_objects
Sample codeView objects
Note You can combine this command with the grep command to filter files. Example: faascmd list_objects | grep "xxx".

Upload an originally compiled file

You can run the faascmd upload_object command to upload original files that are compiled on your local PC to a specified OSS bucket.

The command format:
faascmd upload_object --object=<NewFileNameInOSSBucket> --file= <YourFilePath>/<FileNameYouWantToUpload>           
Sample codeupload_object
Note
  • If the target file is stored in the current directory, you do not need to specify a path.
  • Locally compiled original files provided by Intel FPGA are in the .gbs format and those provided by Xilinx FPGA are compressed as packages in the .tar format after script processing.

Download an object from an OSS bucket

You can run the faascmd get_object command to download the specified object from an OSS bucket.

The command format:
faascmd get_object --object=<YourObjectName> --file=<YourLocalPath>/<YourFileName>
Sample codeget_object
Note If you do not specify a path, the object is downloaded to the current folder.

Create an FPGA image

You can run the faascmd create_image command to submit a request to create an FPGA image. If the request succeeds, fpga imageuuid is returned.

The command format:
faascmd create_image --object=<YourObjectName> 
--fpgatype=<intel/xilinx>  --encrypted=<true/false> 
--kmskey=<key/ If encrypted is set to true, this parameter is required. Otherwise, this parameter is optional.> 
--shell=<Shell Version/Required> --name=<name/Optional> 
--description=<description/Optional> --tags=<tags/Optional>
Sample codecreate_image

View FPGA images

You can run the faascmd list_images command to view information of all FPGA images that you created.

The command format:
faascmd list_images
Sample codelist_images
Note Each RAM user can have up to ten FPGA images.

Delete an FPGA image

You can run the faascmd delete_image command to delete an FPGA image.

The command format:
faascmd delete_image --imageuuid=<yourImageuuid>
Sample codedelete_image

Download an FPGA image

You can run the faascmd download_image command to submit a request to download an FPGA image.

The command format:
faascmd download_image  --instanceId=<YourInstanceId> 
--fpgauuid=<Yourfpgauuid> --fpgatype=<intel/xilinx> 
--imageuuid=<YourImageuuid> --imagetype=<afu> 
--shell=<YourImageShellVersion>
Sample code
faascmd download_image --instanceId=XXXXX --fpgauuid=XXXX --fpgatype=intel --imageuuid=XXXX

View the download status of an FPGA image

You can run the faascmd fpga_status command to view the status of the current FPGA board card or download progress of the FPGA image.

The command format:
faascmd fpga_status --fpgauuid=<Yourfpgauuid> --instanceId=<YourInstanceId>
Sample codefpga_status

Publish an FPGA image

You can run the faascmd publish_image command to submit a request to publish an FPGA image.

The command format:
faascmd publish_image --imageuuid=<YourImageuuid> --imageid=<YourFPGAImageid>
Note
  • imageuuid indicates the ID of the image that you want to publish to Alibaba Cloud Marketplace. You can run the faascmd list_images command to view this image ID.
  • imageid indicates the image ID of the current FPGA-based instance. You can go to the product page in the ECS console to view this image ID.

View information of an FPGA-based ECS instance

You can run the faascmd list_instances command to view basic information of an FPGA-based ECS instance, including the instance ID, FPGA board card information, and shell version.

The command format:
faascmd list_instances --instanceId=<YourInstanceId>
Sample codelist_instances