[PATCH virt-what] Add Support for Alibaba X-Dragon Architecture
Richard W.M. Jones
rjones at redhat.com
Tue Jun 1 09:55:52 UTC 2021
On Tue, Jun 01, 2021 at 02:37:34PM +0800, Weisson wrote:
> Greetings, Sir!
>
> Cloud-init helps to judge current instances, thus I added some code to identify
> if the os is running on X-dragon architecture. But I'm not sure whether it is
> good to do that.
>
> Would you mind reviewing this patch? Looking forward to hearing from you.
You can send patches easier using git-email:
git send-email --to virt-tools-list at redhat.com HEAD^
This change does some "interesting" stuff with curl:
+ # Check for Alibaba Cloud X-Dragon Architecture
+ COMMAND=curl
+ which $COMMAND &>/dev/null;
+ if [ $? = 0 ]; then
+ ALIBABA_CLOUD=`curl --connect-timeout 2 -sSL http://100.100.100.200/latest/meta-datainstance/instance-type` &>/dev/null
+ if echo "$ALIBABA_CLOUD" | grep -q 'ebm'; then
+ echo "alibaba_cloud-x_dragon"
+ fi
+ fi
I'm guessing that 100.100.100.200 is some sort of cloud-init type of
metadata service?
Rather than adding a dependency on curl which may not be present, it
should be possible to test this directly from bash.
I haven't tested it, but something like this should work:
if { echo -e "GET /latest/meta-datainstance/instance-type HTTP/1.0\r\nHost: 100.100.100.200\r\n\r" >&3; grep -sq 'ebm' <&3 ; } 3<> /dev/tcp/100.100.100.200/80 ; then
echo "alibaba_cloud-x_dragon"
fi
I changed the output so it conforms to the standard for facts used by
virt-what, ie. data-subdata
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
libguestfs lets you edit virtual machines. Supports shell scripting,
bindings from many languages. http://libguestfs.org
More information about the virt-tools-list
mailing list