Skip to content
This repository has been archived by the owner on Jul 16, 2020. It is now read-only.

Commit

Permalink
osprepare: allow common net and compute launcher deps
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Tim Pepper committed Aug 26, 2016
1 parent 47528bf commit 143e19f
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 21 deletions.
63 changes: 44 additions & 19 deletions ciao-launcher/deps.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"}),
}
4 changes: 4 additions & 0 deletions ciao-launcher/instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
}
Expand Down
9 changes: 8 additions & 1 deletion ciao-launcher/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions ciao-launcher/overseer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
2 changes: 1 addition & 1 deletion osprepare/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 143e19f

Please sign in to comment.