forked from microsoft/hcsshim
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request microsoft#1239 from katiewasnothere/ncproxy_networ…
…k_endpoint Update ncproxy to include new ncproxy network and endpoint types
- Loading branch information
Showing
17 changed files
with
1,146 additions
and
183 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package networking | ||
|
||
type Endpoint struct { | ||
EndpointName string | ||
NamespaceID string | ||
Settings *EndpointSettings | ||
} | ||
|
||
type EndpointSettings struct { | ||
Name string | ||
Macaddress string | ||
IPAddress string | ||
IPAddressPrefixLength uint32 | ||
NetworkName string | ||
DefaultGateway string | ||
DeviceDetails *DeviceDetails | ||
} | ||
|
||
type DeviceDetails struct { | ||
PCIDeviceDetails *PCIDeviceDetails | ||
} | ||
|
||
type PCIDeviceDetails struct { | ||
DeviceID string | ||
VirtualFunctionIndex uint32 | ||
} | ||
|
||
func NewEndpoint(settings *EndpointSettings) (*Endpoint, error) { | ||
return &Endpoint{ | ||
EndpointName: settings.Name, | ||
Settings: settings, | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package networking | ||
|
||
type Network struct { | ||
NetworkName string | ||
Settings *NetworkSettings | ||
} | ||
|
||
type NetworkSettings struct { | ||
Name string | ||
} | ||
|
||
func NewNetwork(settings *NetworkSettings) (*Network, error) { | ||
return &Network{ | ||
NetworkName: settings.Name, | ||
Settings: settings, | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package store | ||
|
||
import ( | ||
bolt "go.etcd.io/bbolt" | ||
) | ||
|
||
const schemaVersion = "v1" | ||
|
||
var ( | ||
bucketKeyVersion = []byte(schemaVersion) | ||
|
||
bucketKeyNetwork = []byte("network") | ||
bucketKeyEndpoint = []byte("endpoint") | ||
bucketKeyComputeAgent = []byte("computeagent") | ||
) | ||
|
||
// Below is the current database schema. This should be updated any time the schema is | ||
// changed or updated. The version should be incremented if breaking changes are made. | ||
// └──v1 - Schema version bucket | ||
// └──computeagent - Compute agent bucket | ||
// └──containerID : <string> - Entry in compute agent bucket: Address to | ||
// the compute agent for containerID | ||
|
||
// taken from containerd/containerd/metadata/buckets.go | ||
func getBucket(tx *bolt.Tx, keys ...[]byte) *bolt.Bucket { | ||
bkt := tx.Bucket(keys[0]) | ||
|
||
for _, key := range keys[1:] { | ||
if bkt == nil { | ||
break | ||
} | ||
bkt = bkt.Bucket(key) | ||
} | ||
|
||
return bkt | ||
} | ||
|
||
// taken from containerd/containerd/metadata/buckets.go | ||
func createBucketIfNotExists(tx *bolt.Tx, keys ...[]byte) (*bolt.Bucket, error) { | ||
bkt, err := tx.CreateBucketIfNotExists(keys[0]) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
for _, key := range keys[1:] { | ||
bkt, err = bkt.CreateBucketIfNotExists(key) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} | ||
|
||
return bkt, nil | ||
} | ||
|
||
func createNetworkBucket(tx *bolt.Tx) (*bolt.Bucket, error) { | ||
return createBucketIfNotExists(tx, bucketKeyVersion, bucketKeyNetwork) | ||
} | ||
|
||
func getNetworkBucket(tx *bolt.Tx) *bolt.Bucket { | ||
return getBucket(tx, bucketKeyVersion, bucketKeyNetwork) | ||
} | ||
|
||
func createEndpointBucket(tx *bolt.Tx) (*bolt.Bucket, error) { | ||
return createBucketIfNotExists(tx, bucketKeyVersion, bucketKeyEndpoint) | ||
} | ||
|
||
func getEndpointBucket(tx *bolt.Tx) *bolt.Bucket { | ||
return getBucket(tx, bucketKeyVersion, bucketKeyEndpoint) | ||
} | ||
|
||
func createComputeAgentBucket(tx *bolt.Tx) (*bolt.Bucket, error) { | ||
return createBucketIfNotExists(tx, bucketKeyVersion, bucketKeyComputeAgent) | ||
} | ||
|
||
func getComputeAgentBucket(tx *bolt.Tx) *bolt.Bucket { | ||
return getBucket(tx, bucketKeyVersion, bucketKeyComputeAgent) | ||
} |
Oops, something went wrong.