您可以利用命令行工具,通过如下脚本,查询已订阅的镜像市场镜像信息(镜像 ID 和镜像名称)。您可选择下载脚本或编辑脚本内容。
点击下载脚本:
querySubscribedImageId.zip
脚本内容如下:
- `#!/bin/bash
- tcount=`aliyuncli ecs DescribeImages --ImageOwnerAlias marketplace --output json --filter TotalCount`
- pageNum=1
- cat /dev/null >/tmp/imageids.txt
- while ((tcount>0))
- do
- aliyuncli ecs DescribeImages --ImageOwnerAlias marketplace --filter Images.Image[*].ImageId --PageSize 100 --PageNumber $pageNum --output json --filter Images.Image[*].ImageId | sed '1d' | sed '$d' | sed 's/,//g' | sed 's/"//g'| sed 's/ //g'>>/tmp/imageids.txt
- let pageNum++
- let tcount-=100
- done
- cat /tmp/imageids.txt | while read line
- do
- isSubscribed=`aliyuncli ecs DescribeImages --ImageOwnerAlias marketplace --ImageId $line --filter ImageIds.Image[*] --filter Images.Image[*].IsSubscribed --output json | sed '1d' | sed '$d' | sed 's/ //g'`
- if [[ $isSubscribed = "true" ]];then
- echo $line `aliyuncli ecs DescribeImages --ImageOwnerAlias marketplace --ImageId $line --filter ImageIds.Image[*] --filter Images.Image[*].ImageName --output json | sed '1d' | sed '$d' | sed 's/ //g'` >>imagesInfo.txt
- fi
- done
- native2ascii -encoding UTF-8 -reverse imagesInfo.txt imagesInfoCN.txt
- rm -rf imagesInfo.txt
- cat imagesInfoCN.txt`
编辑或下载脚本并赋权(chmod +x)后,您可以通过如下格式直接执行脚本,即会在脚本所在目录下生成包含已订阅镜像的信息文件 imagesInfoCN.txt。
用法示例:
- ./querySubscribedImageId.sh
输出示例:
- # ./querySubscribedImageId.sh
- m-23917oqoi "ASP/.NET 运行环境(Windows200864 位|IIS7.0)V1.0"
- m-23n2589vc "Java 运行环境(Centos64 位|OpenJDK1.7)V1.0"
- m-23u9mjjtk "PW 建站系统(Centos64 位)V1.0"