f-55: lab: fichiers des nœuds sur un ISO dédié, envoi des binaires compilés en local #55
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
f713f482fa
commit
aceffe7b58
16 changed files with 181 additions and 58 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -33,3 +33,7 @@ data/
|
|||
|
||||
# Sphinx build output
|
||||
docs/_build/
|
||||
|
||||
# Binaires compilés en local pour le lab (test/e2e/build.sh)
|
||||
test/e2e/topologies/bin/*
|
||||
!test/e2e/topologies/bin/.gitkeep
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package main
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
|
|
@ -10,8 +9,6 @@ import (
|
|||
"strings"
|
||||
"syscall"
|
||||
"testing"
|
||||
|
||||
"go.yaml.in/yaml/v3"
|
||||
)
|
||||
|
||||
func runLab(args ...string) (int, string, string) {
|
||||
|
|
@ -336,25 +333,14 @@ func TestRun_RenderShipsTheExampleFRRConfigs(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var cfg struct {
|
||||
Files []struct {
|
||||
Path string `yaml:"path"`
|
||||
Content string `yaml:"content"`
|
||||
} `yaml:"write_files"`
|
||||
if !strings.Contains(string(data), "mount -o ro LABEL=LABFILES /run/lab-files") {
|
||||
t.Errorf("%s user-data does not mount its files", node)
|
||||
}
|
||||
if err := yaml.Unmarshal(data, &cfg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var agent []byte
|
||||
for _, f := range cfg.Files {
|
||||
if f.Path == "/etc/lab/files/agent.yml" {
|
||||
if agent, err = base64.StdEncoding.DecodeString(f.Content); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
if !strings.Contains(string(agent), "route_reflectors: [10.255.255.1]") {
|
||||
t.Errorf("%s agent.yml = %q", node, agent)
|
||||
}
|
||||
for _, agent := range []string{"two.yml", "bgp.yml"} {
|
||||
data, err := os.ReadFile(filepath.Join("..", "..", "test", "e2e", "topologies", "agent", agent))
|
||||
if err != nil || !strings.Contains(string(data), "route_reflectors: [10.255.255.1]") {
|
||||
t.Errorf("agent/%s = %q, %v", agent, data, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -250,8 +250,11 @@ Ce que le fichier déclare :
|
|||
* ``provision`` — le chemin d'un script, relatif au fichier de topologie, exécuté au premier
|
||||
démarrage **avant** FRR ;
|
||||
* ``post_provision`` — un second script, exécuté **après** FRR ;
|
||||
* ``files`` — des fichiers déposés dans ``/etc/lab/files/<nom>`` avant les scripts, sous la
|
||||
forme ``{<nom>: <chemin>}`` (``files: {agent.yml: agent/two.yml}``) ;
|
||||
* ``files`` — des fichiers **ou répertoires** déposés dans ``/etc/lab/files/<nom>`` avant les
|
||||
scripts, sous la forme ``{<nom>: <chemin>}`` (``files: {agent.yml: agent/two.yml, bin: bin}``).
|
||||
Ils voyagent dans un ``files.iso`` propre au nœud (volume ``LABFILES``), attaché comme second
|
||||
lecteur et recopié au premier démarrage : la taille n'est pas limitée par cloud-init, et un
|
||||
binaire de plusieurs dizaines de Mio passe ;
|
||||
* ``services`` — les unités systemd que ``lab up`` vérifie actives sur le nœud.
|
||||
|
||||
Les scripts reçoivent ``LAB_NODE`` (nom du nœud), ``LAB_UPLINK`` (interface de son premier
|
||||
|
|
@ -387,6 +390,20 @@ réponde, à travers le switch. Les deux fichiers ``agent/`` donnent à l'agent
|
|||
``agent/two.yml`` met en plus hv1 sur le serveur DHCP intégré (``dhcp.backend: two``),
|
||||
``agent/bgp.yml`` laisse les autres sur dnsmasq.
|
||||
|
||||
**Tester l'arbre courant plutôt que la release.** ``test/e2e/build.sh`` compile ``agent``,
|
||||
``dhcp`` et ``metadata`` pour linux/amd64 dans ``test/e2e/topologies/bin/`` (ignoré par git),
|
||||
que les hyperviseurs reçoivent par ``files: {bin: bin}``. Après ``deploy.sh``,
|
||||
``hypervisor.sh`` installe chaque binaire présent dans ``/opt/two/local/bin/`` et y fait pointer
|
||||
``/opt/two/bin/<nom>`` ; le reste (units, scripts) vient de la release. ``build.sh --clean`` vide
|
||||
le répertoire : le lab suivant teste la release seule.
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
test/e2e/build.sh # binaires de l'arbre courant
|
||||
scripts/lab-host.sh push test/e2e/topologies/evpn-3hv.yml
|
||||
scripts/lab-host.sh ssh './lab up topology/evpn-3hv.yml'
|
||||
test/e2e/build.sh --clean # retour à la release seule
|
||||
|
||||
FRR est installé **après** la provision : il démarre sur le réseau final. Démarré
|
||||
avant la migration, zebra peut perdre la route par défaut quand elle passe de l'uplink à
|
||||
``br-000000`` — constaté le 2026-10-11 sur un hyperviseur sur deux : route reflector
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import (
|
|||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"git.g3e.fr/syonad/two/internal/lab/render"
|
||||
|
|
@ -99,17 +100,11 @@ func ReadInputs(p *topology.Plan, o *render.Options) error {
|
|||
if o.PostProvision, err = readNodeFiles(p, func(n topology.NodePlan) string { return n.PostProvision }); err != nil {
|
||||
return err
|
||||
}
|
||||
o.Files = map[string]map[string][]byte{}
|
||||
for _, n := range p.Nodes {
|
||||
for name, src := range n.Files {
|
||||
data, err := os.ReadFile(src)
|
||||
if err != nil {
|
||||
if _, err := os.Stat(src); err != nil {
|
||||
return fmt.Errorf("node %s: file %s: %w", n.Name, name, err)
|
||||
}
|
||||
if o.Files[n.Name] == nil {
|
||||
o.Files[n.Name] = map[string][]byte{}
|
||||
}
|
||||
o.Files[n.Name][name] = data
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
@ -184,6 +179,21 @@ func Stage(ctx context.Context, r Runner, n render.Node, base string) error {
|
|||
for _, f := range SeedFiles {
|
||||
args = append(args, filepath.Join(n.Dir, f))
|
||||
}
|
||||
if err := r.Run(ctx, "genisoimage", args...); err != nil {
|
||||
return err
|
||||
}
|
||||
if len(n.Files) == 0 {
|
||||
return nil
|
||||
}
|
||||
names := make([]string, 0, len(n.Files))
|
||||
for name := range n.Files {
|
||||
names = append(names, name)
|
||||
}
|
||||
sort.Strings(names)
|
||||
args = []string{"-quiet", "-output", filepath.Join(n.Dir, render.FilesISO), "-volid", render.FilesLabel, "-joliet", "-rock", "-graft-points"}
|
||||
for _, name := range names {
|
||||
args = append(args, name+"="+n.Files[name])
|
||||
}
|
||||
return r.Run(ctx, "genisoimage", args...)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -280,6 +280,31 @@ func TestEnsureKey_ReportsAFailedGeneration(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestStage_BurnsTheNodeFilesIntoTheirOwnISO(t *testing.T) {
|
||||
runner := &fakeRunner{}
|
||||
dir := t.TempDir()
|
||||
n := render.Node{Name: "hv1", Dir: dir, Files: map[string]string{"bin": "/src/bin", "agent.yml": "/src/two.yml"}}
|
||||
if err := Stage(context.Background(), runner, n, "/cache/deb.qcow2"); err != nil {
|
||||
t.Fatalf("Stage: %v", err)
|
||||
}
|
||||
isos := runner.commands("genisoimage")
|
||||
want := []string{"genisoimage", "-quiet", "-output", filepath.Join(dir, "files.iso"), "-volid", "LABFILES", "-joliet", "-rock", "-graft-points",
|
||||
"agent.yml=/src/two.yml", "bin=/src/bin"}
|
||||
if len(isos) != 2 || !reflect.DeepEqual(isos[1], want) {
|
||||
t.Errorf("genisoimage calls:\n%q\nwant second:\n%q", isos, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestStage_NoFilesNoFilesISO(t *testing.T) {
|
||||
runner := &fakeRunner{}
|
||||
if err := Stage(context.Background(), runner, render.Node{Name: "rr1", Dir: t.TempDir()}, "/cache/deb.qcow2"); err != nil {
|
||||
t.Fatalf("Stage: %v", err)
|
||||
}
|
||||
if n := len(runner.commands("genisoimage")); n != 1 {
|
||||
t.Errorf("genisoimage ran %d times, want only the seed", n)
|
||||
}
|
||||
}
|
||||
|
||||
func TestStage_RefusesARelativeBaseImage(t *testing.T) {
|
||||
runner := &fakeRunner{}
|
||||
err := Stage(context.Background(), runner, render.Node{Name: "hv1", Dir: t.TempDir()}, "debian.qcow2")
|
||||
|
|
@ -387,7 +412,7 @@ func TestPrepare_PutsTheFRRConfigIntoTheSeed(t *testing.T) {
|
|||
t.Errorf("hv1 user-data has no /etc/lab/frr.conf:\n%s", data)
|
||||
}
|
||||
|
||||
func TestReadInputs_ReadsTheProvisionScriptsAndFiles(t *testing.T) {
|
||||
func TestReadInputs_ReadsTheScriptsAndChecksTheFiles(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
write := func(name, content string) string {
|
||||
path := filepath.Join(dir, name)
|
||||
|
|
@ -402,6 +427,11 @@ func TestReadInputs_ReadsTheProvisionScriptsAndFiles(t *testing.T) {
|
|||
p.Nodes[2].PostProvision = write("hv-post.sh", "#!/bin/sh\necho post\n")
|
||||
p.Nodes[2].Files = map[string]string{"agent.yml": write("two.yml", "dhcp:\n backend: two\n")}
|
||||
|
||||
if err := os.Mkdir(filepath.Join(dir, "bin"), 0o700); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
p.Nodes[2].Files["bin"] = filepath.Join(dir, "bin")
|
||||
|
||||
var o render.Options
|
||||
if err := ReadInputs(p, &o); err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
@ -412,9 +442,6 @@ func TestReadInputs_ReadsTheProvisionScriptsAndFiles(t *testing.T) {
|
|||
if !reflect.DeepEqual(o.PostProvision, map[string]string{"hv1": "#!/bin/sh\necho post\n"}) {
|
||||
t.Errorf("post_provision = %q", o.PostProvision)
|
||||
}
|
||||
if !reflect.DeepEqual(o.Files, map[string]map[string][]byte{"hv1": {"agent.yml": []byte("dhcp:\n backend: two\n")}}) {
|
||||
t.Errorf("files = %q", o.Files)
|
||||
}
|
||||
|
||||
p.Nodes[3].Files = map[string]string{"agent.yml": filepath.Join(dir, "absent.yml")}
|
||||
if err := ReadInputs(p, &render.Options{}); err == nil || !strings.Contains(err.Error(), "node hv2: file agent.yml: ") {
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@ func qemuArgs(p *topology.Plan, n topology.NodePlan, index int, dir string) []st
|
|||
"-drive", "file=" + filepath.Join(dir, DiskFile) + ",if=virtio,format=qcow2",
|
||||
"-drive", "file=" + filepath.Join(dir, SeedFile) + ",media=cdrom,readonly=on",
|
||||
}
|
||||
if len(n.Files) > 0 {
|
||||
args = append(args, "-drive", "file="+filepath.Join(dir, FilesISO)+",media=cdrom,readonly=on")
|
||||
}
|
||||
|
||||
restrict := "on"
|
||||
if n.Role == topology.RoleSwitch {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ const (
|
|||
|
||||
DiskFile = "disk.qcow2"
|
||||
SeedFile = "seed.iso"
|
||||
FilesISO = "files.iso"
|
||||
FilesLabel = "LABFILES"
|
||||
ConsoleFile = "console.log"
|
||||
QMPFile = "qmp.sock"
|
||||
PIDFile = "qemu.pid"
|
||||
|
|
@ -33,12 +35,12 @@ type Options struct {
|
|||
FRR map[string]string
|
||||
Provision map[string]string
|
||||
PostProvision map[string]string
|
||||
Files map[string]map[string][]byte
|
||||
}
|
||||
|
||||
type Node struct {
|
||||
Name string
|
||||
Dir string
|
||||
Files map[string]string
|
||||
QEMU []string
|
||||
MetaData []byte
|
||||
UserData []byte
|
||||
|
|
@ -59,11 +61,6 @@ func Render(p *topology.Plan, o Options) ([]Node, error) {
|
|||
if _, ok := o.PostProvision[n.Name]; n.PostProvision != "" && !ok {
|
||||
return nil, fmt.Errorf("node %s: post_provision script %s was not read", n.Name, n.PostProvision)
|
||||
}
|
||||
for name, src := range n.Files {
|
||||
if _, ok := o.Files[n.Name][name]; !ok {
|
||||
return nil, fmt.Errorf("node %s: file %s (%s) was not read", n.Name, name, src)
|
||||
}
|
||||
}
|
||||
}
|
||||
var nodes []Node
|
||||
for index, n := range p.Nodes {
|
||||
|
|
@ -83,6 +80,7 @@ func Render(p *topology.Plan, o Options) ([]Node, error) {
|
|||
nodes = append(nodes, Node{
|
||||
Name: n.Name,
|
||||
Dir: dir,
|
||||
Files: n.Files,
|
||||
QEMU: qemuArgs(p, n, index, dir),
|
||||
MetaData: meta,
|
||||
UserData: user,
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ func roleOptions() Options {
|
|||
FRR: frrConfigs,
|
||||
Provision: map[string]string{"hv1": "#!/bin/sh\necho provision\n"},
|
||||
PostProvision: map[string]string{"hv1": "#!/bin/sh\necho post\n"},
|
||||
Files: map[string]map[string][]byte{"hv1": {"agent.yml": []byte("dhcp:\n backend: two\n")}},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -155,9 +154,10 @@ func TestRoles_FRRKeyIsThePinnedRepositoryKey(t *testing.T) {
|
|||
func TestRoles_ProvisioningIsOneScriptThatStopsAtTheFirstFailure(t *testing.T) {
|
||||
nodes := renderRoles(t)
|
||||
env := "LAB_NODE=hv1 LAB_UPLINK=underlay LAB_FILES=/etc/lab/files "
|
||||
files := "mkdir -p /etc/lab/files /run/lab-files\nmount -o ro LABEL=LABFILES /run/lab-files\ncp -R /run/lab-files/. /etc/lab/files/\numount /run/lab-files\n"
|
||||
for name, steps := range map[string]string{
|
||||
"sw1": "systemctl daemon-reload\nsystemctl enable --now lab-switch.service\n/usr/local/sbin/lab-frr\n",
|
||||
"hv1": env + "/usr/local/sbin/lab-node-provision\n/usr/local/sbin/lab-frr\n" + env + "/usr/local/sbin/lab-node-post-provision\n",
|
||||
"hv1": files + env + "/usr/local/sbin/lab-node-provision\n/usr/local/sbin/lab-frr\n" + env + "/usr/local/sbin/lab-node-post-provision\n",
|
||||
} {
|
||||
cfg := user(t, nodeNamed(t, nodes, name))
|
||||
if !reflect.DeepEqual(cfg.Runcmd, [][]string{{"/usr/local/sbin/lab-provision"}}) {
|
||||
|
|
@ -173,7 +173,29 @@ func TestRoles_ProvisioningIsOneScriptThatStopsAtTheFirstFailure(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestRoles_HostReceivesItsScriptsAndFiles(t *testing.T) {
|
||||
func TestRoles_FilesTravelOnASecondCDROM(t *testing.T) {
|
||||
nodes := renderRoles(t)
|
||||
hv1 := nodeNamed(t, nodes, "hv1")
|
||||
if !reflect.DeepEqual(hv1.Files, map[string]string{"agent.yml": "two.yml"}) {
|
||||
t.Errorf("hv1 files = %v", hv1.Files)
|
||||
}
|
||||
drive := "file=/srv/lab/hv1/files.iso,media=cdrom,readonly=on"
|
||||
if !strings.Contains(strings.Join(hv1.QEMU, " "), "-drive "+drive) {
|
||||
t.Errorf("hv1 qemu lacks %s:\n%s", drive, strings.Join(hv1.QEMU, "\n"))
|
||||
}
|
||||
for _, f := range user(t, hv1).WriteFiles {
|
||||
if strings.HasPrefix(f.Path, "/etc/lab/files/") {
|
||||
t.Errorf("hv1 user-data carries %s, files belong to the ISO", f.Path)
|
||||
}
|
||||
}
|
||||
for _, name := range []string{"sw1", "rr1", "hv2"} {
|
||||
if n := nodeNamed(t, nodes, name); strings.Contains(strings.Join(n.QEMU, " "), "files.iso") || n.Files != nil {
|
||||
t.Errorf("%s gets a files ISO", name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestRoles_HostReceivesItsScripts(t *testing.T) {
|
||||
cfg := user(t, nodeNamed(t, renderRoles(t), "hv1"))
|
||||
for path, want := range map[string]struct {
|
||||
content string
|
||||
|
|
@ -181,7 +203,6 @@ func TestRoles_HostReceivesItsScriptsAndFiles(t *testing.T) {
|
|||
}{
|
||||
"/usr/local/sbin/lab-node-provision": {"#!/bin/sh\necho provision\n", "0755"},
|
||||
"/usr/local/sbin/lab-node-post-provision": {"#!/bin/sh\necho post\n", "0755"},
|
||||
"/etc/lab/files/agent.yml": {"dhcp:\n backend: two\n", "0644"},
|
||||
} {
|
||||
f := fileAt(t, cfg, path)
|
||||
got, err := base64.StdEncoding.DecodeString(f.Content)
|
||||
|
|
@ -280,7 +301,6 @@ func TestRoles_RefusesUnreadProvisionInputs(t *testing.T) {
|
|||
}{
|
||||
"provision": {func(o *Options) { o.Provision = nil }, "node hv1: provision script hv.sh was not read"},
|
||||
"post": {func(o *Options) { o.PostProvision = nil }, "node hv1: post_provision script hv-post.sh was not read"},
|
||||
"file": {func(o *Options) { o.Files = nil }, "node hv1: file agent.yml (two.yml) was not read"},
|
||||
}
|
||||
for name, c := range cases {
|
||||
o := roleOptions()
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import (
|
|||
_ "embed"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"go.yaml.in/yaml/v3"
|
||||
|
|
@ -31,6 +30,7 @@ const (
|
|||
NodeProvision = "/usr/local/sbin/lab-node-provision"
|
||||
NodePostProvision = "/usr/local/sbin/lab-node-post-provision"
|
||||
FilesDir = "/etc/lab/files"
|
||||
FilesMount = "/run/lab-files"
|
||||
)
|
||||
|
||||
//go:embed frrouting.gpg
|
||||
|
|
@ -114,13 +114,13 @@ func userData(p *topology.Plan, n topology.NodePlan, o Options) ([]byte, error)
|
|||
}
|
||||
steps = append(steps, "systemctl daemon-reload", "systemctl enable --now lab-node.service")
|
||||
}
|
||||
names := make([]string, 0, len(n.Files))
|
||||
for name := range n.Files {
|
||||
names = append(names, name)
|
||||
}
|
||||
sort.Strings(names)
|
||||
for _, name := range names {
|
||||
cfg.WriteFiles = append(cfg.WriteFiles, writeFile{Path: FilesDir + "/" + name, Permissions: "0644", Encoding: "b64", Content: base64.StdEncoding.EncodeToString(o.Files[n.Name][name])})
|
||||
if len(n.Files) > 0 {
|
||||
steps = append(steps,
|
||||
"mkdir -p "+FilesDir+" "+FilesMount,
|
||||
"mount -o ro LABEL="+FilesLabel+" "+FilesMount,
|
||||
"cp -R "+FilesMount+"/. "+FilesDir+"/",
|
||||
"umount "+FilesMount,
|
||||
)
|
||||
}
|
||||
if n.Provision != "" {
|
||||
cfg.WriteFiles = append(cfg.WriteFiles, writeFile{Path: NodeProvision, Permissions: "0755", Encoding: "b64", Content: base64.StdEncoding.EncodeToString([]byte(o.Provision[n.Name]))})
|
||||
|
|
|
|||
|
|
@ -186,6 +186,10 @@ func TestValidate_ProvisionRejections(t *testing.T) {
|
|||
`hv: { role: host, image: deb, cpus: 1, memory: 512, segments: [red], files: { agent.yml: "" } }`,
|
||||
"node hv: file agent.yml has no source",
|
||||
},
|
||||
"file source with an equals sign": {
|
||||
`hv: { role: host, image: deb, cpus: 1, memory: 512, segments: [red], files: { bin: "a=b" } }`,
|
||||
`node hv: file bin: source "a=b" must not contain '='`,
|
||||
},
|
||||
"service with shell characters": {
|
||||
`hv: { role: host, image: deb, cpus: 1, memory: 512, segments: [red], services: ["agent.service; reboot"] }`,
|
||||
`node hv: service "agent.service; reboot" must match`,
|
||||
|
|
|
|||
|
|
@ -214,6 +214,8 @@ func validateExtras(n Node, segments map[string]Segment, add func(string, ...any
|
|||
add("node %s: file name %q must match %s", n.Name, name, filePattern)
|
||||
case n.Files[name] == "":
|
||||
add("node %s: file %s has no source", n.Name, name)
|
||||
case strings.Contains(n.Files[name], "="):
|
||||
add("node %s: file %s: source %q must not contain '='", n.Name, name, n.Files[name])
|
||||
}
|
||||
}
|
||||
seenUnits := map[string]bool{}
|
||||
|
|
|
|||
45
test/e2e/build.sh
Executable file
45
test/e2e/build.sh
Executable file
|
|
@ -0,0 +1,45 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
E2E_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_DIR="$(cd "${E2E_DIR}/../.." && pwd)"
|
||||
BIN_DIR="${BIN_DIR:-${E2E_DIR}/topologies/bin}"
|
||||
BINARIES="agent dhcp metadata"
|
||||
|
||||
usage () {
|
||||
cat >&2 <<USAGE
|
||||
usage: ${0##*/} [--clean]
|
||||
|
||||
sans option : compile ${BINARIES} pour linux/amd64 depuis l'arbre courant dans ${BIN_DIR} ;
|
||||
le prochain lab les installe par-dessus la release de la topologie
|
||||
--clean : vide ${BIN_DIR} ; le prochain lab teste la release seule
|
||||
USAGE
|
||||
exit 2
|
||||
}
|
||||
|
||||
clean () {
|
||||
local binary
|
||||
for binary in ${BINARIES}; do
|
||||
rm -f "${BIN_DIR}/${binary}" || return 1
|
||||
done
|
||||
}
|
||||
|
||||
build () {
|
||||
local binary
|
||||
for binary in ${BINARIES}; do
|
||||
echo "== ${binary}" >&2
|
||||
(cd "${REPO_DIR}" && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o "${BIN_DIR}/${binary}" "./cmd/${binary}") || return 1
|
||||
done
|
||||
(cd "${BIN_DIR}" && sha256sum ${BINARIES} 2>/dev/null || shasum -a 256 ${BINARIES})
|
||||
}
|
||||
|
||||
main () {
|
||||
case "${1:-}" in
|
||||
"") build ;;
|
||||
--clean) clean ;;
|
||||
*) usage ;;
|
||||
esac
|
||||
}
|
||||
|
||||
if [[ "${BASH_SOURCE[0]}" == "${0}" || -z "${BASH_SOURCE[0]}" ]]; then
|
||||
main "$@"
|
||||
fi
|
||||
0
test/e2e/topologies/bin/.gitkeep
Normal file
0
test/e2e/topologies/bin/.gitkeep
Normal file
|
|
@ -22,10 +22,10 @@ nodes:
|
|||
hv1:
|
||||
{ role: host, image: debian12, cpus: 4, memory: 16384, segments: [underlay],
|
||||
addresses: { underlay: 192.168.14.11 }, frr: frr/hv1.conf, provision: provision/hypervisor.sh,
|
||||
post_provision: provision/hypervisor-post.sh, files: { agent.yml: agent/two.yml },
|
||||
post_provision: provision/hypervisor-post.sh, files: { agent.yml: agent/two.yml, bin: bin },
|
||||
services: [agent.service] }
|
||||
hv2:
|
||||
{ role: host, image: debian12, cpus: 4, memory: 16384, segments: [underlay],
|
||||
addresses: { underlay: 192.168.14.12 }, frr: frr/hv2.conf, provision: provision/hypervisor.sh,
|
||||
post_provision: provision/hypervisor-post.sh, files: { agent.yml: agent/bgp.yml },
|
||||
post_provision: provision/hypervisor-post.sh, files: { agent.yml: agent/bgp.yml, bin: bin },
|
||||
services: [agent.service] }
|
||||
|
|
|
|||
|
|
@ -22,15 +22,15 @@ nodes:
|
|||
hv1:
|
||||
{ role: host, image: debian12, cpus: 4, memory: 16384, segments: [underlay],
|
||||
addresses: { underlay: 192.168.14.11 }, frr: frr/hv1.conf, provision: provision/hypervisor.sh,
|
||||
post_provision: provision/hypervisor-post.sh, files: { agent.yml: agent/two.yml },
|
||||
post_provision: provision/hypervisor-post.sh, files: { agent.yml: agent/two.yml, bin: bin },
|
||||
services: [agent.service] }
|
||||
hv2:
|
||||
{ role: host, image: debian12, cpus: 4, memory: 16384, segments: [underlay],
|
||||
addresses: { underlay: 192.168.14.12 }, frr: frr/hv2.conf, provision: provision/hypervisor.sh,
|
||||
post_provision: provision/hypervisor-post.sh, files: { agent.yml: agent/bgp.yml },
|
||||
post_provision: provision/hypervisor-post.sh, files: { agent.yml: agent/bgp.yml, bin: bin },
|
||||
services: [agent.service] }
|
||||
hv3:
|
||||
{ role: host, image: debian12, cpus: 4, memory: 16384, segments: [underlay],
|
||||
addresses: { underlay: 192.168.14.13 }, frr: frr/hv3.conf, provision: provision/hypervisor.sh,
|
||||
post_provision: provision/hypervisor-post.sh, files: { agent.yml: agent/bgp.yml },
|
||||
post_provision: provision/hypervisor-post.sh, files: { agent.yml: agent/bgp.yml, bin: bin },
|
||||
services: [agent.service] }
|
||||
|
|
|
|||
|
|
@ -17,3 +17,10 @@ for script in deploy.sh bootstrap_kvm.sh; do
|
|||
done
|
||||
chmod 0755 deploy.sh bootstrap_kvm.sh
|
||||
bash ./deploy.sh --noup_script -i -u "${LAB_UPLINK}" -t "${RELEASE}"
|
||||
for binary in "${LAB_FILES}"/bin/*; do
|
||||
[ -f "${binary}" ] || continue
|
||||
name=$(basename "${binary}")
|
||||
install -D -m 0755 "${binary}" "/opt/two/local/bin/${name}"
|
||||
ln -sfn "/opt/two/local/bin/${name}" "/opt/two/bin/${name}"
|
||||
echo "lab: ${name} compilé en local remplace celui de la release ${RELEASE}"
|
||||
done
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue