{"modulePath":"github.com/stackpointcloud/packer","version":"v0.10.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package common\n\n## Constants\n\n```go\nconst (\n\tParallelsToolsModeDisable string = \"disable\"\n\tParallelsToolsModeAttach         = \"attach\"\n\tParallelsToolsModeUpload         = \"upload\"\n)\n```\nThese are the different valid mode values for \"parallels\\_tools\\_mode\" which determine how guest additions are delivered to the guest.\n\n```go\nconst BuilderId = \"packer.parallels\"\n```\nThis is the common builder ID to all of these artifacts.\n\n```go\nconst KeyLeftShift uint32 = 0xFFE1\n```\n\n```go\nconst Prltype string = `\nimport sys\nimport prlsdkapi\n\n##\ndef main():\n    if len(sys.argv) \u003c 3:\n       print \"Usage: prltype VM_NAME SCANCODE...\"\n       sys.exit(1)\n\n    vm_name = sys.argv[1]\n    scancodes = sys.argv[2:]\n\n    server = login()\n    vm, vm_io = connect(server, vm_name)\n\n    send(scancodes, vm, vm_io)\n\n    disconnect(server, vm, vm_io)\n\n##\ndef login():\n    prlsdkapi.prlsdk.InitializeSDK(prlsdkapi.prlsdk.consts.PAM_DESKTOP_MAC)\n    server = prlsdkapi.Server()\n    login_job=server.login_local()\n    login_job.wait()\n\n    return server\n\n##\ndef connect(server, vm_name):\n    vm_list_job = server.get_vm_list()\n    result = vm_list_job.wait()\n\n    vm_list = [result.get_param_by_index(i) for i in range(result.get_params_count())]\n    vm = [vm for vm in vm_list if vm.get_name() == vm_name]\n\n    if not vm:\n       vm_names = [vm.get_name() for vm in vm_list]\n       raise Exception(\"%s: No such VM. Available VM's are:\\n%s\" % (vm_name, \"\\n\".join(vm_names)))\n\n    vm = vm[0]\n\n    vm_io = prlsdkapi.VmIO()\n    vm_io.connect_to_vm(vm).wait()\n\n    return (vm, vm_io)\n\n##\ndef disconnect(server, vm, vm_io):\n    if vm and vm_io:\n        vm_io.disconnect_from_vm(vm)\n\n    if server:\n        server.logoff()\n\n    prlsdkapi.deinit_sdk\n\n##\ndef send(scancodes, vm, vm_io):\n    timeout = 10\n    consts = prlsdkapi.prlsdk.consts\n\n    for scancode in scancodes:\n        c = int(scancode, 16)\n        if (c \u003c 128):\n            vm_io.send_key_event(vm, (c,), consts.PKE_PRESS, timeout)\n        else:\n            vm_io.send_key_event(vm, (c - 128,) , consts.PKE_RELEASE, timeout)\n\n##\nif __name__ == \"__main__\":\n    main()\n`\n```\n\n## Functions\n\n```go\nfunc CommHost(state multistep.StateBag) (string, error)\n```\n\n```go\nfunc NewArtifact(dir string) (packer.Artifact, error)\n```\nNewArtifact returns a Parallels artifact containing the files in the given directory.\n\n```go\nfunc SSHConfigFunc(config SSHConfig) func(multistep.StateBag) (*ssh.ClientConfig, error)\n```\n\n## Types\n\n```go\ntype Driver interface {\n\t// Compact a virtual disk image.\n\tCompactDisk(string) error\n\n\t// Adds new CD/DVD drive to the VM and returns name of this device\n\tDeviceAddCdRom(string, string) (string, error)\n\n\t// Get path to the first virtual disk image\n\tDiskPath(string) (string, error)\n\n\t// Import a VM\n\tImport(string, string, string, bool) error\n\n\t// Checks if the VM with the given name is running.\n\tIsRunning(string) (bool, error)\n\n\t// Stop stops a running machine, forcefully.\n\tStop(string) error\n\n\t// Prlctl executes the given Prlctl command\n\tPrlctl(...string) error\n\n\t// Get the path to the Parallels Tools ISO for the given flavor.\n\tToolsIsoPath(string) (string, error)\n\n\t// Verify checks to make sure that this driver should function\n\t// properly. If there is any indication the driver can't function,\n\t// this will return an error.\n\tVerify() error\n\n\t// Version reads the version of Parallels that is installed.\n\tVersion() (string, error)\n\n\t// Send scancodes to the vm using the prltype python script.\n\tSendKeyScanCodes(string, ...string) error\n\n\t// Apply default сonfiguration settings to the virtual machine\n\tSetDefaultConfiguration(string) error\n\n\t// Finds the MAC address of the NIC nic0\n\tMac(string) (string, error)\n\n\t// Finds the IP address of a VM connected that uses DHCP by its MAC address\n\tIpAddress(string) (string, error)\n}\n```\nA driver is able to talk to Parallels and perform certain operations with it. Some of the operations on here may seem overly specific, but they were built specifically in mind to handle features of the Parallels builder for Packer, and to abstract differences in versions out of the builder steps, so sometimes the methods are extremely specific.\n\n```go\nfunc NewDriver() (Driver, error)\n```\n\n```go\ntype DriverMock struct {\n\tsync.Mutex\n\n\tCompactDiskCalled bool\n\tCompactDiskPath   string\n\tCompactDiskErr    error\n\n\tDeviceAddCdRomCalled bool\n\tDeviceAddCdRomName   string\n\tDeviceAddCdRomImage  string\n\tDeviceAddCdRomResult string\n\tDeviceAddCdRomErr    error\n\n\tDiskPathCalled bool\n\tDiskPathName   string\n\tDiskPathResult string\n\tDiskPathErr    error\n\n\tImportCalled  bool\n\tImportName    string\n\tImportSrcPath string\n\tImportDstPath string\n\tImportErr     error\n\n\tIsRunningName   string\n\tIsRunningReturn bool\n\tIsRunningErr    error\n\n\tStopName string\n\tStopErr  error\n\n\tPrlctlCalls [][]string\n\tPrlctlErrs  []error\n\n\tVerifyCalled bool\n\tVerifyErr    error\n\n\tVersionCalled bool\n\tVersionResult string\n\tVersionErr    error\n\n\tSendKeyScanCodesCalls [][]string\n\tSendKeyScanCodesErrs  []error\n\n\tSetDefaultConfigurationCalled bool\n\tSetDefaultConfigurationError  error\n\n\tToolsIsoPathCalled bool\n\tToolsIsoPathFlavor string\n\tToolsIsoPathResult string\n\tToolsIsoPathErr    error\n\n\tMacName   string\n\tMacReturn string\n\tMacError  error\n\n\tIpAddressMac    string\n\tIpAddressReturn string\n\tIpAddressError  error\n}\n```\n\n```go\nfunc (d *DriverMock) CompactDisk(path string) error\n```\n\n```go\nfunc (d *DriverMock) DeviceAddCdRom(name string, image string) (string, error)\n```\n\n```go\nfunc (d *DriverMock) DiskPath(name string) (string, error)\n```\n\n```go\nfunc (d *DriverMock) Import(name, srcPath, dstPath string, reassignMac bool) error\n```\n\n```go\nfunc (d *DriverMock) IpAddress(mac string) (string, error)\n```\n\n```go\nfunc (d *DriverMock) IsRunning(name string) (bool, error)\n```\n\n```go\nfunc (d *DriverMock) Mac(name string) (string, error)\n```\n\n```go\nfunc (d *DriverMock) Prlctl(args ...string) error\n```\n\n```go\nfunc (d *DriverMock) SendKeyScanCodes(name string, scancodes ...string) error\n```\n\n```go\nfunc (d *DriverMock) SetDefaultConfiguration(name string) error\n```\n\n```go\nfunc (d *DriverMock) Stop(name string) error\n```\n\n```go\nfunc (d *DriverMock) ToolsIsoPath(flavor string) (string, error)\n```\n\n```go\nfunc (d *DriverMock) Verify() error\n```\n\n```go\nfunc (d *DriverMock) Version() (string, error)\n```\n\n```go\ntype FloppyConfig struct {\n\tFloppyFiles []string `mapstructure:\"floppy_files\"`\n}\n```\nFloppyConfig is configuration related to created floppy disks and attaching them to a Parallels virtual machine.\n\n```go\nfunc (c *FloppyConfig) Prepare(ctx *interpolate.Context) []error\n```\n\n```go\ntype HostIPFinder interface {\n\tHostIP() (string, error)\n}\n```\nInterface to help find the host IP that is available from within the Parallels virtual machines.\n\n```go\ntype IfconfigIPFinder struct {\n\tDevices []string\n}\n```\nIfconfigIPFinder finds the host IP based on the output of \\`ifconfig\\`.\n\n```go\nfunc (f *IfconfigIPFinder) HostIP() (string, error)\n```\n\n```go\ntype OutputConfig struct {\n\tOutputDir string `mapstructure:\"output_directory\"`\n}\n```\n\n```go\nfunc (c *OutputConfig) Prepare(ctx *interpolate.Context, pc *common.PackerConfig) []error\n```\n\n```go\ntype Parallels10Driver struct {\n\tParallels9Driver\n}\n```\nParallels10Driver are inherited from Parallels9Driver. Used for Parallels v 10 \u0026 11\n\n```go\nfunc (d *Parallels10Driver) SetDefaultConfiguration(vmName string) error\n```\n\n```go\ntype Parallels11Driver struct {\n\tParallels9Driver\n}\n```\nParallels11Driver are inherited from Parallels9Driver. Used for Parallels Desktop 11, requires Pro or Business Edition\n\n```go\nfunc (d *Parallels11Driver) SetDefaultConfiguration(vmName string) error\n```\n\n```go\nfunc (d *Parallels11Driver) Verify() error\n```\n\n```go\ntype Parallels9Driver struct {\n\t// This is the path to the \"prlctl\" application.\n\tPrlctlPath string\n\n\t// This is the path to the \"prlsrvctl\" application.\n\tPrlsrvctlPath string\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (d *Parallels9Driver) CompactDisk(diskPath string) error\n```\n\n```go\nfunc (d *Parallels9Driver) DeviceAddCdRom(name string, image string) (string, error)\n```\n\n```go\nfunc (d *Parallels9Driver) DiskPath(name string) (string, error)\n```\n\n```go\nfunc (d *Parallels9Driver) Import(name, srcPath, dstDir string, reassignMac bool) error\n```\n\n```go\nfunc (d *Parallels9Driver) IpAddress(mac string) (string, error)\n```\nFinds the IP address of a VM connected that uses DHCP by its MAC address\n\nParses the file /Library/Preferences/Parallels/parallels\\_dhcp\\_leases file contain a list of DHCP leases given by Parallels Desktop Example line: 10.211.55.181=\"1418921112,1800,001c42f593fb,ff42f593fb000100011c25b9ff001c42f593fb\" IP Address   =\"Lease expiry, Lease time, MAC, MAC or DUID\"\n\n```go\nfunc (d *Parallels9Driver) IsRunning(name string) (bool, error)\n```\n\n```go\nfunc (d *Parallels9Driver) Mac(vmName string) (string, error)\n```\n\n```go\nfunc (d *Parallels9Driver) Prlctl(args ...string) error\n```\n\n```go\nfunc (d *Parallels9Driver) SendKeyScanCodes(vmName string, codes ...string) error\n```\n\n```go\nfunc (d *Parallels9Driver) SetDefaultConfiguration(vmName string) error\n```\n\n```go\nfunc (d *Parallels9Driver) Stop(name string) error\n```\n\n```go\nfunc (d *Parallels9Driver) ToolsIsoPath(k string) (string, error)\n```\n\n```go\nfunc (d *Parallels9Driver) Verify() error\n```\n\n```go\nfunc (d *Parallels9Driver) Version() (string, error)\n```\n\n```go\ntype PrlctlConfig struct {\n\tPrlctl [][]string `mapstructure:\"prlctl\"`\n}\n```\n\n```go\nfunc (c *PrlctlConfig) Prepare(ctx *interpolate.Context) []error\n```\n\n```go\ntype PrlctlPostConfig struct {\n\tPrlctlPost [][]string `mapstructure:\"prlctl_post\"`\n}\n```\n\n```go\nfunc (c *PrlctlPostConfig) Prepare(ctx *interpolate.Context) []error\n```\n\n```go\ntype PrlctlVersionConfig struct {\n\tPrlctlVersionFile string `mapstructure:\"prlctl_version_file\"`\n}\n```\n\n```go\nfunc (c *PrlctlVersionConfig) Prepare(ctx *interpolate.Context) []error\n```\n\n```go\ntype RunConfig struct {\n\tRawBootWait string `mapstructure:\"boot_wait\"`\n\n\tBootWait time.Duration ``\n}\n```\n\n```go\nfunc (c *RunConfig) Prepare(ctx *interpolate.Context) []error\n```\n\n```go\ntype SSHConfig struct {\n\tComm communicator.Config `mapstructure:\",squash\"`\n\n\t// These are deprecated, but we keep them around for BC\n\t// TODO(@mitchellh): remove\n\tSSHWaitTimeout time.Duration `mapstructure:\"ssh_wait_timeout\"`\n}\n```\n\n```go\nfunc (c *SSHConfig) Prepare(ctx *interpolate.Context) []error\n```\n\n```go\ntype ShutdownConfig struct {\n\tShutdownCommand    string `mapstructure:\"shutdown_command\"`\n\tRawShutdownTimeout string `mapstructure:\"shutdown_timeout\"`\n\n\tShutdownTimeout time.Duration ``\n}\n```\n\n```go\nfunc (c *ShutdownConfig) Prepare(ctx *interpolate.Context) []error\n```\n\n```go\ntype StepAttachFloppy struct {\n\t// contains filtered or unexported fields\n}\n```\nThis step attaches a floppy to the virtual machine.\n\nUses:\n\n\tdriver Driver\n\tui packer.Ui\n\tvmName string\n\nProduces:\n\n```go\nfunc (s *StepAttachFloppy) Cleanup(state multistep.StateBag)\n```\n\n```go\nfunc (s *StepAttachFloppy) Run(state multistep.StateBag) multistep.StepAction\n```\n\n```go\ntype StepAttachParallelsTools struct {\n\tParallelsToolsMode string\n\t// contains filtered or unexported fields\n}\n```\nThis step attaches the Parallels Tools as an inserted CD onto the virtual machine.\n\nUses:\n\n\tdriver Driver\n\tparallels_tools_path string\n\tui packer.Ui\n\tvmName string\n\nProduces:\n\n```go\nfunc (s *StepAttachParallelsTools) Cleanup(state multistep.StateBag)\n```\n\n```go\nfunc (s *StepAttachParallelsTools) Run(state multistep.StateBag) multistep.StepAction\n```\n\n```go\ntype StepCompactDisk struct {\n\tSkip bool\n}\n```\nThis step removes all empty blocks from expanding Parallels virtual disks and reduces the result disk size\n\nUses:\n\n\tdriver Driver\n\tvmName string\n\tui     packer.Ui\n\nProduces:\n\n\t\u003cnothing\u003e\n\n```go\nfunc (*StepCompactDisk) Cleanup(multistep.StateBag)\n```\n\n```go\nfunc (s *StepCompactDisk) Run(state multistep.StateBag) multistep.StepAction\n```\n\n```go\ntype StepOutputDir struct {\n\tForce bool\n\tPath  string\n\t// contains filtered or unexported fields\n}\n```\nStepOutputDir sets up the output directory by creating it if it does not exist, deleting it if it does exist and we're forcing, and cleaning it up when we're done with it.\n\n```go\nfunc (s *StepOutputDir) Cleanup(state multistep.StateBag)\n```\n\n```go\nfunc (s *StepOutputDir) Run(state multistep.StateBag) multistep.StepAction\n```\n\n```go\ntype StepPrepareParallelsTools struct {\n\tParallelsToolsFlavor string\n\tParallelsToolsMode   string\n}\n```\nThis step prepares parameters related to Parallels Tools.\n\nUses:\n\n\tdriver Driver\n\nProduces:\n\n\tparallels_tools_path string\n\n```go\nfunc (s *StepPrepareParallelsTools) Cleanup(multistep.StateBag)\n```\n\n```go\nfunc (s *StepPrepareParallelsTools) Run(state multistep.StateBag) multistep.StepAction\n```\n\n```go\ntype StepPrlctl struct {\n\tCommands [][]string\n\tCtx      interpolate.Context\n}\n```\nThis step executes additional prlctl commands as specified by the template.\n\nUses:\n\n\tdriver Driver\n\tui packer.Ui\n\tvmName string\n\nProduces:\n\n```go\nfunc (s *StepPrlctl) Cleanup(state multistep.StateBag)\n```\n\n```go\nfunc (s *StepPrlctl) Run(state multistep.StateBag) multistep.StepAction\n```\n\n```go\ntype StepRun struct {\n\tBootWait time.Duration\n\t// contains filtered or unexported fields\n}\n```\nThis step starts the virtual machine.\n\nUses:\n\n\tdriver Driver\n\tui packer.Ui\n\tvmName string\n\nProduces:\n\n```go\nfunc (s *StepRun) Cleanup(state multistep.StateBag)\n```\n\n```go\nfunc (s *StepRun) Run(state multistep.StateBag) multistep.StepAction\n```\n\n```go\ntype StepShutdown struct {\n\tCommand string\n\tTimeout time.Duration\n}\n```\nThis step shuts down the machine. It first attempts to do so gracefully, but ultimately forcefully shuts it down if that fails.\n\nUses:\n\n\tcommunicator packer.Communicator\n\tdriver Driver\n\tui     packer.Ui\n\tvmName string\n\nProduces:\n\n\t\u003cnothing\u003e\n\n```go\nfunc (s *StepShutdown) Cleanup(state multistep.StateBag)\n```\n\n```go\nfunc (s *StepShutdown) Run(state multistep.StateBag) multistep.StepAction\n```\n\n```go\ntype StepTypeBootCommand struct {\n\tBootCommand    []string\n\tHostInterfaces []string\n\tVMName         string\n\tCtx            interpolate.Context\n}\n```\nThis step \"types\" the boot command into the VM via the prltype script, built on the Parallels Virtualization SDK - Python API.\n\nUses:\n\n\tdriver Driver\n\thttp_port int\n\tui     packer.Ui\n\tvmName string\n\nProduces:\n\n\t\u003cnothing\u003e\n\n```go\nfunc (*StepTypeBootCommand) Cleanup(multistep.StateBag)\n```\n\n```go\nfunc (s *StepTypeBootCommand) Run(state multistep.StateBag) multistep.StepAction\n```\n\n```go\ntype StepUploadParallelsTools struct {\n\tParallelsToolsFlavor    string\n\tParallelsToolsGuestPath string\n\tParallelsToolsMode      string\n\tCtx                     interpolate.Context\n}\n```\nThis step uploads the guest additions ISO to the VM.\n\n```go\nfunc (s *StepUploadParallelsTools) Cleanup(state multistep.StateBag)\n```\n\n```go\nfunc (s *StepUploadParallelsTools) Run(state multistep.StateBag) multistep.StepAction\n```\n\n```go\ntype StepUploadVersion struct {\n\tPath string\n}\n```\nThis step uploads a file containing the Parallels version, which can be useful for various provisioning reasons.\n\n```go\nfunc (s *StepUploadVersion) Cleanup(state multistep.StateBag)\n```\n\n```go\nfunc (s *StepUploadVersion) Run(state multistep.StateBag) multistep.StepAction\n```\n\n```go\ntype ToolsConfig struct {\n\tParallelsToolsFlavor    string `mapstructure:\"parallels_tools_flavor\"`\n\tParallelsToolsGuestPath string `mapstructure:\"parallels_tools_guest_path\"`\n\tParallelsToolsMode      string `mapstructure:\"parallels_tools_mode\"`\n}\n```\n\n```go\nfunc (c *ToolsConfig) Prepare(ctx *interpolate.Context) []error\n```\n\n","path":"github.com/stackpointcloud/packer/builder/parallels/common","name":"common","synopsis":"","isRedistributable":true}
