Skip to content

Commit

Permalink
Adds corex support (#1562)
Browse files Browse the repository at this point in the history
Signed-off-by: Ashraf Fouda <ashraf.m.fouda@gmail.com>
  • Loading branch information
ashraffouda authored Jan 20, 2022
1 parent 6a93781 commit 173a9c0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/gridtypes/zos/zmachine.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ type ZMachine struct {
// is going to be used
Entrypoint string `json:"entrypoint"`
// Env variables available for a container
Env map[string]string `json:"env"`
Env map[string]string `json:"env"`
Corex bool `json:"corex"`
}

func (m *ZMachine) MinRootSize() gridtypes.Unit {
Expand Down
25 changes: 25 additions & 0 deletions pkg/primitives/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import (
"crypto/md5"
"encoding/json"
"fmt"
"io"
"net"
"os"
"path/filepath"
"strings"

Expand Down Expand Up @@ -282,6 +284,12 @@ func (p *Primitives) virtualMachineProvisionImpl(ctx context.Context, wl *gridty
if err := p.vmMounts(ctx, deployment, config.Mounts, true, &machine); err != nil {
return result, err
}
if config.Corex {
if err := p.copyFile("/usr/bin/corex", filepath.Join(mnt, "corex"), 0755); err != nil {
return result, errors.Wrap(err, "failed to inject corex binary")
}
entrypoint = "/corex --ipv6 -d 7 --interface eth0"
}
} else {
// if a VM the vm has to have at least one mount
if len(config.Mounts) == 0 {
Expand Down Expand Up @@ -341,6 +349,23 @@ func (p *Primitives) virtualMachineProvisionImpl(ctx context.Context, wl *gridty

return result, err
}
func (p *Primitives) copyFile(srcPath string, destPath string, permissions os.FileMode) error {
src, err := os.Open(srcPath)
if err != nil {
return errors.Wrapf(err, "Coludn't find %s on the node", srcPath)
}
defer src.Close()
dest, err := os.OpenFile(destPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, permissions)
if err != nil {
return errors.Wrapf(err, "Coludn't create %s file", destPath)
}
defer dest.Close()
_, err = io.Copy(dest, src)
if err != nil {
return errors.Wrapf(err, "Couldn't copy to %s", destPath)
}
return nil
}

func (p *Primitives) vmDecomission(ctx context.Context, wl *gridtypes.WorkloadWithID) error {
var (
Expand Down

0 comments on commit 173a9c0

Please sign in to comment.