VMware vSphere Integrated Containers provider (#206)
* Add Virtual Kubelet provider for VIC Initial virtual kubelet provider for VMware VIC. This provider currently handles creating and starting of a pod VM via the VIC portlayer and persona server. Image store handling via the VIC persona server. This provider currently requires the feature/wolfpack branch of VIC. * Added pod stop and delete. Also added node capacity. Added the ability to stop and delete pod VMs via VIC. Also retrieve node capacity information from the VCH. * Cleanup and readme file Some file clean up and added a Readme.md markdown file for the VIC provider. * Cleaned up errors, added function comments, moved operation code 1. Cleaned up error handling. Set standard for creating errors. 2. Added method prototype comments for all interface functions. 3. Moved PodCreator, PodStarter, PodStopper, and PodDeleter to a new folder. * Add mocking code and unit tests for podcache, podcreator, and podstarter Used the unit test framework used in VIC to handle assertions in the provider's unit test. Mocking code generated using OSS project mockery, which is compatible with the testify assertion framework. * Vendored packages for the VIC provider Requires feature/wolfpack branch of VIC and a few specific commit sha of projects used within VIC. * Implementation of POD Stopper and Deleter unit tests (#4) * Updated files for initial PR
This commit is contained in:
218
vendor/github.com/vmware/vic/lib/migration/samples/config/v1/executor/container_vm.go
generated
vendored
Normal file
218
vendor/github.com/vmware/vic/lib/migration/samples/config/v1/executor/container_vm.go
generated
vendored
Normal file
@@ -0,0 +1,218 @@
|
||||
// Copyright 2017 VMware, Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package executor
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
"github.com/vmware/vic/pkg/version"
|
||||
)
|
||||
|
||||
type State int
|
||||
|
||||
const (
|
||||
STARTED State = iota
|
||||
EXITED
|
||||
KILLED
|
||||
)
|
||||
|
||||
// Common data between managed entities, across execution environments
|
||||
type Common struct {
|
||||
// A reference to the components hosting execution environment, if any
|
||||
ExecutionEnvironment string
|
||||
|
||||
// Unambiguous ID with meaning in the context of its hosting execution environment
|
||||
ID string `vic:"0.1" scope:"read-only" key:"id"`
|
||||
|
||||
// Convenience field to record a human readable name
|
||||
Name string `vic:"0.1" scope:"read-only" key:"name"`
|
||||
|
||||
// Freeform notes related to the entity
|
||||
Notes string `vic:"0.1" scope:"hidden" key:"notes"`
|
||||
}
|
||||
|
||||
// Diagnostics records some basic control and lifecycle information for diagnostic purposes
|
||||
type Diagnostics struct {
|
||||
// Should debugging be enabled on whatever component this is and at what level
|
||||
DebugLevel int `vic:"0.1" scope:"read-only" key:"debug"`
|
||||
|
||||
// RessurectionCount is a log of how many times the entity has been restarted due
|
||||
// to error exit
|
||||
ResurrectionCount int `vic:"0.1" scope:"read-write" key:"resurrections"`
|
||||
// ExitLogs is a best effort record of the time of process death and the cause for
|
||||
// restartable entities
|
||||
ExitLogs []ExitLog `vic:"0.1" scope:"read-write" key:"exitlogs"`
|
||||
}
|
||||
|
||||
// ExitLog records some basic diagnostics about anomalous exit for restartable entities
|
||||
type ExitLog struct {
|
||||
Time time.Time
|
||||
ExitStatus int
|
||||
Message string
|
||||
}
|
||||
|
||||
// MountSpec details a mount that must be executed within the executor
|
||||
// A mount is a URI -> path mapping with a credential of some kind
|
||||
// In the case of a labeled disk:
|
||||
// label://<label name> => </mnt/path>
|
||||
type MountSpec struct {
|
||||
// A URI->path mapping, e.g.
|
||||
// May contain credentials
|
||||
Source url.URL `vic:"0.1" scope:"read-only" key:"source"`
|
||||
|
||||
// The path in the executor at which this should be mounted
|
||||
Path string `vic:"0.1" scope:"read-only" key:"dest"`
|
||||
|
||||
// Freeform mode string, which could translate directly to mount options
|
||||
// We may want to turn this into a more structured form eventually
|
||||
Mode string `vic:"0.1" scope:"read-only" key:"mode"`
|
||||
}
|
||||
|
||||
// ContainerVM holds that data tightly associated with a containerVM, but that should not
|
||||
// be visible to the guest. This is the external complement to ExecutorConfig.
|
||||
type ContainerVM struct {
|
||||
Common
|
||||
|
||||
// The version of the bootstrap image that this container was booted from.
|
||||
Version string
|
||||
|
||||
// Name aliases for this specific container, Maps alias to unambiguous name
|
||||
// This uses unambiguous name rather than reified network endpoint to persist
|
||||
// the intent rather than a point-in-time manifesting of that intent.
|
||||
Aliases map[string]string
|
||||
|
||||
// The location of the interaction service that the tether should connect to. Examples:
|
||||
// * tcp://x.x.x.x:2377
|
||||
// * vmci://moid - should this be an moid or a VMCI CID? Does one insulate us from reboots?
|
||||
Interaction url.URL
|
||||
|
||||
// Key is the host key used during communicate back with the Interaction endpoint if any
|
||||
// Used if the vSocket agent is responsible for authenticating the connection
|
||||
AgentKey []byte
|
||||
}
|
||||
|
||||
// ExecutorConfig holds the data tightly associated with an Executor. This is distinct from Sessions
|
||||
// in that there is no process inherently associated - this is closer to a ThreadPool than a Thread and
|
||||
// is the owner of the shared filesystem environment. This is the guest visible complement to ContainerVM.
|
||||
type ExecutorConfig struct {
|
||||
Common `vic:"0.1" scope:"read-only" key:"common"`
|
||||
|
||||
// CreateTime stamp
|
||||
CreateTime int64 `vic:"0.1" scope:"read-write" key:"createtime"`
|
||||
|
||||
// Diagnostics holds basic diagnostics data
|
||||
Diagnostics Diagnostics `vic:"0.1" scope:"read-only" key:"diagnostics"`
|
||||
|
||||
// Sessions is the set of sessions currently hosted by this executor
|
||||
// These are keyed by session ID
|
||||
Sessions map[string]*SessionConfig `vic:"0.1" scope:"read-only" key:"sessions"`
|
||||
|
||||
// Maps the mount name to the detail mount specification
|
||||
Mounts map[string]MountSpec `vic:"0.1" scope:"read-only" key:"mounts"`
|
||||
|
||||
// This describes an executors presence on a network, and contains sufficient
|
||||
// information to configure the interface in the guest.
|
||||
Networks map[string]*NetworkEndpoint `vic:"0.1" scope:"read-only" key:"networks"`
|
||||
|
||||
// Key is the host key used during communicate back with the Interaction endpoint if any
|
||||
// Used if the in-guest tether is responsible for authenticating the connection
|
||||
Key []byte `vic:"0.1" scope:"read-only" key:"key"`
|
||||
|
||||
// Layer id that is backing this container VM
|
||||
LayerID string `vic:"0.1" scope:"read-only" key:"layerid"`
|
||||
|
||||
// Blob metadata for the caller
|
||||
Annotations map[string]string `vic:"0.1" scope:"hidden" key:"annotations"`
|
||||
|
||||
// Repository requested by user
|
||||
// TODO: a bit docker specific
|
||||
RepoName string `vic:"0.1" scope:"read-only" key:"repo"`
|
||||
|
||||
// version
|
||||
Version *version.Build `vic:"0.1" scope:"read-only" key:"version"`
|
||||
}
|
||||
|
||||
// Cmd is here because the encoding packages seem to have issues with the full exec.Cmd struct
|
||||
type Cmd struct {
|
||||
// Path is the command to run
|
||||
Path string `vic:"0.1" scope:"read-only" key:"Path"`
|
||||
|
||||
// Args is the command line arguments including the command in Args[0]
|
||||
Args []string `vic:"0.1" scope:"read-only" key:"Args"`
|
||||
|
||||
// Env specifies the environment of the process
|
||||
Env []string `vic:"0.1" scope:"read-only" key:"Env"`
|
||||
|
||||
// Dir specifies the working directory of the command
|
||||
Dir string `vic:"0.1" scope:"read-only" key:"Dir"`
|
||||
}
|
||||
|
||||
// SessionConfig defines the content of a session - this maps to the root of a process tree
|
||||
// inside an executor
|
||||
// This is close to but not perfectly aligned with the new docker/docker/daemon/execdriver/driver:CommonProcessConfig
|
||||
type SessionConfig struct {
|
||||
// The primary session may have the same ID as the executor owning it
|
||||
Common `vic:"0.1" scope:"read-only" key:"common"`
|
||||
Detail `vic:"0.1" scope:"read-write" key:"detail"`
|
||||
|
||||
// The primary process for the session
|
||||
Cmd Cmd `vic:"0.1" scope:"read-only" key:"cmd"`
|
||||
|
||||
// Allow attach
|
||||
Attach bool `vic:"0.1" scope:"read-only" key:"attach"`
|
||||
|
||||
OpenStdin bool `vic:"0.1" scope:"read-only" key:"openstdin"`
|
||||
|
||||
// Delay launching the Cmd until an attach request comes
|
||||
RunBlock bool `vic:"0.1" scope:"read-only" key:"runblock"`
|
||||
|
||||
// Allocate a tty or not
|
||||
Tty bool `vic:"0.1" scope:"read-only" key:"tty"`
|
||||
|
||||
ExitStatus int `vic:"0.1" scope:"read-write" key:"status"`
|
||||
|
||||
Started string `vic:"0.1" scope:"read-write" key:"started"`
|
||||
|
||||
Restart bool `vic:"0.1" scope:"read-only" key:"restart"`
|
||||
|
||||
// StopSignal is the signal name or number used to stop container session
|
||||
StopSignal string `vic:"0.1" scope:"read-only" key:"stopSignal"`
|
||||
|
||||
// Diagnostics holds basic diagnostics data
|
||||
Diagnostics Diagnostics `vic:"0.1" scope:"read-only" key:"diagnostics"`
|
||||
|
||||
// Maps the intent to the signal for this specific app
|
||||
// Signals map[int]int
|
||||
|
||||
// Use struct composition to add in the guest specific portions
|
||||
// http://attilaolah.eu/2014/09/10/json-and-struct-composition-in-go/
|
||||
// ulimits
|
||||
// user
|
||||
// rootfs - within the container context
|
||||
|
||||
// User and group for setuid programs.
|
||||
// Need to go here since UID/GID resolution must be done on appliance
|
||||
User string `vic:"0.1" scope:"read-only" key:"User"`
|
||||
Group string `vic:"0.1" scope:"read-only" key:"Group"`
|
||||
}
|
||||
|
||||
type Detail struct {
|
||||
|
||||
// creation, started & stopped timestamps
|
||||
CreateTime int64 `vic:"0.1" scope:"read-write" key:"createtime"`
|
||||
StartTime int64 `vic:"0.1" scope:"read-write" key:"starttime"`
|
||||
StopTime int64 `vic:"0.1" scope:"read-write" key:"stoptime"`
|
||||
}
|
||||
81
vendor/github.com/vmware/vic/lib/migration/samples/config/v1/executor/network_interface.go
generated
vendored
Normal file
81
vendor/github.com/vmware/vic/lib/migration/samples/config/v1/executor/network_interface.go
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
// Copyright 2017 VMware, Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package executor
|
||||
|
||||
import (
|
||||
"net"
|
||||
|
||||
"github.com/vmware/vic/pkg/ip"
|
||||
)
|
||||
|
||||
// NetworkEndpoint describes a network presence in the form a vNIC in sufficient detail that it can be:
|
||||
// a. created - the vNIC added to a VM
|
||||
// b. identified - the guestOS can determine which interface it corresponds to
|
||||
// c. configured - the guestOS can configure the interface correctly
|
||||
type NetworkEndpoint struct {
|
||||
// Common.Name - the nic alias requested (only one name and one alias possible in linux)
|
||||
// Common.ID - pci slot of the vnic allowing for interface identifcation in-guest
|
||||
Common
|
||||
|
||||
// Whether this endpoint's IP was specified by the client (true if it was)
|
||||
Static bool `vic:"0.1" scope:"read-only" key:"static"`
|
||||
|
||||
// IP address to assign
|
||||
IP *net.IPNet `vic:"0.1" scope:"read-only" key:"ip"`
|
||||
|
||||
// Actual IP address assigned
|
||||
Assigned net.IPNet `vic:"0.1" scope:"read-write" key:"assigned"`
|
||||
|
||||
// The network in which this information should be interpreted. This is embedded directly rather than
|
||||
// as a pointer so that we can ensure the data is consistent
|
||||
Network ContainerNetwork `vic:"0.1" scope:"read-only" key:"network"`
|
||||
|
||||
// The list of exposed ports on the container
|
||||
Ports []string `vic:"0.1" scope:"read-only" key:"ports"`
|
||||
}
|
||||
|
||||
// ContainerNetwork is the data needed on a per container basis both for vSphere to ensure it's attached
|
||||
// to the correct network, and in the guest to ensure the interface is correctly configured.
|
||||
type ContainerNetwork struct {
|
||||
// Common.Name - the symbolic name for the network, e.g. web or backend
|
||||
// Common.ID - identifier of the underlay for the network
|
||||
Common
|
||||
|
||||
Type string `vic:"0.1" scope:"read-write" key:"type"`
|
||||
|
||||
// Destinations is a list of CIDRs used for routing traffic to the gateway
|
||||
Destinations []net.IPNet `vic:"0.1" scope:"read-only" key:"destinations"`
|
||||
|
||||
// The network scope the IP belongs to.
|
||||
// The IP address is the default gateway
|
||||
Gateway net.IPNet `vic:"0.1" scope:"read-only" key:"gateway"`
|
||||
|
||||
// Should this gateway be the default route for containers on the network
|
||||
Default bool `vic:"0.1" scope:"read-only" key:"default"`
|
||||
|
||||
// The set of nameservers associated with this network - may be empty
|
||||
Nameservers []net.IP `vic:"0.1" scope:"read-only" key:"dns"`
|
||||
|
||||
// The IP ranges for this network
|
||||
Pools []ip.Range `vic:"0.1" scope:"read-only" key:"pools"`
|
||||
|
||||
// set of network wide links and aliases for this container on this network
|
||||
Aliases []string `vic:"0.1" scope:"hidden" key:"aliases"`
|
||||
|
||||
Assigned struct {
|
||||
Gateway net.IPNet `vic:"0.1" scope:"read-write" key:"gateway"`
|
||||
Nameservers []net.IP `vic:"0.1" scope:"read-write" key:"dns"`
|
||||
} `vic:"0.1" scope:"read-write" key:"assigned"`
|
||||
}
|
||||
190
vendor/github.com/vmware/vic/lib/migration/samples/config/v1/virtual_container_host.go
generated
vendored
Normal file
190
vendor/github.com/vmware/vic/lib/migration/samples/config/v1/virtual_container_host.go
generated
vendored
Normal file
@@ -0,0 +1,190 @@
|
||||
// Copyright 2017 VMware, Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
"net"
|
||||
"net/mail"
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
"github.com/vmware/govmomi/vim25/types"
|
||||
"github.com/vmware/vic/lib/config/executor"
|
||||
)
|
||||
|
||||
// PatternToken is a set of tokens that can be placed into string constants
|
||||
// for containerVMs that will be replaced with the specific values
|
||||
type PatternToken string
|
||||
|
||||
const (
|
||||
// VM is the VM name - i.e. [ds] {vm}/{vm}.vmx
|
||||
VM PatternToken = "{vm}"
|
||||
// ID is the container ID for the VM
|
||||
ID = "{id}"
|
||||
// Name is the container name of the VM
|
||||
Name = "{name}"
|
||||
)
|
||||
|
||||
// Can we just treat the VCH appliance as a containerVM booting off a specific bootstrap image
|
||||
// It has many of the same requirements (around networks being attached, version recorded,
|
||||
// volumes mounted, et al). Each of the components can easily be captured as a Session given they
|
||||
// are simply processes.
|
||||
// This would require that the bootstrap read session record for the VM and relaunch them - that
|
||||
// actually aligns very well with containerVMs restarting their processes if restarted directly
|
||||
// (this is obviously a behaviour we'd want to toggles for in regular containers).
|
||||
|
||||
// VirtualContainerHostConfigSpec holds the metadata for a Virtual Container Host that should be visible inside the appliance VM.
|
||||
type VirtualContainerHostConfigSpec struct {
|
||||
// The base config for the appliance. This includes the networks that are to be attached
|
||||
// and disks to be mounted.
|
||||
// Networks are keyed by interface name
|
||||
executor.ExecutorConfig `vic:"0.1" scope:"read-only" key:"init"`
|
||||
|
||||
// vSphere connection configuration
|
||||
Connection `vic:"0.1" scope:"read-only" key:"connect"`
|
||||
|
||||
// basic contact information
|
||||
Contacts `vic:"0.1" scope:"read-only" key:"contact"`
|
||||
|
||||
// certificate configuration, for both inbound and outbound access
|
||||
Certificate `vic:"0.1" scope:"read-only" key:"cert"`
|
||||
|
||||
// Port Layer - storage
|
||||
Storage `vic:"0.1" scope:"read-only" key:"storage"`
|
||||
|
||||
// Port Layer - network
|
||||
Network `vic:"0.1" scope:"read-only" key:"network"`
|
||||
|
||||
// Port Layer - exec
|
||||
Container `vic:"0.1" scope:"read-only" key:"container"`
|
||||
|
||||
// Registry configuration for Imagec
|
||||
Registry `vic:"0.1" scope:"read-only" key:"registry"`
|
||||
|
||||
// configuration for vic-machine
|
||||
CreateBridgeNetwork bool `vic:"0.1" scope:"read-only" key:"create_bridge_network"`
|
||||
}
|
||||
|
||||
// ContainerConfig holds the container configuration for a virtual container host
|
||||
type Container struct {
|
||||
// Default containerVM capacity
|
||||
ContainerVMSize Resources `vic:"0.1" scope:"read-only" recurse:"depth=0"`
|
||||
// Resource pools under which all containers will be created
|
||||
ComputeResources []types.ManagedObjectReference `vic:"0.1" scope:"read-only"`
|
||||
// Path of the ISO to use for bootstrapping containers
|
||||
BootstrapImagePath string `vic:"0.1" scope:"read-only" key:"bootstrap_image_path"`
|
||||
// Allow custom naming convention for containerVMs
|
||||
ContainerNameConvention string
|
||||
// Permitted datastore URLs for container storage for this virtual container host
|
||||
ContainerStores []url.URL `vic:"0.1" scope:"read-only" recurse:"depth=0"`
|
||||
}
|
||||
|
||||
// RegistryConfig defines the registries virtual container host can talk to
|
||||
type Registry struct {
|
||||
// Whitelist of registries
|
||||
RegistryWhitelist []url.URL `vic:"0.1" scope:"read-only" recurse:"depth=0"`
|
||||
// Blacklist of registries
|
||||
RegistryBlacklist []url.URL `vic:"0.1" scope:"read-only" recurse:"depth=0"`
|
||||
// Insecure registries
|
||||
InsecureRegistries []url.URL `vic:"0.1" scope:"read-only" key:"insecure_registries"`
|
||||
}
|
||||
|
||||
// NetworkConfig defines the network configuration of virtual container host
|
||||
type Network struct {
|
||||
// The network to use by default to provide access to the world
|
||||
BridgeNetwork string `vic:"0.1" scope:"read-only" key:"bridge_network"`
|
||||
// Published networks available for containers to join, keyed by consumption name
|
||||
ContainerNetworks map[string]*executor.ContainerNetwork `vic:"0.1" scope:"read-only" key:"container_networks"`
|
||||
// The IP range for the bridge networks
|
||||
BridgeIPRange *net.IPNet `vic:"0.1" scope:"read-only" key:"bridge-ip-range"`
|
||||
// The width of each new bridge network
|
||||
BridgeNetworkWidth *net.IPMask `vic:"0.1" scope:"read-only" key:"bridge-net-width"`
|
||||
}
|
||||
|
||||
// StorageConfig defines the storage configuration including images and volumes
|
||||
type Storage struct {
|
||||
// Datastore URLs for image stores - the top layer is [0], the bottom layer is [len-1]
|
||||
ImageStores []url.URL `vic:"0.1" scope:"read-only" key:"image_stores"`
|
||||
// Permitted datastore URL roots for volumes
|
||||
// Keyed by the volume store name (which is used by the docker user to
|
||||
// refer to the datstore + path), valued by the datastores and the path.
|
||||
VolumeLocations map[string]*url.URL `vic:"0.1" scope:"read-only"`
|
||||
// default size for root image
|
||||
ScratchSize int64 `vic:"0.1" scope:"read-only" key:"scratch_size"`
|
||||
}
|
||||
|
||||
type Certificate struct {
|
||||
// Certificates for user authentication - this needs to be expanded to allow for directory server auth
|
||||
UserCertificates []*RawCertificate
|
||||
// Certificates for general outgoing network access, keyed by CIDR (IPNet.String())
|
||||
NetworkCertificates map[string]*RawCertificate
|
||||
// The certificate used to validate the appliance to clients
|
||||
HostCertificate *RawCertificate `vic:"0.1" scope:"read-only"`
|
||||
// The CAs to validate client connections
|
||||
CertificateAuthorities []byte `vic:"0.1" scope:"read-only"`
|
||||
// The CAs to validate docker registry connections
|
||||
RegistryCertificateAuthorities []byte `vic:"0.1" scope:"read-only"`
|
||||
// Certificates for specific system access, keyed by FQDN
|
||||
HostCertificates map[string]*RawCertificate
|
||||
}
|
||||
|
||||
// Connection holds the vSphere connection configuration
|
||||
type Connection struct {
|
||||
// The sdk URL
|
||||
Target string `vic:"0.1" scope:"read-only" key:"target"`
|
||||
// Username for target login
|
||||
Username string `vic:"0.1" scope:"read-only" key:"username"`
|
||||
// Token is an SSO token or password
|
||||
Token string `vic:"0.1" scope:"secret" key:"token"`
|
||||
// TargetThumbprint is the SHA-1 digest of the Target's public certificate
|
||||
TargetThumbprint string `vic:"0.1" scope:"read-only" key:"target_thumbprint"`
|
||||
// The session timeout
|
||||
Keepalive time.Duration `vic:"0.1" scope:"read-only" key:"keepalive"`
|
||||
}
|
||||
|
||||
type Contacts struct {
|
||||
// Administrative contact for the Virtual Container Host
|
||||
Admin []mail.Address
|
||||
// Administrative contact for hosting infrastructure
|
||||
InfrastructureAdmin []mail.Address
|
||||
}
|
||||
|
||||
// RawCertificate is present until we add extraconfig support for [][]byte slices that are present
|
||||
// in tls.Certificate
|
||||
type RawCertificate struct {
|
||||
Key []byte `vic:"0.1" scope:"secret"`
|
||||
Cert []byte
|
||||
}
|
||||
|
||||
// CustomerExperienceImprovementProgram provides configuration for the phone home mechanism
|
||||
// This is broken out so that we can have more granular configuration in here in the future
|
||||
// and so that it is insulated from changes to Virtual Container Host structure
|
||||
type CustomerExperienceImprovementProgram struct {
|
||||
// The server target is as follows, where the uuid is the raw number, no dashes
|
||||
// "https://vcsa.vmware.com/ph-stg/api/hyper/send?_v=1.0&_c=vic.1_0&_i="+vc.uuid
|
||||
// If this is non-nil then it's enabled
|
||||
CEIPGateway url.URL
|
||||
}
|
||||
|
||||
// Resources is used instead of the ResourceAllocation structs in govmomi as
|
||||
// those don't currently hold IO or storage related data.
|
||||
type Resources struct {
|
||||
CPU types.ResourceAllocationInfo
|
||||
Memory types.ResourceAllocationInfo
|
||||
IO types.ResourceAllocationInfo
|
||||
Storage types.ResourceAllocationInfo
|
||||
}
|
||||
|
||||
// Remove all methods from this file to reduce binary size
|
||||
218
vendor/github.com/vmware/vic/lib/migration/samples/config/v2/executor/container_vm.go
generated
vendored
Normal file
218
vendor/github.com/vmware/vic/lib/migration/samples/config/v2/executor/container_vm.go
generated
vendored
Normal file
@@ -0,0 +1,218 @@
|
||||
// Copyright 2017 VMware, Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package executor
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
"github.com/vmware/vic/pkg/version"
|
||||
)
|
||||
|
||||
type State int
|
||||
|
||||
const (
|
||||
STARTED State = iota
|
||||
EXITED
|
||||
KILLED
|
||||
)
|
||||
|
||||
// Common data between managed entities, across execution environments
|
||||
type Common struct {
|
||||
// A reference to the components hosting execution environment, if any
|
||||
ExecutionEnvironment string
|
||||
|
||||
// Unambiguous ID with meaning in the context of its hosting execution environment
|
||||
ID string `vic:"0.1" scope:"read-only" key:"id"`
|
||||
|
||||
// Convenience field to record a human readable name
|
||||
Name string `vic:"0.1" scope:"read-only" key:"name"`
|
||||
|
||||
// Freeform notes related to the entity
|
||||
Notes string `vic:"0.1" scope:"hidden" key:"notes"`
|
||||
}
|
||||
|
||||
// Diagnostics records some basic control and lifecycle information for diagnostic purposes
|
||||
type Diagnostics struct {
|
||||
// Should debugging be enabled on whatever component this is and at what level
|
||||
DebugLevel int `vic:"0.1" scope:"read-only" key:"debug"`
|
||||
|
||||
// RessurectionCount is a log of how many times the entity has been restarted due
|
||||
// to error exit
|
||||
ResurrectionCount int `vic:"0.1" scope:"read-write" key:"resurrections"`
|
||||
// ExitLogs is a best effort record of the time of process death and the cause for
|
||||
// restartable entities
|
||||
ExitLogs []ExitLog `vic:"0.1" scope:"read-write" key:"exitlogs"`
|
||||
}
|
||||
|
||||
// ExitLog records some basic diagnostics about anomalous exit for restartable entities
|
||||
type ExitLog struct {
|
||||
Time time.Time
|
||||
ExitStatus int
|
||||
Message string
|
||||
}
|
||||
|
||||
// MountSpec details a mount that must be executed within the executor
|
||||
// A mount is a URI -> path mapping with a credential of some kind
|
||||
// In the case of a labeled disk:
|
||||
// label://<label name> => </mnt/path>
|
||||
type MountSpec struct {
|
||||
// A URI->path mapping, e.g.
|
||||
// May contain credentials
|
||||
Source url.URL `vic:"0.1" scope:"read-only" key:"source"`
|
||||
|
||||
// The path in the executor at which this should be mounted
|
||||
Path string `vic:"0.1" scope:"read-only" key:"dest"`
|
||||
|
||||
// Freeform mode string, which could translate directly to mount options
|
||||
// We may want to turn this into a more structured form eventually
|
||||
Mode string `vic:"0.1" scope:"read-only" key:"mode"`
|
||||
}
|
||||
|
||||
// ContainerVM holds that data tightly associated with a containerVM, but that should not
|
||||
// be visible to the guest. This is the external complement to ExecutorConfig.
|
||||
type ContainerVM struct {
|
||||
Common
|
||||
|
||||
// The version of the bootstrap image that this container was booted from.
|
||||
Version string
|
||||
|
||||
// Name aliases for this specific container, Maps alias to unambiguous name
|
||||
// This uses unambiguous name rather than reified network endpoint to persist
|
||||
// the intent rather than a point-in-time manifesting of that intent.
|
||||
Aliases map[string]string
|
||||
|
||||
// The location of the interaction service that the tether should connect to. Examples:
|
||||
// * tcp://x.x.x.x:2377
|
||||
// * vmci://moid - should this be an moid or a VMCI CID? Does one insulate us from reboots?
|
||||
Interaction url.URL
|
||||
|
||||
// Key is the host key used during communicate back with the Interaction endpoint if any
|
||||
// Used if the vSocket agent is responsible for authenticating the connection
|
||||
AgentKey []byte
|
||||
}
|
||||
|
||||
// ExecutorConfig holds the data tightly associated with an Executor. This is distinct from Sessions
|
||||
// in that there is no process inherently associated - this is closer to a ThreadPool than a Thread and
|
||||
// is the owner of the shared filesystem environment. This is the guest visible complement to ContainerVM.
|
||||
type ExecutorConfig struct {
|
||||
Common `vic:"0.1" scope:"read-only" key:"common"`
|
||||
|
||||
// CreateTime stamp
|
||||
CreateTime int64 `vic:"0.1" scope:"read-write" key:"createtime"`
|
||||
|
||||
// Diagnostics holds basic diagnostics data
|
||||
Diagnostics Diagnostics `vic:"0.1" scope:"read-only" key:"diagnostics"`
|
||||
|
||||
// Sessions is the set of sessions currently hosted by this executor
|
||||
// These are keyed by session ID
|
||||
Sessions map[string]*SessionConfig `vic:"0.1" scope:"read-only" key:"sessions"`
|
||||
|
||||
// Maps the mount name to the detail mount specification
|
||||
Mounts map[string]MountSpec `vic:"0.1" scope:"read-only" key:"mounts"`
|
||||
|
||||
// This describes an executors presence on a network, and contains sufficient
|
||||
// information to configure the interface in the guest.
|
||||
Networks map[string]*NetworkEndpoint `vic:"0.1" scope:"read-only" key:"networks"`
|
||||
|
||||
// Key is the host key used during communicate back with the Interaction endpoint if any
|
||||
// Used if the in-guest tether is responsible for authenticating the connection
|
||||
Key []byte `vic:"0.1" scope:"read-only" key:"key"`
|
||||
|
||||
// Layer id that is backing this container VM
|
||||
LayerID string `vic:"0.1" scope:"read-only" key:"layerid"`
|
||||
|
||||
// Blob metadata for the caller
|
||||
Annotations map[string]string `vic:"0.1" scope:"hidden" key:"annotations"`
|
||||
|
||||
// Repository requested by user
|
||||
// TODO: a bit docker specific
|
||||
RepoName string `vic:"0.1" scope:"read-only" key:"repo"`
|
||||
|
||||
// version
|
||||
Version *version.Build `vic:"0.1" scope:"read-only" key:"version"`
|
||||
}
|
||||
|
||||
// Cmd is here because the encoding packages seem to have issues with the full exec.Cmd struct
|
||||
type Cmd struct {
|
||||
// Path is the command to run
|
||||
Path string `vic:"0.1" scope:"read-only" key:"Path"`
|
||||
|
||||
// Args is the command line arguments including the command in Args[0]
|
||||
Args []string `vic:"0.1" scope:"read-only" key:"Args"`
|
||||
|
||||
// Env specifies the environment of the process
|
||||
Env []string `vic:"0.1" scope:"read-only" key:"Env"`
|
||||
|
||||
// Dir specifies the working directory of the command
|
||||
Dir string `vic:"0.1" scope:"read-only" key:"Dir"`
|
||||
}
|
||||
|
||||
// SessionConfig defines the content of a session - this maps to the root of a process tree
|
||||
// inside an executor
|
||||
// This is close to but not perfectly aligned with the new docker/docker/daemon/execdriver/driver:CommonProcessConfig
|
||||
type SessionConfig struct {
|
||||
// The primary session may have the same ID as the executor owning it
|
||||
Common `vic:"0.1" scope:"read-only" key:"common"`
|
||||
Detail `vic:"0.1" scope:"read-write" key:"detail"`
|
||||
|
||||
// The primary process for the session
|
||||
Cmd Cmd `vic:"0.1" scope:"read-only" key:"cmd"`
|
||||
|
||||
// Allow attach
|
||||
Attach bool `vic:"0.1" scope:"read-only" key:"attach"`
|
||||
|
||||
OpenStdin bool `vic:"0.1" scope:"read-only" key:"openstdin"`
|
||||
|
||||
// Delay launching the Cmd until an attach request comes
|
||||
RunBlock bool `vic:"0.1" scope:"read-only" key:"runblock"`
|
||||
|
||||
// Allocate a tty or not
|
||||
Tty bool `vic:"0.1" scope:"read-only" key:"tty"`
|
||||
|
||||
ExitStatus int `vic:"0.1" scope:"read-write" key:"status"`
|
||||
|
||||
Started string `vic:"0.1" scope:"read-write" key:"started"`
|
||||
|
||||
Restart bool `vic:"0.1" scope:"read-only" key:"restart"`
|
||||
|
||||
// StopSignal is the signal name or number used to stop container session
|
||||
StopSignal string `vic:"0.1" scope:"read-only" key:"stopSignal"`
|
||||
|
||||
// Diagnostics holds basic diagnostics data
|
||||
Diagnostics Diagnostics `vic:"0.1" scope:"read-only" key:"diagnostics"`
|
||||
|
||||
// Maps the intent to the signal for this specific app
|
||||
// Signals map[int]int
|
||||
|
||||
// Use struct composition to add in the guest specific portions
|
||||
// http://attilaolah.eu/2014/09/10/json-and-struct-composition-in-go/
|
||||
// ulimits
|
||||
// user
|
||||
// rootfs - within the container context
|
||||
|
||||
// User and group for setuid programs.
|
||||
// Need to go here since UID/GID resolution must be done on appliance
|
||||
User string `vic:"0.1" scope:"read-only" key:"User"`
|
||||
Group string `vic:"0.1" scope:"read-only" key:"Group"`
|
||||
}
|
||||
|
||||
type Detail struct {
|
||||
|
||||
// creation, started & stopped timestamps
|
||||
CreateTime int64 `vic:"0.1" scope:"read-write" key:"createtime"`
|
||||
StartTime int64 `vic:"0.1" scope:"read-write" key:"starttime"`
|
||||
StopTime int64 `vic:"0.1" scope:"read-write" key:"stoptime"`
|
||||
}
|
||||
81
vendor/github.com/vmware/vic/lib/migration/samples/config/v2/executor/network_interface.go
generated
vendored
Normal file
81
vendor/github.com/vmware/vic/lib/migration/samples/config/v2/executor/network_interface.go
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
// Copyright 2017 VMware, Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package executor
|
||||
|
||||
import (
|
||||
"net"
|
||||
|
||||
"github.com/vmware/vic/pkg/ip"
|
||||
)
|
||||
|
||||
// NetworkEndpoint describes a network presence in the form a vNIC in sufficient detail that it can be:
|
||||
// a. created - the vNIC added to a VM
|
||||
// b. identified - the guestOS can determine which interface it corresponds to
|
||||
// c. configured - the guestOS can configure the interface correctly
|
||||
type NetworkEndpoint struct {
|
||||
// Common.Name - the nic alias requested (only one name and one alias possible in linux)
|
||||
// Common.ID - pci slot of the vnic allowing for interface identifcation in-guest
|
||||
Common
|
||||
|
||||
// Whether this endpoint's IP was specified by the client (true if it was)
|
||||
Static bool `vic:"0.1" scope:"read-only" key:"static"`
|
||||
|
||||
// IP address to assign
|
||||
IP *net.IPNet `vic:"0.1" scope:"read-only" key:"ip"`
|
||||
|
||||
// Actual IP address assigned
|
||||
Assigned net.IPNet `vic:"0.1" scope:"read-write" key:"assigned"`
|
||||
|
||||
// The network in which this information should be interpreted. This is embedded directly rather than
|
||||
// as a pointer so that we can ensure the data is consistent
|
||||
Network ContainerNetwork `vic:"0.1" scope:"read-only" key:"network"`
|
||||
|
||||
// The list of exposed ports on the container
|
||||
Ports []string `vic:"0.1" scope:"read-only" key:"ports"`
|
||||
}
|
||||
|
||||
// ContainerNetwork is the data needed on a per container basis both for vSphere to ensure it's attached
|
||||
// to the correct network, and in the guest to ensure the interface is correctly configured.
|
||||
type ContainerNetwork struct {
|
||||
// Common.Name - the symbolic name for the network, e.g. web or backend
|
||||
// Common.ID - identifier of the underlay for the network
|
||||
Common
|
||||
|
||||
Type string `vic:"0.1" scope:"read-write" key:"type"`
|
||||
|
||||
// Destinations is a list of CIDRs used for routing traffic to the gateway
|
||||
Destinations []net.IPNet `vic:"0.1" scope:"read-only" key:"destinations"`
|
||||
|
||||
// The network scope the IP belongs to.
|
||||
// The IP address is the default gateway
|
||||
Gateway net.IPNet `vic:"0.1" scope:"read-only" key:"gateway"`
|
||||
|
||||
// Should this gateway be the default route for containers on the network
|
||||
Default bool `vic:"0.1" scope:"read-only" key:"default"`
|
||||
|
||||
// The set of nameservers associated with this network - may be empty
|
||||
Nameservers []net.IP `vic:"0.1" scope:"read-only" key:"dns"`
|
||||
|
||||
// The IP ranges for this network
|
||||
Pools []ip.Range `vic:"0.1" scope:"read-only" key:"pools"`
|
||||
|
||||
// set of network wide links and aliases for this container on this network
|
||||
Aliases []string `vic:"0.1" scope:"hidden" key:"aliases"`
|
||||
|
||||
Assigned struct {
|
||||
Gateway net.IPNet `vic:"0.1" scope:"read-write" key:"gateway"`
|
||||
Nameservers []net.IP `vic:"0.1" scope:"read-write" key:"dns"`
|
||||
} `vic:"0.1" scope:"read-write" key:"assigned"`
|
||||
}
|
||||
190
vendor/github.com/vmware/vic/lib/migration/samples/config/v2/virtual_container_host.go
generated
vendored
Normal file
190
vendor/github.com/vmware/vic/lib/migration/samples/config/v2/virtual_container_host.go
generated
vendored
Normal file
@@ -0,0 +1,190 @@
|
||||
// Copyright 2017 VMware, Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package v2
|
||||
|
||||
import (
|
||||
"net"
|
||||
"net/mail"
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
"github.com/vmware/govmomi/vim25/types"
|
||||
"github.com/vmware/vic/lib/config/executor"
|
||||
)
|
||||
|
||||
// PatternToken is a set of tokens that can be placed into string constants
|
||||
// for containerVMs that will be replaced with the specific values
|
||||
type PatternToken string
|
||||
|
||||
const (
|
||||
// VM is the VM name - i.e. [ds] {vm}/{vm}.vmx
|
||||
VM PatternToken = "{vm}"
|
||||
// ID is the container ID for the VM
|
||||
ID = "{id}"
|
||||
// Name is the container name of the VM
|
||||
Name = "{name}"
|
||||
)
|
||||
|
||||
// Can we just treat the VCH appliance as a containerVM booting off a specific bootstrap image
|
||||
// It has many of the same requirements (around networks being attached, version recorded,
|
||||
// volumes mounted, et al). Each of the components can easily be captured as a Session given they
|
||||
// are simply processes.
|
||||
// This would require that the bootstrap read session record for the VM and relaunch them - that
|
||||
// actually aligns very well with containerVMs restarting their processes if restarted directly
|
||||
// (this is obviously a behaviour we'd want to toggles for in regular containers).
|
||||
|
||||
// VirtualContainerHostConfigSpec holds the metadata for a Virtual Container Host that should be visible inside the appliance VM.
|
||||
type VirtualContainerHostConfigSpec struct {
|
||||
// The base config for the appliance. This includes the networks that are to be attached
|
||||
// and disks to be mounted.
|
||||
// Networks are keyed by interface name
|
||||
executor.ExecutorConfig `vic:"0.1" scope:"read-only" key:"init"`
|
||||
|
||||
// vSphere connection configuration
|
||||
Connection `vic:"0.1" scope:"read-only" key:"connect"`
|
||||
|
||||
// basic contact information
|
||||
Contacts `vic:"0.1" scope:"read-only" key:"contact"`
|
||||
|
||||
// certificate configuration, for both inbound and outbound access
|
||||
Certificate `vic:"0.1" scope:"read-only" key:"cert"`
|
||||
|
||||
// Port Layer - storage
|
||||
Storage `vic:"0.1" scope:"read-only" key:"storage"`
|
||||
|
||||
// Port Layer - network
|
||||
Network `vic:"0.1" scope:"read-only" key:"network"`
|
||||
|
||||
// Port Layer - exec
|
||||
Container `vic:"0.1" scope:"read-only" key:"container"`
|
||||
|
||||
// Registry configuration for Imagec
|
||||
Registry `vic:"0.1" scope:"read-only" key:"registry"`
|
||||
|
||||
// configuration for vic-machine
|
||||
CreateBridgeNetwork bool `vic:"0.1" scope:"read-only" key:"create_bridge_network"`
|
||||
}
|
||||
|
||||
// ContainerConfig holds the container configuration for a virtual container host
|
||||
type Container struct {
|
||||
// Default containerVM capacity
|
||||
ContainerVMSize Resources `vic:"0.1" scope:"read-only" recurse:"depth=0"`
|
||||
// Resource pools under which all containers will be created
|
||||
ComputeResources []types.ManagedObjectReference `vic:"0.1" scope:"read-only"`
|
||||
// Path of the ISO to use for bootstrapping containers
|
||||
BootstrapImagePath string `vic:"0.1" scope:"read-only" key:"bootstrap_image_path"`
|
||||
// Allow custom naming convention for containerVMs
|
||||
ContainerNameConvention string
|
||||
// Permitted datastore URLs for container storage for this virtual container host
|
||||
ContainerStores []url.URL `vic:"0.1" scope:"read-only" recurse:"depth=0"`
|
||||
}
|
||||
|
||||
// RegistryConfig defines the registries virtual container host can talk to
|
||||
type Registry struct {
|
||||
// Whitelist of registries
|
||||
RegistryWhitelist []url.URL `vic:"0.1" scope:"read-only" recurse:"depth=0"`
|
||||
// Blacklist of registries
|
||||
RegistryBlacklist []url.URL `vic:"0.1" scope:"read-only" recurse:"depth=0"`
|
||||
// Insecure registries
|
||||
InsecureRegistries []url.URL `vic:"0.1" scope:"read-only" key:"insecure_registries"`
|
||||
}
|
||||
|
||||
// NetworkConfig defines the network configuration of virtual container host
|
||||
type Network struct {
|
||||
// The network to use by default to provide access to the world
|
||||
BridgeNetwork string `vic:"0.1" scope:"read-only" key:"bridge_network"`
|
||||
// Published networks available for containers to join, keyed by consumption name
|
||||
ContainerNetworks map[string]*executor.ContainerNetwork `vic:"0.1" scope:"read-only" key:"container_networks"`
|
||||
// The IP range for the bridge networks
|
||||
BridgeIPRange *net.IPNet `vic:"0.1" scope:"read-only" key:"bridge-ip-range"`
|
||||
// The width of each new bridge network
|
||||
BridgeNetworkWidth *net.IPMask `vic:"0.1" scope:"read-only" key:"bridge-net-width"`
|
||||
}
|
||||
|
||||
// StorageConfig defines the storage configuration including images and volumes
|
||||
type Storage struct {
|
||||
// Datastore URLs for image stores - the top layer is [0], the bottom layer is [len-1]
|
||||
ImageStores []url.URL `vic:"0.1" scope:"read-only" key:"image_stores"`
|
||||
// Permitted datastore URL roots for volumes
|
||||
// Keyed by the volume store name (which is used by the docker user to
|
||||
// refer to the datstore + path), valued by the datastores and the path.
|
||||
VolumeLocations map[string]*url.URL `vic:"0.1" scope:"read-only"`
|
||||
// default size for root image
|
||||
ScratchSize int64 `vic:"0.1" scope:"read-only" key:"scratch_size"`
|
||||
}
|
||||
|
||||
type Certificate struct {
|
||||
// Certificates for user authentication - this needs to be expanded to allow for directory server auth
|
||||
UserCertificates []*RawCertificate
|
||||
// Certificates for general outgoing network access, keyed by CIDR (IPNet.String())
|
||||
NetworkCertificates map[string]*RawCertificate
|
||||
// The certificate used to validate the appliance to clients
|
||||
HostCertificate *RawCertificate `vic:"0.1" scope:"read-only"`
|
||||
// The CAs to validate client connections
|
||||
CertificateAuthorities []byte `vic:"0.1" scope:"read-only"`
|
||||
// The CAs to validate docker registry connections
|
||||
RegistryCertificateAuthorities []byte `vic:"0.1" scope:"read-only"`
|
||||
// Certificates for specific system access, keyed by FQDN
|
||||
HostCertificates map[string]*RawCertificate
|
||||
}
|
||||
|
||||
// Connection holds the vSphere connection configuration
|
||||
type Connection struct {
|
||||
// The sdk URL
|
||||
Target string `vic:"0.1" scope:"read-only" key:"target"`
|
||||
// Username for target login
|
||||
Username string `vic:"0.1" scope:"read-only" key:"username"`
|
||||
// Token is an SSO token or password
|
||||
Token string `vic:"0.1" scope:"secret" key:"token"`
|
||||
// TargetThumbprint is the SHA-1 digest of the Target's public certificate
|
||||
TargetThumbprint string `vic:"0.1" scope:"read-only" key:"target_thumbprint"`
|
||||
// The session timeout
|
||||
Keepalive time.Duration `vic:"0.1" scope:"read-only" key:"keepalive"`
|
||||
}
|
||||
|
||||
type Contacts struct {
|
||||
// Administrative contact for the Virtual Container Host
|
||||
Admin []mail.Address
|
||||
// Administrative contact for hosting infrastructure
|
||||
InfrastructureAdmin []mail.Address
|
||||
}
|
||||
|
||||
// RawCertificate is present until we add extraconfig support for [][]byte slices that are present
|
||||
// in tls.Certificate
|
||||
type RawCertificate struct {
|
||||
Key []byte `vic:"0.1" scope:"secret"`
|
||||
Cert []byte
|
||||
}
|
||||
|
||||
// CustomerExperienceImprovementProgram provides configuration for the phone home mechanism
|
||||
// This is broken out so that we can have more granular configuration in here in the future
|
||||
// and so that it is insulated from changes to Virtual Container Host structure
|
||||
type CustomerExperienceImprovementProgram struct {
|
||||
// The server target is as follows, where the uuid is the raw number, no dashes
|
||||
// "https://vcsa.vmware.com/ph-stg/api/hyper/send?_v=1.0&_c=vic.1_0&_i="+vc.uuid
|
||||
// If this is non-nil then it's enabled
|
||||
CEIPGateway url.URL
|
||||
}
|
||||
|
||||
// Resources is used instead of the ResourceAllocation structs in govmomi as
|
||||
// those don't currently hold IO or storage related data.
|
||||
type Resources struct {
|
||||
CPU types.ResourceAllocationInfo
|
||||
Memory types.ResourceAllocationInfo
|
||||
IO types.ResourceAllocationInfo
|
||||
Storage types.ResourceAllocationInfo
|
||||
}
|
||||
|
||||
// Remove all methods from this file to reduce binary size
|
||||
23
vendor/github.com/vmware/vic/lib/migration/samples/plugins/init.go
generated
vendored
Normal file
23
vendor/github.com/vmware/vic/lib/migration/samples/plugins/init.go
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
// Copyright 2017 VMware, Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package plugins
|
||||
|
||||
// import all plugin packages here to register plugins
|
||||
|
||||
import (
|
||||
// imported for the side effect
|
||||
_ "github.com/vmware/vic/lib/migration/samples/plugins/plugin1"
|
||||
_ "github.com/vmware/vic/lib/migration/samples/plugins/plugin2"
|
||||
)
|
||||
111
vendor/github.com/vmware/vic/lib/migration/samples/plugins/plugin1/stop_signal_rename_sample.go
generated
vendored
Normal file
111
vendor/github.com/vmware/vic/lib/migration/samples/plugins/plugin1/stop_signal_rename_sample.go
generated
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
// Copyright 2017 VMware, Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package plugin1
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
|
||||
"github.com/vmware/vic/lib/migration/errors"
|
||||
"github.com/vmware/vic/lib/migration/manager"
|
||||
"github.com/vmware/vic/pkg/trace"
|
||||
"github.com/vmware/vic/pkg/vsphere/extraconfig"
|
||||
"github.com/vmware/vic/pkg/vsphere/session"
|
||||
)
|
||||
|
||||
// sample plugin to migrate data in appliance configuration VirtualContainerHost
|
||||
// If only a couple of items changed in the configuration, you don't have to copy all VirtualContainerHost. Only define the few items used by
|
||||
// this upgrade plugin will simplify the extraconfig encoding/decoding process
|
||||
const (
|
||||
version = 1
|
||||
target = manager.ApplianceConfigure
|
||||
)
|
||||
|
||||
func init() {
|
||||
defer trace.End(trace.Begin(fmt.Sprintf("Registering plugin %s:%d", target, version)))
|
||||
if err := manager.Migrator.Register(version, target, &ApplianceStopSignalRename{}); err != nil {
|
||||
log.Errorf("Failed to register plugin %s:%d, %s", target, version, err)
|
||||
}
|
||||
}
|
||||
|
||||
// ApplianceStopSignalRename is plugin for vic 0.8.0-GA version upgrade
|
||||
type ApplianceStopSignalRename struct {
|
||||
}
|
||||
|
||||
type OldStopSignal struct {
|
||||
ExecutorConfig `vic:"0.1" scope:"read-only" key:"init"`
|
||||
}
|
||||
|
||||
type ExecutorConfig struct {
|
||||
Sessions map[string]*SessionConfig `vic:"0.1" scope:"read-only" key:"sessions"`
|
||||
}
|
||||
|
||||
type SessionConfig struct {
|
||||
StopSignal string `vic:"0.1" scope:"read-only" key:"stopSignal"`
|
||||
}
|
||||
|
||||
type NewStopSignal struct {
|
||||
NewExecutorConfig `vic:"0.1" scope:"read-only" key:"init"`
|
||||
}
|
||||
|
||||
type NewExecutorConfig struct {
|
||||
Sessions map[string]*NewSessionConfig `vic:"0.1" scope:"read-only" key:"sessions"`
|
||||
}
|
||||
|
||||
type NewSessionConfig struct {
|
||||
StopSignal string `vic:"0.1" scope:"read-only" key:"forceStopSignal"`
|
||||
}
|
||||
|
||||
func (p *ApplianceStopSignalRename) Migrate(ctx context.Context, s *session.Session, data interface{}) error {
|
||||
defer trace.End(trace.Begin(fmt.Sprintf("%d", version)))
|
||||
if data == nil {
|
||||
return nil
|
||||
}
|
||||
mapData := data.(map[string]string)
|
||||
oldStruct := &OldStopSignal{}
|
||||
result := extraconfig.Decode(extraconfig.MapSource(mapData), oldStruct)
|
||||
if result == nil {
|
||||
return &errors.DecodeError{}
|
||||
}
|
||||
keys := extraconfig.CalculateKeys(oldStruct, "ExecutorConfig.Sessions.*.StopSignal", "")
|
||||
for _, key := range keys {
|
||||
log.Debugf("old %s:%s", key, mapData[key])
|
||||
}
|
||||
|
||||
newStruct := &NewStopSignal{}
|
||||
if len(oldStruct.ExecutorConfig.Sessions) == 0 {
|
||||
return nil
|
||||
}
|
||||
newStruct.Sessions = make(map[string]*NewSessionConfig)
|
||||
for id, sess := range oldStruct.ExecutorConfig.Sessions {
|
||||
newSess := &NewSessionConfig{}
|
||||
newSess.StopSignal = sess.StopSignal
|
||||
newStruct.Sessions[id] = newSess
|
||||
}
|
||||
|
||||
cfg := make(map[string]string)
|
||||
extraconfig.Encode(extraconfig.MapSink(cfg), newStruct)
|
||||
// remove old data
|
||||
for _, key := range keys {
|
||||
delete(mapData, key)
|
||||
}
|
||||
for k, v := range cfg {
|
||||
log.Debugf("New data: %s:%s", k, v)
|
||||
mapData[k] = v
|
||||
}
|
||||
return nil
|
||||
}
|
||||
123
vendor/github.com/vmware/vic/lib/migration/samples/plugins/plugin2/another_plugin_sample.go
generated
vendored
Normal file
123
vendor/github.com/vmware/vic/lib/migration/samples/plugins/plugin2/another_plugin_sample.go
generated
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
// Copyright 2017 VMware, Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package plugin2
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
|
||||
"github.com/vmware/vic/lib/migration/errors"
|
||||
"github.com/vmware/vic/lib/migration/manager"
|
||||
"github.com/vmware/vic/lib/migration/samples/config/v2"
|
||||
"github.com/vmware/vic/pkg/kvstore"
|
||||
"github.com/vmware/vic/pkg/trace"
|
||||
"github.com/vmware/vic/pkg/vsphere/datastore"
|
||||
"github.com/vmware/vic/pkg/vsphere/extraconfig"
|
||||
"github.com/vmware/vic/pkg/vsphere/session"
|
||||
)
|
||||
|
||||
// Sample plugin to migrate data in keyvalue store
|
||||
// If there is any key/value change, should create a new keyvalue store file with version appendix, like .v2, to differentiate with old keyvalue store file
|
||||
// Migrate keyvalue plugin should read configuration from input VirtualContainerHost configuration, and then read from old keyvalue store file directly
|
||||
// After migration, write back to new datastore file with version appendix
|
||||
// Data migration framework is not responsible for data roll back. With versioned datastore file, even roll back happens, old version's datastore file is still useable by old binary
|
||||
// Make sure to delete existing new version datastore file, which might be a left over of last failed data migration attempt.
|
||||
const (
|
||||
version = 2
|
||||
target = manager.ApplianceConfigure
|
||||
|
||||
KVStoreFolder = "kvStores"
|
||||
APIKV = "apiKV"
|
||||
|
||||
oldKey = "image.name"
|
||||
newKey = "image.tag"
|
||||
)
|
||||
|
||||
func init() {
|
||||
log.Debugf("Registering plugin %s:%d", target, version)
|
||||
if err := manager.Migrator.Register(version, target, &NewImageMeta{}); err != nil {
|
||||
log.Errorf("Failed to register plugin %s:%d, %s", target, version, err)
|
||||
}
|
||||
}
|
||||
|
||||
// NewImageMeta is plugin for vic 0.8.0-GA version upgrade
|
||||
type NewImageMeta struct {
|
||||
}
|
||||
|
||||
func (p *NewImageMeta) Migrate(ctx context.Context, s *session.Session, data interface{}) error {
|
||||
defer trace.End(trace.Begin(fmt.Sprintf("%d", version)))
|
||||
if data == nil {
|
||||
return nil
|
||||
}
|
||||
vchConfMap := data.(map[string]string)
|
||||
// No plugin query keyvalue store yet, load from datastore file
|
||||
// get a ds helper for this ds url
|
||||
vchConf := &v2.VirtualContainerHostConfigSpec{}
|
||||
extraconfig.Decode(extraconfig.MapSource(vchConfMap), vchConf)
|
||||
|
||||
imageURL := vchConf.ImageStores[0]
|
||||
// TODO: sample code, should get datastore from imageURL
|
||||
dsHelper, err := datastore.NewHelper(trace.NewOperation(ctx, "datastore helper creation"), s,
|
||||
s.Datastore, fmt.Sprintf("%s/%s", imageURL.Path, KVStoreFolder))
|
||||
if err != nil {
|
||||
return &errors.InternalError{
|
||||
Message: fmt.Sprintf("unable to get datastore helper for %s store creation: %s", APIKV, err.Error()),
|
||||
}
|
||||
}
|
||||
// restore the modified K/V store
|
||||
oldKeyValStore, err := kvstore.NewKeyValueStore(ctx, kvstore.NewDatastoreBackend(dsHelper), APIKV)
|
||||
if err != nil && !os.IsExist(err) {
|
||||
return &errors.InternalError{
|
||||
Message: fmt.Sprintf("unable to create %s datastore backed store: %s", APIKV, err.Error()),
|
||||
}
|
||||
}
|
||||
|
||||
// create new k/v store with version appendix v2
|
||||
newDsFile := fmt.Sprintf("%s.v%d", APIKV, version)
|
||||
// try to remove new k/v store file in case it's created already
|
||||
dsHelper.Rm(ctx, newDsFile)
|
||||
newKeyValueStore, err := kvstore.NewKeyValueStore(ctx, kvstore.NewDatastoreBackend(dsHelper), newDsFile)
|
||||
if err != nil && !os.IsExist(err) {
|
||||
return &errors.InternalError{
|
||||
Message: fmt.Sprintf("unable to create %s datastore backed store: %s", newDsFile, err.Error()),
|
||||
}
|
||||
}
|
||||
|
||||
// copy all key/value from old k/v store
|
||||
allKeyVals, err := oldKeyValStore.List(".*")
|
||||
if err != nil {
|
||||
return &errors.InternalError{
|
||||
Message: fmt.Sprintf("unable to list key/value store %s: %s", APIKV, err.Error()),
|
||||
}
|
||||
}
|
||||
|
||||
for key, val := range allKeyVals {
|
||||
newKeyValueStore.Put(ctx, key, val)
|
||||
}
|
||||
val, err := newKeyValueStore.Get(oldKey)
|
||||
if err != nil && err != kvstore.ErrKeyNotFound {
|
||||
return &errors.InternalError{
|
||||
Message: fmt.Sprintf("failed to get %s from store %s: %s", oldKey, APIKV, err.Error()),
|
||||
}
|
||||
}
|
||||
// put the new key/value to store, and leave the old key/value there, in case upgrade failed, old binary still works well with half-changed store
|
||||
newKeyValueStore.Put(ctx, newKey, []byte(fmt.Sprintf("%s:%s", val, "latest")))
|
||||
// persist new data back to vsphere, framework does not take of it
|
||||
newKeyValueStore.Save(ctx)
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user