switch Packet references to Equinix Metal

Signed-off-by: Avi Deitcher <avi@deitcher.net>
This commit is contained in:
Avi Deitcher
2024-07-05 17:17:17 +03:00
parent 3f80ca694f
commit 8f6ea3c85e
24 changed files with 148 additions and 228 deletions

View File

@@ -1,12 +1,22 @@
module github.com/linuxkit/linuxkit/pkg/metadata
go 1.16
go 1.21
require (
github.com/diskfs/go-diskfs v1.3.1-0.20230612151643-22d22fd7e558
github.com/packethost/packngo v0.1.0
github.com/sirupsen/logrus v1.9.0
github.com/vishvananda/netlink v0.0.0-20170808154308-f5a6f697a596
github.com/vishvananda/netns v0.0.0-20170707011535-86bef332bfc3 // indirect
github.com/vmware/vmw-guestinfo v0.0.0-20220317130741-510905f0efa3
)
require (
github.com/elliotwutingfeng/asciiset v0.0.0-20230602022725-51bbb787efab // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/pierrec/lz4/v4 v4.1.17 // indirect
github.com/pkg/xattr v0.4.9 // indirect
github.com/ulikunitz/xz v0.5.11 // indirect
github.com/vishvananda/netns v0.0.0-20170707011535-86bef332bfc3 // indirect
golang.org/x/sys v0.5.0 // indirect
gopkg.in/djherbis/times.v1 v1.3.0 // indirect
)

View File

@@ -77,7 +77,7 @@ func main() {
log.SetLevel(log.DebugLevel)
}
providers := []string{"aws", "gcp", "hetzner", "openstack", "scaleway", "vultr", "digitalocean", "packet", "metaldata", "vmware", "cdrom"}
providers := []string{"aws", "gcp", "hetzner", "openstack", "scaleway", "vultr", "digitalocean", "equinixmetal", "metaldata", "vmware", "cdrom"}
args := flag.Args()
if len(args) > 0 {
providers = args
@@ -92,8 +92,8 @@ func main() {
netProviders = append(netProviders, NewHetzner())
case p == "openstack":
netProviders = append(netProviders, NewOpenstack())
case p == "packet":
netProviders = append(netProviders, NewPacket())
case p == "equinixmetal":
netProviders = append(netProviders, NewEquinixMetal())
case p == "scaleway":
netProviders = append(netProviders, NewScaleway())
case p == "vultr":

View File

@@ -12,30 +12,30 @@ import (
"github.com/vishvananda/netlink"
)
// ProviderPacket is the type implementing the Provider interface for Packet.net
type ProviderPacket struct {
// ProviderEquinixMetal is the type implementing the Provider interface for Equinix Metal
type ProviderEquinixMetal struct {
metadata *metadata.CurrentDevice
err error
}
// NewPacket returns a new ProviderPacket
func NewPacket() *ProviderPacket {
return &ProviderPacket{}
// NewEquinixMetal returns a new ProviderEquinixMetal
func NewEquinixMetal() *ProviderEquinixMetal {
return &ProviderEquinixMetal{}
}
func (p *ProviderPacket) String() string {
return "Packet"
func (p *ProviderEquinixMetal) String() string {
return "EquinixMetal"
}
// Probe checks if we are running on Packet
func (p *ProviderPacket) Probe() bool {
// Probe checks if we are running on EquinixMetal
func (p *ProviderEquinixMetal) Probe() bool {
// Unfortunately the host is resolveable globally, so no easy test
p.metadata, p.err = metadata.GetMetadata()
return p.err == nil
}
// Extract gets both the Packet specific and generic userdata
func (p *ProviderPacket) Extract() ([]byte, error) {
// Extract gets both the EquinixMetal specific and generic userdata
func (p *ProviderEquinixMetal) Extract() ([]byte, error) {
// do not retrieve if we Probed
if p.metadata == nil && p.err == nil {
p.metadata, p.err = metadata.GetMetadata()
@@ -47,7 +47,7 @@ func (p *ProviderPacket) Extract() ([]byte, error) {
}
if err := os.WriteFile(path.Join(ConfigPath, Hostname), []byte(p.metadata.Hostname), 0644); err != nil {
return nil, fmt.Errorf("Packet: Failed to write hostname: %s", err)
return nil, fmt.Errorf("EquinixMetal: Failed to write hostname: %s", err)
}
if err := os.MkdirAll(path.Join(ConfigPath, SSH), 0755); err != nil {
@@ -66,7 +66,7 @@ func (p *ProviderPacket) Extract() ([]byte, error) {
userData, err := metadata.GetUserData()
if err != nil {
return nil, fmt.Errorf("Packet: failed to get userdata: %s", err)
return nil, fmt.Errorf("EquinixMetal: failed to get userdata: %s", err)
}
if len(userData) == 0 {
@@ -81,7 +81,7 @@ func (p *ProviderPacket) Extract() ([]byte, error) {
return userData, nil
}
// networkConfig handles Packet network configuration, primarily bonding
// networkConfig handles EquinixMetal network configuration, primarily bonding
func networkConfig(ni metadata.NetworkInfo) error {
// rename interfaces to match what the metadata calls them
links, err := netlink.LinkList()
@@ -119,7 +119,7 @@ func networkConfig(ni metadata.NetworkInfo) error {
// set up bonding
la := netlink.LinkAttrs{Name: "bond0"}
bond := &netlink.GenericLink{la, "bond"}
bond := &netlink.GenericLink{LinkAttrs: la, LinkType: "bond"}
if err := netlink.LinkAdd(bond); err != nil {
// weirdly creating a bind always seems to return EEXIST
fmt.Fprintf(os.Stderr, "Error adding bond0: %v (ignoring)", err)

View File

@@ -1,15 +0,0 @@
module github.com/diskfs/go-diskfs
go 1.19
require (
github.com/elliotwutingfeng/asciiset v0.0.0-20230602022725-51bbb787efab
github.com/go-test/deep v1.0.8
github.com/google/uuid v1.3.0
github.com/pierrec/lz4/v4 v4.1.17
github.com/pkg/xattr v0.4.9
github.com/sirupsen/logrus v1.9.0
github.com/ulikunitz/xz v0.5.11
golang.org/x/sys v0.5.0
gopkg.in/djherbis/times.v1 v1.3.0
)

View File

@@ -1,31 +0,0 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/elliotwutingfeng/asciiset v0.0.0-20230602022725-51bbb787efab h1:h1UgjJdAAhj+uPL68n7XASS6bU+07ZX1WJvVS2eyoeY=
github.com/elliotwutingfeng/asciiset v0.0.0-20230602022725-51bbb787efab/go.mod h1:GLo/8fDswSAniFG+BFIaiSPcK610jyzgEhWYPQwuQdw=
github.com/go-test/deep v1.0.8 h1:TDsG77qcSprGbC6vTN8OuXp5g+J+b5Pcguhf7Zt61VM=
github.com/go-test/deep v1.0.8/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/pierrec/lz4/v4 v4.1.17 h1:kV4Ip+/hUBC+8T6+2EgburRtkE9ef4nbY3f4dFhGjMc=
github.com/pierrec/lz4/v4 v4.1.17/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
github.com/pkg/xattr v0.4.9 h1:5883YPCtkSd8LFbs13nXplj9g9tlrwoJRjgpgMu1/fE=
github.com/pkg/xattr v0.4.9/go.mod h1:di8WF84zAKk8jzR1UBTEWh9AUlIZZ7M/JNt8e9B6ktU=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8=
github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
golang.org/x/sys v0.0.0-20220408201424-a24fb2fb8a0f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/djherbis/times.v1 v1.3.0 h1:uxMS4iMtH6Pwsxog094W0FYldiNnfY/xba00vq6C2+o=
gopkg.in/djherbis/times.v1 v1.3.0/go.mod h1:AQlg6unIsrsCEdQYhTzERy542dz6SFdQFZFv6mUY0P8=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View File

@@ -1,3 +0,0 @@
module github.com/elliotwutingfeng/asciiset
go 1.11

View File

@@ -1 +0,0 @@
module github.com/google/uuid

View File

@@ -1,3 +0,0 @@
module github.com/pierrec/lz4/v4
go 1.14

View File

@@ -1,5 +0,0 @@
module github.com/pkg/xattr
go 1.14
require golang.org/x/sys v0.0.0-20220408201424-a24fb2fb8a0f

View File

@@ -1,4 +0,0 @@
golang.org/x/sys v0.0.0-20201101102859-da207088b7d1 h1:a/mKvvZr9Jcc8oKfcmgzyp7OwF73JPWsQLvH1z2Kxck=
golang.org/x/sys v0.0.0-20201101102859-da207088b7d1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20220408201424-a24fb2fb8a0f h1:8w7RhxzTVgUzw/AH/9mUV5q0vMgy40SQRursCcfmkCw=
golang.org/x/sys v0.0.0-20220408201424-a24fb2fb8a0f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

View File

@@ -1,9 +0,0 @@
module github.com/sirupsen/logrus
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/stretchr/testify v1.7.0
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8
)
go 1.13

View File

@@ -1,14 +0,0 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View File

@@ -1,3 +0,0 @@
module github.com/ulikunitz/xz
go 1.12

View File

@@ -1,5 +1,5 @@
# github.com/diskfs/go-diskfs v1.3.1-0.20230612151643-22d22fd7e558
## explicit
## explicit; go 1.19
github.com/diskfs/go-diskfs
github.com/diskfs/go-diskfs/disk
github.com/diskfs/go-diskfs/filesystem
@@ -12,24 +12,29 @@ github.com/diskfs/go-diskfs/partition/mbr
github.com/diskfs/go-diskfs/partition/part
github.com/diskfs/go-diskfs/util
# github.com/elliotwutingfeng/asciiset v0.0.0-20230602022725-51bbb787efab
## explicit; go 1.11
github.com/elliotwutingfeng/asciiset
# github.com/google/uuid v1.3.0
## explicit
github.com/google/uuid
# github.com/packethost/packngo v0.1.0
## explicit
github.com/packethost/packngo/metadata
# github.com/pierrec/lz4/v4 v4.1.17
## explicit; go 1.14
github.com/pierrec/lz4/v4
github.com/pierrec/lz4/v4/internal/lz4block
github.com/pierrec/lz4/v4/internal/lz4errors
github.com/pierrec/lz4/v4/internal/lz4stream
github.com/pierrec/lz4/v4/internal/xxh32
# github.com/pkg/xattr v0.4.9
## explicit; go 1.14
github.com/pkg/xattr
# github.com/sirupsen/logrus v1.9.0
## explicit
## explicit; go 1.13
github.com/sirupsen/logrus
# github.com/ulikunitz/xz v0.5.11
## explicit; go 1.12
github.com/ulikunitz/xz
github.com/ulikunitz/xz/internal/hash
github.com/ulikunitz/xz/internal/xlog
@@ -42,15 +47,17 @@ github.com/vishvananda/netlink/nl
## explicit
github.com/vishvananda/netns
# github.com/vmware/vmw-guestinfo v0.0.0-20220317130741-510905f0efa3
## explicit
## explicit; go 1.12
github.com/vmware/vmw-guestinfo/bdoor
github.com/vmware/vmw-guestinfo/message
github.com/vmware/vmw-guestinfo/rpcout
github.com/vmware/vmw-guestinfo/rpcvmx
github.com/vmware/vmw-guestinfo/vmcheck
# golang.org/x/sys v0.5.0
## explicit; go 1.17
golang.org/x/sys/internal/unsafeheader
golang.org/x/sys/unix
golang.org/x/sys/windows
# gopkg.in/djherbis/times.v1 v1.3.0
## explicit
gopkg.in/djherbis/times.v1