Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vqfx qcow #234

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions vqfx/Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
VENDOR=Juniper
NAME=vQFX
IMAGE_FORMAT=vmdk
IMAGE_GLOB=*.vmdk
IMAGE_FORMAT=qcow2
IMAGE_GLOB=*.qcow2

# match versions like:
# vqfx10k-re-15.1X53-D60.vmdk
VERSION=$(shell echo $(IMAGE) | sed -e 's/^vqfx10k-re-\([0-9][0-9]\.[0-9][A-Z][0-9]\+\(\.[0-9]\+\)\?\(-D[0-9]\+\)\)[^0-9].*$$/\1/')
# New vqfx are named: vqfx-19.4R1.10-re-qemu.qcow2
VERSION=$(shell echo $(IMAGE) | sed -e 's/^vqfx-//'|sed -e 's/-re-qemu.qcow2//' )

PFE_BASE_VERSION=$(shell echo $VERSION | sed -e s'/.*//')
PFE_IMAGE=$(shell ls vqfx-$(PFE_BASE_VERSION)*-pfe-qemu.qcow*)

-include ../makefile-sanity.include
-include ../makefile.include

# vqfx10k-pfe-20160609-2.vmdk
# TODO: we should make sure we only copy one PFE image (the latest?), in case there are many
docker-pre-build:
cp vqfx10k-pfe*.vmdk docker/
echo "pfe $(PFE_IMAGE)"
cp vqfx*-pfe*.qcow* docker/
echo "image $(IMAGE)"
echo "version $(VERSION)"

# mostly copied from makefile.include, i wish this was easier to change
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need to copy this. What is it that you want to change / inject? Turn whatever that is into a variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Kristian. I've changed jobs, so probably won't spend anymore time on this. Hope all is well.

docker-build-common: docker-clean-build docker-pre-build
@if [ -z "$$IMAGE" ]; then echo "ERROR: No IMAGE specified"; exit 1; fi
@if [ "$(IMAGE)" = "$(VERSION)" ]; then echo "ERROR: Incorrect version string ($(IMAGE)). The regexp for extracting version information is likely incorrect, check the regexp in the Makefile or open an issue at https://github.com/plajjan/vrnetlab/issues/new including the image file name you are using."; exit 1; fi
@echo "Building docker image using $(IMAGE) as $(REGISTRY)vr-$(VR_NAME):$(VERSION)"
cp ../common/* docker/
$(MAKE) IMAGE=$$IMAGE docker-build-image-copy
(cd docker; docker build --build-arg http_proxy=$(http_proxy) --build-arg https_proxy=$(https_proxy) --build-arg RE_IMAGE=$(IMAGE) --build-arg PFE_IMAGE=$(PFE_IMAGE) -t $(REGISTRY)vr-$(VR_NAME):$(VERSION) .)
20 changes: 14 additions & 6 deletions vqfx/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,24 @@ RUN apt-get update -qy \
&& apt-get install -y \
bridge-utils \
iproute2 \
python3-ipy \
python3 \
socat \
qemu-kvm \
&& rm -rf /var/lib/apt/lists/*

ARG IMAGE
COPY $IMAGE /
COPY *-pfe-* /
COPY *.py /
ARG RE_IMAGE
ARG PFE_IMAGE

COPY $RE_IMAGE /
COPY $PFE_IMAGE /

RUN echo $RE_IMAGE > /re_image
RUN echo $PFE_IMAGE > /pfe_image

COPY healthcheck.py /
COPY vrnetlab.py /
COPY launch.py /

EXPOSE 22 161/udp 830 5000 10000-10099
HEALTHCHECK CMD ["/healthcheck.py"]
ENTRYPOINT ["/launch_vqfx.py"]
ENTRYPOINT ["/launch.py"]
19 changes: 4 additions & 15 deletions vqfx/docker/launch_vqfx.py → vqfx/docker/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,8 @@
import datetime
import logging
import os
import random
import re
import signal
import subprocess
import sys
import telnetlib
import time

import IPy

import vrnetlab

Expand All @@ -37,10 +30,8 @@ def trace(self, message, *args, **kws):

class VQFX_vcp(vrnetlab.VM):
def __init__(self, username, password):
for e in os.listdir("/"):
if re.search("-re-.*.vmdk", e):
vrnetlab.run_command(["qemu-img", "create", "-b", "/" + e, "-f", "qcow", "/vcp.qcow2"])
super(VQFX_vcp, self).__init__(username, password, disk_image="/vcp.qcow2", ram=2048)
re_image_name = open('/re_image').read().strip()
super(VQFX_vcp, self).__init__(username, password, disk_image=re_image_name, ram=2048)
self.num_nics = 12


Expand Down Expand Up @@ -162,10 +153,8 @@ def wait_write(self, cmd, wait='#', timeout=None):

class VQFX_vpfe(vrnetlab.VM):
def __init__(self):
for e in os.listdir("/"):
if re.search("-pfe-.*.vmdk", e):
vrnetlab.run_command(["qemu-img", "create", "-b", "/" + e, "-f", "qcow", "/vpfe.qcow2"])
super(VQFX_vpfe, self).__init__(None, None, disk_image="/vpfe.qcow2", num=1, ram=2048)
pfe_image_name = open('/pfe_image').read().strip()
super(VQFX_vpfe, self).__init__(None, None, disk_image=pfe_image_name, num=1, ram=2048)
self.num_nics = 0


Expand Down