1// Copyright 2016-2018 VMware, Inc. All Rights Reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//    http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package constants
16
17import (
18	"fmt"
19	"time"
20
21	"github.com/vmware/vic/pkg/version"
22)
23
24/* VCH constants */
25const (
26	SerialOverLANPort  = 2377
27	VchAdminPortalPort = 2378
28	AttachServerPort   = 2379
29	ManagementHostName = "management.localhost"
30	ClientHostName     = "client.localhost"
31
32	// DebugPortLayerPort defines the portlayer port while debug level is greater than 2
33	DebugPortLayerPort = 2380
34
35	// BridgeScopeType denotes a scope that is of type bridge
36	BridgeScopeType = "bridge"
37	// ExternalScopeType denotes a scope that is of type external
38	ExternalScopeType = "external"
39	// DefaultBridgeRange is the default pool for bridge networks
40	DefaultBridgeRange = "172.16.0.0/12"
41	// DefaultBridgeNetworkWidth is the default allocation prefix for bridge networks
42	DefaultBridgeNetworkWidth = 16
43	// PortsOpenNetwork indicates no port blocking
44	PortsOpenNetwork = "0-65535"
45	// Constants for assemble the VM display name on vSphere
46	MaxVMNameLength = 80
47	ShortIDLen      = 12
48	// vSphere Display name for the VCH's Guest Name and for VAC support
49	defaultAltVCHGuestName       = "Photon - VCH"
50	defaultAltContainerGuestName = "Photon - Container"
51
52	PropertyCollectorTimeout = 3 * time.Minute
53
54	// Temporary names until they're altered to actual URLs.
55	ContainerStoreName = "container"
56	VolumeStoreName    = "volume"
57
58	// volume mode flag
59	Mode = "Mode"
60
61	// PCI Slot Number logic
62	PCISlotNumberBegin int32 = 0x4A0
63	PCISlotNumberEnd   int32 = 1 << 11
64	PCISlotNumberInc   int32 = 1 << 5
65
66	// NilSlot is an invalid PCI slot number
67	NilSlot int32 = 0
68
69	// All paths on the datastore for images are relative to <datastore>/VIC/
70	StorageParentDir = "VIC"
71
72	// Key-value storage directory.
73	KVStoreFolder = "kvStores"
74
75	// All volumes are stored in this directory.
76	VolumesDir = "volumes"
77
78	// Scratch layer ID
79	ScratchLayerID = "scratch"
80
81	// Task States
82	TaskRunningState = "running"
83	TaskStoppedState = "stopped"
84	TaskCreatedState = "created"
85	TaskFailedState  = "failed"
86	TaskUnknownState = "unknown"
87)
88
89func DefaultAltVCHGuestName() string {
90	return fmt.Sprintf("%s %s, %s, %7s", defaultAltVCHGuestName, version.Version, version.BuildNumber, version.GitCommit)
91}
92
93func DefaultAltContainerGuestName() string {
94	return fmt.Sprintf("%s %s, %s, %7s", defaultAltContainerGuestName, version.Version, version.BuildNumber, version.GitCommit)
95}
96