mirror of
https://github.com/mulgadc/spinifex.git
synced 2026-10-15 09:01:31 +00:00
refactor: colocate ENI allocation with VM runtime
This commit is contained in:
@@ -15,7 +15,6 @@ import (
|
||||
handlers_ec2_vpc "github.com/mulgadc/spinifex/spinifex/handlers/ec2/vpc"
|
||||
"github.com/mulgadc/spinifex/spinifex/runtime/compute/qmp"
|
||||
"github.com/mulgadc/spinifex/spinifex/runtime/compute/vm"
|
||||
spxtypes "github.com/mulgadc/spinifex/spinifex/types"
|
||||
"github.com/mulgadc/spinifex/spinifex/utils"
|
||||
"github.com/nats-io/nats.go"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -118,7 +117,7 @@ func newENIHotPlugFixture(t *testing.T) *eniHotPlugFixture {
|
||||
ID: "i-hp-test",
|
||||
Status: vm.StateRunning,
|
||||
QMPClient: &qmp.QMPClient{},
|
||||
ENIRequests: spxtypes.ENIRequests{
|
||||
ENIRequests: vm.ENIRequests{
|
||||
AvailableSlots: []int{1, 2, 3, 4},
|
||||
AttachedByENIID: map[string]int{},
|
||||
},
|
||||
@@ -352,7 +351,7 @@ func TestHandleDetachNetworkInterface_WrongOwner(t *testing.T) {
|
||||
otherVM := &vm.VM{
|
||||
ID: "i-other",
|
||||
Status: vm.StateRunning,
|
||||
ENIRequests: spxtypes.ENIRequests{
|
||||
ENIRequests: vm.ENIRequests{
|
||||
AvailableSlots: []int{1},
|
||||
AttachedByENIID: map[string]int{},
|
||||
},
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/mulgadc/spinifex/spinifex/runtime/compute/qmp"
|
||||
"github.com/mulgadc/spinifex/spinifex/types"
|
||||
)
|
||||
|
||||
// newHotPlugTestVM returns a VM in StateRunning with a non-nil QMPClient
|
||||
@@ -39,7 +38,7 @@ func newHotPlugTestVMWithPlumber(t *testing.T, slots int) (*Manager, *VM, *StubD
|
||||
ID: "i-test",
|
||||
Status: StateRunning,
|
||||
QMPClient: &qmp.QMPClient{},
|
||||
ENIRequests: types.ENIRequests{
|
||||
ENIRequests: ENIRequests{
|
||||
AvailableSlots: available,
|
||||
AttachedByENIID: make(map[string]int),
|
||||
},
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/mulgadc/spinifex/spinifex/runtime/compute/qmp"
|
||||
"github.com/mulgadc/spinifex/spinifex/types"
|
||||
)
|
||||
|
||||
func TestENISlotFromDeviceID(t *testing.T) {
|
||||
@@ -67,7 +66,7 @@ func TestAdoptENISlot(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAdoptENISlot_NilMap(t *testing.T) {
|
||||
v := &VM{ENIRequests: types.ENIRequests{AvailableSlots: []int{1}}}
|
||||
v := &VM{ENIRequests: ENIRequests{AvailableSlots: []int{1}}}
|
||||
m := &Manager{}
|
||||
m.AdoptENISlot(v, "eni-a", 1)
|
||||
if got := v.ENIRequests.AttachedByENIID["eni-a"]; got != 1 {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package types
|
||||
package vm
|
||||
|
||||
import "sync"
|
||||
|
||||
@@ -88,7 +88,7 @@ type VM struct {
|
||||
Config Config `json:"config"`
|
||||
|
||||
EBSRequests types.EBSRequests `json:"ebs_requests"`
|
||||
ENIRequests types.ENIRequests `json:"eni_requests"`
|
||||
ENIRequests ENIRequests `json:"eni_requests"`
|
||||
|
||||
QMPClient *qmp.QMPClient `json:"-"`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user