阿里云FPGA云服务器(FaaS) Python SDK正式发布啦!

安装

pip install aliyun-python-sdk-faas
  • 说明

    1. 在使用Python SDK前,需要在aliyun-python-sdk-core里增加一个endpoint,具体为:/usr/local/lib/python2.7/site-packages/aliyunsdkcore/endpoints.xml的648行,增加如下语句

      `
      <Product><ProductName>faas</ProductName><DomainName>faas.cn-hangzhou.aliyuncs.com</DomainName></Product>
      `
      

## 卸载

pip uninstall aliyun-python-sdk-faas

## 创建镜像

from aliyunsdkcore import client
clt = client.AcsClient(<用户AK>,<用户AS>,'cn-hangzhou')
from aliyunsdkfaas.request.v20170824 import CreateFpgaImageTaskRequest
request = CreateFpgaImageTaskRequest.CreateFpgaImageTaskRequest()
request.set_Bucket(<DCP/bitstream所在的OSS bucket>)
request.set_Object(<DCP/bitstream在OSS中的object name>)
request.set_FpgaType(<Fpga类型>)
request.set_ShellUUID(<shell类型>)
request.set_Name(<给镜像取个方便记的名字>)
request.set_RoleArn(<给faas-admin帐号创建的角色>)
request.set_Encrypted(<是否加密,True/False>)
request.set_KeyId(<如果加密,指定KMS中key的ID>)
result = clt.do_action_with_exception(request)
print result

## 删除镜像

from aliyunsdkcore import client
clt = client.AcsClient(<用户AK>,<用户AS>,'cn-hangzhou')
from aliyunsdkfaas.request.v20170824 import DeleteFpgaImageRequest
request = DeleteFpgaImageRequest.DeleteFpgaImageRequest()
request.set_FpgaImageUUID(<需要删除的镜像UUID>)
result = clt.do_action_with_exception(request)
print result

## 查看镜像

from aliyunsdkcore import client
clt = client.AcsClient(<用户AK>,<用户AS>,'cn-hangzhou')
from aliyunsdkfaas.request.v20170824 import DescribeFpgaImagesRequest
request = DescribeFpgaImagesRequest.DescribeFpgaImagesRequest()
result = clt.do_action_with_exception(request)
print result

## 查看实例

from aliyunsdkcore import client
clt = client.AcsClient(<用户AK>,<用户AS>,'cn-hangzhou')
from aliyunsdkfaas.request.v20170824 import DescribeFpgaInstancesRequest
request = DescribeFpgaInstancesRequest.DescribeFpgaInstancesRequest()
request.set_InstanceId(<指定实例名>)
request.set_RoleArn(<给faas-admin帐号创建的角色>)
result = clt.do_action_with_exception(request)
print result

## 下载镜像

from aliyunsdkcore import client
clt = client.AcsClient(<用户AK>,<用户AS>,'cn-hangzhou')
from aliyunsdkfaas.request.v20170824 import LoadFpgaImageTaskRequest
request = LoadFpgaImageTaskRequest.LoadFpgaImageTaskRequest()
request.set_InstanceId(<指定实例名>)
request.set_FpgaUUID(<需要操作的FPGA>)
request.set_FpgaType(<Fpga类型>)
request.set_FpgaImageUUID(<需要下载的镜像UUID>)
request.set_FpgaImageType(<镜像类型>)
request.set_ShellUUID(<指定shell>)
request.set_RoleArn(<给faas-admin帐号创建的角色>)
result = clt.do_action_with_exception(request)
print result

## 查看下载结果

from aliyunsdkcore import client
clt = client.AcsClient(<用户AK>,<用户AS>,'cn-hangzhou')
from aliyunsdkfaas.request.v20170824 import DescribeLoadTaskStatusRequest
request = DescribeLoadTaskStatusRequest.DescribeLoadTaskStatusRequest()
request.set_FpgaUUID(<需要操作的FPGA>)
request.set_InstanceId(<指定实例名>)
request.set_RoleArn(<给faas-admin帐号创建的角色>)
result = clt.do_action_with_exception(request)
print result

##发布自己FPGA镜像到阿里云镜像市场

from aliyunsdkcore import client
clt = client.AcsClient(<用户AK>,<用户AS>,'cn-hangzhou')
from aliyunsdkfaas.request.v20170824 import PublishFpgaImageRequest
request = PublishFpgaImageRequest.PublishFpgaImageRequest()
request.set_FpgaImageUUID(<需要发布的镜像UUID>)
request.set_ImageID(<在云市场发布的ECS镜像ID>)
result = clt.do_action_with_exception(request)
print result
上一篇:Ctrl + z 和 Linux jobs


下一篇:【对讲机的那点事】了解这四点,就知道如何合法合理的使用对讲机