Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.
Merged
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
4 changes: 4 additions & 0 deletions api/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ func (v *VolumeDescription) IsDir() bool {
return v.Format == "vfs"
}

func (v *VolumeDescription) IsNas() bool {
return v.Format == "nas"
}

func SandboxInfoFromOCF(s *specs.Spec) *SandboxConfig {
return &SandboxConfig{
Hostname: s.Hostname,
Expand Down
4 changes: 2 additions & 2 deletions hypervisor/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,8 @@ func (ctx *VmContext) AddVolume(vol *api.VolumeDescription, result chan api.Resu

dc := NewDiskContext(ctx, vol)

if vol.IsDir() {
ctx.Log(INFO, "return volume add success for dir %s", vol.Name)
if vol.IsDir() || vol.IsNas() {
ctx.Log(INFO, "return volume add success for dir/nas %s", vol.Name)
result <- api.NewResultBase(vol.Name, true, "")
} else {
ctx.Log(DEBUG, "insert disk for volume %s", vol.Name)
Expand Down
12 changes: 10 additions & 2 deletions hypervisor/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package hypervisor
import (
"sync"

"github.com/hyperhq/runv/api"
"strconv"
"strings"

"github.com/hyperhq/runv/api"
)

type DiskDescriptor struct {
Expand All @@ -24,6 +25,10 @@ func (d *DiskDescriptor) IsDir() bool {
return d.Format == "vfs"
}

func (d *DiskDescriptor) IsNas() bool {
return d.Format == "nas"
}

type DiskContext struct {
*DiskDescriptor

Expand All @@ -49,6 +54,9 @@ func NewDiskContext(ctx *VmContext, vol *api.VolumeDescription) *DiskContext {
}
if vol.IsDir() {
dc.ready = true
} else if vol.IsNas() {
dc.DeviceName = vol.Source
dc.ready = true
} else if vol.Format == "rbd" {
dc.Options = map[string]string{
"user": vol.Options.User,
Expand Down Expand Up @@ -107,7 +115,7 @@ func (dc *DiskContext) remove(result chan<- api.Result) {
result = make(chan api.Result, 4)
}

if dc.IsDir() {
if dc.IsDir() || dc.IsNas() {
result <- api.NewResultBase(dc.Name, true, "no need to unplug")
return
}
Expand Down