Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
virl-utils-hs-fulda
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sebastian Rieger
virl-utils-hs-fulda
Commits
0ce1c65f
Commit
0ce1c65f
authored
9 years ago
by
Sebastian Rieger
Browse files
Options
Downloads
Patches
Plain Diff
first commit
parents
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
create-arista-veos-image.sh
+103
-0
103 additions, 0 deletions
create-arista-veos-image.sh
with
103 additions
and
0 deletions
create-arista-veos-image.sh
0 → 100644
+
103
−
0
View file @
0ce1c65f
#!/bin/bash
# usage
if
[
!
$#
-eq
3
]
;
then
echo
-e
"usage:
$0
<Aboot-veos-serial-version.iso> <vEOS-version.vmdk> <new glance image name>, e.g.:
\n
"
echo
"
$0
Aboot-veos-serial-2.0.8.iso vEOS-4.13.4F.vmdk vEOS"
exit
-1
fi
# sudo check
if
[
!
$UID
-eq
0
]
;
then
echo
"Insufficient privileges. Please consider using sudo."
exit
-1
fi
ABOOT_SERIAL_ISO
=
$1
ABOOT_SERIAL_ISO_BASENAME
=
$(
basename
-s
.iso
$1
)
VEOS_VMDK
=
$2
VEOS_VMDK_BASENAME
=
$(
basename
-s
.vmdk
$2
)
GLANCE_IMAGE_NAME
=
$3
GLANCE_IMAGE_RELEASE
=
$VEOS_VMDK_BASENAME
-
$ABOOT_SERIAL_ISO_BASENAME
TMP_NAME
=
"vEOS-
$GLANCE_IMAGE_RELEASE
"
echo
"Creating vEOS image..."
echo
"==========================================================="
# create a copy of Aboot bootloader and extend it to 3G
cp
$1
$TMP_NAME
.raw
truncate
-s
+3G
$TMP_NAME
.raw
echo
"Extracting partitions from vEOS vmdk..."
echo
"==========================================================="
# convert vmdk to raw and extract two partitions in it
qemu-img convert
-O
raw
$2
$VEOS_VMDK_BASENAME
.raw
kpartx
-av
$VEOS_VMDK_BASENAME
.raw
dd
if
=
/dev/loop0p1
of
=
$VEOS_VMDK_BASENAME
-p1
.raw
dd
if
=
/dev/loop0p2
of
=
$VEOS_VMDK_BASENAME
-p2
.raw
kpartx
-d
$VEOS_VMDK_BASENAME
.raw
echo
"Injecting new partitions from vEOS vmdk in Aboot image..."
echo
"==========================================================="
# calulate size of the two partitions
PART1_START
=
$(
fdisk
-l
$VEOS_VMDK_BASENAME
.raw |
grep
"
\.
raw1"
|
tr
-s
" "
|
cut
-d
' '
-f
3
)
PART1_END
=
$(
fdisk
-l
$VEOS_VMDK_BASENAME
.raw |
grep
"
\.
raw1"
|
tr
-s
" "
|
cut
-d
' '
-f
4
)
PART1_LENGTH
=
$(
expr
$PART1_END
-
$PART1_START
)
PART2_START
=
$(
fdisk
-l
$VEOS_VMDK_BASENAME
.raw |
grep
"
\.
raw2"
|
tr
-s
" "
|
cut
-d
' '
-f
2
)
PART2_END
=
$(
fdisk
-l
$VEOS_VMDK_BASENAME
.raw |
grep
"
\.
raw2"
|
tr
-s
" "
|
cut
-d
' '
-f
3
)
PART2_LENGTH
=
$(
expr
$PART2_END
-
$PART2_START
)
# append the two partitions from vmdk in the bootloader iso
echo
-e
"n
p
+
$PART1_LENGTH
t
2
c
a
2
n
p
+
$PART2_LENGTH
t
3
12
w"
| fdisk
$TMP_NAME
.raw
>
/dev/null
# copy the partitions from vEOS vmdk to new image
kpartx
-av
$TMP_NAME
.raw
dd
if
=
$VEOS_VMDK_BASENAME
-p1
.raw
of
=
/dev/loop0p2
dd
if
=
$VEOS_VMDK_BASENAME
-p2
.raw
of
=
/dev/loop0p3
kpartx
-d
$TMP_NAME
.raw
echo
"Convert new image to qcow2..."
echo
"==========================================================="
# convert raw to qcow2
qemu-img convert
-O
qcow2
$TMP_NAME
.raw
$TMP_NAME
.qcow2
echo
"Cleaning up..."
echo
"==========================================================="
#cleanup
rm
$TMP_NAME
.raw
rm
$VEOS_VMDK_BASENAME
-p1
.raw
rm
$VEOS_VMDK_BASENAME
-p2
.raw
rm
$VEOS_VMDK_BASENAME
.raw
echo
"Importing image into glance..."
echo
"==========================================================="
glance image-create
--container-format
bare
--disk-format
qcow2
--is-public
true
--name
$GLANCE_IMAGE_NAME
--file
$TMP_NAME
.qcow2
--property
hw_disk_bus
=
ide
--property
serial
=
1
--property
hw_vif_model
=
e1000
--property
hw_cdrom_type
=
ide
--property
release
=
"
$GLANCE_IMAGE_RELEASE
"
--property
subtype
=
IOSv
--property
config_disk_type
=
cdrom
#testing:
#
# nova boot --image "Arista vEOS Disk" --flavor m1.small veos --nic net-id=abc7ad47-55fd-4396-8d31-91dd4d41a18a --nic net-id=abc7ad47-55fd-4396-8d31-91dd4d41a18a --nic net-id=abc7ad47-55fd-4396-8d31-91dd4d41a18a --nic net-id=abc7ad47-55fd-4396-8d31-91dd4d41a18a --nic net-id=abc7ad47-55fd-4396-8d31-91dd4d41a18a
#
# using VM Maestro, the image can be chosen as "VM image", e.g., for an IOSv or IOSvL2 node
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment