-
Notifications
You must be signed in to change notification settings - Fork 28
/
sonic-gns3a.sh
82 lines (73 loc) · 1.87 KB
/
sonic-gns3a.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
# This script creates a .gns3a SONiC appliance file
IMGFILE="sonic-vs.image"
RELEASE="latest"
usage() {
echo "`basename $0` [ -r <ReleaseNumber> ] -b <SONiC VS image: sonic-vs.image>"
echo "e.g.: `basename $0` -r 1.1 -b <store_path>/sonic-vs.image"
exit 0
}
while getopts "r:b:h" arg; do
case $arg in
h)
usage
;;
r)
RELEASE=$OPTARG
;;
b)
IMGFILE=$OPTARG
;;
esac
done
if [ ! -e ${IMGFILE} ]; then
echo "ERROR: ${IMGFILE} not found"
exit 2
fi
MD5SUMIMGFILE=`md5sum ${IMGFILE} | cut -f 1 -d " "`
LENIMGFILE=`stat -c %s ${IMGFILE}`
GNS3APPNAME="SONiC-${RELEASE}.gns3a"
NAMEIMGFILE=`basename $IMGFILE`
echo "
{
\"name\": \"SONiC\",
\"category\": \"router\",
\"description\": \"SONiC Virtual Switch/Router\",
\"vendor_name\": \"SONiC\",
\"vendor_url\": \"https://sonic-net.github.io/SONiC/\",
\"product_name\": \"SONiC\",
\"product_url\": \"https://sonic-net.github.io/SONiC/\",
\"registry_version\": 3,
\"status\": \"experimental\",
\"maintainer\": \"SONiC\",
\"maintainer_email\": \"[email protected]\",
\"usage\": \"Supports SONiC release: ${RELEASE}\",
\"first_port_name\": \"eth0\",
\"qemu\": {
\"adapter_type\": \"e1000\",
\"adapters\": 10,
\"ram\": 2048,
\"hda_disk_interface\": \"virtio\",
\"arch\": \"x86_64\",
\"console_type\": \"telnet\",
\"boot_priority\": \"d\",
\"kvm\": \"require\"
},
\"images\": [
{
\"filename\": \"${NAMEIMGFILE}\",
\"version\": \"${RELEASE}\",
\"md5sum\": \"${MD5SUMIMGFILE}\",
\"filesize\": ${LENIMGFILE}
}
],
\"versions\": [
{
\"name\": \"${RELEASE}\",
\"images\": {
\"hda_disk_image\": \"${NAMEIMGFILE}\"
}
}
]
}
" > ${GNS3APPNAME}