Skip to content
This repository has been archived by the owner on Dec 3, 2021. It is now read-only.

Commit

Permalink
Modified images to support a standard build process
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Oswalt <[email protected]>
  • Loading branch information
Mierdin committed Jul 24, 2019
1 parent 95c7ed0 commit dda2963
Show file tree
Hide file tree
Showing 18 changed files with 222 additions and 454 deletions.
9 changes: 9 additions & 0 deletions images/asterisk/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# SHELL=/bin/bash

TARGET_VERSION ?= latest

all: docker

docker:
docker build -t antidotelabs/asterisk:$(TARGET_VERSION) .
docker push antidotelabs/asterisk:$(TARGET_VERSION)
34 changes: 21 additions & 13 deletions images/container-vqfx/Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
# Copyright (c) 2018, Juniper Networks, Inc.
# All rights reserved.
# SHELL=/bin/bash

all: build
TARGET_VERSION ?= latest

build: src/cosim.tgz
./build.sh
all: docker

src/cosim.tgz:
cd vagrant && ./extract_pfe_files.sh ../src
docker:

run:
docker run -ti --rm --name vqfx --privileged antidote/vqfx:18.4R1.8
./download_packages.sh

run1:
docker run -ti --rm --name vqfx --privileged antidote/vqfx:18.1R1.9
TARGET_VERSION=$(TARGET_VERSION) ./build.sh

stop:
docker kill vqfx || true
# The below might be useful for building an image with snapshots.
# Currently leaving this commented out so that we can finish the rest of the pipeline without this added
# complexity, not to mention that some infrastructure improvements (both prod and selfmedicate) might mean
# we don't need to do the snapshot trick. However, if it proves necessary in the future, this does work,
# we just need to add the logic to copy the resulting disk file out and into its own container, so we don't
# create a monster image.
#
# docker kill vqfx-full || true
# docker rm vqfx-full || true
# sleep 5
# docker run -d --name vqfx-full -v $$(pwd):/cap --rm -p 2222:22 -p 4001:4000 -p 5001:5000 --privileged antidotelabs/vqfx-full:$(TARGET_VERSION)
# ./wait_for_live.sh
# docker exec vqfx-full /create_snapshot.expect

docker push antidotelabs/container-vqfx:$(TARGET_VERSION)
10 changes: 8 additions & 2 deletions images/container-vqfx/build.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
#!/bin/bash

target=antidotelabs/vqfx-full
target=antidotelabs/container-vqfx
ocpkg=$(ls junos-openconfig-*.tgz)

docker build -f src/Dockerfile -t container-vqfx src

for image in *.img; do
version=$(echo "${image%.*}" | cut -d- -f5)

# Originally, we got the tag from the Junos version. However, we are removing this now
# in favor of the Antidote-relevant tag.
#
# version=$(echo "${image%.*}" | cut -d- -f5)
version=$TARGET_VERSION

echo "Building container $target:$version ... "
docker build -f Dockerfile.junos --build-arg image=$image --build-arg ocpkg=$ocpkg -t $target:$version .
done
21 changes: 21 additions & 0 deletions images/container-vqfx/download_packages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

# This script uses the gsutil utility from Google Cloud
# to download files from the relevant bucket. See
# https://cloud.google.com/sdk/docs/ for instructions on installing
# the Google Cloud SDK, which includes this utility.

declare -a arr=(
"container-vqfx/junos-openconfig-0.0.0.10-1-signed.tgz"
"container-vqfx/cosim.tgz"
"container-vqfx/jinstall-vqfx-10-f-18.1R1.9.img"
)

for i in "${arr[@]}"
do
gsutil cp "gs://nrelabs-curriculum-base-images/$i" "./$i"
mv "$i" ./
done

rm -rf container-vqfx/
mv cosim.tgz src/
5 changes: 3 additions & 2 deletions images/container-vqfx/src/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ RUN rm -f /root/pecosim/*.tgz
FROM ubuntu:18.04

RUN export DEBIAN_FRONTEND=noninteractive \
&& apt-get update && apt-get install -y -q qemu-kvm qemu-utils dosfstools pwgen telnet \
&& apt-get update && apt-get install -y -q qemu-kvm qemu-utils dosfstools \
pwgen telnet screen socat expect vim tcl tclsh \
ca-certificates netbase libpcap0.8 \
tcpdump macchanger gettext-base net-tools ethtool\
file iproute2 docker.io \
Expand All @@ -19,7 +20,7 @@ RUN export DEBIAN_FRONTEND=noninteractive \
COPY --from=cosim /root/pecosim /root/pecosim

COPY create_config_drive.sh launch.sh \
create_apply_group.sh fix_network_order.sh /
create_apply_group.sh fix_network_order.sh create_snapshot.expect /

RUN chmod a+rx /*.sh

Expand Down
67 changes: 67 additions & 0 deletions images/container-vqfx/src/create_snapshot.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/expect -f
#
# This Expect script was generated by autoexpect on Mon Jul 22 07:12:58 2019
# Expect and autoexpect were both written by Don Libes, NIST.
#
# Note that autoexpect does not guarantee a working script. It
# necessarily has to guess about certain things. Two reasons a script
# might fail are:
#
# 1) timing - A surprising number of programs (rn, ksh, zsh, telnet,
# etc.) and devices discard or ignore keystrokes that arrive "too
# quickly" after prompts. If you find your new script hanging up at
# one spot, try adding a short sleep just before the previous send.
# Setting "force_conservative" to 1 (see below) makes Expect do this
# automatically - pausing briefly before sending each character. This
# pacifies every program I know of. The -c flag makes the script do
# this in the first place. The -C flag allows you to define a
# character to toggle this mode off and on.

set force_conservative 0 ;# set to 1 to force conservative mode even if
;# script wasn't run conservatively originally
if {$force_conservative} {
set send_slow {1 .1}
proc send {ignore arg} {
sleep .1
exp_send -s -- $arg
}
}

#
# 2) differing output - Some programs produce different output each time
# they run. The "date" command is an obvious example. Another is
# ftp, if it produces throughput statistics at the end of a file
# transfer. If this causes a problem, delete these patterns or replace
# them with wildcards. An alternative is to use the -p flag (for
# "prompt") which makes Expect only look for the last line of output
# (i.e., the prompt). The -P flag allows you to define a character to
# toggle this mode off and on.
#
# Read the man page for more info.
#
# -Don


set timeout -1
spawn telnet 127.0.0.1 4000
match_max 100000
expect -exact "Trying 127.0.0.1...\r
Connected to 127.0.0.1.\r
Escape character is '^\]'.\r
QEMU 2.11.1 monitor - type 'help' for more information\r
(qemu) "
send -- "stop\r"
expect -exact "stop\r
s\[K\[Dst\[K\[D\[Dsto\[K\[D\[D\[Dstop\[K\r
(qemu) \r
(qemu) "
send -- "savevm speedy\r"
expect -exact "savevm speedy\r
s\[K\[Dsa\[K\[D\[Dsav\[K\[D\[D\[Dsave\[K\[D\[D\[D\[Dsavev\[K\[D\[D\[D\[D\[Dsavevm\[K\[D\[D\[D\[D\[D\[Dsavevm \[K\[D\[D\[D\[D\[D\[D\[Dsavevm s\[K\[D\[D\[D\[D\[D\[D\[D\[Dsavevm sp\[K\[D\[D\[D\[D\[D\[D\[D\[D\[Dsavevm spe\[K\[D\[D\[D\[D\[D\[D\[D\[D\[D\[Dsavevm spee\[K\[D\[D\[D\[D\[D\[D\[D\[D\[D\[D\[Dsavevm speed\[K\[D\[D\[D\[D\[D\[D\[D\[D\[D\[D\[D\[Dsavevm speedy\[K\r
(qemu) \r
(qemu) "
send -- ""
expect -exact "^\]\r
telnet> "
send -- "quit\r"
expect eof
21 changes: 21 additions & 0 deletions images/container-vqfx/wait_for_live.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash


until sshpass -p antidotepassword ssh -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" -q antidote@localhost -p 2222 exit
do
echo "return is $?, waiting for 0"
sleep 5
done

echo "Device is Live"

while [[ $xeifs -eq 24 ]]
do
# Wait until PFE is active
xeifs=$((sshpass -p antidotepassword ssh -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" -q antidote@localhost -p 2222 show interfaces terse | grep xe-0 | wc -l))

echo "xeifs is $xeifs, waiting for 24"
sleep 1
done

echo "cosim is live"
9 changes: 9 additions & 0 deletions images/netbox/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# SHELL=/bin/bash

TARGET_VERSION ?= latest

all: docker

docker:
docker build -t antidotelabs/netbox:$(TARGET_VERSION) .
docker push antidotelabs/netbox:$(TARGET_VERSION)
8 changes: 0 additions & 8 deletions images/newvmx/Dockerfile

This file was deleted.

Loading

0 comments on commit dda2963

Please sign in to comment.