예제 #1
0
파일: create.go 프로젝트: kjplatz/vic
// Flags return all cli flags for create
func (c *Create) Flags() []cli.Flag {
	flags := []cli.Flag{
		cli.StringFlag{
			Name:        "image-store, i",
			Value:       "",
			Usage:       "Image datastore path in format \"datastore/path\"",
			Destination: &c.ImageDatastorePath,
		},
		cli.StringFlag{
			Name:        "container-store, cs",
			Value:       "",
			Usage:       "Container datastore path - not supported yet, default to image datastore",
			Destination: &c.ContainerDatastoreName,
		},
		cli.StringSliceFlag{
			Name:  "volume-store, vs",
			Value: &c.volumeStores,
			Usage: "Specify location and label for volume store; path optional: \"datastore/path:label\" or \"datastore:label\"",
		},
		cli.StringFlag{
			Name:        "bridge-network, b",
			Value:       "",
			Usage:       "The bridge network (private port group for containers). Default to Virtual Container Host name",
			Destination: &c.BridgeNetworkName,
		},
		cli.StringFlag{
			Name:        "external-network, en",
			Value:       "",
			Usage:       "The external network (can see hub.docker.com)",
			Destination: &c.ExternalNetworkName,
		},
		cli.StringFlag{
			Name:        "management-network, mn",
			Value:       "",
			Usage:       "The management network (provides route to target hosting vSphere)",
			Destination: &c.ManagementNetworkName,
		},
		cli.StringFlag{
			Name:        "client-network, cln",
			Value:       "",
			Usage:       "The client network (restricts DOCKER_API access to this network)",
			Destination: &c.ClientNetworkName,
		},
		cli.StringSliceFlag{
			Name:  "container-network, cn",
			Value: &c.containerNetworks,
			Usage: "Networks that containers can use",
		},
		cli.StringSliceFlag{
			Name:  "container-network-gateway, cng",
			Value: &c.containerNetworksGateway,
			Usage: "Gateway for the container network's subnet in CONTAINER-NETWORK:SUBNET format, e.g. a_network:172.16.0.0/16",
		},
		cli.StringSliceFlag{
			Name:  "container-network-ip-range, cnr",
			Value: &c.containerNetworksIPRanges,
			Usage: "IP range for the container network in CONTAINER-NETWORK:IP-RANGE format, e.g. a_network:172.16.0.0/24, a_network:172.16.0.10-20",
		},
		cli.StringSliceFlag{
			Name:  "container-network-dns, cnd",
			Value: &c.containerNetworksDNS,
			Usage: "DNS servers for the container network in CONTAINER-NETWORK:DNS format, e.g. a_network:8.8.8.8",
		},
		cli.IntFlag{
			Name:        "pool-memory-reservation, pmr",
			Value:       0,
			Usage:       "VCH Memory reservation in MB",
			Destination: &c.VCHMemoryReservationsMB,
		},
		cli.IntFlag{
			Name:        "pool-memory-limit, pml",
			Value:       0,
			Usage:       "VCH Memory limit in MB",
			Destination: &c.VCHMemoryLimitsMB,
		},
		cli.GenericFlag{
			Name:  "pool-memory-shares, pms",
			Value: flags.NewSharesFlag(&c.VCHMemoryShares),
			Usage: "VCH Memory shares in level or share number, e.g. high, normal, low, or 163840",
		},
		cli.IntFlag{
			Name:        "pool-cpu-reservation, pcr",
			Value:       0,
			Usage:       "VCH vCPUs reservation in MHz",
			Destination: &c.VCHCPUReservationsMHz,
		},
		cli.IntFlag{
			Name:        "pool-cpu-limit, pcl",
			Value:       0,
			Usage:       "VCH vCPUs limit in MHz",
			Destination: &c.VCHCPULimitsMHz,
		},
		cli.GenericFlag{
			Name:  "pool-cpu-shares, pcs",
			Value: flags.NewSharesFlag(&c.VCHCPUShares),
			Usage: "VCH vCPUs shares, in level or share number, e.g. high, normal, low, or 4000",
		},
		cli.StringFlag{
			Name:        "bridge-network-range, bnr",
			Value:       "172.16.0.0/12",
			Usage:       "The ip range from which bridge networks are allocated",
			Destination: &c.BridgeIPRange,
		},
		cli.StringFlag{
			Name:        "appliance-iso, ai",
			Value:       "",
			Usage:       "The appliance iso",
			Destination: &c.ApplianceISO,
		},
		cli.StringFlag{
			Name:        "bootstrap-iso, bi",
			Value:       "",
			Usage:       "The bootstrap iso",
			Destination: &c.BootstrapISO,
		},
		cli.StringFlag{
			Name:        "key",
			Value:       "",
			Usage:       "Virtual Container Host private key file",
			Destination: &c.key,
		},
		cli.StringFlag{
			Name:        "cert",
			Value:       "",
			Usage:       "Virtual Container Host x509 certificate file",
			Destination: &c.cert,
		},
		cli.BoolFlag{
			Name:        "no-tls, k",
			Usage:       "Disable TLS support",
			Destination: &c.noTLS,
		},
		cli.BoolFlag{
			Name:        "force, f",
			Usage:       "Force the install, removing existing if present",
			Destination: &c.Force,
		},
		cli.DurationFlag{
			Name:        "timeout",
			Value:       3 * time.Minute,
			Usage:       "Time to wait for create",
			Destination: &c.Timeout,
		},
		cli.BoolFlag{
			Name:        "advanced-options, x",
			Usage:       "Show all options",
			Destination: &c.advancedOptions,
		},
		cli.IntFlag{
			Name:        "appliance-memory",
			Value:       2048,
			Usage:       "Memory for the appliance VM, in MB",
			Hidden:      true,
			Destination: &c.MemoryMB,
		},
		cli.IntFlag{
			Name:        "appliance-cpu",
			Value:       1,
			Usage:       "vCPUs for the appliance VM",
			Hidden:      true,
			Destination: &c.NumCPUs,
		},
		cli.BoolFlag{
			Name:        "use-rp",
			Usage:       "Use resource pool for vch parent in VC",
			Destination: &c.UseRP,
			Hidden:      true,
		},
	}
	preFlags := append(c.TargetFlags(), c.ComputeFlags()...)
	flags = append(preFlags, flags...)
	flags = append(flags, c.DebugFlags()...)
	return flags
}
예제 #2
0
파일: create.go 프로젝트: vmware/vic
// Flags return all cli flags for create
func (c *Create) Flags() []cli.Flag {
	create := []cli.Flag{
		// images
		cli.StringFlag{
			Name:        "image-store, i",
			Value:       "",
			Usage:       "Image datastore path in format \"datastore/path\"",
			Destination: &c.ImageDatastorePath,
		},
		cli.StringFlag{
			Name:        "base-image-size",
			Value:       "8GB",
			Usage:       "Specify the size of the base image from which all other images are created e.g. 8GB/8000MB",
			Destination: &c.ScratchSize,
			Hidden:      true,
		},

		// container disk
		cli.StringFlag{
			Name:        "container-store, cs",
			Value:       "",
			Usage:       "Container datastore path - not supported yet, defaults to image datastore",
			Destination: &c.ContainerDatastoreName,
			Hidden:      true,
		},

		// volume
		cli.StringSliceFlag{
			Name:  "volume-store, vs",
			Value: &c.volumeStores,
			Usage: "Specify a list of location and label for volume store, e.g. \"datastore/path:label\" or \"datastore:label\".",
		},

		// bridge
		cli.StringFlag{
			Name:        "bridge-network, b",
			Value:       "",
			Usage:       "The bridge network port group name (private port group for containers). Defaults to the Virtual Container Host name",
			Destination: &c.BridgeNetworkName,
		},
		cli.StringFlag{
			Name:        "bridge-network-range, bnr",
			Value:       "172.16.0.0/12",
			Usage:       "The IP range from which bridge networks are allocated",
			Destination: &c.BridgeIPRange,
			Hidden:      true,
		},

		// client
		cli.StringFlag{
			Name:        "client-network, cln",
			Value:       "",
			Usage:       "The client network port group name (restricts DOCKER_API access to this network). Defaults to DCHP - see advanced help (-x)",
			Destination: &c.clientNetworkName,
		},
		cli.StringFlag{
			Name:        "client-network-gateway",
			Value:       "",
			Usage:       "Gateway for the VCH on the client network, e.g. 10.0.0.1/24",
			Destination: &c.clientNetworkGateway,
			Hidden:      true,
		},
		cli.StringFlag{
			Name:        "client-network-ip",
			Value:       "",
			Usage:       "IP address for the VCH on the client network, e.g. 10.0.0.2/24",
			Destination: &c.clientNetworkIP,
			Hidden:      true,
		},

		// external
		cli.StringFlag{
			Name:        "external-network, en",
			Value:       "",
			Usage:       "The external network port group name (port forwarding and default route). Defaults to 'VM Network' and DHCP -- see advanced help (-x)",
			Destination: &c.externalNetworkName,
		},
		cli.StringFlag{
			Name:        "external-network-gateway",
			Value:       "",
			Usage:       "Gateway for the VCH on the external network, e.g. 10.0.1.1/24",
			Destination: &c.externalNetworkGateway,
			Hidden:      true,
		},
		cli.StringFlag{
			Name:        "external-network-ip",
			Value:       "",
			Usage:       "IP address for the VCH on the external network, e.g. 10.0.1.2/24",
			Destination: &c.externalNetworkIP,
			Hidden:      true,
		},

		// management
		cli.StringFlag{
			Name:        "management-network, mn",
			Value:       "",
			Usage:       "The management network port group name (provides route to target hosting vSphere). Defaults to DCHP - see advanced help (-x)",
			Destination: &c.managementNetworkName,
		},
		cli.StringFlag{
			Name:        "management-network-gateway",
			Value:       "",
			Usage:       "Gateway for the VCH on the management network, e.g. 10.0.2.1/24",
			Destination: &c.managementNetworkGateway,
			Hidden:      true,
		},
		cli.StringFlag{
			Name:        "management-network-ip",
			Value:       "",
			Usage:       "IP address for the VCH on the management network, e.g. 10.0.2.2/24",
			Destination: &c.managementNetworkIP,
			Hidden:      true,
		},

		// general DNS
		cli.StringSliceFlag{
			Name:   "dns-server",
			Value:  &c.dns,
			Usage:  "DNS server for the client, external, and management networks. Defaults to 8.8.8.8 and 8.8.4.4 when not using DHCP",
			Hidden: true,
		},

		// container networks - mapped from vSphere
		cli.StringSliceFlag{
			Name:  "container-network, cn",
			Value: &c.containerNetworks,
			Usage: "vSphere network list that containers can use directly with labels, e.g. vsphere-net:backend. Defaults to DCHP - see advanced help (-x).",
		},
		cli.StringSliceFlag{
			Name:   "container-network-gateway, cng",
			Value:  &c.containerNetworksGateway,
			Usage:  "Gateway for the container network's subnet in CONTAINER-NETWORK:SUBNET format, e.g. vsphere-net:172.16.0.1/16.",
			Hidden: true,
		},
		cli.StringSliceFlag{
			Name:   "container-network-ip-range, cnr",
			Value:  &c.containerNetworksIPRanges,
			Usage:  "IP range for the container network in CONTAINER-NETWORK:IP-RANGE format, e.g. vsphere-net:172.16.0.0/24, vsphere-net:172.16.0.10-20.",
			Hidden: true,
		},
		cli.StringSliceFlag{
			Name:   "container-network-dns, cnd",
			Value:  &c.containerNetworksDNS,
			Usage:  "DNS servers for the container network in CONTAINER-NETWORK:DNS format, e.g. vsphere-net:8.8.8.8. Ignored if no static IP assigned.",
			Hidden: true,
		},

		// memory
		cli.IntFlag{
			Name:        "memory, mem",
			Value:       0,
			Usage:       "VCH resource pool memory limit in MB (unlimited=0)",
			Destination: &c.VCHMemoryLimitsMB,
		},
		cli.IntFlag{
			Name:        "memory-reservation, memr",
			Value:       0,
			Usage:       "VCH resource pool memory reservation in MB",
			Destination: &c.VCHMemoryReservationsMB,
			Hidden:      true,
		},
		cli.GenericFlag{
			Name:   "memory-shares, mems",
			Value:  flags.NewSharesFlag(&c.VCHMemoryShares),
			Usage:  "VCH resource pool memory shares in level or share number, e.g. high, normal, low, or 163840",
			Hidden: true,
		},
		cli.IntFlag{
			Name:        "appliance-memory",
			Value:       2048,
			Usage:       "Memory for the appliance VM, in MB. Does not impact resources allocated per container.",
			Hidden:      true,
			Destination: &c.MemoryMB,
		},

		// cpu
		cli.IntFlag{
			Name:        "cpu",
			Value:       0,
			Usage:       "VCH resource pool vCPUs limit in MHz (unlimited=0)",
			Destination: &c.VCHCPULimitsMHz,
		},
		cli.IntFlag{
			Name:        "cpu-reservation, cpur",
			Value:       0,
			Usage:       "VCH resource pool reservation in MHz",
			Destination: &c.VCHCPUReservationsMHz,
			Hidden:      true,
		},
		cli.GenericFlag{
			Name:   "cpu-shares, cpus",
			Value:  flags.NewSharesFlag(&c.VCHCPUShares),
			Usage:  "VCH VCH resource pool vCPUs shares, in level or share number, e.g. high, normal, low, or 4000",
			Hidden: true,
		},
		cli.IntFlag{
			Name:        "appliance-cpu",
			Value:       1,
			Usage:       "vCPUs for the appliance VM",
			Hidden:      true,
			Destination: &c.NumCPUs,
		},

		// TLS
		cli.StringFlag{
			Name:        "tls-cname",
			Value:       "",
			Usage:       "Common Name to use in generated CA certificate when requiring client certificate authentication",
			Destination: &c.cname,
		},
		cli.StringSliceFlag{
			Name:   "organization",
			Usage:  "A list of identifiers to record in the generated certificates. Defaults to VCH name and IP/FQND if provided.",
			Value:  &c.org,
			Hidden: true,
		},
		cli.BoolFlag{
			Name:        "no-tlsverify, kv",
			Usage:       "Disable authentication via client certificates - for more tls options see advanced help (-x)",
			Destination: &c.noTLSverify,
		},
		cli.BoolFlag{
			Name:        "no-tls, k",
			Usage:       "Disable TLS support completely",
			Destination: &c.noTLS,
			Hidden:      true,
		},
		cli.StringFlag{
			Name:        "key",
			Value:       "",
			Usage:       "Virtual Container Host private key file",
			Destination: &c.key,
			Hidden:      true,
		},
		cli.StringFlag{
			Name:        "cert",
			Value:       "",
			Usage:       "Virtual Container Host x509 certificate file",
			Destination: &c.cert,
			Hidden:      true,
		},
		cli.StringSliceFlag{
			Name:   "tls-ca, ca",
			Usage:  "Specify a list of certificate authority files to use for client verification",
			Value:  &c.clientCAs,
			Hidden: true,
		},
		cli.IntFlag{
			Name:        "certificate-key-size, ksz",
			Usage:       "Size of key to use when generating certificates",
			Value:       2048,
			Destination: &c.keySize,
			Hidden:      true,
		},

		// registries
		cli.StringSliceFlag{
			Name:  "insecure-registry, dir",
			Value: &c.insecureRegistries,
			Usage: "Specify a list of permitted insecure registry server URLs",
		},

		// proxies
		cli.StringFlag{
			Name:        "https-proxy, sproxy",
			Value:       "",
			Usage:       "An HTTPS proxy for use when fetching images, in the form https://fqdn_or_ip:port",
			Destination: &c.httpsProxy,
			Hidden:      true,
		},

		cli.StringFlag{
			Name:        "http-proxy, hproxy",
			Value:       "",
			Usage:       "An HTTP proxy for use when fetching images, in the form http://fqdn_or_ip:port",
			Destination: &c.httpProxy,
			Hidden:      true,
		},
	}

	util := []cli.Flag{
		// miscellaneous
		cli.BoolFlag{
			Name:        "use-rp",
			Usage:       "Use resource pool for vch parent in VC instead of a vApp",
			Destination: &c.UseRP,
			Hidden:      true,
		},

		cli.BoolFlag{
			Name:        "force, f",
			Usage:       "Force the install, removing existing if present",
			Destination: &c.Force,
		},
		cli.DurationFlag{
			Name:        "timeout",
			Value:       3 * time.Minute,
			Usage:       "Time to wait for create",
			Destination: &c.Timeout,
		},
	}

	help := []cli.Flag{
		// help options
		cli.BoolFlag{
			Name:        "extended-help, x",
			Usage:       "Show all options - this must be specified instead of --help",
			Destination: &c.advancedOptions,
		},
	}

	target := c.TargetFlags()
	compute := c.ComputeFlags()
	iso := c.ImageFlags(true)
	debug := c.DebugFlags()

	// flag arrays are declared, now combined
	var flags []cli.Flag
	for _, f := range [][]cli.Flag{target, compute, create, iso, util, debug, help} {
		flags = append(flags, f...)
	}

	return flags
}