From 143e19f59f550b89c1aaf6d9e0cf2083b1d0f820 Mon Sep 17 00:00:00 2001 From: Tim Pepper Date: Fri, 26 Aug 2016 14:06:02 -0700 Subject: [PATCH] osprepare: allow common net and compute launcher deps osprepare's PackageRequirements type doesn't need to use a pointer. In that case it's easier to compose two PackageRequirements instances which back on a common list of type PackageRequirement. With that, and the prior patch's addition of a Role() getter function to the ssntp client interface, ciao-launcher can articulate common and unique dependencies for the Agent and NetAgent role and insure the applicable set is applied at runtime. Signed-off-by: Tim Pepper --- ciao-launcher/deps.go | 63 ++++++++++++++++++++++++---------- ciao-launcher/instance_test.go | 4 +++ ciao-launcher/main.go | 9 ++++- ciao-launcher/overseer_test.go | 4 +++ osprepare/main.go | 2 +- 5 files changed, 61 insertions(+), 21 deletions(-) diff --git a/ciao-launcher/deps.go b/ciao-launcher/deps.go index f8b495a46..d2bf9cdc5 100644 --- a/ciao-launcher/deps.go +++ b/ciao-launcher/deps.go @@ -18,24 +18,49 @@ package main import "github.com/01org/ciao/osprepare" -var launcherDeps = osprepare.PackageRequirements{ +// common launcher node needs are: +// +// qemu/kvm for VM's +// xorriso for cloud init config drive +// fuser for qemu instance pid + +var launcherClearLinuxCommonDeps = []osprepare.PackageRequirement{ + {"/usr/bin/qemu-system-x86_64", "cloud-control"}, + {"/usr/bin/xorriso", "cloud-control"}, + {"/usr/sbin/fuser", "cloud-control"}, +} + +var launcherFedoraCommonDeps = []osprepare.PackageRequirement{ + {"/usr/bin/qemu-system-x86_64", "qemu-system-x86"}, + {"/usr/bin/xorriso", "xorriso"}, + {"/usr/sbin/fuser", "psmisc"}, +} + +var launcherUbuntuCommonDeps = []osprepare.PackageRequirement{ + {"/usr/bin/qemu-system-x86_64", "qemu-system-x86"}, + {"/usr/bin/xorriso", "xorriso"}, + {"/bin/fuser", "psmisc"}, +} + +var launcherNetNodeDeps = map[string][]osprepare.PackageRequirement{ + // network nodes have a unique additional need for: + // + // none currently + + "clearlinux": launcherClearLinuxCommonDeps, + "fedora": launcherFedoraCommonDeps, + "ubuntu": launcherUbuntuCommonDeps, +} + +var launcherComputeNodeDeps = map[string][]osprepare.PackageRequirement{ + // compute nodes have a unique additional need for: + // // docker for containers - // qemu/kvm for VM's - // xorriso for cloud init config drive - - "clearlinux": { - {"/usr/bin/docker", "cloud-control"}, - {"/usr/bin/qemu-system-x86_64", "cloud-control"}, - {"/usr/bin/xorriso", "cloud-control"}, - }, - "fedora": { - {"/usr/bin/docker", "docker-engine"}, - {"/usr/bin/qemu-system-x86_64", "qemu-system-x86"}, - {"/usr/bin/xorriso", "xorriso"}, - }, - "ubuntu": { - {"/usr/bin/docker", "docker"}, - {"/usr/bin/qemu-system-x86_64", "qemu-system-x86"}, - {"/usr/bin/xorriso", "xorriso"}, - }, + + "clearlinux": append(launcherClearLinuxCommonDeps, + osprepare.PackageRequirement{BinaryName: "/usr/bin/docker", PackageName: "cloud-control"}), + "fedora": append(launcherFedoraCommonDeps, + osprepare.PackageRequirement{BinaryName: "/usr/bin/docker", PackageName: "docker-engine"}), + "ubuntu": append(launcherUbuntuCommonDeps, + osprepare.PackageRequirement{BinaryName: "/usr/bin/docker", PackageName: "docker"}), } diff --git a/ciao-launcher/instance_test.go b/ciao-launcher/instance_test.go index 559f66f4d..072db0032 100644 --- a/ciao-launcher/instance_test.go +++ b/ciao-launcher/instance_test.go @@ -177,6 +177,10 @@ func (v *instanceTestState) SendCommand(cmd ssntp.Command, payload []byte) (int, return 0, nil } +func (v *instanceTestState) Role() ssntp.Role { + return ssntp.AGENT | ssntp.NETAGENT +} + func (v *instanceTestState) UUID() string { return "" } diff --git a/ciao-launcher/main.go b/ciao-launcher/main.go index 8d17334fc..a77ba0670 100644 --- a/ciao-launcher/main.go +++ b/ciao-launcher/main.go @@ -102,6 +102,7 @@ type serverConn interface { Dial(config *ssntp.Config, ntf ssntp.ClientNotifier) error SendStatus(status ssntp.Status, payload []byte) (int, error) SendCommand(cmd ssntp.Command, payload []byte) (int, error) + Role() ssntp.Role UUID() string Close() isConnected() bool @@ -402,7 +403,13 @@ DONE: } printClusterConfig() - osprepare.InstallDeps(launcherDeps) + role := client.conn.Role() + if role.IsNetAgent() { + osprepare.InstallDeps(launcherNetNodeDeps) + } + if role.IsAgent() { + osprepare.InstallDeps(launcherComputeNodeDeps) + } err = startNetwork(doneCh) if err != nil { diff --git a/ciao-launcher/overseer_test.go b/ciao-launcher/overseer_test.go index 61b814edc..826671fe7 100644 --- a/ciao-launcher/overseer_test.go +++ b/ciao-launcher/overseer_test.go @@ -149,6 +149,10 @@ func (v *overseerTestState) SendCommand(cmd ssntp.Command, payload []byte) (int, return 0, nil } +func (v *overseerTestState) Role() ssntp.Role { + return ssntp.AGENT | ssntp.NETAGENT +} + func (v *overseerTestState) UUID() string { return "test-uuid" } diff --git a/osprepare/main.go b/osprepare/main.go index a3b95b28f..5fa57f784 100644 --- a/osprepare/main.go +++ b/osprepare/main.go @@ -48,7 +48,7 @@ type PackageRequirement struct { // {"/usr/bin/docker", "containers-basic"}, // }, // ) -type PackageRequirements map[string][]*PackageRequirement +type PackageRequirements map[string][]PackageRequirement // BootstrapRequirements lists required dependencies for absolutely core // functionality across all Ciao components