├── .travis.yml ├── LICENSE ├── Makefile ├── README.md ├── c ├── Makefile └── run-in-mntns.c ├── cmd ├── ami-publisher │ ├── addVolumes.go │ ├── copyBootstrapImage.go │ ├── debug.go │ ├── delete.go │ ├── deleteTags.go │ ├── expire.go │ ├── importKeyPair.go │ ├── launchInstances.go │ ├── listImages.go │ ├── listStreams.go │ ├── listUnpackers.go │ ├── main.go │ ├── prepareUnpackers.go │ ├── publish.go │ ├── removeUnusedVolumes.go │ ├── setExclusiveTags.go │ ├── setTags.go │ ├── startInstances.go │ ├── stopIdleUnpackers.go │ ├── terminateInstances.go │ ├── unusedImages.go │ └── usedImages.go ├── builder-tool │ ├── buildImage.go │ ├── buildRaw.go │ ├── main.go │ ├── manifest.go │ └── stub.go ├── dominator │ ├── README.md │ ├── health-check.yml │ ├── install │ ├── main.go │ └── required-methods ├── domtool │ ├── README.md │ ├── clearSafetyShutoff.go │ ├── configureSubs.go │ ├── disableUpdates.go │ ├── enableUpdates.go │ ├── getDefaultImage.go │ ├── getSubsConfiguration.go │ ├── main.go │ └── setDefaultImage.go ├── filegen-client │ ├── README.md │ └── main.go ├── filegen-server │ ├── README.md │ ├── health-check.yml │ ├── install │ ├── main.go │ └── register.go ├── fleet-manager │ ├── README.md │ ├── example-topology │ │ ├── NYC │ │ │ ├── rack0 │ │ │ │ ├── machines.json │ │ │ │ └── subnets.json │ │ │ ├── rack1 │ │ │ │ ├── machines.json │ │ │ │ └── subnets.json │ │ │ └── subnets.json │ │ ├── README.md │ │ ├── SJC │ │ │ ├── rack0 │ │ │ │ ├── machines.json │ │ │ │ └── subnets.json │ │ │ ├── rack1 │ │ │ │ ├── machines.json │ │ │ │ └── subnets.json │ │ │ └── subnets.json │ │ └── SYD │ │ │ ├── rack0 │ │ │ └── machines.json │ │ │ ├── rack1 │ │ │ └── machines.json │ │ │ └── subnets.json │ ├── health-check.yml │ ├── main.go │ └── required-methods ├── fs2objectcache │ ├── convert.go │ ├── main.go │ └── walk.go ├── fsbench │ └── main.go ├── fsreadslow │ └── main.go ├── hyper-control │ ├── README.md │ ├── addAddress.go │ ├── addSubnet.go │ ├── changeTags.go │ ├── getMachineInfo.go │ ├── getUpdates.go │ ├── installerShell.go │ ├── main.go │ ├── makeInstallerIso.go │ ├── moveIpAddress.go │ ├── netbootHost.go │ ├── netbootMachine.go │ ├── reinstall.go │ ├── removeAddress.go │ ├── removeExcessAddresses.go │ ├── rolloutImage.go │ ├── showNetworkConfiguration.go │ ├── updateNetworkConfiguration.go │ └── writeNetbootFiles.go ├── hypervisor │ ├── README.md │ ├── control.go │ ├── health-check.yml │ ├── install │ ├── main.go │ └── required-methods ├── image-unpacker │ ├── health-check.yml │ ├── install │ ├── main.go │ ├── required-methods │ └── stub.go ├── imageserver │ ├── README.md │ ├── health-check.yml │ ├── html.go │ ├── install │ ├── main.go │ └── required-methods ├── imagetool │ ├── README.md │ ├── addImageCommon.go │ ├── addImagefile.go │ ├── addImageimage.go │ ├── addImagesub.go │ ├── addReplaceImage.go │ ├── checkDirectory.go │ ├── checkImage.go │ ├── chownDirectory.go │ ├── computedFiles.go │ ├── copyImageSubcommand.go │ ├── deleteImage.go │ ├── deleteUnreferencedObjects.go │ ├── diffImages.go │ ├── estimate.go │ ├── expiration.go │ ├── findLatestImage.go │ ├── getFileInImage.go │ ├── getImage.go │ ├── getImageArchiveData.go │ ├── listDirectories.go │ ├── listImages.go │ ├── listUnreferencedObjects.go │ ├── main.go │ ├── makeDirectory.go │ ├── makeRawImage.go │ ├── matchTriggers.go │ ├── mergeFilters.go │ ├── mergeTriggers.go │ ├── showImage.go │ ├── tarImage.go │ └── testDownloadSpeed.go ├── imaginator │ ├── README.md │ ├── conf.json │ ├── example-manifests │ │ ├── dominator │ │ │ ├── computed-files │ │ │ ├── files │ │ │ │ ├── etc │ │ │ │ │ ├── dominator │ │ │ │ │ │ └── flags.default │ │ │ │ │ ├── issue.net │ │ │ │ │ ├── mdb.json │ │ │ │ │ └── systemd │ │ │ │ │ │ └── system │ │ │ │ │ │ ├── dominator.service.d │ │ │ │ │ │ └── env.conf │ │ │ │ │ │ ├── filegen-server.service.d │ │ │ │ │ │ └── env.conf │ │ │ │ │ │ └── mdbd.service.d │ │ │ │ │ │ └── env.conf │ │ │ │ └── var │ │ │ │ │ └── lib │ │ │ │ │ └── filegen-server │ │ │ │ │ ├── computed-files │ │ │ │ │ └── issue.net.template │ │ │ │ │ └── config │ │ │ ├── filter.add │ │ │ ├── manifest │ │ │ ├── package-list │ │ │ ├── scripts │ │ │ │ ├── 01_install_dominator │ │ │ │ ├── 01_install_filegen-server │ │ │ │ └── 01_install_mdbd │ │ │ └── triggers.add │ │ └── imageserver │ │ │ ├── computed-files │ │ │ ├── files │ │ │ └── etc │ │ │ │ ├── imageserver │ │ │ │ └── flags.default │ │ │ │ ├── issue.net │ │ │ │ ├── mdb.json │ │ │ │ └── systemd │ │ │ │ └── system │ │ │ │ └── imageserver.service.d │ │ │ │ └── env.conf │ │ │ ├── filter.add │ │ │ ├── manifest │ │ │ ├── package-list │ │ │ ├── scripts │ │ │ └── 01_install │ │ │ └── triggers.add │ ├── health-check.yml │ ├── install │ ├── main.go │ ├── required-methods │ ├── required-methods.slave │ ├── slaveDriver.go │ ├── streams.json │ └── stub.go ├── installer │ ├── configureLocalNetwork.go │ ├── configureNetwork.go │ ├── configureStorage.go │ ├── lib.go │ ├── main.go │ ├── make-tarball │ ├── objects.go │ ├── pty.go │ ├── required-methods │ ├── server.go │ ├── shell.go │ └── stub.go ├── logtool │ ├── main.go │ ├── remoteLog.go │ ├── setDebugLevel.go │ └── watch.go ├── mdb-relayd │ └── main.go ├── mdbd │ ├── README.md │ ├── daemon.go │ ├── generators.go │ ├── health-check.yml │ ├── httpd.go │ ├── install │ ├── loadAws.go │ ├── loadCis.go │ ├── loadDsHostFqdn.go │ ├── loadFleetManager.go │ ├── loadHypervisor.go │ ├── loadText.go │ ├── main.go │ ├── required-methods │ └── server.go ├── objecttool │ ├── addObjects.go │ ├── checkObject.go │ ├── getObject.go │ ├── getObjects.go │ ├── main.go │ └── testBandwidth.go ├── scan │ └── main.go ├── show-cert │ └── main.go ├── srpc-test │ └── main.go ├── subd │ ├── README.md │ ├── health-check.yml │ ├── install │ ├── loadConfiguration.go │ ├── main.go │ ├── required-methods │ └── vCpu.go ├── subtool │ ├── README.md │ ├── boostCpuLimit.go │ ├── cleanup.go │ ├── delete.go │ ├── fetch.go │ ├── getConfig.go │ ├── getFile.go │ ├── listMissingObjects.go │ ├── main.go │ ├── poll.go │ ├── pushFile.go │ ├── pushImage.go │ ├── pushMissingObjects.go │ ├── restartService.go │ ├── setConfig.go │ ├── showUpdateRequest.go │ └── waitForImage.go ├── unpacker-tool │ ├── addDevice.go │ ├── associate.go │ ├── exportImage.go │ ├── getStatus.go │ ├── main.go │ ├── prepareForCapture.go │ ├── prepareForCopy.go │ ├── prepareForUnpack.go │ ├── removeDevice.go │ └── unpackImage.go └── vm-control │ ├── README.md │ ├── becomePrimaryVmOwner.go │ ├── changeVmConsoleType.go │ ├── changeVmDestroyProtection.go │ ├── changeVmMigrating.go │ ├── changeVmOwnerUsers.go │ ├── changeVmTags.go │ ├── connectToVmConsole.go │ ├── connectToVmSerialPort.go │ ├── copyVm.go │ ├── createVm.go │ ├── deleteVmVolume.go │ ├── destroyVm.go │ ├── dial.go │ ├── discardVmOldImage.go │ ├── discardVmOldUserData.go │ ├── discardVmSnapshot.go │ ├── exportLocalVm.go │ ├── exportVirshVm.go │ ├── findHypervisor.go │ ├── getVmInfo.go │ ├── getVmUserData.go │ ├── getVmVolume.go │ ├── importLocalVm.go │ ├── importVirshVm.go │ ├── listHypervisors.go │ ├── listLocations.go │ ├── listVMs.go │ ├── main.go │ ├── migrateVm.go │ ├── patchVmImage.go │ ├── probeVmPort.go │ ├── replaceVmImage.go │ ├── replaceVmUserData.go │ ├── restoreVmFromSnapshot.go │ ├── restoreVmImage.go │ ├── restoreVmUserData.go │ ├── snapshotVm.go │ ├── startVm.go │ ├── stopVm.go │ ├── traceMetadata.go │ ├── variables_darwin.go │ └── variables_linux.go ├── design-docs ├── Dominator │ ├── ArchitecturalOverview.md │ ├── FactSheet.md │ └── README.md ├── MachineBirthing │ └── README.md ├── SmallStack │ └── README.md └── pictures │ ├── BirtherSystemComponents.svg │ ├── DominatorComputedFiles.svg │ ├── DominatorSystemComponents.svg │ ├── Hypervisor.svg │ ├── ImageReplication.svg │ └── SmallStackComponents.svg ├── dom ├── herd │ ├── api.go │ ├── herd.go │ ├── html.go │ ├── httpd.go │ ├── listSubs.go │ ├── mdb.go │ ├── metrics.go │ ├── showSubs.go │ ├── status.go │ ├── sub.go │ ├── subStatus.go │ └── subUpdate.go ├── images │ ├── api.go │ └── impl.go ├── lib │ ├── api.go │ ├── buildMissingLists.go │ ├── buildUpdateRequest.go │ ├── buildUpdateRequest_test.go │ └── pushObjects.go └── rpcd │ ├── api.go │ ├── clearSafetyShutoff.go │ ├── configureSubs.go │ ├── disableUpdates.go │ ├── enableUpdates.go │ ├── getDefaultImage.go │ ├── getSubsConfiguration.go │ └── setDefaultImage.go ├── fleetmanager ├── httpd │ ├── api.go │ └── status.go ├── hypervisors │ ├── api.go │ ├── dashboard.go │ ├── fsstorer │ │ ├── api.go │ │ ├── check.go │ │ ├── get.go │ │ ├── ip.go │ │ ├── load.go │ │ ├── mutate.go │ │ └── vm.go │ ├── get.go │ ├── ipmi.go │ ├── listHypervisors.go │ ├── listLocations.go │ ├── listVMs.go │ ├── monitor.go │ ├── moveIpAddresses.go │ ├── notifier.go │ ├── showHypervisor.go │ ├── start.go │ ├── status.go │ ├── subnets.go │ └── update.go ├── rpcd │ ├── api.go │ ├── changeMachineTags.go │ ├── getHypervisorForVm.go │ ├── getMachineInfo.go │ ├── getUpdates.go │ ├── html.go │ ├── listHypervisorLocations.go │ ├── listHypervisorsInLocation.go │ ├── listVMsInLocation.go │ └── moveIpAddresses.go └── topology │ ├── api.go │ ├── check.go │ ├── compare.go │ ├── compare_test.go │ ├── get.go │ ├── impl.go │ ├── list.go │ ├── read.go │ └── walk.go ├── hypervisor ├── client │ ├── api.go │ └── impl.go ├── dhcpd │ ├── api.go │ └── impl.go ├── httpd │ ├── api.go │ ├── listAvailableAddresses.go │ ├── listSubnets.go │ ├── listVMs.go │ ├── showBootLog.go │ ├── showVM.go │ └── status.go ├── manager │ ├── addressPool.go │ ├── api.go │ ├── cpu.go │ ├── html.go │ ├── memory.go │ ├── owners.go │ ├── start.go │ ├── stop.go │ ├── subnets.go │ ├── update.go │ ├── vm.go │ └── volumes.go ├── metadatad │ ├── api.go │ ├── daemons.go │ └── httpHandler.go ├── rpcd │ ├── acknowledgeVm.go │ ├── api.go │ ├── becomePrimaryVmOwner.go │ ├── changeAddressPool.go │ ├── changeOwners.go │ ├── changeVmConsoleType.go │ ├── changeVmDestroyProtection.go │ ├── changeVmOwnerUsers.go │ ├── changeVmTags.go │ ├── commitImportedVm.go │ ├── connectToVmConsole.go │ ├── connectToVmSerialPort.go │ ├── copyVm.go │ ├── createVm.go │ ├── deleteVmVolume.go │ ├── destroyVm.go │ ├── discardVmAccessToken.go │ ├── discardVmOldImage.go │ ├── discardVmOldUserData.go │ ├── discardVmSnapshot.go │ ├── exportLocalVm.go │ ├── getUpdates.go │ ├── getVmAccessToken.go │ ├── getVmInfo.go │ ├── getVmUserData.go │ ├── getVmVolume.go │ ├── html.go │ ├── importLocalVm.go │ ├── listVMs.go │ ├── listVolumeDirectories.go │ ├── migrateVm.go │ ├── netbootMachine.go │ ├── patchVmImage.go │ ├── prepareVmForMigration.go │ ├── probeVmPort.go │ ├── replaceVmImage.go │ ├── replaceVmUserData.go │ ├── restoreVmFromSnapshot.go │ ├── restoreVmImage.go │ ├── restoreVmUserData.go │ ├── snapshotVm.go │ ├── startVm.go │ ├── stopVm.go │ ├── traceVmMetadata.go │ └── updateSubnets.go └── tftpbootd │ ├── api.go │ └── impl.go ├── imagebuilder ├── builder │ ├── addImage.go │ ├── api.go │ ├── bootstrapImage.go │ ├── build.go │ ├── getLatestImage.go │ ├── html.go │ ├── image.go │ ├── load.go │ ├── processManifest.go │ ├── streams.go │ └── variables.go ├── client │ ├── api.go │ └── impl.go ├── httpd │ ├── api.go │ ├── showBuildLog.go │ ├── showImageStream.go │ ├── showImageStreams.go │ └── status.go └── rpcd │ ├── api.go │ ├── buildImage.go │ └── html.go ├── imagepublishers └── amipublisher │ ├── addVolumes.go │ ├── api.go │ ├── copyBootstrapImage.go │ ├── delete.go │ ├── expire.go │ ├── importKeyPair.go │ ├── iterators.go │ ├── launchInstances.go │ ├── libAws.go │ ├── listImages.go │ ├── listStreams.go │ ├── listUnpackers.go │ ├── marshal.go │ ├── prepareUnpackers.go │ ├── publish.go │ ├── removeUnusedVolumes.go │ ├── setExclusiveTags.go │ ├── setTags.go │ ├── startInstances.go │ ├── stopIdleUnpackers.go │ ├── terminateInstances.go │ ├── unusedImages.go │ └── usedImages.go ├── imageserver ├── client │ ├── addImage.go │ ├── api.go │ ├── checkDirectory.go │ ├── checkImage.go │ ├── chownDirectory.go │ ├── deleteImage.go │ ├── deleteUnreferencedObjects.go │ ├── expiration.go │ ├── findLatestImage.go │ ├── getImage.go │ ├── listDirectories.go │ ├── listImages.go │ ├── listUnreferencedObjects.go │ └── makeDirectory.go ├── httpd │ ├── api.go │ ├── listBuildLog.go │ ├── listComputedInodes.go │ ├── listDirectories.go │ ├── listFilter.go │ ├── listImage.go │ ├── listImages.go │ ├── listObject.go │ ├── listPackages.go │ ├── listReleaseNotes.go │ ├── listTriggers.go │ ├── showImage.go │ └── status.go ├── rpcd │ ├── addImage.go │ ├── api.go │ ├── checkDirectory.go │ ├── checkImage.go │ ├── chownDirectory.go │ ├── deleteImage.go │ ├── deleteUnreferencedObjects.go │ ├── expiration.go │ ├── findLatestImage.go │ ├── getImage.go │ ├── getImageUpdates.go │ ├── html.go │ ├── lib.go │ ├── listDirectories.go │ ├── listImages.go │ ├── listUnreferencedObjects.go │ ├── makeDirectory.go │ └── replicator.go └── scanner │ ├── api.go │ ├── expire.go │ ├── garbageCollector.go │ ├── html.go │ ├── imdb.go │ └── load.go ├── imageunpacker ├── client │ ├── addDevice.go │ ├── api.go │ └── misc.go ├── httpd │ ├── api.go │ ├── showFileSystem.go │ └── status.go ├── rpcd │ ├── addDevice.go │ ├── api.go │ ├── associateStreamWithDevice.go │ ├── exportImage.go │ ├── getStatus.go │ ├── html.go │ ├── prepareForCapture.go │ ├── prepareForCopy.go │ ├── prepareForUnpack.go │ ├── removeDevice.go │ └── unpackImage.go └── unpacker │ ├── addDevice.go │ ├── api.go │ ├── associateWithDevice.go │ ├── exportImage.go │ ├── getFileSystem.go │ ├── getStatus.go │ ├── html.go │ ├── load.go │ ├── prepareForCapture.go │ ├── prepareForCopy.go │ ├── prepareForUnpack.go │ ├── removeDevice.go │ ├── streamManager.go │ ├── unpackImage.go │ └── writeState.go ├── init.d ├── dominator.Debian-7 ├── dominator.Ubuntu-12.04 ├── dominator.Ubuntu-14.04 ├── dominator.service ├── filegen-server.Debian-7 ├── filegen-server.Ubuntu-12.04 ├── filegen-server.Ubuntu-14.04 ├── filegen-server.service ├── fleet-manager.Debian-7 ├── fleet-manager.Ubuntu-12.04 ├── fleet-manager.Ubuntu-14.04 ├── fleet-manager.Ubuntu-16.04 ├── fleet-manager.service ├── hypervisor.Debian-7 ├── hypervisor.Ubuntu-14.04 ├── hypervisor.Ubuntu-16.04 ├── hypervisor.service ├── image-unpacker.Debian-7 ├── image-unpacker.Ubuntu-12.04 ├── image-unpacker.Ubuntu-14.04 ├── image-unpacker.service ├── imageserver.Debian-7 ├── imageserver.Ubuntu-12.04 ├── imageserver.Ubuntu-14.04 ├── imageserver.service ├── imaginator.Debian-7 ├── imaginator.Ubuntu-12.04 ├── imaginator.Ubuntu-14.04 ├── imaginator.Ubuntu-16.04 ├── imaginator.service ├── mdbd.Debian-7 ├── mdbd.Ubuntu-12.04 ├── mdbd.Ubuntu-14.04 ├── mdbd.service ├── subd.CentOS-6 ├── subd.Debian-7 ├── subd.Ubuntu-12.04 ├── subd.Ubuntu-14.04 ├── subd.service └── virtual-machines.service ├── lib ├── awsutil │ ├── accounts.go │ ├── api.go │ ├── credentials.go │ ├── flag.go │ ├── iterators.go │ ├── regions.go │ └── tags.go ├── bufwriter │ ├── api.go │ └── impl.go ├── concurrent │ ├── api.go │ ├── impl.go │ └── incrementer.go ├── configwatch │ ├── api.go │ └── impl.go ├── connpool │ ├── api.go │ ├── conn.go │ ├── pool.go │ └── usage_test.go ├── constants │ └── constants.go ├── cpulimiter │ ├── api.go │ └── limiter.go ├── cpusharer │ ├── api.go │ ├── fifo.go │ └── lib.go ├── errors │ └── api.go ├── filegen │ ├── api.go │ ├── client │ │ ├── api.go │ │ ├── machine.go │ │ └── manager.go │ ├── connect.go │ ├── file.go │ ├── html.go │ ├── httpd │ │ ├── api.go │ │ ├── listGenerators.go │ │ └── status.go │ ├── manager.go │ ├── mdb.go │ ├── register.go │ ├── template.go │ └── util │ │ ├── api.go │ │ └── load.go ├── filesystem │ ├── api.go │ ├── compare.go │ ├── encoding.go │ ├── estimate.go │ ├── filter.go │ ├── get.go │ ├── iterators.go │ ├── list.go │ ├── rebuild.go │ ├── scanner │ │ ├── api.go │ │ ├── getObject.go │ │ └── walk.go │ ├── tar │ │ ├── api.go │ │ ├── encode.go │ │ └── write.go │ ├── untar │ │ ├── api.go │ │ ├── decode.go │ │ └── sort.go │ ├── util │ │ ├── api.go │ │ ├── computedFiles.go │ │ ├── copyMtimes.go │ │ ├── filter.go │ │ ├── replaceComputedFiles.go │ │ ├── unpack.go │ │ └── writeRaw.go │ └── write.go ├── filter │ ├── api.go │ ├── filter.go │ ├── match_test.go │ └── merge.go ├── flags │ └── loadflags │ │ ├── api.go │ │ └── impl.go ├── flagutil │ ├── api.go │ ├── size.go │ ├── stringList.go │ └── stringToRuneMap.go ├── format │ ├── api.go │ └── format.go ├── fsbench │ ├── fsbench.go │ ├── odirect_linux.go │ └── stubs.go ├── fsrateio │ ├── api.go │ └── reader.go ├── fsutil │ ├── api.go │ ├── checksummer.go │ ├── compare.go │ ├── copy.go │ ├── fallocate.go │ ├── force.go │ ├── load.go │ ├── loopback.go │ ├── makeMutable.go │ ├── readDirnames.go │ ├── renamingWriter.go │ ├── update.go │ ├── waitFile.go │ ├── waitFile_test.go │ ├── watchFile.go │ ├── watchFileWithFsNotifyStub.go │ ├── watchFile_linux.go │ └── watchFile_test.go ├── hash │ ├── api.go │ └── marshal.go ├── html │ ├── api.go │ ├── benchmark.go │ ├── footer.go │ ├── header.go │ └── register.go ├── image │ ├── api.go │ ├── getMissingObjects.go │ ├── iterators.go │ ├── list.go │ ├── replace.go │ ├── sort.go │ └── verify.go ├── json │ ├── api.go │ ├── read.go │ └── write.go ├── log │ ├── api.go │ ├── cmdlogger │ │ ├── api.go │ │ └── impl.go │ ├── debuglogger │ │ └── api.go │ ├── logutil │ │ ├── api.go │ │ └── impl.go │ ├── nulllogger │ │ └── api.go │ ├── prefixlogger │ │ └── api.go │ ├── serverlogger │ │ ├── api.go │ │ └── impl.go │ ├── teelogger │ │ └── api.go │ └── testlogger │ │ └── api.go ├── logbuf │ ├── api.go │ ├── http.go │ └── impl.go ├── mbr │ ├── api.go │ ├── impl.go │ └── tableType.go ├── mdb │ ├── api.go │ ├── compare.go │ ├── compare_test.go │ ├── debug.go │ ├── mdbd │ │ ├── api.go │ │ ├── metrics.go │ │ └── watchd.go │ ├── updateFrom.go │ └── updateFrom_test.go ├── meminfo │ ├── api.go │ ├── getMemInfo_linux.go │ └── stubs.go ├── memstats │ └── memstats.go ├── net │ ├── api.go │ ├── bind.go │ ├── configurator │ │ ├── api.go │ │ ├── compute.go │ │ ├── debian.go │ │ ├── resolvConf.go │ │ └── update.go │ ├── cpuSharingDialer.go │ ├── createTapDevice.go │ ├── createTapDevice_linux.go │ ├── getBridgeVlanId.go │ ├── listBroadcastInterfaces.go │ ├── measuringDialer.go │ ├── proxy │ │ ├── api.go │ │ ├── common.go │ │ └── socks.go │ ├── reverseconnection │ │ ├── api.go │ │ ├── common.go │ │ ├── dialer.go │ │ ├── listen_test.go │ │ └── listener.go │ ├── rpc │ │ ├── api.go │ │ └── rpc.go │ ├── rrdialer │ │ ├── api.go │ │ ├── dial_test.go │ │ └── impl.go │ ├── tcpsockopt_darwin.go │ ├── tcpsockopt_unix.go │ ├── terminal │ │ └── client │ │ │ ├── api.go │ │ │ └── impl.go │ ├── testCarrier.go │ ├── tls │ │ ├── api.go │ │ ├── dial_test.go │ │ └── impl.go │ └── util │ │ ├── api.go │ │ ├── getDefaultRoute.go │ │ ├── getMyIP.go │ │ └── getResolverConfiguration.go ├── netspeed │ ├── api.go │ └── impl.go ├── objectcache │ ├── api.go │ ├── compare.go │ ├── encoding.go │ ├── filename.go │ ├── mapToCache.go │ ├── read.go │ └── walk.go ├── objectserver │ ├── api.go │ ├── cachingreader │ │ ├── api.go │ │ ├── get.go │ │ ├── html.go │ │ ├── link.go │ │ ├── lru.go │ │ └── new.go │ ├── client │ │ ├── addObject.go │ │ ├── api.go │ │ ├── checkObjects.go │ │ ├── client.go │ │ ├── getObjects.go │ │ └── queue.go │ ├── filesystem │ │ ├── add.go │ │ ├── api.go │ │ ├── check.go │ │ ├── delete.go │ │ ├── garbageCollector.go │ │ ├── get.go │ │ ├── html.go │ │ ├── list.go │ │ ├── new.go │ │ ├── scan │ │ │ ├── api.go │ │ │ └── scan.go │ │ └── stash.go │ ├── lib.go │ └── memory │ │ ├── add.go │ │ ├── api.go │ │ ├── check.go │ │ ├── get.go │ │ ├── list.go │ │ └── new.go ├── pprof │ ├── api.go │ └── impl.go ├── queue │ ├── api.go │ ├── dataQueue.go │ └── eventQueue.go ├── rateio │ ├── api.go │ ├── metrics.go │ └── reader.go ├── resourcepool │ ├── api.go │ ├── impl.go │ ├── locking_test.go │ └── metrics.go ├── rpcclientpool │ ├── api.go │ ├── impl.go │ └── usage_test.go ├── rsync │ ├── api.go │ ├── getBlocks.go │ └── serveBlocks.go ├── slavedriver │ ├── api.go │ ├── impl.go │ └── smallstack │ │ ├── api.go │ │ └── impl.go ├── srpc │ ├── api.go │ ├── call_test.go │ ├── client.go │ ├── clientProxy.go │ ├── coders.go │ ├── connection.go │ ├── load.go │ ├── managed.go │ ├── proxy │ │ ├── api.go │ │ └── impl.go │ ├── server.go │ ├── serverutil │ │ ├── api.go │ │ └── perUserMethodLimiter.go │ ├── setupclient │ │ ├── api.go │ │ └── impl.go │ └── setupserver │ │ ├── api.go │ │ └── impl.go ├── stringutil │ ├── api.go │ └── dedup.go ├── tags │ ├── api.go │ └── tags.go ├── triggers │ ├── api.go │ ├── load.go │ ├── make.go │ ├── match.go │ ├── merge.go │ └── replace.go ├── url │ ├── api.go │ ├── last.go │ ├── parseQuery.go │ ├── parsedQuery.go │ └── urlutil │ │ ├── api.go │ │ ├── open.go │ │ ├── watchUrl.go │ │ └── watchUrlCached.go ├── verstr │ ├── api.go │ ├── less.go │ ├── less_test.go │ └── sort.go ├── wsyscall │ ├── api.go │ ├── wrappers_darwin.go │ ├── wrappers_linux.go │ └── wrappers_windows.go └── x509util │ ├── api.go │ ├── getPermittedMethods.go │ └── getUsername.go ├── objectserver └── rpcd │ ├── addObjects.go │ ├── api.go │ ├── checkObjects.go │ ├── getObjects.go │ ├── html.go │ ├── lib │ ├── addObjects.go │ ├── addObjectsWithMaster.go │ └── api.go │ └── testBandwidth.go ├── proto ├── common │ └── messages.go ├── dominator │ └── messages.go ├── filegenerator │ └── messages.go ├── fleetmanager │ ├── messages.go │ └── methods.go ├── hypervisor │ ├── messages.go │ └── methods.go ├── imageserver │ ├── gob.go │ └── messages.go ├── imageunpacker │ ├── messages.go │ └── string.go ├── imaginator │ └── messages.go ├── installer │ └── messages.go ├── logger │ └── messages.go ├── mdbserver │ └── messages.go ├── objectserver │ └── messages.go ├── proxy │ └── messages.go ├── rsync │ └── messages.go ├── sub │ ├── gob.go │ ├── messages.go │ └── string.go └── test │ └── messages.go ├── scripts ├── image-pusher │ ├── export-image │ ├── init.wrapper │ ├── push-to-importer │ ├── push-to-seed │ └── subd.default ├── install.lib ├── list-methods ├── make-cert └── make-tarball ├── sub ├── client │ ├── api.go │ ├── boostCpuLimit.go │ ├── cleanup.go │ ├── fetch.go │ ├── getConfiguration.go │ ├── getFiles.go │ ├── poll.go │ ├── setConfiguration.go │ └── update.go ├── httpd │ ├── api.go │ └── status.go ├── lib │ ├── api.go │ └── update.go ├── rpcd │ ├── addObjects.go │ ├── api.go │ ├── boostCpuLimit.go │ ├── cleanup.go │ ├── fetch.go │ ├── getConfiguration.go │ ├── getFiles.go │ ├── html.go │ ├── poll.go │ ├── setConfiguration.go │ └── update.go └── scanner │ ├── api.go │ ├── compare.go │ ├── html.go │ ├── limits.go │ ├── metrics.go │ ├── scand.go │ ├── update.go │ └── walk.go └── user-guide ├── README.md ├── getting-started.md ├── image-manifest.md └── making-images.md /.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | # go1.11beta1 breaks the tests for lib/net/reverseconnection 4 | go: 5 | - "1.10" 6 | 7 | before_install: 8 | - go get github.com/mattn/goveralls 9 | - REPO_NAME=$(basename $PWD) 10 | - GITHUB_PATH=$(dirname $(dirname $PWD)) 11 | - SYMANTEC_PROJECT_DIR=${GITHUB_PATH}/Symantec/${REPO_NAME} 12 | - mkdir -p ${SYMANTEC_PROJECT_DIR} 13 | - rsync -az ${TRAVIS_BUILD_DIR}/ ${SYMANTEC_PROJECT_DIR}/ 14 | - export TRAVIS_BUILD_DIR=${SYMANTEC_PROJECT_DIR} 15 | - cd ${SYMANTEC_PROJECT_DIR} 16 | - go get ./... 17 | 18 | script: 19 | - go test -covermode=count -coverprofile=coverage.out ./... 20 | - $HOME/gopath/bin/goveralls -coverprofile=coverage.out -service=travis-ci 21 | - make all build-darwin test 22 | -------------------------------------------------------------------------------- /c/Makefile: -------------------------------------------------------------------------------- 1 | all: $(GOPATH)/bin/run-in-mntns 2 | 3 | $(GOPATH)/bin/run-in-mntns: run-in-mntns.c 4 | cc -static -s -o $(GOPATH)/bin/run-in-mntns run-in-mntns.c 5 | -------------------------------------------------------------------------------- /cmd/ami-publisher/addVolumes.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "strconv" 7 | 8 | "github.com/Symantec/Dominator/imagepublishers/amipublisher" 9 | "github.com/Symantec/Dominator/lib/log" 10 | ) 11 | 12 | func addVolumesSubcommand(args []string, logger log.DebugLogger) { 13 | if err := addVolumes(args[0], logger); err != nil { 14 | fmt.Fprintf(os.Stderr, "Error adding volumes: %s\n", err) 15 | os.Exit(1) 16 | } 17 | os.Exit(0) 18 | } 19 | 20 | func addVolumes(sizeStr string, logger log.DebugLogger) error { 21 | sizeInGiB, err := strconv.ParseInt(sizeStr, 10, 64) 22 | if err != nil { 23 | return err 24 | } 25 | return amipublisher.AddVolumes(targets, skipTargets, tags, 26 | *instanceName, uint64(sizeInGiB)<<30, logger) 27 | } 28 | -------------------------------------------------------------------------------- /cmd/ami-publisher/debug.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "runtime" 5 | 6 | "github.com/Symantec/Dominator/lib/format" 7 | "github.com/Symantec/Dominator/lib/log" 8 | ) 9 | 10 | func logMemoryUsage(logger log.DebugLogger) { 11 | var memStats runtime.MemStats 12 | runtime.ReadMemStats(&memStats) 13 | logger.Debugf(0, "Memory: allocated: %s system: %s\n", 14 | format.FormatBytes(memStats.Alloc), 15 | format.FormatBytes(memStats.Sys)) 16 | } 17 | -------------------------------------------------------------------------------- /cmd/ami-publisher/expire.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/Symantec/Dominator/imagepublishers/amipublisher" 8 | "github.com/Symantec/Dominator/lib/log" 9 | ) 10 | 11 | func expireSubcommand(args []string, logger log.DebugLogger) { 12 | err := amipublisher.ExpireResources(targets, skipTargets, logger) 13 | if err != nil { 14 | fmt.Fprintf(os.Stderr, "Error expiring resources: %s\n", err) 15 | os.Exit(1) 16 | } 17 | os.Exit(0) 18 | } 19 | -------------------------------------------------------------------------------- /cmd/ami-publisher/importKeyPair.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "io/ioutil" 6 | "os" 7 | 8 | "github.com/Symantec/Dominator/imagepublishers/amipublisher" 9 | "github.com/Symantec/Dominator/lib/log" 10 | ) 11 | 12 | func importKeyPairSubcommand(args []string, logger log.DebugLogger) { 13 | err := importKeyPair(args[0], args[1], logger) 14 | if err != nil { 15 | fmt.Fprintf(os.Stderr, "Error importing key pair: %s\n", err) 16 | os.Exit(1) 17 | } 18 | os.Exit(0) 19 | } 20 | 21 | func importKeyPair(keyName string, pubKeyFilename string, 22 | logger log.DebugLogger) error { 23 | publicKey, err := ioutil.ReadFile(pubKeyFilename) 24 | if err != nil { 25 | return err 26 | } 27 | return amipublisher.ImportKeyPair(targets, skipTargets, keyName, publicKey, 28 | logger) 29 | } 30 | -------------------------------------------------------------------------------- /cmd/ami-publisher/listImages.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/Symantec/Dominator/imagepublishers/amipublisher" 8 | libjson "github.com/Symantec/Dominator/lib/json" 9 | "github.com/Symantec/Dominator/lib/log" 10 | ) 11 | 12 | func listImagesSubcommand(args []string, logger log.DebugLogger) { 13 | err := listImages(logger) 14 | if err != nil { 15 | fmt.Fprintf(os.Stderr, "Error listing images: %s\n", err) 16 | os.Exit(1) 17 | } 18 | os.Exit(0) 19 | } 20 | 21 | func listImages(logger log.DebugLogger) error { 22 | results, err := amipublisher.ListImages(targets, skipTargets, searchTags, 23 | excludeSearchTags, *minImageAge, logger) 24 | if err != nil { 25 | return err 26 | } 27 | return libjson.WriteWithIndent(os.Stdout, " ", results) 28 | } 29 | -------------------------------------------------------------------------------- /cmd/ami-publisher/listUnpackers.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/Symantec/Dominator/imagepublishers/amipublisher" 8 | libjson "github.com/Symantec/Dominator/lib/json" 9 | "github.com/Symantec/Dominator/lib/log" 10 | ) 11 | 12 | func listUnpackersSubcommand(args []string, logger log.DebugLogger) { 13 | err := listUnpackers(logger) 14 | if err != nil { 15 | fmt.Fprintf(os.Stderr, "Error listing unpackers: %s\n", err) 16 | os.Exit(1) 17 | } 18 | os.Exit(0) 19 | } 20 | 21 | func listUnpackers(logger log.DebugLogger) error { 22 | results, err := amipublisher.ListUnpackers(targets, skipTargets, 23 | *instanceName, logger) 24 | if err != nil { 25 | return err 26 | } 27 | return libjson.WriteWithIndent(os.Stdout, " ", results) 28 | } 29 | -------------------------------------------------------------------------------- /cmd/ami-publisher/prepareUnpackers.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "path" 7 | 8 | "github.com/Symantec/Dominator/imagepublishers/amipublisher" 9 | "github.com/Symantec/Dominator/lib/log" 10 | ) 11 | 12 | func prepareUnpackersSubcommand(args []string, logger log.DebugLogger) { 13 | streamName := "" 14 | if len(args) > 0 { 15 | streamName = path.Clean(args[0]) 16 | } 17 | err := amipublisher.PrepareUnpackers(streamName, targets, skipTargets, 18 | *instanceName, logger) 19 | if err != nil { 20 | fmt.Fprintf(os.Stderr, "Error preparing unpackers: %s\n", err) 21 | os.Exit(1) 22 | } 23 | os.Exit(0) 24 | } 25 | -------------------------------------------------------------------------------- /cmd/ami-publisher/removeUnusedVolumes.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/Symantec/Dominator/imagepublishers/amipublisher" 8 | "github.com/Symantec/Dominator/lib/log" 9 | ) 10 | 11 | func removeUnusedVolumesSubcommand(args []string, logger log.DebugLogger) { 12 | if err := removeUnusedVolumes(logger); err != nil { 13 | fmt.Fprintf(os.Stderr, "Error removing unused volumes: %s\n", err) 14 | os.Exit(1) 15 | } 16 | os.Exit(0) 17 | } 18 | 19 | func removeUnusedVolumes(logger log.DebugLogger) error { 20 | return amipublisher.RemoveUnusedVolumes(targets, skipTargets, *instanceName, 21 | logger) 22 | } 23 | -------------------------------------------------------------------------------- /cmd/ami-publisher/setTags.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/Symantec/Dominator/imagepublishers/amipublisher" 8 | "github.com/Symantec/Dominator/lib/log" 9 | ) 10 | 11 | func setTagsSubcommand(args []string, logger log.DebugLogger) { 12 | if err := setTags(logger); err != nil { 13 | fmt.Fprintf(os.Stderr, "Error setting tags: %s\n", err) 14 | os.Exit(1) 15 | } 16 | os.Exit(0) 17 | } 18 | 19 | func setTags(logger log.DebugLogger) error { 20 | return amipublisher.SetTags(targets, skipTargets, *instanceName, tags, 21 | logger) 22 | } 23 | -------------------------------------------------------------------------------- /cmd/ami-publisher/stopIdleUnpackers.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/Symantec/Dominator/imagepublishers/amipublisher" 8 | "github.com/Symantec/Dominator/lib/log" 9 | ) 10 | 11 | func stopIdleUnpackersSubcommand(args []string, logger log.DebugLogger) { 12 | err := amipublisher.StopIdleUnpackers(targets, skipTargets, *instanceName, 13 | *maxIdleTime, logger) 14 | if err != nil { 15 | fmt.Fprintf(os.Stderr, "Error stopping idle unpackers: %s\n", err) 16 | os.Exit(1) 17 | } 18 | os.Exit(0) 19 | } 20 | -------------------------------------------------------------------------------- /cmd/ami-publisher/terminateInstances.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/Symantec/Dominator/imagepublishers/amipublisher" 8 | "github.com/Symantec/Dominator/lib/log" 9 | ) 10 | 11 | func terminateInstancesSubcommand(args []string, logger log.DebugLogger) { 12 | err := amipublisher.TerminateInstances(targets, skipTargets, *instanceName, 13 | logger) 14 | if err != nil { 15 | fmt.Fprintf(os.Stderr, "Error terminating instances: %s\n", err) 16 | os.Exit(1) 17 | } 18 | os.Exit(0) 19 | } 20 | -------------------------------------------------------------------------------- /cmd/ami-publisher/usedImages.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/Symantec/Dominator/imagepublishers/amipublisher" 8 | libjson "github.com/Symantec/Dominator/lib/json" 9 | "github.com/Symantec/Dominator/lib/log" 10 | ) 11 | 12 | func listUsedImagesSubcommand(args []string, logger log.DebugLogger) { 13 | err := listUsedImages(logger) 14 | if err != nil { 15 | fmt.Fprintf(os.Stderr, "Error listing used images: %s\n", err) 16 | os.Exit(1) 17 | } 18 | logMemoryUsage(logger) 19 | os.Exit(0) 20 | } 21 | 22 | func listUsedImages(logger log.DebugLogger) error { 23 | results, err := amipublisher.ListUsedImages(targets, skipTargets, 24 | searchTags, excludeSearchTags, logger) 25 | if err != nil { 26 | return err 27 | } 28 | if err := libjson.WriteWithIndent(os.Stdout, " ", results); err != nil { 29 | return err 30 | } 31 | return nil 32 | } 33 | -------------------------------------------------------------------------------- /cmd/builder-tool/stub.go: -------------------------------------------------------------------------------- 1 | // +build !linux 2 | 3 | package main 4 | 5 | import ( 6 | "os" 7 | 8 | "github.com/Symantec/Dominator/lib/log" 9 | ) 10 | 11 | func notAvailable() { 12 | os.Stderr.Write([]byte("Not available on this OS\n")) 13 | os.Exit(1) 14 | } 15 | 16 | func buildFromManifestSubcommand(args []string, logger log.DebugLogger) { 17 | notAvailable() 18 | } 19 | 20 | func buildRawFromManifestSubcommand(args []string, logger log.DebugLogger) { 21 | notAvailable() 22 | } 23 | 24 | func buildTreeFromManifestSubcommand(args []string, logger log.DebugLogger) { 25 | notAvailable() 26 | } 27 | 28 | func processManifestSubcommand(args []string, logger log.DebugLogger) { 29 | notAvailable() 30 | } 31 | -------------------------------------------------------------------------------- /cmd/dominator/health-check.yml: -------------------------------------------------------------------------------- 1 | --- 2 | type: url 3 | probe-freq: 10 4 | specs: 5 | url-path: /healthz 6 | url-port: 6970 7 | -------------------------------------------------------------------------------- /cmd/dominator/install: -------------------------------------------------------------------------------- 1 | #! /bin/bash --posix 2 | 3 | set -o nounset 4 | 5 | cd "${0%/*}" 6 | 7 | . ./scripts/install.lib 8 | 9 | install_all dominator 10 | -------------------------------------------------------------------------------- /cmd/dominator/required-methods: -------------------------------------------------------------------------------- 1 | FileGenerator.Connect 2 | ImageServer.GetImage 3 | ImageServer.GetImageExpiration 4 | ObjectServer.AddObjects 5 | Subd.* 6 | -------------------------------------------------------------------------------- /cmd/domtool/clearSafetyShutoff.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/Symantec/Dominator/lib/srpc" 8 | "github.com/Symantec/Dominator/proto/dominator" 9 | ) 10 | 11 | func clearSafetyShutoffSubcommand(client *srpc.Client, args []string) { 12 | if err := clearSafetyShutoff(client, args[0]); err != nil { 13 | fmt.Fprintf(os.Stderr, "Error clearing safety shutoff: %s\n", err) 14 | os.Exit(1) 15 | } 16 | os.Exit(0) 17 | } 18 | 19 | func clearSafetyShutoff(client *srpc.Client, subHostname string) error { 20 | var request dominator.ClearSafetyShutoffRequest 21 | var reply dominator.ClearSafetyShutoffResponse 22 | request.Hostname = subHostname 23 | return client.RequestReply("Dominator.ClearSafetyShutoff", request, &reply) 24 | } 25 | -------------------------------------------------------------------------------- /cmd/domtool/configureSubs.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/Symantec/Dominator/lib/srpc" 8 | "github.com/Symantec/Dominator/proto/dominator" 9 | ) 10 | 11 | func configureSubsSubcommand(client *srpc.Client, args []string) { 12 | if err := configureSubs(client); err != nil { 13 | fmt.Fprintf(os.Stderr, "Error setting config for subs: %s\n", err) 14 | os.Exit(1) 15 | } 16 | os.Exit(0) 17 | } 18 | 19 | func configureSubs(client *srpc.Client) error { 20 | var request dominator.ConfigureSubsRequest 21 | var reply dominator.ConfigureSubsResponse 22 | request.CpuPercent = *cpuPercent 23 | request.NetworkSpeedPercent = *networkSpeedPercent 24 | request.ScanExclusionList = scanExcludeList 25 | request.ScanSpeedPercent = *scanSpeedPercent 26 | return client.RequestReply("Dominator.ConfigureSubs", request, &reply) 27 | } 28 | -------------------------------------------------------------------------------- /cmd/domtool/disableUpdates.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "os" 7 | 8 | "github.com/Symantec/Dominator/lib/srpc" 9 | "github.com/Symantec/Dominator/proto/dominator" 10 | ) 11 | 12 | func disableUpdatesSubcommand(client *srpc.Client, args []string) { 13 | if err := disableUpdates(client, args[0]); err != nil { 14 | fmt.Fprintf(os.Stderr, "Error disabling updates: %s\n", err) 15 | os.Exit(1) 16 | } 17 | os.Exit(0) 18 | } 19 | 20 | func disableUpdates(client *srpc.Client, reason string) error { 21 | if reason == "" { 22 | return errors.New("cannot disable updates: no reason given") 23 | } 24 | var request dominator.DisableUpdatesRequest 25 | var reply dominator.DisableUpdatesResponse 26 | request.Reason = reason 27 | return client.RequestReply("Dominator.DisableUpdates", request, &reply) 28 | } 29 | -------------------------------------------------------------------------------- /cmd/domtool/enableUpdates.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "os" 7 | 8 | "github.com/Symantec/Dominator/lib/srpc" 9 | "github.com/Symantec/Dominator/proto/dominator" 10 | ) 11 | 12 | func enableUpdatesSubcommand(client *srpc.Client, args []string) { 13 | if err := enableUpdates(client, args[0]); err != nil { 14 | fmt.Fprintf(os.Stderr, "Error enabling updates: %s\n", err) 15 | os.Exit(1) 16 | } 17 | os.Exit(0) 18 | } 19 | 20 | func enableUpdates(client *srpc.Client, reason string) error { 21 | if reason == "" { 22 | return errors.New("cannot enable updates: no reason given") 23 | } 24 | var request dominator.EnableUpdatesRequest 25 | var reply dominator.EnableUpdatesResponse 26 | request.Reason = reason 27 | return client.RequestReply("Dominator.EnableUpdates", request, &reply) 28 | } 29 | -------------------------------------------------------------------------------- /cmd/domtool/getDefaultImage.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/Symantec/Dominator/lib/srpc" 8 | "github.com/Symantec/Dominator/proto/dominator" 9 | ) 10 | 11 | func getDefaultImageSubcommand(client *srpc.Client, args []string) { 12 | if err := getDefaultImage(client); err != nil { 13 | fmt.Fprintf(os.Stderr, "Error getting default image: %s\n", err) 14 | os.Exit(1) 15 | } 16 | os.Exit(0) 17 | } 18 | 19 | func getDefaultImage(client *srpc.Client) error { 20 | var request dominator.GetDefaultImageRequest 21 | var reply dominator.GetDefaultImageResponse 22 | if err := client.RequestReply("Dominator.GetDefaultImage", request, 23 | &reply); err != nil { 24 | return err 25 | } 26 | if reply.ImageName != "" { 27 | fmt.Println(reply.ImageName) 28 | } 29 | return nil 30 | } 31 | -------------------------------------------------------------------------------- /cmd/domtool/getSubsConfiguration.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/Symantec/Dominator/lib/srpc" 8 | "github.com/Symantec/Dominator/proto/dominator" 9 | "github.com/Symantec/Dominator/proto/sub" 10 | ) 11 | 12 | func getSubsConfigurationSubcommand(client *srpc.Client, args []string) { 13 | if err := getSubsConfiguration(client); err != nil { 14 | fmt.Fprintf(os.Stderr, "Error getting config for subs: %s\n", err) 15 | os.Exit(1) 16 | } 17 | os.Exit(0) 18 | } 19 | 20 | func getSubsConfiguration(client *srpc.Client) error { 21 | var request dominator.GetSubsConfigurationRequest 22 | var reply dominator.GetSubsConfigurationResponse 23 | if err := client.RequestReply("Dominator.GetSubsConfiguration", request, 24 | &reply); err != nil { 25 | return err 26 | } 27 | fmt.Println(sub.Configuration(reply)) 28 | return nil 29 | } 30 | -------------------------------------------------------------------------------- /cmd/domtool/setDefaultImage.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/Symantec/Dominator/lib/srpc" 8 | "github.com/Symantec/Dominator/proto/dominator" 9 | ) 10 | 11 | func setDefaultImageSubcommand(client *srpc.Client, args []string) { 12 | if err := setDefaultImage(client, args[0]); err != nil { 13 | fmt.Fprintf(os.Stderr, "Error setting default image: %s\n", err) 14 | os.Exit(1) 15 | } 16 | os.Exit(0) 17 | } 18 | 19 | func setDefaultImage(client *srpc.Client, imageName string) error { 20 | var request dominator.SetDefaultImageRequest 21 | var reply dominator.SetDefaultImageResponse 22 | request.ImageName = imageName 23 | if err := client.RequestReply("Dominator.SetDefaultImage", request, 24 | &reply); err != nil { 25 | return err 26 | } 27 | return nil 28 | } 29 | -------------------------------------------------------------------------------- /cmd/filegen-server/health-check.yml: -------------------------------------------------------------------------------- 1 | --- 2 | type: url 3 | probe-freq: 10 4 | specs: 5 | url-path: /healthz 6 | url-port: 6972 7 | -------------------------------------------------------------------------------- /cmd/filegen-server/install: -------------------------------------------------------------------------------- 1 | #! /bin/bash --posix 2 | 3 | set -o nounset 4 | 5 | cd "${0%/*}" 6 | 7 | . ./scripts/install.lib 8 | 9 | install_all filegen-server 10 | -------------------------------------------------------------------------------- /cmd/fleet-manager/example-topology/NYC/rack0/subnets.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "Id": "Production", 4 | "IpGateway": "10.0.0.1", 5 | "IpMask": "255.255.255.0", 6 | "DomainName": "nyc.prod.company.com", 7 | "DomainNameServers": [ 8 | "172.16.0.2", 9 | "172.16.0.3" 10 | ], 11 | "VlanId": 10 12 | }, 13 | { 14 | "Id": "Infrastructure", 15 | "IpGateway": "172.16.0.1", 16 | "IpMask": "255.255.255.0", 17 | "DomainName": "nyc.prod.company.com", 18 | "DomainNameServers": [ 19 | "172.16.0.2", 20 | "172.16.0.3" 21 | ], 22 | "VlanId": 20 23 | } 24 | ] 25 | -------------------------------------------------------------------------------- /cmd/fleet-manager/example-topology/NYC/rack1/subnets.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "Id": "Production", 4 | "IpGateway": "10.0.1.1", 5 | "IpMask": "255.255.255.0", 6 | "DomainName": "nyc.prod.company.com", 7 | "DomainNameServers": [ 8 | "172.16.0.2", 9 | "172.16.0.3" 10 | ], 11 | "VlanId": 10 12 | }, 13 | { 14 | "Id": "Infrastructure", 15 | "IpGateway": "172.16.1.1", 16 | "IpMask": "255.255.255.0", 17 | "DomainName": "nyc.prod.company.com", 18 | "DomainNameServers": [ 19 | "172.16.0.2", 20 | "172.16.0.3" 21 | ], 22 | "VlanId": 20 23 | } 24 | ] 25 | -------------------------------------------------------------------------------- /cmd/fleet-manager/example-topology/NYC/subnets.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "Id": "Egress", 4 | "IpGateway": "192.168.0.1", 5 | "IpMask": "255.255.255.0", 6 | "DomainName": "nyc.prod.company.com", 7 | "DomainNameServers": [ 8 | "172.16.0.2", 9 | "172.16.0.3" 10 | ], 11 | "VlanId": 30 12 | } 13 | ] 14 | -------------------------------------------------------------------------------- /cmd/fleet-manager/example-topology/README.md: -------------------------------------------------------------------------------- 1 | # Example topology for Fleet Manager 2 | 3 | This example toplogy contains 2 large regions (NYC and SJC) and a small region 4 | (SYD). Each region has 3 VLANS: 5 | - `Production`: for products serving customers 6 | - `Infrastructure`: for internal infrastructure services 7 | - `Egress`: for VMs which have Internet egress access via a NAT gateway 8 | 9 | While the large regions have the `Production` and `Infrastructure` subnets 10 | segmented per rack, the smaller SYD region has all subnets covering the entire 11 | region. 12 | -------------------------------------------------------------------------------- /cmd/fleet-manager/example-topology/SJC/rack0/subnets.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "Id": "Production", 4 | "IpGateway": "10.10.0.1", 5 | "IpMask": "255.255.255.0", 6 | "DomainName": "sjc.prod.company.com", 7 | "DomainNameServers": [ 8 | "172.16.10.2", 9 | "172.16.10.3" 10 | ], 11 | "VlanId": 10 12 | }, 13 | { 14 | "Id": "Infrastructure", 15 | "IpGateway": "172.16.10.1", 16 | "IpMask": "255.255.255.0", 17 | "DomainName": "sjc.prod.company.com", 18 | "DomainNameServers": [ 19 | "172.16.10.2", 20 | "172.16.10.3" 21 | ], 22 | "VlanId": 20 23 | } 24 | ] 25 | -------------------------------------------------------------------------------- /cmd/fleet-manager/example-topology/SJC/rack1/subnets.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "Id": "Production", 4 | "IpGateway": "10.10.1.1", 5 | "IpMask": "255.255.255.0", 6 | "DomainName": "sjc.prod.company.com", 7 | "DomainNameServers": [ 8 | "172.16.10.2", 9 | "172.16.10.3" 10 | ], 11 | "VlanId": 10 12 | }, 13 | { 14 | "Id": "Infrastructure", 15 | "IpGateway": "172.16.11.1", 16 | "IpMask": "255.255.255.0", 17 | "DomainName": "sjc.prod.company.com", 18 | "DomainNameServers": [ 19 | "172.16.10.2", 20 | "172.16.10.3" 21 | ], 22 | "VlanId": 20 23 | } 24 | ] 25 | -------------------------------------------------------------------------------- /cmd/fleet-manager/example-topology/SJC/subnets.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "Id": "Egress", 4 | "IpGateway": "192.168.1.1", 5 | "IpMask": "255.255.255.0", 6 | "DomainName": "sjc.prod.company.com", 7 | "DomainNameServers": [ 8 | "172.16.10.2", 9 | "172.16.10.3" 10 | ], 11 | "VlanId": 30 12 | } 13 | ] 14 | -------------------------------------------------------------------------------- /cmd/fleet-manager/example-topology/SYD/rack0/machines.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "Hostname": "row00-rack0.syd.prod.company.com" 4 | }, 5 | { 6 | "Hostname": "row01-rack0.syd.prod.company.com" 7 | }, 8 | { 9 | "Hostname": "row02-rack0.syd.prod.company.com" 10 | }, 11 | { 12 | "Hostname": "row03-rack0.syd.prod.company.com" 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /cmd/fleet-manager/example-topology/SYD/rack1/machines.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "Hostname": "row00-rack1.syd.prod.company.com" 4 | }, 5 | { 6 | "Hostname": "row01-rack1.syd.prod.company.com" 7 | }, 8 | { 9 | "Hostname": "row02-rack1.syd.prod.company.com" 10 | }, 11 | { 12 | "Hostname": "row03-rack1.syd.prod.company.com" 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /cmd/fleet-manager/health-check.yml: -------------------------------------------------------------------------------- 1 | --- 2 | type: url 3 | probe-freq: 10 4 | specs: 5 | url-path: /healthz 6 | url-port: 6977 7 | -------------------------------------------------------------------------------- /cmd/fleet-manager/required-methods: -------------------------------------------------------------------------------- 1 | Hypervisor.* 2 | -------------------------------------------------------------------------------- /cmd/fs2objectcache/convert.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "crypto/sha512" 5 | "io" 6 | "os" 7 | "path" 8 | 9 | "github.com/Symantec/Dominator/lib/fsutil" 10 | "github.com/Symantec/Dominator/lib/hash" 11 | "github.com/Symantec/Dominator/lib/objectcache" 12 | ) 13 | 14 | func convertToObject(pathname, objectsDir string) error { 15 | file, err := os.Open(pathname) 16 | if err != nil { 17 | return err 18 | } 19 | defer file.Close() 20 | hasher := sha512.New() 21 | _, err = io.Copy(hasher, file) 22 | if err != nil { 23 | return err 24 | } 25 | var hashVal hash.Hash 26 | copy(hashVal[:], hasher.Sum(nil)) 27 | objPathname := path.Join(objectsDir, objectcache.HashToFilename(hashVal)) 28 | if err = os.MkdirAll(path.Dir(objPathname), 0755); err != nil { 29 | return err 30 | } 31 | return fsutil.ForceRename(pathname, objPathname) 32 | } 33 | -------------------------------------------------------------------------------- /cmd/fsbench/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/Symantec/Dominator/lib/fsbench" 8 | ) 9 | 10 | // Benchmark the read speed of the underlying block device for a given file. 11 | func main() { 12 | pathname := "/" 13 | if len(os.Args) == 2 { 14 | pathname = os.Args[1] 15 | } 16 | bytesPerSecond, blocksPerSecond, err := fsbench.GetReadSpeed(pathname) 17 | if err != nil { 18 | fmt.Fprintf(os.Stderr, "Error! %s\n", err) 19 | return 20 | } 21 | fmt.Printf("speed=%d MiB/s ", bytesPerSecond>>20) 22 | if blocksPerSecond > 0 { 23 | fmt.Printf("%d blocks/s\n", blocksPerSecond) 24 | } else { 25 | fmt.Println("I/O accounting not available") 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /cmd/hypervisor/health-check.yml: -------------------------------------------------------------------------------- 1 | --- 2 | type: url 3 | probe-freq: 10 4 | specs: 5 | url-path: /healthz 6 | url-port: 6976 7 | -------------------------------------------------------------------------------- /cmd/hypervisor/install: -------------------------------------------------------------------------------- 1 | #! /bin/bash --posix 2 | 3 | set -o nounset 4 | 5 | cd "${0%/*}" 6 | 7 | . ./scripts/install.lib 8 | 9 | install_all hypervisor 10 | install_service virtual-machines 11 | -------------------------------------------------------------------------------- /cmd/hypervisor/required-methods: -------------------------------------------------------------------------------- 1 | Hypervisor.PrepareVmForMigration 2 | ImageServer.CheckDirectory 3 | ImageServer.FindLatestImage 4 | ImageServer.GetImage 5 | ObjectServer.GetObjects 6 | -------------------------------------------------------------------------------- /cmd/image-unpacker/health-check.yml: -------------------------------------------------------------------------------- 1 | --- 2 | type: url 3 | probe-freq: 10 4 | specs: 5 | url-path: /healthz 6 | url-port: 6974 7 | -------------------------------------------------------------------------------- /cmd/image-unpacker/install: -------------------------------------------------------------------------------- 1 | #! /bin/bash --posix 2 | 3 | set -o nounset 4 | 5 | cd "${0%/*}" 6 | 7 | . ./scripts/install.lib 8 | 9 | $echo cp -p scripts/image-pusher/* /usr/local/etc || exit 10 | install_all image-unpacker 11 | -------------------------------------------------------------------------------- /cmd/image-unpacker/required-methods: -------------------------------------------------------------------------------- 1 | ImageServer.GetImage 2 | ObjectServer.GetObjects 3 | -------------------------------------------------------------------------------- /cmd/image-unpacker/stub.go: -------------------------------------------------------------------------------- 1 | // +build !linux 2 | 3 | package main 4 | 5 | import ( 6 | "os" 7 | ) 8 | 9 | func main() { 10 | os.Stderr.Write([]byte("Not available on this OS\n")) 11 | os.Exit(1) 12 | } 13 | -------------------------------------------------------------------------------- /cmd/imageserver/health-check.yml: -------------------------------------------------------------------------------- 1 | --- 2 | type: url 3 | probe-freq: 10 4 | specs: 5 | url-path: /healthz 6 | url-port: 6971 7 | -------------------------------------------------------------------------------- /cmd/imageserver/install: -------------------------------------------------------------------------------- 1 | #! /bin/bash --posix 2 | 3 | set -o nounset 4 | 5 | cd "${0%/*}" 6 | 7 | . ./scripts/install.lib 8 | 9 | install_all imageserver 10 | -------------------------------------------------------------------------------- /cmd/imageserver/required-methods: -------------------------------------------------------------------------------- 1 | ImageServer.AddImageTrusted 2 | ImageServer.GetImageUpdates 3 | ImageServer.GetImage 4 | ObjectServer.AddObjects 5 | ObjectServer.CheckObjects 6 | ObjectServer.GetObjects 7 | -------------------------------------------------------------------------------- /cmd/imagetool/checkDirectory.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/Symantec/Dominator/imageserver/client" 8 | ) 9 | 10 | func checkDirectorySubcommand(args []string) { 11 | imageSClient, _ := getClients() 12 | directoryExists, err := client.CheckDirectory(imageSClient, args[0]) 13 | if err != nil { 14 | fmt.Fprintf(os.Stderr, "Error checking directory: %s\n", err) 15 | os.Exit(1) 16 | } 17 | if directoryExists { 18 | os.Exit(0) 19 | } 20 | os.Exit(1) 21 | } 22 | -------------------------------------------------------------------------------- /cmd/imagetool/checkImage.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/Symantec/Dominator/imageserver/client" 8 | ) 9 | 10 | func checkImageSubcommand(args []string) { 11 | imageSClient, _ := getClients() 12 | imageExists, err := client.CheckImage(imageSClient, args[0]) 13 | if err != nil { 14 | fmt.Fprintf(os.Stderr, "Error checking image\t%s\n", err) 15 | os.Exit(1) 16 | } 17 | if imageExists { 18 | os.Exit(0) 19 | } 20 | os.Exit(1) 21 | } 22 | -------------------------------------------------------------------------------- /cmd/imagetool/chownDirectory.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/Symantec/Dominator/imageserver/client" 8 | ) 9 | 10 | func chownDirectorySubcommand(args []string) { 11 | imageSClient, _ := getClients() 12 | if err := client.ChownDirectory(imageSClient, args[0], 13 | args[1]); err != nil { 14 | fmt.Fprintf(os.Stderr, "Error changing directory ownership: %s\n", err) 15 | os.Exit(1) 16 | } 17 | os.Exit(0) 18 | } 19 | -------------------------------------------------------------------------------- /cmd/imagetool/computedFiles.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "errors" 5 | 6 | "github.com/Symantec/Dominator/lib/filesystem" 7 | "github.com/Symantec/Dominator/lib/filesystem/util" 8 | ) 9 | 10 | type computedFileType struct { 11 | Filename string 12 | Source string 13 | } 14 | 15 | func spliceComputedFiles(fs *filesystem.FileSystem) error { 16 | if *computedFiles == "" { 17 | return nil 18 | } 19 | cfl, err := util.LoadComputedFiles(*computedFiles) 20 | if err != nil { 21 | return errors.New("cannot load computed files: " + err.Error()) 22 | } 23 | if err := util.SpliceComputedFiles(fs, cfl); err != nil { 24 | return errors.New("cannot splice computed files: " + err.Error()) 25 | } 26 | return nil 27 | } 28 | -------------------------------------------------------------------------------- /cmd/imagetool/deleteImage.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/Symantec/Dominator/imageserver/client" 8 | ) 9 | 10 | func deleteImageSubcommand(args []string) { 11 | imageSClient, _ := getClients() 12 | if err := client.DeleteImage(imageSClient, args[0]); err != nil { 13 | fmt.Fprintf(os.Stderr, "Error deleting image\t%s\n", err) 14 | os.Exit(1) 15 | } 16 | os.Exit(0) 17 | } 18 | -------------------------------------------------------------------------------- /cmd/imagetool/deleteUnreferencedObjects.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "strconv" 7 | 8 | "github.com/Symantec/Dominator/imageserver/client" 9 | ) 10 | 11 | func deleteUnreferencedObjectsSubcommand(args []string) { 12 | imageSClient, _ := getClients() 13 | percentage, err := strconv.ParseUint(args[0], 10, 8) 14 | if err != nil { 15 | fmt.Fprintf(os.Stderr, "Error parsing percentage: %s\n", err) 16 | os.Exit(1) 17 | } 18 | bytes, err := strconv.ParseUint(args[1], 10, 64) 19 | if err != nil { 20 | fmt.Fprintf(os.Stderr, "Error parsing bytes: %s\n", err) 21 | os.Exit(1) 22 | } 23 | if err := client.DeleteUnreferencedObjects(imageSClient, uint8(percentage), 24 | bytes); err != nil { 25 | fmt.Fprintf(os.Stderr, "Error deleting unreferenced objects: %s\n", err) 26 | os.Exit(1) 27 | } 28 | os.Exit(0) 29 | } 30 | -------------------------------------------------------------------------------- /cmd/imagetool/estimate.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/Symantec/Dominator/lib/format" 8 | "github.com/Symantec/Dominator/lib/srpc" 9 | ) 10 | 11 | func estimateImageUsageSubcommand(args []string) { 12 | imageSClient, _ := getClients() 13 | if err := estimateImageUsage(imageSClient, args[0]); err != nil { 14 | fmt.Fprintf(os.Stderr, "Error estimating image size: %s\n", err) 15 | os.Exit(1) 16 | } 17 | os.Exit(0) 18 | } 19 | 20 | func estimateImageUsage(client *srpc.Client, image string) error { 21 | fs, err := getFsOfImage(client, image) 22 | if err != nil { 23 | return err 24 | } 25 | _, err = fmt.Println(format.FormatBytes(fs.EstimateUsage(0))) 26 | return err 27 | } 28 | -------------------------------------------------------------------------------- /cmd/imagetool/findLatestImage.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "os" 7 | 8 | "github.com/Symantec/Dominator/imageserver/client" 9 | ) 10 | 11 | func findLatestImageSubcommand(args []string) { 12 | if err := findLatestImage(args[0]); err != nil { 13 | fmt.Fprintf(os.Stderr, "Error finding latest image: %s\n", err) 14 | os.Exit(1) 15 | } 16 | os.Exit(0) 17 | } 18 | 19 | func findLatestImage(dirname string) error { 20 | imageSClient, _ := getClients() 21 | imageName, err := client.FindLatestImage(imageSClient, dirname, 22 | *ignoreExpiring) 23 | if err != nil { 24 | return err 25 | } 26 | if imageName == "" { 27 | return errors.New("no image found") 28 | } 29 | fmt.Println(imageName) 30 | return nil 31 | } 32 | -------------------------------------------------------------------------------- /cmd/imagetool/listImages.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/Symantec/Dominator/imageserver/client" 8 | "github.com/Symantec/Dominator/lib/srpc" 9 | "github.com/Symantec/Dominator/lib/verstr" 10 | ) 11 | 12 | func listImagesSubcommand(args []string) { 13 | imageClient, _ := getClients() 14 | if err := listImages(imageClient); err != nil { 15 | fmt.Fprintf(os.Stderr, "Error listing images\t%s\n", err) 16 | os.Exit(1) 17 | } 18 | os.Exit(0) 19 | } 20 | 21 | func listImages(imageSClient *srpc.Client) error { 22 | imageNames, err := client.ListImages(imageSClient) 23 | if err != nil { 24 | return err 25 | } 26 | verstr.Sort(imageNames) 27 | for _, name := range imageNames { 28 | fmt.Println(name) 29 | } 30 | return nil 31 | } 32 | -------------------------------------------------------------------------------- /cmd/imagetool/makeDirectory.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/Symantec/Dominator/imageserver/client" 8 | ) 9 | 10 | func makeDirectorySubcommand(args []string) { 11 | imageSClient, _ := getClients() 12 | if err := client.MakeDirectory(imageSClient, args[0]); err != nil { 13 | fmt.Fprintf(os.Stderr, "Error creating directory: %s\n", err) 14 | os.Exit(1) 15 | } 16 | os.Exit(0) 17 | } 18 | -------------------------------------------------------------------------------- /cmd/imagetool/mergeFilters.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/Symantec/Dominator/lib/filter" 8 | ) 9 | 10 | func mergeFiltersSubcommand(args []string) { 11 | err := mergeFilters(args) 12 | if err != nil { 13 | fmt.Fprintf(os.Stderr, "Error merging filter: %s\n", err) 14 | os.Exit(1) 15 | } 16 | os.Exit(0) 17 | } 18 | 19 | func mergeFilters(filterFiles []string) error { 20 | mergeableFilter := &filter.MergeableFilter{} 21 | for _, filterFile := range filterFiles { 22 | filt, err := filter.Load(filterFile) 23 | if err != nil { 24 | return err 25 | } 26 | mergeableFilter.Merge(filt) 27 | } 28 | filt := mergeableFilter.ExportFilter() 29 | for _, filterLine := range filt.FilterLines { 30 | if _, err := fmt.Println(filterLine); err != nil { 31 | return err 32 | } 33 | } 34 | return nil 35 | } 36 | -------------------------------------------------------------------------------- /cmd/imagetool/mergeTriggers.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | json "github.com/Symantec/Dominator/lib/json" 8 | "github.com/Symantec/Dominator/lib/triggers" 9 | ) 10 | 11 | func mergeTriggersSubcommand(args []string) { 12 | err := mergeTriggers(args) 13 | if err != nil { 14 | fmt.Fprintf(os.Stderr, "Error merging triggers: %s\n", err) 15 | os.Exit(1) 16 | } 17 | os.Exit(0) 18 | } 19 | 20 | func mergeTriggers(triggerFiles []string) error { 21 | mergeableTriggers := &triggers.MergeableTriggers{} 22 | for _, triggerFile := range triggerFiles { 23 | trig, err := triggers.Load(triggerFile) 24 | if err != nil { 25 | return err 26 | } 27 | mergeableTriggers.Merge(trig) 28 | } 29 | trig := mergeableTriggers.ExportTriggers() 30 | return json.WriteWithIndent(os.Stdout, " ", trig.Triggers) 31 | } 32 | -------------------------------------------------------------------------------- /cmd/imagetool/showImage.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | ) 7 | 8 | func showImageSubcommand(args []string) { 9 | if err := showImage(args[0]); err != nil { 10 | fmt.Fprintf(os.Stderr, "Error showing image\t%s\n", err) 11 | os.Exit(1) 12 | } 13 | os.Exit(0) 14 | } 15 | 16 | func showImage(image string) error { 17 | fs, err := getTypedImage(image) 18 | if err != nil { 19 | return err 20 | } 21 | return fs.Listf(os.Stdout, listSelector, listFilter) 22 | } 23 | -------------------------------------------------------------------------------- /cmd/imaginator/example-manifests/dominator/computed-files: -------------------------------------------------------------------------------- 1 | /etc/issue.net localhost:6972 2 | /etc/mdb.json localhost:6972 3 | /etc/ssl/CA.pem localhost:6972 4 | /etc/ssl/dominator/cert.pem localhost:6972 5 | /etc/ssl/dominator/key.pem localhost:6972 6 | -------------------------------------------------------------------------------- /cmd/imaginator/example-manifests/dominator/files/etc/dominator/flags.default: -------------------------------------------------------------------------------- 1 | fdLimit = 64000 2 | idleMarkTimeout = 5m 3 | imageServerHostname = imageserver.prod.acme.com 4 | -------------------------------------------------------------------------------- /cmd/imaginator/example-manifests/dominator/files/etc/issue.net: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Symantec/Dominator/aa74118a1c98d808a8c9332bf9219a4ce60bf8e9/cmd/imaginator/example-manifests/dominator/files/etc/issue.net -------------------------------------------------------------------------------- /cmd/imaginator/example-manifests/dominator/files/etc/mdb.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Symantec/Dominator/aa74118a1c98d808a8c9332bf9219a4ce60bf8e9/cmd/imaginator/example-manifests/dominator/files/etc/mdb.json -------------------------------------------------------------------------------- /cmd/imaginator/example-manifests/dominator/files/etc/systemd/system/dominator.service.d/env.conf: -------------------------------------------------------------------------------- 1 | [Service] 2 | LimitNOFILE=65536 3 | User=dominator 4 | -------------------------------------------------------------------------------- /cmd/imaginator/example-manifests/dominator/files/etc/systemd/system/filegen-server.service.d/env.conf: -------------------------------------------------------------------------------- 1 | [Service] 2 | ExecStart= 3 | ExecStart=/usr/local/sbin/filegen-server /var/lib/filegen-server/computed-files/root 4 | User=filegen-server 5 | -------------------------------------------------------------------------------- /cmd/imaginator/example-manifests/dominator/files/etc/systemd/system/mdbd.service.d/env.conf: -------------------------------------------------------------------------------- 1 | [Service] 2 | User=mdbd 3 | -------------------------------------------------------------------------------- /cmd/imaginator/example-manifests/dominator/files/var/lib/filegen-server/computed-files/issue.net.template: -------------------------------------------------------------------------------- 1 | This system is Dominated with image {{.RequiredImage}} and kernel v\r \m \n \l 2 | -------------------------------------------------------------------------------- /cmd/imaginator/example-manifests/dominator/files/var/lib/filegen-server/config: -------------------------------------------------------------------------------- 1 | DynamicTemplateFile /etc/issue.net /var/lib/filegen-server/computed-files/issue.net.template 2 | -------------------------------------------------------------------------------- /cmd/imaginator/example-manifests/dominator/filter.add: -------------------------------------------------------------------------------- 1 | /etc/dominator/flags[.]extra 2 | /etc/filegen-server/flags[.]extra 3 | /etc/mdbd/flags[.]extra 4 | /etc/ssl/mdbd(|/.*)$ 5 | /var/lib/Dominator/.* 6 | /var/lib/filegen-server/.* 7 | -------------------------------------------------------------------------------- /cmd/imaginator/example-manifests/dominator/manifest: -------------------------------------------------------------------------------- 1 | { 2 | "SourceImage": "image-team/minimal/Debian-9" 3 | } 4 | -------------------------------------------------------------------------------- /cmd/imaginator/example-manifests/dominator/package-list: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Symantec/Dominator/aa74118a1c98d808a8c9332bf9219a4ce60bf8e9/cmd/imaginator/example-manifests/dominator/package-list -------------------------------------------------------------------------------- /cmd/imaginator/example-manifests/dominator/scripts/01_install_dominator: -------------------------------------------------------------------------------- 1 | #! /bin/bash --posix 2 | 3 | set -ex 4 | 5 | readonly dir='/tmp/dominator-unpack' 6 | 7 | rm -rf "$dir" || true 8 | mkdir -p "$dir" 9 | wget -q -O /tmp/dominator.tar.gz http://mirror.prod.acme.com/misc/Dominator/dominator.tar.gz 10 | tar -C "$dir" -xzf /tmp/dominator.tar.gz 11 | rm /tmp/dominator.tar.gz 12 | 13 | "$dir/install" 14 | rm -rf "$dir" 15 | 16 | mkdir -p /var/lib/Dominator /var/log/dominator 17 | 18 | chown -R dominator /etc/ssl/dominator /var/lib/Dominator /var/log/dominator 19 | 20 | # Remove noise. 21 | rm -f /etc/motd 22 | -------------------------------------------------------------------------------- /cmd/imaginator/example-manifests/dominator/scripts/01_install_filegen-server: -------------------------------------------------------------------------------- 1 | #! /bin/bash --posix 2 | 3 | set -ex 4 | 5 | readonly dir='/tmp/filegen-server-unpack' 6 | 7 | rm -rf "$dir" || true 8 | mkdir -p "$dir" 9 | wget -q -O /tmp/filegen-server.tar.gz http://mirror.prod.acme.com/misc/Dominator/filegen-server.tar.gz 10 | tar -C "$dir" -xzf /tmp/filegen-server.tar.gz 11 | rm /tmp/filegen-server.tar.gz 12 | 13 | "$dir/install" 14 | rm -rf "$dir" 15 | 16 | mkdir -p /var/lib/filegen-server /var/log/filegen-server 17 | 18 | chown -R filegen-server /etc/ssl/filegen-server /var/lib/filegen-server \ 19 | /var/log/filegen-server 20 | -------------------------------------------------------------------------------- /cmd/imaginator/example-manifests/dominator/scripts/01_install_mdbd: -------------------------------------------------------------------------------- 1 | #! /bin/bash --posix 2 | 3 | set -ex 4 | 5 | readonly dir='/tmp/mdbd-unpack' 6 | 7 | rm -rf "$dir" || true 8 | mkdir -p "$dir" 9 | wget -q -O /tmp/mdbd.tar.gz http://mirror.prod.acme.com/misc/Dominator/mdbd.tar.gz 10 | tar -C "$dir" -xzf /tmp/mdbd.tar.gz 11 | rm /tmp/mdbd.tar.gz 12 | 13 | "$dir/install" 14 | rm -rf "$dir" 15 | 16 | mkdir -p /var/log/mdbd 17 | 18 | chown -R mdbd /var/log/mdbd 19 | -------------------------------------------------------------------------------- /cmd/imaginator/example-manifests/imageserver/computed-files: -------------------------------------------------------------------------------- 1 | /etc/issue.net localhost:6972 2 | /etc/mdb.json localhost:6972 3 | /etc/ssl/imageserver/cert.pem localhost:6972 4 | /etc/ssl/imageserver/key.pem localhost:6972 5 | -------------------------------------------------------------------------------- /cmd/imaginator/example-manifests/imageserver/files/etc/imageserver/flags.default: -------------------------------------------------------------------------------- 1 | imageDir = /data/imageserver 2 | objectDir = /data/objectserver 3 | -------------------------------------------------------------------------------- /cmd/imaginator/example-manifests/imageserver/files/etc/issue.net: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Symantec/Dominator/aa74118a1c98d808a8c9332bf9219a4ce60bf8e9/cmd/imaginator/example-manifests/imageserver/files/etc/issue.net -------------------------------------------------------------------------------- /cmd/imaginator/example-manifests/imageserver/files/etc/mdb.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Symantec/Dominator/aa74118a1c98d808a8c9332bf9219a4ce60bf8e9/cmd/imaginator/example-manifests/imageserver/files/etc/mdb.json -------------------------------------------------------------------------------- /cmd/imaginator/example-manifests/imageserver/files/etc/systemd/system/imageserver.service.d/env.conf: -------------------------------------------------------------------------------- 1 | [Service] 2 | User=imageserver 3 | -------------------------------------------------------------------------------- /cmd/imaginator/example-manifests/imageserver/filter.add: -------------------------------------------------------------------------------- 1 | /data(|/.*)$ 2 | /etc/imageserver/flags[.]extra 3 | -------------------------------------------------------------------------------- /cmd/imaginator/example-manifests/imageserver/manifest: -------------------------------------------------------------------------------- 1 | { 2 | "SourceImage": "image-team/minimal/Debian-9" 3 | } 4 | -------------------------------------------------------------------------------- /cmd/imaginator/example-manifests/imageserver/package-list: -------------------------------------------------------------------------------- 1 | bash-completion 2 | curl 3 | dnsutils 4 | lsof 5 | ltrace 6 | man-db 7 | manpages 8 | mtr-tiny 9 | strace 10 | tcpdump 11 | tcptraceroute 12 | tcsh 13 | telnet 14 | tmpreaper 15 | traceroute 16 | -------------------------------------------------------------------------------- /cmd/imaginator/example-manifests/imageserver/scripts/01_install: -------------------------------------------------------------------------------- 1 | #! /bin/bash --posix 2 | 3 | set -ex 4 | 5 | readonly dir='/tmp/imageserver-unpack' 6 | 7 | rm -rf "$dir" || true 8 | mkdir -p "$dir" 9 | wget -q -O /tmp/imageserver.tar.gz http://mirror.prod.acme.com/misc/Dominator/imageserver.tar.gz 10 | tar -C "$dir" -xzf /tmp/imageserver.tar.gz 11 | rm /tmp/imageserver.tar.gz 12 | 13 | "$dir/install" 14 | rm -rf "$dir" 15 | 16 | mkdir -p /data /etc/imageserver /var/log/imageserver 17 | chmod a-w /data 18 | 19 | chown -R imageserver /etc/imageserver /etc/ssl/imageserver /var/log/imageserver 20 | 21 | # Remove noise. 22 | rm -f /etc/motd 23 | -------------------------------------------------------------------------------- /cmd/imaginator/example-manifests/imageserver/triggers.add: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "MatchLines": [ 4 | "/etc/imageserver/.*", 5 | "/etc/reverse-listeners/Scotty", 6 | "/etc/ssl/CA[.]pem", 7 | "/etc/ssl/imageserver/.*", 8 | "/etc/systemd/system/imageserver[.]service[.d]/.*", 9 | "/lib/systemd/system/imageserver[.]service", 10 | "/usr/local/sbin/imageserver" 11 | ], 12 | "Service": "imageserver" 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /cmd/imaginator/health-check.yml: -------------------------------------------------------------------------------- 1 | --- 2 | type: url 3 | probe-freq: 10 4 | specs: 5 | url-path: /healthz 6 | url-port: 6975 7 | -------------------------------------------------------------------------------- /cmd/imaginator/install: -------------------------------------------------------------------------------- 1 | #! /bin/bash --posix 2 | 3 | set -o nounset 4 | 5 | cd "${0%/*}" 6 | 7 | . ./scripts/install.lib 8 | 9 | install_all imaginator 10 | -------------------------------------------------------------------------------- /cmd/imaginator/required-methods: -------------------------------------------------------------------------------- 1 | ImageServer.AddImage 2 | ImageServer.GetImage 3 | ImageServer.ListDirectories 4 | ImageServer.ListImages 5 | ImageServer.MakeDirectory 6 | Imaginator.BuildImage 7 | ObjectServer.AddObjects 8 | ObjectServer.GetObjects 9 | -------------------------------------------------------------------------------- /cmd/imaginator/required-methods.slave: -------------------------------------------------------------------------------- 1 | ImageServer.GetImage 2 | ImageServer.ListDirectories 3 | ImageServer.ListImages 4 | ObjectServer.AddObjects 5 | ObjectServer.GetObjects 6 | -------------------------------------------------------------------------------- /cmd/imaginator/streams.json: -------------------------------------------------------------------------------- 1 | { 2 | "Streams": { 3 | "image-team/base/Ubuntu-14.04": { 4 | "ManifestUrl": "https://git.company.com/Prod-team/image-team.git", 5 | "ManifestDirectory": "$IMAGE_STREAM" 6 | }, 7 | "image-team/minimal/Ubuntu-14.04": { 8 | "ManifestUrl": "https://git.company.com/Prod-team/image-team.git", 9 | "ManifestDirectory": "$IMAGE_STREAM" 10 | }, 11 | "dev-team/webapp/widget-app": { 12 | "ManifestUrl": "https://$GIT_USERNAME:$GIT_PASSWORD@secure-git.company.com/Products/Widgets/webapp.git", 13 | "ManifestDirectory": "" 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /cmd/imaginator/stub.go: -------------------------------------------------------------------------------- 1 | // +build !linux 2 | 3 | package main 4 | 5 | import ( 6 | "os" 7 | ) 8 | 9 | func main() { 10 | os.Stderr.Write([]byte("Not available on this OS\n")) 11 | os.Exit(1) 12 | } 13 | -------------------------------------------------------------------------------- /cmd/installer/make-tarball: -------------------------------------------------------------------------------- 1 | #! /bin/bash --posix 2 | 3 | set -eu 4 | 5 | readonly command="$1" 6 | shift 7 | 8 | readonly bin="$GOPATH/bin/$command" 9 | readonly target="/tmp/$LOGNAME/$command.tar.gz" 10 | 11 | (cd $GOPATH/src; go install github.com/Symantec/Dominator/cmd/$command) 12 | 13 | strip -o "$bin~" "$bin" 14 | if cmp -s "$bin~" "$bin"; then 15 | rm "$bin~" 16 | else 17 | touch -r "$bin" "$bin~" 18 | mv "$bin~" "$bin" 19 | fi 20 | 21 | readonly tmpdir="$(mktemp -d '/tmp/make-tarball.XXXXXX')" || exit 22 | trap "rm -rf $tmpdir" EXIT 23 | 24 | mkdir -p "$tmpdir/etc/ssl/installer" "$tmpdir/usr/local/sbin" 25 | cp -p "$ETCDIR/ssl/"*.pem "$tmpdir/etc/ssl" 26 | cp -p "$ETCDIR/ssl/installer/"* "$tmpdir/etc/ssl/installer" 27 | cp -p "$bin" "$tmpdir/usr/local/sbin" 28 | 29 | tar --owner=0 --group=0 -czf "$target" -C "$tmpdir" . 30 | -------------------------------------------------------------------------------- /cmd/installer/required-methods: -------------------------------------------------------------------------------- 1 | ImageServer.CheckDirectory 2 | ImageServer.FindLatestImage 3 | ImageServer.GetImage 4 | ObjectServer.GetObjects 5 | -------------------------------------------------------------------------------- /cmd/installer/shell.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "os" 5 | "os/exec" 6 | 7 | "github.com/Symantec/Dominator/lib/log" 8 | ) 9 | 10 | func runShellOnConsole(logger log.DebugLogger) { 11 | for { 12 | logger.Println("starting shell on console") 13 | cmd := exec.Command("/bin/busybox", "sh", "-i") 14 | cmd.Stdin = os.Stdin 15 | cmd.Stdout = os.Stdout 16 | cmd.Stderr = os.Stderr 17 | if err := cmd.Run(); err != nil { 18 | logger.Printf("error running shell: %s\n", err) 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /cmd/installer/stub.go: -------------------------------------------------------------------------------- 1 | // +build !linux 2 | 3 | package main 4 | 5 | import ( 6 | "os" 7 | ) 8 | 9 | func main() { 10 | os.Stderr.Write([]byte("Not available on this OS\n")) 11 | os.Exit(1) 12 | } 13 | -------------------------------------------------------------------------------- /cmd/mdbd/health-check.yml: -------------------------------------------------------------------------------- 1 | --- 2 | type: url 3 | probe-freq: 10 4 | specs: 5 | url-path: /healthz 6 | url-port: 6973 7 | -------------------------------------------------------------------------------- /cmd/mdbd/install: -------------------------------------------------------------------------------- 1 | #! /bin/bash --posix 2 | 3 | set -o nounset 4 | 5 | cd "${0%/*}" 6 | 7 | . ./scripts/install.lib 8 | 9 | echo= 10 | 11 | $echo mkdir -p /usr/local/sbin || exit 12 | $echo cp -p bin/* /usr/local/sbin || exit 13 | $echo mkdir -p /etc/health-agent/tests.d 14 | $echo cp -p health-check.yml /etc/health-agent/tests.d/mdbd.yml || exit 15 | install_service mdbd || exit 16 | -------------------------------------------------------------------------------- /cmd/mdbd/required-methods: -------------------------------------------------------------------------------- 1 | FleetManager.GetUpdates 2 | Hypervisor.GetUpdates 3 | -------------------------------------------------------------------------------- /cmd/objecttool/checkObject.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/Symantec/Dominator/lib/hash" 8 | "github.com/Symantec/Dominator/lib/objectcache" 9 | "github.com/Symantec/Dominator/lib/objectserver" 10 | ) 11 | 12 | func checkObjectSubcommand(objSrv objectserver.ObjectServer, args []string) { 13 | hashes := make([]hash.Hash, 1) 14 | var err error 15 | hashes[0], err = objectcache.FilenameToHash(args[0]) 16 | if err != nil { 17 | fmt.Fprintf(os.Stderr, "Error parsing hash\t%s\n", err) 18 | os.Exit(2) 19 | } 20 | objectSizes, err := objSrv.CheckObjects(hashes) 21 | if err != nil { 22 | fmt.Fprintf(os.Stderr, "Error checking object\t%s\n", err) 23 | os.Exit(2) 24 | } 25 | if objectSizes[0] > 0 { 26 | os.Exit(0) 27 | } else { 28 | os.Exit(1) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /cmd/subd/health-check.yml: -------------------------------------------------------------------------------- 1 | --- 2 | type: url 3 | probe-freq: 10 4 | specs: 5 | url-path: /healthz 6 | url-port: 6969 7 | -------------------------------------------------------------------------------- /cmd/subd/install: -------------------------------------------------------------------------------- 1 | #! /bin/bash --posix 2 | 3 | set -o nounset 4 | 5 | cd "${0%/*}" 6 | 7 | . ./scripts/install.lib 8 | 9 | install_all subd 10 | -------------------------------------------------------------------------------- /cmd/subd/required-methods: -------------------------------------------------------------------------------- 1 | ObjectServer.GetObjects 2 | -------------------------------------------------------------------------------- /cmd/subtool/boostCpuLimit.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "os" 5 | 6 | "github.com/Symantec/Dominator/lib/srpc" 7 | "github.com/Symantec/Dominator/sub/client" 8 | ) 9 | 10 | func boostCpuLimitSubcommand(getSubClient getSubClientFunc, args []string) { 11 | if err := boostCpuLimit(getSubClient()); err != nil { 12 | logger.Fatalf("Error boosting CPU limit: %s\n", err) 13 | } 14 | os.Exit(0) 15 | } 16 | 17 | func boostCpuLimit(srpcClient *srpc.Client) error { 18 | return client.BoostCpuLimit(srpcClient) 19 | } 20 | -------------------------------------------------------------------------------- /cmd/subtool/cleanup.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "os" 5 | 6 | "github.com/Symantec/Dominator/lib/srpc" 7 | "github.com/Symantec/Dominator/proto/sub" 8 | "github.com/Symantec/Dominator/sub/client" 9 | ) 10 | 11 | func cleanupSubcommand(getSubClient getSubClientFunc, args []string) { 12 | if err := cleanup(getSubClient()); err != nil { 13 | logger.Fatalf("Error cleaning up: %s\n", err) 14 | } 15 | os.Exit(0) 16 | } 17 | 18 | func cleanup(srpcClient *srpc.Client) error { 19 | var request sub.PollRequest 20 | var reply sub.PollResponse 21 | if err := client.CallPoll(srpcClient, request, &reply); err != nil { 22 | return err 23 | } 24 | if len(reply.ObjectCache) < 1 { 25 | return nil 26 | } 27 | logger.Printf("Deleting: %d objects\n", len(reply.ObjectCache)) 28 | return client.Cleanup(srpcClient, reply.ObjectCache) 29 | } 30 | -------------------------------------------------------------------------------- /cmd/subtool/delete.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "os" 5 | 6 | "github.com/Symantec/Dominator/lib/srpc" 7 | "github.com/Symantec/Dominator/proto/sub" 8 | "github.com/Symantec/Dominator/sub/client" 9 | ) 10 | 11 | func deleteSubcommand(getSubClient getSubClientFunc, args []string) { 12 | if err := deletePaths(getSubClient(), args); err != nil { 13 | logger.Fatalf("Error deleting: %s\n", err) 14 | } 15 | os.Exit(0) 16 | } 17 | 18 | func deletePaths(srpcClient *srpc.Client, pathnames []string) error { 19 | return client.CallUpdate(srpcClient, sub.UpdateRequest{ 20 | PathsToDelete: pathnames, 21 | Wait: true}, 22 | &sub.UpdateResponse{}) 23 | } 24 | -------------------------------------------------------------------------------- /cmd/subtool/getConfig.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/Symantec/Dominator/lib/srpc" 8 | "github.com/Symantec/Dominator/sub/client" 9 | ) 10 | 11 | func getConfigSubcommand(getSubClient getSubClientFunc, args []string) { 12 | if err := getConfig(getSubClient()); err != nil { 13 | logger.Fatalf("Error getting config: %s\n", err) 14 | } 15 | os.Exit(0) 16 | } 17 | 18 | func getConfig(srpcClient *srpc.Client) error { 19 | config, err := client.GetConfiguration(srpcClient) 20 | if err != nil { 21 | return err 22 | } 23 | fmt.Println(config) 24 | return nil 25 | } 26 | -------------------------------------------------------------------------------- /cmd/subtool/setConfig.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "os" 5 | 6 | "github.com/Symantec/Dominator/lib/srpc" 7 | "github.com/Symantec/Dominator/proto/sub" 8 | "github.com/Symantec/Dominator/sub/client" 9 | ) 10 | 11 | func setConfigSubcommand(getSubClient getSubClientFunc, args []string) { 12 | if err := setConfig(getSubClient()); err != nil { 13 | logger.Fatalf("Error setting config: %s\n", err) 14 | } 15 | os.Exit(0) 16 | } 17 | 18 | func setConfig(srpcClient *srpc.Client) error { 19 | var config sub.Configuration 20 | config.CpuPercent = *cpuPercent 21 | config.NetworkSpeedPercent = *networkSpeedPercent 22 | config.ScanExclusionList = scanExcludeList 23 | config.ScanSpeedPercent = *scanSpeedPercent 24 | return client.SetConfiguration(srpcClient, config) 25 | } 26 | -------------------------------------------------------------------------------- /cmd/unpacker-tool/associate.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/Symantec/Dominator/imageunpacker/client" 8 | "github.com/Symantec/Dominator/lib/srpc" 9 | ) 10 | 11 | func associateSubcommand(srpcClient *srpc.Client, args []string) { 12 | err := client.AssociateStreamWithDevice(srpcClient, args[0], args[1]) 13 | if err != nil { 14 | fmt.Fprintf(os.Stderr, "Error associating: %s\n", err) 15 | os.Exit(1) 16 | } 17 | os.Exit(0) 18 | } 19 | -------------------------------------------------------------------------------- /cmd/unpacker-tool/exportImage.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/Symantec/Dominator/imageunpacker/client" 8 | "github.com/Symantec/Dominator/lib/srpc" 9 | ) 10 | 11 | func exportImageSubcommand(srpcClient *srpc.Client, args []string) { 12 | err := client.ExportImage(srpcClient, args[0], args[1], args[2]) 13 | if err != nil { 14 | fmt.Fprintf(os.Stderr, "Error exporting image: %s\n", err) 15 | os.Exit(1) 16 | } 17 | os.Exit(0) 18 | } 19 | -------------------------------------------------------------------------------- /cmd/unpacker-tool/prepareForCapture.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/Symantec/Dominator/imageunpacker/client" 8 | "github.com/Symantec/Dominator/lib/srpc" 9 | ) 10 | 11 | func prepareForCaptureSubcommand(srpcClient *srpc.Client, args []string) { 12 | if err := client.PrepareForCapture(srpcClient, args[0]); err != nil { 13 | fmt.Fprintf(os.Stderr, "Error preparing for capture: %s\n", err) 14 | os.Exit(1) 15 | } 16 | os.Exit(0) 17 | } 18 | -------------------------------------------------------------------------------- /cmd/unpacker-tool/prepareForCopy.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/Symantec/Dominator/imageunpacker/client" 8 | "github.com/Symantec/Dominator/lib/srpc" 9 | ) 10 | 11 | func prepareForCopySubcommand(srpcClient *srpc.Client, args []string) { 12 | if err := client.PrepareForCopy(srpcClient, args[0]); err != nil { 13 | fmt.Fprintf(os.Stderr, "Error preparing for copy: %s\n", err) 14 | os.Exit(1) 15 | } 16 | os.Exit(0) 17 | } 18 | -------------------------------------------------------------------------------- /cmd/unpacker-tool/prepareForUnpack.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/Symantec/Dominator/imageunpacker/client" 8 | "github.com/Symantec/Dominator/lib/srpc" 9 | ) 10 | 11 | func prepareForUnpackSubcommand(srpcClient *srpc.Client, args []string) { 12 | if err := prepareForUnpack(srpcClient, args[0]); err != nil { 13 | fmt.Fprintf(os.Stderr, "Error preparing for unpack: %s\n", err) 14 | os.Exit(1) 15 | } 16 | os.Exit(0) 17 | } 18 | 19 | func prepareForUnpack(srpcClient *srpc.Client, streamName string) error { 20 | return client.PrepareForUnpack(srpcClient, streamName, false, false) 21 | } 22 | -------------------------------------------------------------------------------- /cmd/unpacker-tool/removeDevice.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/Symantec/Dominator/imageunpacker/client" 8 | "github.com/Symantec/Dominator/lib/srpc" 9 | ) 10 | 11 | func removeDeviceSubcommand(srpcClient *srpc.Client, args []string) { 12 | if err := client.RemoveDevice(srpcClient, args[0]); err != nil { 13 | fmt.Fprintf(os.Stderr, "Error removing device: %s\n", err) 14 | os.Exit(1) 15 | } 16 | os.Exit(0) 17 | } 18 | -------------------------------------------------------------------------------- /cmd/unpacker-tool/unpackImage.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/Symantec/Dominator/imageunpacker/client" 8 | "github.com/Symantec/Dominator/lib/srpc" 9 | ) 10 | 11 | func unpackImageSubcommand(srpcClient *srpc.Client, args []string) { 12 | if err := client.UnpackImage(srpcClient, args[0], args[1]); err != nil { 13 | fmt.Fprintf(os.Stderr, "Error unpacking image: %s\n", err) 14 | os.Exit(1) 15 | } 16 | os.Exit(0) 17 | } 18 | -------------------------------------------------------------------------------- /cmd/vm-control/dial.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/srpc" 5 | ) 6 | 7 | func dialFleetManager(address string) (*srpc.Client, error) { 8 | return srpc.DialHTTPWithDialer("tcp", address, rrDialer) 9 | } 10 | 11 | func dialHypervisor(address string) (*srpc.Client, error) { 12 | return srpc.DialHTTP("tcp", address, 0) 13 | } 14 | -------------------------------------------------------------------------------- /cmd/vm-control/variables_darwin.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | const defaultVncViewer = "" 4 | -------------------------------------------------------------------------------- /cmd/vm-control/variables_linux.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | const defaultVncViewer = "vncviewer" 4 | -------------------------------------------------------------------------------- /dom/rpcd/api.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/dom/herd" 5 | "github.com/Symantec/Dominator/lib/log" 6 | "github.com/Symantec/Dominator/lib/srpc" 7 | ) 8 | 9 | type rpcType struct { 10 | herd *herd.Herd 11 | logger log.Logger 12 | } 13 | 14 | func Setup(herd *herd.Herd, logger log.Logger) { 15 | rpcObj := &rpcType{ 16 | herd: herd, 17 | logger: logger} 18 | srpc.RegisterName("Dominator", rpcObj) 19 | } 20 | -------------------------------------------------------------------------------- /dom/rpcd/clearSafetyShutoff.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/srpc" 5 | "github.com/Symantec/Dominator/proto/dominator" 6 | ) 7 | 8 | func (t *rpcType) ClearSafetyShutoff(conn *srpc.Conn, 9 | request dominator.ClearSafetyShutoffRequest, 10 | reply *dominator.ClearSafetyShutoffResponse) error { 11 | if conn.Username() == "" { 12 | t.logger.Printf("ClearSafetyShutoff(%s)\n", request.Hostname) 13 | } else { 14 | t.logger.Printf("ClearSafetyShutoff(%s): by %s\n", 15 | request.Hostname, conn.Username()) 16 | } 17 | return t.herd.ClearSafetyShutoff(request.Hostname) 18 | } 19 | -------------------------------------------------------------------------------- /dom/rpcd/configureSubs.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/srpc" 5 | "github.com/Symantec/Dominator/proto/dominator" 6 | "github.com/Symantec/Dominator/proto/sub" 7 | ) 8 | 9 | func (t *rpcType) ConfigureSubs(conn *srpc.Conn, 10 | request dominator.ConfigureSubsRequest, 11 | reply *dominator.ConfigureSubsResponse) error { 12 | if conn.Username() == "" { 13 | t.logger.Printf("ConfigureSubs()\n") 14 | } else { 15 | t.logger.Printf("ConfigureSubs(): by %s\n", conn.Username()) 16 | } 17 | return t.herd.ConfigureSubs(sub.Configuration(request)) 18 | } 19 | -------------------------------------------------------------------------------- /dom/rpcd/disableUpdates.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/srpc" 5 | "github.com/Symantec/Dominator/proto/dominator" 6 | ) 7 | 8 | func (t *rpcType) DisableUpdates(conn *srpc.Conn, 9 | request dominator.DisableUpdatesRequest, 10 | reply *dominator.DisableUpdatesResponse) error { 11 | if conn.Username() == "" { 12 | t.logger.Printf("DisableUpdates(%s)\n", request.Reason) 13 | } else { 14 | t.logger.Printf("DisableUpdates(%s): by %s\n", 15 | request.Reason, conn.Username()) 16 | } 17 | return t.herd.DisableUpdates(conn.Username(), request.Reason) 18 | } 19 | -------------------------------------------------------------------------------- /dom/rpcd/enableUpdates.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/srpc" 5 | "github.com/Symantec/Dominator/proto/dominator" 6 | ) 7 | 8 | func (t *rpcType) EnableUpdates(conn *srpc.Conn, 9 | request dominator.EnableUpdatesRequest, 10 | reply *dominator.EnableUpdatesResponse) error { 11 | if conn.Username() == "" { 12 | t.logger.Printf("EnableUpdates(%s)\n", request.Reason) 13 | } else { 14 | t.logger.Printf("EnableUpdates(%s): by %s\n", 15 | request.Reason, conn.Username()) 16 | } 17 | return t.herd.EnableUpdates() 18 | } 19 | -------------------------------------------------------------------------------- /dom/rpcd/getDefaultImage.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/srpc" 5 | "github.com/Symantec/Dominator/proto/dominator" 6 | ) 7 | 8 | func (t *rpcType) GetDefaultImage(conn *srpc.Conn, 9 | request dominator.GetDefaultImageRequest, 10 | reply *dominator.GetDefaultImageResponse) error { 11 | reply.ImageName = t.herd.GetDefaultImage() 12 | return nil 13 | } 14 | -------------------------------------------------------------------------------- /dom/rpcd/getSubsConfiguration.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/srpc" 5 | "github.com/Symantec/Dominator/proto/dominator" 6 | ) 7 | 8 | func (t *rpcType) GetSubsConfiguration(conn *srpc.Conn, 9 | request dominator.GetSubsConfigurationRequest, 10 | reply *dominator.GetSubsConfigurationResponse) error { 11 | *reply = dominator.GetSubsConfigurationResponse( 12 | t.herd.GetSubsConfiguration()) 13 | return nil 14 | } 15 | -------------------------------------------------------------------------------- /dom/rpcd/setDefaultImage.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/srpc" 5 | "github.com/Symantec/Dominator/proto/dominator" 6 | ) 7 | 8 | func (t *rpcType) SetDefaultImage(conn *srpc.Conn, 9 | request dominator.SetDefaultImageRequest, 10 | reply *dominator.SetDefaultImageResponse) error { 11 | if conn.Username() == "" { 12 | t.logger.Printf("SetDefaultImage(%s)\n", request.ImageName) 13 | } else { 14 | t.logger.Printf("SetDefaultImage(%s): by %s\n", 15 | request.ImageName, conn.Username()) 16 | } 17 | return t.herd.SetDefaultImage(request.ImageName) 18 | } 19 | -------------------------------------------------------------------------------- /fleetmanager/hypervisors/fsstorer/check.go: -------------------------------------------------------------------------------- 1 | package fsstorer 2 | 3 | import ( 4 | "errors" 5 | "net" 6 | ) 7 | 8 | func (s *Storer) checkIpIsRegistered(addr net.IP) (bool, error) { 9 | if ip, err := netIpToIp(addr); err != nil { 10 | return false, err 11 | } else { 12 | s.mutex.RLock() 13 | defer s.mutex.RUnlock() 14 | _, ok := s.ipToHypervisor[ip] 15 | return ok, nil 16 | } 17 | } 18 | 19 | func netIpToIp(netIP net.IP) (IP, error) { 20 | switch len(netIP) { 21 | case 4: 22 | case 16: 23 | netIP = netIP.To4() 24 | if netIP == nil { 25 | return zeroIP, errors.New("bad IP") 26 | } 27 | default: 28 | return zeroIP, errors.New("bad IP") 29 | } 30 | var ip IP 31 | copy(ip[:], netIP) 32 | return ip, nil 33 | } 34 | -------------------------------------------------------------------------------- /fleetmanager/hypervisors/fsstorer/get.go: -------------------------------------------------------------------------------- 1 | package fsstorer 2 | 3 | import ( 4 | "net" 5 | ) 6 | 7 | func (s *Storer) getHypervisorForIp(addr net.IP) (net.IP, error) { 8 | if ip, err := netIpToIp(addr); err != nil { 9 | return nil, err 10 | } else { 11 | s.mutex.RLock() 12 | hypervisor, ok := s.ipToHypervisor[ip] 13 | s.mutex.RUnlock() 14 | if !ok { 15 | return nil, nil 16 | } 17 | return hypervisor[:], nil 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /fleetmanager/hypervisors/fsstorer/ip.go: -------------------------------------------------------------------------------- 1 | package fsstorer 2 | 3 | import "fmt" 4 | 5 | func (ip IP) string() string { 6 | return fmt.Sprintf("%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]) 7 | } 8 | -------------------------------------------------------------------------------- /fleetmanager/hypervisors/status.go: -------------------------------------------------------------------------------- 1 | package hypervisors 2 | 3 | func (s probeStatus) String() string { 4 | switch s { 5 | case probeStatusNotYetProbed: 6 | return "not yet probed" 7 | case probeStatusConnected: 8 | return "connected" 9 | case probeStatusNoSrpc: 10 | return "no SRPC" 11 | case probeStatusNoService: 12 | return "no service" 13 | case probeStatusConnectionRefused: 14 | return "connection refused" 15 | case probeStatusUnreachable: 16 | return "unreachable" 17 | case probeStatusOff: 18 | return "off" 19 | default: 20 | return "UNKNOWN" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /fleetmanager/rpcd/changeMachineTags.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/errors" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | "github.com/Symantec/Dominator/proto/fleetmanager" 7 | ) 8 | 9 | func (t *srpcType) ChangeMachineTags(conn *srpc.Conn, 10 | request fleetmanager.ChangeMachineTagsRequest, 11 | reply *fleetmanager.ChangeMachineTagsResponse) error { 12 | *reply = fleetmanager.ChangeMachineTagsResponse{ 13 | errors.ErrorToString(t.hypervisorsManager.ChangeMachineTags( 14 | request.Hostname, conn.GetAuthInformation(), request.Tags))} 15 | return nil 16 | } 17 | -------------------------------------------------------------------------------- /fleetmanager/rpcd/getHypervisorForVm.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/Symantec/Dominator/lib/constants" 7 | "github.com/Symantec/Dominator/lib/errors" 8 | "github.com/Symantec/Dominator/lib/srpc" 9 | proto "github.com/Symantec/Dominator/proto/fleetmanager" 10 | ) 11 | 12 | func (t *srpcType) GetHypervisorForVM(conn *srpc.Conn, 13 | request proto.GetHypervisorForVMRequest, 14 | reply *proto.GetHypervisorForVMResponse) error { 15 | hypervisor, err := t.hypervisorsManager.GetHypervisorForVm( 16 | request.IpAddress) 17 | response := proto.GetHypervisorForVMResponse{ 18 | Error: errors.ErrorToString(err), 19 | } 20 | if err == nil { 21 | response.HypervisorAddress = fmt.Sprintf("%s:%d", 22 | hypervisor, constants.HypervisorPortNumber) 23 | } 24 | *reply = response 25 | return nil 26 | } 27 | -------------------------------------------------------------------------------- /fleetmanager/rpcd/html.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "io" 5 | ) 6 | 7 | func (hw *htmlWriter) writeHtml(writer io.Writer) { 8 | } 9 | -------------------------------------------------------------------------------- /fleetmanager/rpcd/listHypervisorLocations.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/errors" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | proto "github.com/Symantec/Dominator/proto/fleetmanager" 7 | ) 8 | 9 | func (t *srpcType) ListHypervisorLocations(conn *srpc.Conn, 10 | request proto.ListHypervisorLocationsRequest, 11 | reply *proto.ListHypervisorLocationsResponse) error { 12 | locations, err := t.hypervisorsManager.ListLocations(request.TopLocation) 13 | *reply = proto.ListHypervisorLocationsResponse{ 14 | Locations: locations, 15 | Error: errors.ErrorToString(err), 16 | } 17 | return nil 18 | } 19 | -------------------------------------------------------------------------------- /fleetmanager/rpcd/listHypervisorsInLocation.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/errors" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | proto "github.com/Symantec/Dominator/proto/fleetmanager" 7 | ) 8 | 9 | func (t *srpcType) ListHypervisorsInLocation(conn *srpc.Conn, 10 | request proto.ListHypervisorsInLocationRequest, 11 | reply *proto.ListHypervisorsInLocationResponse) error { 12 | addresses, err := t.hypervisorsManager.ListHypervisorsInLocation(request) 13 | *reply = proto.ListHypervisorsInLocationResponse{ 14 | HypervisorAddresses: addresses, 15 | Error: errors.ErrorToString(err), 16 | } 17 | return nil 18 | } 19 | -------------------------------------------------------------------------------- /fleetmanager/rpcd/moveIpAddresses.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/errors" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | fm_proto "github.com/Symantec/Dominator/proto/fleetmanager" 7 | ) 8 | 9 | func (t *srpcType) MoveIpAddresses(conn *srpc.Conn, 10 | request fm_proto.MoveIpAddressesRequest, 11 | reply *fm_proto.MoveIpAddressesResponse) error { 12 | err := t.hypervisorsManager.MoveIpAddresses(request.HypervisorHostname, 13 | request.IpAddresses) 14 | if err != nil { 15 | *reply = fm_proto.MoveIpAddressesResponse{ 16 | Error: errors.ErrorToString(err)} 17 | } 18 | return nil 19 | } 20 | -------------------------------------------------------------------------------- /fleetmanager/topology/check.go: -------------------------------------------------------------------------------- 1 | package topology 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func (t *Topology) checkIfMachineHasSubnet(name, subnetId string) ( 8 | bool, error) { 9 | if directory, ok := t.machineParents[name]; !ok { 10 | return false, fmt.Errorf("unknown machine: %s", name) 11 | } else { 12 | // TODO(rgooch): It would be faster to have a single map for all the 13 | // subnets down to the directory, but it would consume 14 | // more memory. Revisit this if needed. 15 | for ; directory != nil; directory = directory.parent { 16 | if _, ok := directory.subnetIdToSubnet[subnetId]; ok { 17 | return true, nil 18 | } 19 | } 20 | return false, nil 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /fleetmanager/topology/get.go: -------------------------------------------------------------------------------- 1 | package topology 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func (t *Topology) getLocationOfMachine(name string) (string, error) { 8 | if directory, ok := t.machineParents[name]; !ok { 9 | return "", fmt.Errorf("unknown machine: %s", name) 10 | } else { 11 | return directory.path, nil 12 | } 13 | } 14 | 15 | func (t *Topology) getSubnetsForMachine(name string) ([]*Subnet, error) { 16 | if directory, ok := t.machineParents[name]; !ok { 17 | return nil, fmt.Errorf("unknown machine: %s", name) 18 | } else { 19 | var subnets []*Subnet 20 | for ; directory != nil; directory = directory.parent { 21 | subnets = append(subnets, directory.Subnets...) 22 | } 23 | return subnets, nil 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /fleetmanager/topology/walk.go: -------------------------------------------------------------------------------- 1 | package topology 2 | 3 | func (directory *Directory) walk(fn func(*Directory) error) error { 4 | if err := fn(directory); err != nil { 5 | return err 6 | } 7 | for _, subdir := range directory.Directories { 8 | if err := subdir.walk(fn); err != nil { 9 | return err 10 | } 11 | } 12 | return nil 13 | } 14 | -------------------------------------------------------------------------------- /hypervisor/httpd/listAvailableAddresses.go: -------------------------------------------------------------------------------- 1 | package httpd 2 | 3 | import ( 4 | "bufio" 5 | "net/http" 6 | 7 | "github.com/Symantec/Dominator/lib/json" 8 | ) 9 | 10 | func (s state) listAvailableAddressesHandler(w http.ResponseWriter, 11 | req *http.Request) { 12 | writer := bufio.NewWriter(w) 13 | defer writer.Flush() 14 | addresses := s.manager.ListAvailableAddresses() 15 | json.WriteWithIndent(writer, " ", addresses) 16 | } 17 | -------------------------------------------------------------------------------- /hypervisor/httpd/listSubnets.go: -------------------------------------------------------------------------------- 1 | package httpd 2 | 3 | import ( 4 | "bufio" 5 | "net/http" 6 | 7 | "github.com/Symantec/Dominator/lib/json" 8 | ) 9 | 10 | func (s state) listSubnetsHandler(w http.ResponseWriter, req *http.Request) { 11 | writer := bufio.NewWriter(w) 12 | defer writer.Flush() 13 | subnets := s.manager.ListSubnets(true) 14 | json.WriteWithIndent(writer, " ", subnets) 15 | } 16 | -------------------------------------------------------------------------------- /hypervisor/manager/cpu.go: -------------------------------------------------------------------------------- 1 | package manager 2 | 3 | import ( 4 | "errors" 5 | ) 6 | 7 | var ( 8 | errorInsufficientUnallocatedCPU = errors.New( 9 | "insufficient unallocated CPU") 10 | ) 11 | 12 | func (m *Manager) checkSufficientCPUWithLock(milliCPU uint) error { 13 | if milliCPU > m.getAvailableMilliCPUWithLock() { 14 | return errorInsufficientUnallocatedCPU 15 | } 16 | return nil 17 | } 18 | 19 | func (m *Manager) getAvailableMilliCPU() uint { 20 | m.mutex.RLock() 21 | defer m.mutex.RUnlock() 22 | return m.getAvailableMilliCPUWithLock() 23 | } 24 | 25 | func (m *Manager) getAvailableMilliCPUWithLock() uint { 26 | available := m.numCPU * 1000 27 | for _, vm := range m.vms { 28 | available -= int(vm.MilliCPUs) 29 | } 30 | if available < 0 { 31 | return 0 32 | } 33 | return uint(available) 34 | } 35 | -------------------------------------------------------------------------------- /hypervisor/rpcd/acknowledgeVm.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/errors" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | "github.com/Symantec/Dominator/proto/hypervisor" 7 | ) 8 | 9 | func (t *srpcType) AcknowledgeVm(conn *srpc.Conn, 10 | request hypervisor.AcknowledgeVmRequest, 11 | reply *hypervisor.AcknowledgeVmResponse) error { 12 | response := hypervisor.AcknowledgeVmResponse{ 13 | errors.ErrorToString(t.manager.AcknowledgeVm(request.IpAddress, 14 | conn.GetAuthInformation()))} 15 | *reply = response 16 | return nil 17 | } 18 | -------------------------------------------------------------------------------- /hypervisor/rpcd/becomePrimaryVmOwner.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/errors" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | "github.com/Symantec/Dominator/proto/hypervisor" 7 | ) 8 | 9 | func (t *srpcType) BecomePrimaryVmOwner(conn *srpc.Conn, 10 | request hypervisor.BecomePrimaryVmOwnerRequest, 11 | reply *hypervisor.BecomePrimaryVmOwnerResponse) error { 12 | *reply = hypervisor.BecomePrimaryVmOwnerResponse{ 13 | errors.ErrorToString( 14 | t.manager.BecomePrimaryVmOwner(request.IpAddress, 15 | conn.GetAuthInformation()))} 16 | return nil 17 | } 18 | -------------------------------------------------------------------------------- /hypervisor/rpcd/changeOwners.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/errors" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | "github.com/Symantec/Dominator/proto/hypervisor" 7 | ) 8 | 9 | func (t *srpcType) ChangeOwners(conn *srpc.Conn, 10 | request hypervisor.ChangeOwnersRequest, 11 | reply *hypervisor.ChangeOwnersResponse) error { 12 | response := hypervisor.ChangeOwnersResponse{ 13 | errors.ErrorToString( 14 | t.manager.ChangeOwners(request.OwnerGroups, request.OwnerUsers))} 15 | *reply = response 16 | return nil 17 | } 18 | -------------------------------------------------------------------------------- /hypervisor/rpcd/changeVmConsoleType.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/errors" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | "github.com/Symantec/Dominator/proto/hypervisor" 7 | ) 8 | 9 | func (t *srpcType) ChangeVmConsoleType(conn *srpc.Conn, 10 | request hypervisor.ChangeVmConsoleTypeRequest, 11 | reply *hypervisor.ChangeVmConsoleTypeResponse) error { 12 | *reply = hypervisor.ChangeVmConsoleTypeResponse{ 13 | errors.ErrorToString( 14 | t.manager.ChangeVmConsoleType(request.IpAddress, 15 | conn.GetAuthInformation(), 16 | request.ConsoleType))} 17 | return nil 18 | } 19 | -------------------------------------------------------------------------------- /hypervisor/rpcd/changeVmDestroyProtection.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/errors" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | "github.com/Symantec/Dominator/proto/hypervisor" 7 | ) 8 | 9 | func (t *srpcType) ChangeVmDestroyProtection(conn *srpc.Conn, 10 | request hypervisor.ChangeVmDestroyProtectionRequest, 11 | reply *hypervisor.ChangeVmDestroyProtectionResponse) error { 12 | *reply = hypervisor.ChangeVmDestroyProtectionResponse{ 13 | errors.ErrorToString( 14 | t.manager.ChangeVmDestroyProtection(request.IpAddress, 15 | conn.GetAuthInformation(), 16 | request.DestroyProtection))} 17 | return nil 18 | } 19 | -------------------------------------------------------------------------------- /hypervisor/rpcd/changeVmOwnerUsers.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/errors" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | "github.com/Symantec/Dominator/proto/hypervisor" 7 | ) 8 | 9 | func (t *srpcType) ChangeVmOwnerUsers(conn *srpc.Conn, 10 | request hypervisor.ChangeVmOwnerUsersRequest, 11 | reply *hypervisor.ChangeVmOwnerUsersResponse) error { 12 | response := hypervisor.ChangeVmOwnerUsersResponse{ 13 | errors.ErrorToString( 14 | t.manager.ChangeVmOwnerUsers(request.IpAddress, 15 | conn.GetAuthInformation(), 16 | request.OwnerUsers))} 17 | *reply = response 18 | return nil 19 | } 20 | -------------------------------------------------------------------------------- /hypervisor/rpcd/changeVmTags.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/errors" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | "github.com/Symantec/Dominator/proto/hypervisor" 7 | ) 8 | 9 | func (t *srpcType) ChangeVmTags(conn *srpc.Conn, 10 | request hypervisor.ChangeVmTagsRequest, 11 | reply *hypervisor.ChangeVmTagsResponse) error { 12 | response := hypervisor.ChangeVmTagsResponse{ 13 | errors.ErrorToString( 14 | t.manager.ChangeVmTags(request.IpAddress, conn.GetAuthInformation(), 15 | request.Tags))} 16 | *reply = response 17 | return nil 18 | } 19 | -------------------------------------------------------------------------------- /hypervisor/rpcd/commitImportedVm.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/errors" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | "github.com/Symantec/Dominator/proto/hypervisor" 7 | ) 8 | 9 | func (t *srpcType) CommitImportedVm(conn *srpc.Conn, 10 | request hypervisor.CommitImportedVmRequest, 11 | reply *hypervisor.CommitImportedVmResponse) error { 12 | *reply = hypervisor.CommitImportedVmResponse{ 13 | errors.ErrorToString( 14 | t.manager.CommitImportedVm(request.IpAddress, 15 | conn.GetAuthInformation()))} 16 | return nil 17 | } 18 | -------------------------------------------------------------------------------- /hypervisor/rpcd/copyVm.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/srpc" 5 | "github.com/Symantec/Dominator/proto/hypervisor" 6 | ) 7 | 8 | func (t *srpcType) CopyVm(conn *srpc.Conn) error { 9 | if err := t.copyVm(conn); err != nil { 10 | return conn.Encode(hypervisor.CopyVmResponse{Error: err.Error()}) 11 | } 12 | return nil 13 | } 14 | 15 | func (t *srpcType) copyVm(conn *srpc.Conn) error { 16 | var request hypervisor.CopyVmRequest 17 | if err := conn.Decode(&request); err != nil { 18 | return err 19 | } 20 | return t.manager.CopyVm(conn, request) 21 | } 22 | -------------------------------------------------------------------------------- /hypervisor/rpcd/createVm.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/srpc" 5 | ) 6 | 7 | func (t *srpcType) CreateVm(conn *srpc.Conn) error { 8 | return t.manager.CreateVm(conn) 9 | } 10 | -------------------------------------------------------------------------------- /hypervisor/rpcd/deleteVmVolume.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/errors" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | "github.com/Symantec/Dominator/proto/hypervisor" 7 | ) 8 | 9 | func (t *srpcType) DeleteVmVolume(conn *srpc.Conn, 10 | request hypervisor.DeleteVmVolumeRequest, 11 | reply *hypervisor.DeleteVmVolumeResponse) error { 12 | *reply = hypervisor.DeleteVmVolumeResponse{ 13 | errors.ErrorToString(t.manager.DeleteVmVolume(request.IpAddress, 14 | conn.GetAuthInformation(), request.AccessToken, 15 | request.VolumeIndex))} 16 | return nil 17 | } 18 | -------------------------------------------------------------------------------- /hypervisor/rpcd/destroyVm.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/errors" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | "github.com/Symantec/Dominator/proto/hypervisor" 7 | ) 8 | 9 | func (t *srpcType) DestroyVm(conn *srpc.Conn, 10 | request hypervisor.DestroyVmRequest, 11 | reply *hypervisor.DestroyVmResponse) error { 12 | response := hypervisor.DestroyVmResponse{ 13 | errors.ErrorToString(t.manager.DestroyVm(request.IpAddress, 14 | conn.GetAuthInformation(), request.AccessToken))} 15 | *reply = response 16 | return nil 17 | } 18 | -------------------------------------------------------------------------------- /hypervisor/rpcd/discardVmAccessToken.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/errors" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | "github.com/Symantec/Dominator/proto/hypervisor" 7 | ) 8 | 9 | func (t *srpcType) DiscardVmAccessToken(conn *srpc.Conn, 10 | request hypervisor.DiscardVmAccessTokenRequest, 11 | reply *hypervisor.DiscardVmAccessTokenResponse) error { 12 | *reply = hypervisor.DiscardVmAccessTokenResponse{ 13 | errors.ErrorToString(t.manager.DiscardVmAccessToken(request.IpAddress, 14 | conn.GetAuthInformation(), request.AccessToken))} 15 | return nil 16 | } 17 | -------------------------------------------------------------------------------- /hypervisor/rpcd/discardVmOldImage.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/errors" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | "github.com/Symantec/Dominator/proto/hypervisor" 7 | ) 8 | 9 | func (t *srpcType) DiscardVmOldImage(conn *srpc.Conn, 10 | request hypervisor.DiscardVmOldImageRequest, 11 | reply *hypervisor.DiscardVmOldImageResponse) error { 12 | response := hypervisor.DiscardVmOldImageResponse{ 13 | errors.ErrorToString(t.manager.DiscardVmOldImage(request.IpAddress, 14 | conn.GetAuthInformation()))} 15 | *reply = response 16 | return nil 17 | } 18 | -------------------------------------------------------------------------------- /hypervisor/rpcd/discardVmOldUserData.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/errors" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | "github.com/Symantec/Dominator/proto/hypervisor" 7 | ) 8 | 9 | func (t *srpcType) DiscardVmOldUserData(conn *srpc.Conn, 10 | request hypervisor.DiscardVmOldUserDataRequest, 11 | reply *hypervisor.DiscardVmOldUserDataResponse) error { 12 | response := hypervisor.DiscardVmOldUserDataResponse{ 13 | errors.ErrorToString(t.manager.DiscardVmOldUserData(request.IpAddress, 14 | conn.GetAuthInformation()))} 15 | *reply = response 16 | return nil 17 | } 18 | -------------------------------------------------------------------------------- /hypervisor/rpcd/discardVmSnapshot.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/errors" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | "github.com/Symantec/Dominator/proto/hypervisor" 7 | ) 8 | 9 | func (t *srpcType) DiscardVmSnapshot(conn *srpc.Conn, 10 | request hypervisor.DiscardVmSnapshotRequest, 11 | reply *hypervisor.DiscardVmSnapshotResponse) error { 12 | response := hypervisor.DiscardVmSnapshotResponse{ 13 | errors.ErrorToString(t.manager.DiscardVmSnapshot(request.IpAddress, 14 | conn.GetAuthInformation()))} 15 | *reply = response 16 | return nil 17 | } 18 | -------------------------------------------------------------------------------- /hypervisor/rpcd/exportLocalVm.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/errors" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | "github.com/Symantec/Dominator/proto/hypervisor" 7 | ) 8 | 9 | func (t *srpcType) ExportLocalVm(conn *srpc.Conn, 10 | request hypervisor.ExportLocalVmRequest, 11 | reply *hypervisor.ExportLocalVmResponse) error { 12 | vmInfo, err := t.exportLocalVm(conn, request) 13 | *reply = hypervisor.ExportLocalVmResponse{ 14 | Error: errors.ErrorToString(err), 15 | VmInfo: *vmInfo, 16 | } 17 | return nil 18 | } 19 | 20 | func (t *srpcType) exportLocalVm(conn *srpc.Conn, 21 | request hypervisor.ExportLocalVmRequest) ( 22 | *hypervisor.ExportLocalVmInfo, error) { 23 | if err := testIfLoopback(conn); err != nil { 24 | return nil, err 25 | } 26 | return t.manager.ExportLocalVm(conn.GetAuthInformation(), request) 27 | } 28 | -------------------------------------------------------------------------------- /hypervisor/rpcd/getVmAccessToken.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/errors" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | "github.com/Symantec/Dominator/proto/hypervisor" 7 | ) 8 | 9 | func (t *srpcType) GetVmAccessToken(conn *srpc.Conn, 10 | request hypervisor.GetVmAccessTokenRequest, 11 | reply *hypervisor.GetVmAccessTokenResponse) error { 12 | token, err := t.manager.GetVmAccessToken(request.IpAddress, 13 | conn.GetAuthInformation(), request.Lifetime) 14 | response := hypervisor.GetVmAccessTokenResponse{ 15 | Token: token, 16 | Error: errors.ErrorToString(err), 17 | } 18 | *reply = response 19 | return nil 20 | } 21 | -------------------------------------------------------------------------------- /hypervisor/rpcd/getVmInfo.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/errors" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | "github.com/Symantec/Dominator/proto/hypervisor" 7 | ) 8 | 9 | func (t *srpcType) GetVmInfo(conn *srpc.Conn, 10 | request hypervisor.GetVmInfoRequest, 11 | reply *hypervisor.GetVmInfoResponse) error { 12 | info, err := t.manager.GetVmInfo(request.IpAddress) 13 | response := hypervisor.GetVmInfoResponse{ 14 | VmInfo: info, 15 | Error: errors.ErrorToString(err), 16 | } 17 | *reply = response 18 | return nil 19 | } 20 | -------------------------------------------------------------------------------- /hypervisor/rpcd/getVmVolume.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/srpc" 5 | ) 6 | 7 | func (t *srpcType) GetVmVolume(conn *srpc.Conn) error { 8 | return t.manager.GetVmVolume(conn) 9 | } 10 | -------------------------------------------------------------------------------- /hypervisor/rpcd/html.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "io" 5 | ) 6 | 7 | func (hw *htmlWriter) writeHtml(writer io.Writer) { 8 | } 9 | -------------------------------------------------------------------------------- /hypervisor/rpcd/listVMs.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "net" 5 | 6 | "github.com/Symantec/Dominator/lib/srpc" 7 | "github.com/Symantec/Dominator/proto/hypervisor" 8 | ) 9 | 10 | func (t *srpcType) ListVMs(conn *srpc.Conn, 11 | request hypervisor.ListVMsRequest, 12 | reply *hypervisor.ListVMsResponse) error { 13 | ipAddressStrings := t.manager.ListVMs(request.OwnerUsers, request.Sort) 14 | ipAddresses := make([]net.IP, 0, len(ipAddressStrings)) 15 | for _, ipAddressString := range ipAddressStrings { 16 | ipAddress := net.ParseIP(ipAddressString) 17 | if shrunkIP := ipAddress.To4(); shrunkIP != nil { 18 | ipAddress = shrunkIP 19 | } 20 | ipAddresses = append(ipAddresses, ipAddress) 21 | } 22 | *reply = hypervisor.ListVMsResponse{IpAddresses: ipAddresses} 23 | return nil 24 | } 25 | -------------------------------------------------------------------------------- /hypervisor/rpcd/listVolumeDirectories.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/errors" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | "github.com/Symantec/Dominator/proto/hypervisor" 7 | ) 8 | 9 | func (t *srpcType) ListVolumeDirectories(conn *srpc.Conn, 10 | request hypervisor.ListVolumeDirectoriesRequest, 11 | reply *hypervisor.ListVolumeDirectoriesResponse) error { 12 | directories, err := t.listVolumeDirectories(conn) 13 | *reply = hypervisor.ListVolumeDirectoriesResponse{directories, 14 | errors.ErrorToString(err)} 15 | return nil 16 | } 17 | 18 | func (t *srpcType) listVolumeDirectories(conn *srpc.Conn) ([]string, error) { 19 | if err := testIfLoopback(conn); err != nil { 20 | return nil, err 21 | } 22 | return t.manager.ListVolumeDirectories(), nil 23 | } 24 | -------------------------------------------------------------------------------- /hypervisor/rpcd/migrateVm.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/srpc" 5 | "github.com/Symantec/Dominator/proto/hypervisor" 6 | ) 7 | 8 | func (t *srpcType) MigrateVm(conn *srpc.Conn) error { 9 | if err := t.manager.MigrateVm(conn); err != nil { 10 | return conn.Encode(hypervisor.MigrateVmResponse{Error: err.Error()}) 11 | } 12 | return conn.Encode(hypervisor.MigrateVmResponse{Final: true}) 13 | } 14 | -------------------------------------------------------------------------------- /hypervisor/rpcd/patchVmImage.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/errors" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | "github.com/Symantec/Dominator/proto/hypervisor" 7 | ) 8 | 9 | func (t *srpcType) PatchVmImage(conn *srpc.Conn) error { 10 | var request hypervisor.PatchVmImageRequest 11 | if err := conn.Decode(&request); err != nil { 12 | return err 13 | } 14 | return conn.Encode(hypervisor.PatchVmImageResponse{ 15 | Error: errors.ErrorToString(t.manager.PatchVmImage(conn, request)), 16 | Final: true, 17 | }) 18 | return nil 19 | } 20 | -------------------------------------------------------------------------------- /hypervisor/rpcd/prepareVmForMigration.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/errors" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | "github.com/Symantec/Dominator/proto/hypervisor" 7 | ) 8 | 9 | func (t *srpcType) PrepareVmForMigration(conn *srpc.Conn, 10 | request hypervisor.PrepareVmForMigrationRequest, 11 | reply *hypervisor.PrepareVmForMigrationResponse) error { 12 | *reply = hypervisor.PrepareVmForMigrationResponse{ 13 | Error: errors.ErrorToString( 14 | t.manager.PrepareVmForMigration(request.IpAddress, 15 | conn.GetAuthInformation(), request.AccessToken, 16 | request.Enable)), 17 | } 18 | return nil 19 | } 20 | -------------------------------------------------------------------------------- /hypervisor/rpcd/replaceVmImage.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/srpc" 5 | ) 6 | 7 | func (t *srpcType) ReplaceVmImage(conn *srpc.Conn) error { 8 | return t.manager.ReplaceVmImage(conn, conn.GetAuthInformation()) 9 | } 10 | -------------------------------------------------------------------------------- /hypervisor/rpcd/replaceVmUserData.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/errors" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | "github.com/Symantec/Dominator/proto/hypervisor" 7 | ) 8 | 9 | func (t *srpcType) ReplaceVmUserData(conn *srpc.Conn, 10 | request hypervisor.ReplaceVmUserDataRequest, 11 | reply *hypervisor.ReplaceVmUserDataResponse) error { 12 | response := hypervisor.ReplaceVmUserDataResponse{ 13 | errors.ErrorToString(t.manager.ReplaceVmUserData(request.IpAddress, 14 | conn, request.Size, conn.GetAuthInformation()))} 15 | *reply = response 16 | return nil 17 | } 18 | -------------------------------------------------------------------------------- /hypervisor/rpcd/restoreVmFromSnapshot.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/errors" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | "github.com/Symantec/Dominator/proto/hypervisor" 7 | ) 8 | 9 | func (t *srpcType) RestoreVmFromSnapshot(conn *srpc.Conn, 10 | request hypervisor.RestoreVmFromSnapshotRequest, 11 | reply *hypervisor.RestoreVmFromSnapshotResponse) error { 12 | response := hypervisor.RestoreVmFromSnapshotResponse{ 13 | errors.ErrorToString(t.manager.RestoreVmFromSnapshot(request.IpAddress, 14 | conn.GetAuthInformation(), request.ForceIfNotStopped))} 15 | *reply = response 16 | return nil 17 | } 18 | -------------------------------------------------------------------------------- /hypervisor/rpcd/restoreVmImage.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/errors" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | "github.com/Symantec/Dominator/proto/hypervisor" 7 | ) 8 | 9 | func (t *srpcType) RestoreVmImage(conn *srpc.Conn, 10 | request hypervisor.RestoreVmImageRequest, 11 | reply *hypervisor.RestoreVmImageResponse) error { 12 | response := hypervisor.RestoreVmImageResponse{ 13 | errors.ErrorToString(t.manager.RestoreVmImage(request.IpAddress, 14 | conn.GetAuthInformation()))} 15 | *reply = response 16 | return nil 17 | } 18 | -------------------------------------------------------------------------------- /hypervisor/rpcd/restoreVmUserData.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/errors" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | "github.com/Symantec/Dominator/proto/hypervisor" 7 | ) 8 | 9 | func (t *srpcType) RestoreVmUserData(conn *srpc.Conn, 10 | request hypervisor.RestoreVmUserDataRequest, 11 | reply *hypervisor.RestoreVmUserDataResponse) error { 12 | response := hypervisor.RestoreVmUserDataResponse{ 13 | errors.ErrorToString(t.manager.RestoreVmUserData(request.IpAddress, 14 | conn.GetAuthInformation()))} 15 | *reply = response 16 | return nil 17 | } 18 | -------------------------------------------------------------------------------- /hypervisor/rpcd/snapshotVm.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/errors" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | "github.com/Symantec/Dominator/proto/hypervisor" 7 | ) 8 | 9 | func (t *srpcType) SnapshotVm(conn *srpc.Conn, 10 | request hypervisor.SnapshotVmRequest, 11 | reply *hypervisor.SnapshotVmResponse) error { 12 | err := t.manager.SnapshotVm(request.IpAddress, conn.GetAuthInformation(), 13 | request.ForceIfNotStopped, request.RootOnly) 14 | *reply = hypervisor.SnapshotVmResponse{errors.ErrorToString(err)} 15 | return nil 16 | } 17 | -------------------------------------------------------------------------------- /hypervisor/rpcd/startVm.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/errors" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | "github.com/Symantec/Dominator/proto/hypervisor" 7 | ) 8 | 9 | func (t *srpcType) StartVm(conn *srpc.Conn, 10 | request hypervisor.StartVmRequest, 11 | reply *hypervisor.StartVmResponse) error { 12 | dhcpTimedOut, err := t.manager.StartVm(request.IpAddress, 13 | conn.GetAuthInformation(), request.AccessToken, request.DhcpTimeout) 14 | response := hypervisor.StartVmResponse{dhcpTimedOut, 15 | errors.ErrorToString(err)} 16 | *reply = response 17 | return nil 18 | } 19 | -------------------------------------------------------------------------------- /hypervisor/rpcd/stopVm.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/errors" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | "github.com/Symantec/Dominator/proto/hypervisor" 7 | ) 8 | 9 | func (t *srpcType) StopVm(conn *srpc.Conn, 10 | request hypervisor.StopVmRequest, reply *hypervisor.StopVmResponse) error { 11 | response := hypervisor.StopVmResponse{ 12 | errors.ErrorToString(t.manager.StopVm(request.IpAddress, 13 | conn.GetAuthInformation(), request.AccessToken))} 14 | *reply = response 15 | return nil 16 | } 17 | -------------------------------------------------------------------------------- /hypervisor/rpcd/updateSubnets.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/errors" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | "github.com/Symantec/Dominator/proto/hypervisor" 7 | ) 8 | 9 | func (t *srpcType) UpdateSubnets(conn *srpc.Conn, 10 | request hypervisor.UpdateSubnetsRequest, 11 | reply *hypervisor.UpdateSubnetsResponse) error { 12 | *reply = hypervisor.UpdateSubnetsResponse{ 13 | errors.ErrorToString(t.manager.UpdateSubnets(request))} 14 | return nil 15 | } 16 | -------------------------------------------------------------------------------- /imagebuilder/builder/variables.go: -------------------------------------------------------------------------------- 1 | package builder 2 | 3 | func (b *Builder) getVariableFunc( 4 | extraVariables0, extraVariables1 map[string]string) func(string) string { 5 | return func(varName string) string { 6 | if extraVariables0 != nil { 7 | if varValue, ok := extraVariables0[varName]; ok { 8 | return varValue 9 | } 10 | } 11 | if extraVariables1 != nil { 12 | if varValue, ok := extraVariables1[varName]; ok { 13 | return varValue 14 | } 15 | } 16 | return b.variables[varName] 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /imagebuilder/client/api.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "io" 5 | 6 | "github.com/Symantec/Dominator/lib/srpc" 7 | proto "github.com/Symantec/Dominator/proto/imaginator" 8 | ) 9 | 10 | func BuildImage(client *srpc.Client, request proto.BuildImageRequest, 11 | response *proto.BuildImageResponse, logWriter io.Writer) error { 12 | return buildImage(client, request, response, logWriter) 13 | } 14 | -------------------------------------------------------------------------------- /imagebuilder/httpd/showImageStream.go: -------------------------------------------------------------------------------- 1 | package httpd 2 | 3 | import ( 4 | "bufio" 5 | "fmt" 6 | "net/http" 7 | ) 8 | 9 | func (s state) showImageStreamHandler(w http.ResponseWriter, 10 | req *http.Request) { 11 | writer := bufio.NewWriter(w) 12 | defer writer.Flush() 13 | streamName := req.URL.RawQuery 14 | fmt.Fprintf(writer, "image stream %s\n", streamName) 15 | fmt.Fprintln(writer, "") 16 | s.builder.ShowImageStream(writer, streamName) 17 | fmt.Fprintln(writer, "") 18 | } 19 | -------------------------------------------------------------------------------- /imagebuilder/httpd/showImageStreams.go: -------------------------------------------------------------------------------- 1 | package httpd 2 | 3 | import ( 4 | "bufio" 5 | "fmt" 6 | "net/http" 7 | ) 8 | 9 | func (s state) showImageStreamsHandler(w http.ResponseWriter, 10 | req *http.Request) { 11 | writer := bufio.NewWriter(w) 12 | defer writer.Flush() 13 | fmt.Fprintln(writer, "imaginator image streams") 14 | fmt.Fprintln(writer, ``) 19 | fmt.Fprintln(writer, "") 20 | fmt.Fprintln(writer, "

") 21 | s.builder.ShowImageStreams(writer) 22 | fmt.Fprintln(writer, "") 23 | } 24 | -------------------------------------------------------------------------------- /imagebuilder/rpcd/html.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "io" 5 | ) 6 | 7 | func (hw *htmlWriter) writeHtml(writer io.Writer) { 8 | } 9 | -------------------------------------------------------------------------------- /imagepublishers/amipublisher/listImages.go: -------------------------------------------------------------------------------- 1 | package amipublisher 2 | 3 | import ( 4 | "time" 5 | 6 | "github.com/Symantec/Dominator/lib/awsutil" 7 | "github.com/Symantec/Dominator/lib/log" 8 | libtags "github.com/Symantec/Dominator/lib/tags" 9 | ) 10 | 11 | func listImages(targets awsutil.TargetList, skipList awsutil.TargetList, 12 | searchTags, excludeSearchTags libtags.Tags, minImageAge time.Duration, 13 | logger log.DebugLogger) ([]Image, error) { 14 | logger.Debugln(0, "loading credentials") 15 | cs, err := awsutil.LoadCredentials() 16 | if err != nil { 17 | return nil, err 18 | } 19 | rawResults, err := listUnusedImagesCS(targets, skipList, searchTags, 20 | excludeSearchTags, minImageAge, cs, true, logger) 21 | if err != nil { 22 | return nil, err 23 | } 24 | return generateResults(rawResults, logger).UnusedImages, nil 25 | } 26 | -------------------------------------------------------------------------------- /imageserver/client/addImage.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/image" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | "github.com/Symantec/Dominator/proto/imageserver" 7 | ) 8 | 9 | func addImage(client *srpc.Client, name string, img *image.Image) error { 10 | request := imageserver.AddImageRequest{name, img} 11 | var reply imageserver.AddImageResponse 12 | return client.RequestReply("ImageServer.AddImage", request, &reply) 13 | } 14 | 15 | func addImageTrusted(client *srpc.Client, name string, img *image.Image) error { 16 | request := imageserver.AddImageRequest{name, img} 17 | var reply imageserver.AddImageResponse 18 | return client.RequestReply("ImageServer.AddImageTrusted", request, &reply) 19 | } 20 | -------------------------------------------------------------------------------- /imageserver/client/checkDirectory.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/srpc" 5 | "github.com/Symantec/Dominator/proto/imageserver" 6 | ) 7 | 8 | func checkDirectory(client *srpc.Client, name string) (bool, error) { 9 | request := imageserver.CheckDirectoryRequest{name} 10 | var reply imageserver.CheckDirectoryResponse 11 | err := client.RequestReply("ImageServer.CheckDirectory", request, &reply) 12 | if err != nil { 13 | return false, err 14 | } 15 | return reply.DirectoryExists, nil 16 | } 17 | -------------------------------------------------------------------------------- /imageserver/client/checkImage.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/srpc" 5 | "github.com/Symantec/Dominator/proto/imageserver" 6 | ) 7 | 8 | func checkImage(client *srpc.Client, name string) (bool, error) { 9 | request := imageserver.CheckImageRequest{name} 10 | var reply imageserver.CheckImageResponse 11 | err := client.RequestReply("ImageServer.CheckImage", request, &reply) 12 | if err != nil { 13 | return false, err 14 | } 15 | return reply.ImageExists, nil 16 | } 17 | -------------------------------------------------------------------------------- /imageserver/client/chownDirectory.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/srpc" 5 | "github.com/Symantec/Dominator/proto/imageserver" 6 | ) 7 | 8 | func chownDirectory(client *srpc.Client, dirname, ownerGroup string) error { 9 | request := imageserver.ChangeOwnerRequest{DirectoryName: dirname, 10 | OwnerGroup: ownerGroup} 11 | var reply imageserver.ChangeOwnerResponse 12 | return client.RequestReply("ImageServer.ChownDirectory", request, &reply) 13 | } 14 | -------------------------------------------------------------------------------- /imageserver/client/deleteImage.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/srpc" 5 | "github.com/Symantec/Dominator/proto/imageserver" 6 | ) 7 | 8 | func deleteImage(client *srpc.Client, name string) error { 9 | request := imageserver.DeleteImageRequest{name} 10 | var reply imageserver.DeleteImageResponse 11 | return client.RequestReply("ImageServer.DeleteImage", request, &reply) 12 | } 13 | -------------------------------------------------------------------------------- /imageserver/client/deleteUnreferencedObjects.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/srpc" 5 | "github.com/Symantec/Dominator/proto/imageserver" 6 | ) 7 | 8 | func deleteUnreferencedObjects(client *srpc.Client, percentage uint8, 9 | bytes uint64) error { 10 | request := imageserver.DeleteUnreferencedObjectsRequest{percentage, bytes} 11 | var reply imageserver.DeleteUnreferencedObjectsResponse 12 | return client.RequestReply("ImageServer.DeleteUnreferencedObjects", 13 | request, &reply) 14 | } 15 | -------------------------------------------------------------------------------- /imageserver/client/findLatestImage.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/errors" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | "github.com/Symantec/Dominator/proto/imageserver" 7 | ) 8 | 9 | func findLatestImage(client *srpc.Client, dirname string, 10 | ignoreExpiring bool) (string, error) { 11 | request := imageserver.FindLatestImageRequest{ 12 | DirectoryName: dirname, 13 | IgnoreExpiringImages: ignoreExpiring, 14 | } 15 | var reply imageserver.FindLatestImageResponse 16 | err := client.RequestReply("ImageServer.FindLatestImage", request, &reply) 17 | if err == nil { 18 | err = errors.New(reply.Error) 19 | } 20 | if err != nil { 21 | return "", err 22 | } 23 | return reply.ImageName, nil 24 | } 25 | -------------------------------------------------------------------------------- /imageserver/client/getImage.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "time" 5 | 6 | "github.com/Symantec/Dominator/lib/image" 7 | "github.com/Symantec/Dominator/lib/srpc" 8 | "github.com/Symantec/Dominator/proto/imageserver" 9 | ) 10 | 11 | func getImage(client *srpc.Client, name string, timeout time.Duration) ( 12 | *image.Image, error) { 13 | request := imageserver.GetImageRequest{ImageName: name, Timeout: timeout} 14 | var reply imageserver.GetImageResponse 15 | err := client.RequestReply("ImageServer.GetImage", request, &reply) 16 | if err != nil { 17 | return nil, err 18 | } 19 | return reply.Image, nil 20 | } 21 | -------------------------------------------------------------------------------- /imageserver/client/listDirectories.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/image" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | ) 7 | 8 | func listDirectories(client *srpc.Client) ([]image.Directory, error) { 9 | conn, err := client.Call("ImageServer.ListDirectories") 10 | if err != nil { 11 | return nil, err 12 | } 13 | defer conn.Close() 14 | directories := make([]image.Directory, 0) 15 | for { 16 | var directory image.Directory 17 | if err := conn.Decode(&directory); err != nil { 18 | return nil, err 19 | } 20 | if directory.Name == "" { 21 | break 22 | } 23 | directories = append(directories, directory) 24 | } 25 | return directories, nil 26 | } 27 | -------------------------------------------------------------------------------- /imageserver/client/listImages.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/srpc" 5 | ) 6 | 7 | func listImages(client *srpc.Client) ([]string, error) { 8 | conn, err := client.Call("ImageServer.ListImages") 9 | if err != nil { 10 | return nil, err 11 | } 12 | defer conn.Close() 13 | images := make([]string, 0) 14 | for { 15 | line, err := conn.ReadString('\n') 16 | if err != nil { 17 | return nil, err 18 | } 19 | line = line[:len(line)-1] 20 | if line == "" { 21 | break 22 | } 23 | images = append(images, line) 24 | } 25 | return images, nil 26 | } 27 | -------------------------------------------------------------------------------- /imageserver/client/listUnreferencedObjects.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/hash" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | "github.com/Symantec/Dominator/proto/imageserver" 7 | ) 8 | 9 | func listUnreferencedObjects(client *srpc.Client) ( 10 | map[hash.Hash]uint64, error) { 11 | conn, err := client.Call("ImageServer.ListUnreferencedObjects") 12 | if err != nil { 13 | return nil, err 14 | } 15 | defer conn.Close() 16 | objects := make(map[hash.Hash]uint64) 17 | for { 18 | var object imageserver.Object 19 | if err := conn.Decode(&object); err != nil { 20 | return nil, err 21 | } 22 | if object.Size < 1 { 23 | break 24 | } 25 | objects[object.Hash] = object.Size 26 | } 27 | return objects, nil 28 | } 29 | -------------------------------------------------------------------------------- /imageserver/client/makeDirectory.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/srpc" 5 | "github.com/Symantec/Dominator/proto/imageserver" 6 | ) 7 | 8 | func makeDirectory(client *srpc.Client, dirname string) error { 9 | request := imageserver.MakeDirectoryRequest{dirname} 10 | var reply imageserver.MakeDirectoryResponse 11 | return client.RequestReply("ImageServer.MakeDirectory", request, &reply) 12 | } 13 | -------------------------------------------------------------------------------- /imageserver/httpd/listImage.go: -------------------------------------------------------------------------------- 1 | package httpd 2 | 3 | import ( 4 | "bufio" 5 | "fmt" 6 | "net/http" 7 | ) 8 | 9 | func (s state) listImageHandler(w http.ResponseWriter, req *http.Request) { 10 | writer := bufio.NewWriter(w) 11 | defer writer.Flush() 12 | imageName := req.URL.RawQuery 13 | fmt.Fprintf(writer, "image %s\n", imageName) 14 | fmt.Fprintln(writer, "") 15 | fmt.Fprintln(writer, "

") 16 | image := s.imageDataBase.GetImage(imageName) 17 | if image == nil { 18 | fmt.Fprintf(writer, "Image: %s UNKNOWN!\n", imageName) 19 | } else { 20 | fmt.Fprintf(writer, "File-system data for image: %s\n", imageName) 21 | fmt.Fprintln(writer, "

") 22 | fmt.Fprintln(writer, "
")
23 | 		image.FileSystem.List(writer)
24 | 		fmt.Fprintln(writer, "
") 25 | } 26 | fmt.Fprintln(writer, "") 27 | } 28 | -------------------------------------------------------------------------------- /imageserver/httpd/listObject.go: -------------------------------------------------------------------------------- 1 | package httpd 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | 7 | "github.com/Symantec/Dominator/lib/hash" 8 | "github.com/Symantec/Dominator/lib/objectserver/filesystem" 9 | ) 10 | 11 | func listObject(writer io.Writer, objSrv *filesystem.ObjectServer, 12 | hashP *hash.Hash) { 13 | _, reader, err := objSrv.GetObject(*hashP) 14 | if err != nil { 15 | fmt.Fprintln(writer, err) 16 | return 17 | } 18 | defer reader.Close() 19 | fmt.Fprintln(writer, "
")
20 | 	io.Copy(writer, reader)
21 | 	fmt.Fprintln(writer, "
") 22 | } 23 | -------------------------------------------------------------------------------- /imageserver/rpcd/checkDirectory.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/srpc" 5 | "github.com/Symantec/Dominator/proto/imageserver" 6 | ) 7 | 8 | func (t *srpcType) CheckDirectory(conn *srpc.Conn, 9 | request imageserver.CheckDirectoryRequest, 10 | reply *imageserver.CheckDirectoryResponse) error { 11 | response := imageserver.CheckDirectoryResponse{ 12 | t.imageDataBase.CheckDirectory(request.DirectoryName)} 13 | *reply = response 14 | return nil 15 | } 16 | -------------------------------------------------------------------------------- /imageserver/rpcd/checkImage.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/srpc" 5 | "github.com/Symantec/Dominator/proto/imageserver" 6 | ) 7 | 8 | func (t *srpcType) CheckImage(conn *srpc.Conn, 9 | request imageserver.CheckImageRequest, 10 | reply *imageserver.CheckImageResponse) error { 11 | var response imageserver.CheckImageResponse 12 | response.ImageExists = t.imageDataBase.CheckImage(request.ImageName) 13 | *reply = response 14 | return nil 15 | } 16 | -------------------------------------------------------------------------------- /imageserver/rpcd/chownDirectory.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "errors" 5 | "os/user" 6 | 7 | "github.com/Symantec/Dominator/lib/srpc" 8 | "github.com/Symantec/Dominator/proto/imageserver" 9 | ) 10 | 11 | func (t *srpcType) ChownDirectory(conn *srpc.Conn, 12 | request imageserver.ChangeOwnerRequest, 13 | reply *imageserver.ChangeOwnerResponse) error { 14 | username := conn.Username() 15 | if username == "" { 16 | return errors.New("no username: unauthenticated connection") 17 | } 18 | if request.OwnerGroup != "" { 19 | if _, err := user.LookupGroup(request.OwnerGroup); err != nil { 20 | return err 21 | } 22 | } 23 | t.logger.Printf("ChownDirectory(%s) to: \"%s\" by %s\n", 24 | request.DirectoryName, request.OwnerGroup, username) 25 | return t.imageDataBase.ChownDirectory(request.DirectoryName, 26 | request.OwnerGroup, conn.GetAuthInformation()) 27 | } 28 | -------------------------------------------------------------------------------- /imageserver/rpcd/deleteImage.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "errors" 5 | 6 | "github.com/Symantec/Dominator/lib/srpc" 7 | "github.com/Symantec/Dominator/proto/imageserver" 8 | ) 9 | 10 | func (t *srpcType) DeleteImage(conn *srpc.Conn, 11 | request imageserver.DeleteImageRequest, 12 | reply *imageserver.DeleteImageResponse) error { 13 | username := conn.Username() 14 | if err := t.checkMutability(); err != nil { 15 | return err 16 | } 17 | if !t.imageDataBase.CheckImage(request.ImageName) { 18 | return errors.New("image does not exist") 19 | } 20 | if username == "" { 21 | t.logger.Printf("DeleteImage(%s)\n", request.ImageName) 22 | } else { 23 | t.logger.Printf("DeleteImage(%s) by %s\n", request.ImageName, username) 24 | } 25 | return t.imageDataBase.DeleteImage(request.ImageName, 26 | conn.GetAuthInformation()) 27 | } 28 | -------------------------------------------------------------------------------- /imageserver/rpcd/deleteUnreferencedObjects.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/format" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | "github.com/Symantec/Dominator/proto/imageserver" 7 | ) 8 | 9 | func (t *srpcType) DeleteUnreferencedObjects(conn *srpc.Conn, 10 | request imageserver.DeleteUnreferencedObjectsRequest, 11 | reply *imageserver.DeleteUnreferencedObjectsResponse) error { 12 | username := conn.Username() 13 | if username == "" { 14 | t.logger.Printf("DeleteUnreferencedObjects(%d%%, %s)\n", 15 | request.Percentage, format.FormatBytes(request.Bytes)) 16 | } else { 17 | t.logger.Printf("DeleteUnreferencedObjects(%d%%, %s) by %s\n", 18 | request.Percentage, format.FormatBytes(request.Bytes), username) 19 | } 20 | return t.imageDataBase.DeleteUnreferencedObjects(request.Percentage, 21 | request.Bytes) 22 | } 23 | -------------------------------------------------------------------------------- /imageserver/rpcd/findLatestImage.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/errors" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | "github.com/Symantec/Dominator/proto/imageserver" 7 | ) 8 | 9 | func (t *srpcType) FindLatestImage(conn *srpc.Conn, 10 | request imageserver.FindLatestImageRequest, 11 | reply *imageserver.FindLatestImageResponse) error { 12 | imageName, err := t.imageDataBase.FindLatestImage(request.DirectoryName, 13 | request.IgnoreExpiringImages) 14 | *reply = imageserver.FindLatestImageResponse{ 15 | ImageName: imageName, 16 | Error: errors.ErrorToString(err), 17 | } 18 | return nil 19 | } 20 | -------------------------------------------------------------------------------- /imageserver/rpcd/html.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | ) 7 | 8 | func (hw *htmlWriter) writeHtml(writer io.Writer) { 9 | fmt.Fprintf(writer, "Replication clients: %d
\n", 10 | hw.getNumReplicationClients()) 11 | } 12 | 13 | func (hw *htmlWriter) getNumReplicationClients() uint { 14 | hw.numReplicationClientsLock.RLock() 15 | defer hw.numReplicationClientsLock.RUnlock() 16 | return hw.numReplicationClients 17 | } 18 | -------------------------------------------------------------------------------- /imageserver/rpcd/lib.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "errors" 5 | ) 6 | 7 | func (t *srpcType) checkMutability() error { 8 | if t.replicationMaster != "" { 9 | return errors.New(replicationMessage + t.replicationMaster) 10 | } 11 | return nil 12 | } 13 | -------------------------------------------------------------------------------- /imageserver/rpcd/listDirectories.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/image" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | ) 7 | 8 | func (t *srpcType) ListDirectories(conn *srpc.Conn) error { 9 | for _, directory := range t.imageDataBase.ListDirectories() { 10 | if err := conn.Encode(directory); err != nil { 11 | return err 12 | } 13 | } 14 | return conn.Encode(image.Directory{}) 15 | } 16 | -------------------------------------------------------------------------------- /imageserver/rpcd/listImages.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/srpc" 5 | ) 6 | 7 | func (t *srpcType) ListImages(conn *srpc.Conn) error { 8 | for _, name := range t.imageDataBase.ListImages() { 9 | if _, err := conn.WriteString(name + "\n"); err != nil { 10 | return err 11 | } 12 | } 13 | _, err := conn.WriteString("\n") 14 | return err 15 | } 16 | -------------------------------------------------------------------------------- /imageserver/rpcd/listUnreferencedObjects.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/srpc" 5 | "github.com/Symantec/Dominator/proto/imageserver" 6 | ) 7 | 8 | func (t *srpcType) ListUnreferencedObjects(conn *srpc.Conn) error { 9 | for hashVal, size := range t.imageDataBase.ListUnreferencedObjects() { 10 | obj := imageserver.Object{Hash: hashVal, Size: size} 11 | if err := conn.Encode(obj); err != nil { 12 | return err 13 | } 14 | } 15 | return conn.Encode(imageserver.Object{}) 16 | } 17 | -------------------------------------------------------------------------------- /imageserver/rpcd/makeDirectory.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/srpc" 5 | "github.com/Symantec/Dominator/proto/imageserver" 6 | ) 7 | 8 | func (t *srpcType) MakeDirectory(conn *srpc.Conn, 9 | request imageserver.MakeDirectoryRequest, 10 | reply *imageserver.MakeDirectoryResponse) error { 11 | username := conn.Username() 12 | if err := t.checkMutability(); err != nil { 13 | return err 14 | } 15 | if username == "" { 16 | t.logger.Printf("MakeDirectory(%s)\n", request.DirectoryName) 17 | } else { 18 | t.logger.Printf("MakeDirectory(%s) by %s\n", 19 | request.DirectoryName, username) 20 | } 21 | return t.imageDataBase.MakeDirectory(request.DirectoryName, 22 | conn.GetAuthInformation()) 23 | } 24 | -------------------------------------------------------------------------------- /imageserver/scanner/html.go: -------------------------------------------------------------------------------- 1 | package scanner 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | ) 7 | 8 | func (imdb *ImageDataBase) writeHtml(writer io.Writer) { 9 | fmt.Fprintf(writer, 10 | "Number of images: "+ 11 | "%d
\n", 12 | imdb.CountImages()) 13 | fmt.Fprintf(writer, 14 | "Number of directories: "+ 15 | "%d
\n", 16 | imdb.CountDirectories()) 17 | } 18 | -------------------------------------------------------------------------------- /imageunpacker/rpcd/addDevice.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/srpc" 5 | ) 6 | 7 | func (t *srpcType) AddDevice(conn *srpc.Conn) error { 8 | t.addDeviceLock.Lock() 9 | defer t.addDeviceLock.Unlock() 10 | if err := t.unpacker.PrepareForAddDevice(); err != nil { 11 | _, err = conn.WriteString(err.Error() + "\n") 12 | return err 13 | } 14 | if _, err := conn.WriteString("\n"); err != nil { 15 | return err 16 | } 17 | if err := conn.Flush(); err != nil { 18 | return err 19 | } 20 | deviceId, err := conn.ReadString('\n') 21 | if err != nil { 22 | return err 23 | } 24 | deviceId = deviceId[:len(deviceId)-1] 25 | if err := t.unpacker.AddDevice(deviceId); err != nil { 26 | t.logger.Println(err) 27 | _, err = conn.WriteString(err.Error() + "\n") 28 | return err 29 | } 30 | _, err = conn.WriteString("\n") 31 | return err 32 | } 33 | -------------------------------------------------------------------------------- /imageunpacker/rpcd/api.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "io" 5 | "sync" 6 | 7 | "github.com/Symantec/Dominator/imageunpacker/unpacker" 8 | "github.com/Symantec/Dominator/lib/log" 9 | "github.com/Symantec/Dominator/lib/srpc" 10 | ) 11 | 12 | type srpcType struct { 13 | unpacker *unpacker.Unpacker 14 | logger log.Logger 15 | addDeviceLock sync.Mutex 16 | } 17 | 18 | type htmlWriter srpcType 19 | 20 | func (hw *htmlWriter) WriteHtml(writer io.Writer) { 21 | hw.writeHtml(writer) 22 | } 23 | 24 | func Setup(unpackerObj *unpacker.Unpacker, logger log.Logger) *htmlWriter { 25 | srpcObj := srpcType{ 26 | unpacker: unpackerObj, 27 | logger: logger} 28 | srpc.RegisterName("ImageUnpacker", &srpcObj) 29 | return (*htmlWriter)(&srpcObj) 30 | } 31 | -------------------------------------------------------------------------------- /imageunpacker/rpcd/associateStreamWithDevice.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/srpc" 5 | proto "github.com/Symantec/Dominator/proto/imageunpacker" 6 | ) 7 | 8 | func (t *srpcType) AssociateStreamWithDevice(conn *srpc.Conn, 9 | request proto.AssociateStreamWithDeviceRequest, 10 | reply *proto.AssociateStreamWithDeviceResponse) error { 11 | return t.unpacker.AssociateStreamWithDevice(request.StreamName, 12 | request.DeviceId) 13 | } 14 | -------------------------------------------------------------------------------- /imageunpacker/rpcd/exportImage.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/srpc" 5 | proto "github.com/Symantec/Dominator/proto/imageunpacker" 6 | ) 7 | 8 | func (t *srpcType) ExportImage(conn *srpc.Conn, 9 | request proto.ExportImageRequest, 10 | reply *proto.ExportImageResponse) error { 11 | return t.unpacker.ExportImage(request.StreamName, request.Type, 12 | request.Destination) 13 | } 14 | -------------------------------------------------------------------------------- /imageunpacker/rpcd/getStatus.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/srpc" 5 | proto "github.com/Symantec/Dominator/proto/imageunpacker" 6 | ) 7 | 8 | func (t *srpcType) GetStatus(conn *srpc.Conn, request proto.GetStatusRequest, 9 | reply *proto.GetStatusResponse) error { 10 | *reply = t.unpacker.GetStatus() 11 | return nil 12 | } 13 | -------------------------------------------------------------------------------- /imageunpacker/rpcd/html.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "io" 5 | ) 6 | 7 | func (hw *htmlWriter) writeHtml(writer io.Writer) { 8 | } 9 | -------------------------------------------------------------------------------- /imageunpacker/rpcd/prepareForCapture.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/srpc" 5 | proto "github.com/Symantec/Dominator/proto/imageunpacker" 6 | ) 7 | 8 | func (t *srpcType) PrepareForCapture(conn *srpc.Conn, 9 | request proto.PrepareForCaptureRequest, 10 | reply *proto.PrepareForCaptureResponse) error { 11 | return t.unpacker.PrepareForCapture(request.StreamName) 12 | } 13 | -------------------------------------------------------------------------------- /imageunpacker/rpcd/prepareForCopy.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/srpc" 5 | proto "github.com/Symantec/Dominator/proto/imageunpacker" 6 | ) 7 | 8 | func (t *srpcType) PrepareForCopy(conn *srpc.Conn, 9 | request proto.PrepareForCopyRequest, 10 | reply *proto.PrepareForCopyResponse) error { 11 | return t.unpacker.PrepareForCopy(request.StreamName) 12 | } 13 | -------------------------------------------------------------------------------- /imageunpacker/rpcd/prepareForUnpack.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/srpc" 5 | proto "github.com/Symantec/Dominator/proto/imageunpacker" 6 | ) 7 | 8 | func (t *srpcType) PrepareForUnpack(conn *srpc.Conn, 9 | request proto.PrepareForUnpackRequest, 10 | reply *proto.PrepareForUnpackResponse) error { 11 | return t.unpacker.PrepareForUnpack(request.StreamName, 12 | request.SkipIfPrepared, request.DoNotWaitForResult) 13 | } 14 | -------------------------------------------------------------------------------- /imageunpacker/rpcd/removeDevice.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/srpc" 5 | proto "github.com/Symantec/Dominator/proto/imageunpacker" 6 | ) 7 | 8 | func (t *srpcType) RemoveDevice(conn *srpc.Conn, 9 | request proto.RemoveDeviceRequest, 10 | reply *proto.RemoveDeviceResponse) error { 11 | return t.unpacker.RemoveDevice(request.DeviceId) 12 | } 13 | -------------------------------------------------------------------------------- /imageunpacker/rpcd/unpackImage.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/srpc" 5 | proto "github.com/Symantec/Dominator/proto/imageunpacker" 6 | ) 7 | 8 | func (t *srpcType) UnpackImage(conn *srpc.Conn, 9 | request proto.UnpackImageRequest, 10 | reply *proto.UnpackImageResponse) error { 11 | return t.unpacker.UnpackImage(request.StreamName, request.ImageLeafName) 12 | } 13 | -------------------------------------------------------------------------------- /imageunpacker/unpacker/getFileSystem.go: -------------------------------------------------------------------------------- 1 | package unpacker 2 | 3 | import ( 4 | "errors" 5 | 6 | "github.com/Symantec/Dominator/lib/filesystem" 7 | ) 8 | 9 | func (u *Unpacker) getFileSystem(streamName string) ( 10 | *filesystem.FileSystem, error) { 11 | u.rwMutex.RLock() 12 | defer u.rwMutex.RUnlock() 13 | streamInfo := u.getStream(streamName) 14 | if streamInfo == nil { 15 | return nil, errors.New("unknown stream") 16 | } 17 | return streamInfo.scannedFS, nil 18 | } 19 | -------------------------------------------------------------------------------- /imageunpacker/unpacker/getStatus.go: -------------------------------------------------------------------------------- 1 | package unpacker 2 | 3 | import ( 4 | "time" 5 | 6 | proto "github.com/Symantec/Dominator/proto/imageunpacker" 7 | ) 8 | 9 | func (u *Unpacker) getStatus() proto.GetStatusResponse { 10 | u.rwMutex.RLock() 11 | defer u.rwMutex.RUnlock() 12 | devices := make(map[string]proto.DeviceInfo) 13 | imageStreams := make(map[string]proto.ImageStreamInfo, 14 | len(u.pState.ImageStreams)) 15 | for deviceId, device := range u.pState.Devices { 16 | devices[deviceId] = proto.DeviceInfo{ 17 | device.DeviceName, device.size, device.StreamName} 18 | } 19 | for name, stream := range u.pState.ImageStreams { 20 | imageStreams[name] = proto.ImageStreamInfo{ 21 | stream.DeviceId, stream.status} 22 | } 23 | return proto.GetStatusResponse{devices, imageStreams, 24 | time.Since(u.lastUsedTime)} 25 | } 26 | -------------------------------------------------------------------------------- /imageunpacker/unpacker/html.go: -------------------------------------------------------------------------------- 1 | package unpacker 2 | 3 | import ( 4 | "io" 5 | ) 6 | 7 | func (u *Unpacker) writeHtml(writer io.Writer) { 8 | } 9 | -------------------------------------------------------------------------------- /imageunpacker/unpacker/removeDevice.go: -------------------------------------------------------------------------------- 1 | package unpacker 2 | 3 | import ( 4 | "errors" 5 | ) 6 | 7 | func (u *Unpacker) removeDevice(deviceId string) error { 8 | u.rwMutex.Lock() 9 | defer u.rwMutex.Unlock() 10 | defer u.updateUsageTimeWithLock() 11 | if device, ok := u.pState.Devices[deviceId]; !ok { 12 | return errors.New("unknown device ID: " + deviceId) 13 | } else { 14 | if device.StreamName != "" { 15 | return errors.New( 16 | "device ID: " + deviceId + " used by: " + device.StreamName) 17 | } 18 | delete(u.pState.Devices, deviceId) 19 | return u.writeStateWithLock() 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /init.d/dominator.Ubuntu-12.04: -------------------------------------------------------------------------------- 1 | dominator.Debian-7 -------------------------------------------------------------------------------- /init.d/dominator.Ubuntu-14.04: -------------------------------------------------------------------------------- 1 | dominator.Debian-7 -------------------------------------------------------------------------------- /init.d/dominator.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Dominator daemon 3 | After=network.target 4 | 5 | [Service] 6 | ExecStart=/usr/local/sbin/dominator 7 | ExecReload=/bin/kill -HUP $MAINPID 8 | Restart=always 9 | RestartSec=1 10 | 11 | [Install] 12 | WantedBy=multi-user.target 13 | -------------------------------------------------------------------------------- /init.d/filegen-server.Ubuntu-12.04: -------------------------------------------------------------------------------- 1 | filegen-server.Debian-7 -------------------------------------------------------------------------------- /init.d/filegen-server.Ubuntu-14.04: -------------------------------------------------------------------------------- 1 | filegen-server.Debian-7 -------------------------------------------------------------------------------- /init.d/filegen-server.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Filegen Server 3 | After=network.target 4 | 5 | [Service] 6 | ExecStart=/usr/local/sbin/filegen-server 7 | ExecReload=/bin/kill -HUP $MAINPID 8 | Restart=always 9 | RestartSec=1 10 | 11 | [Install] 12 | WantedBy=multi-user.target 13 | -------------------------------------------------------------------------------- /init.d/fleet-manager.Ubuntu-12.04: -------------------------------------------------------------------------------- 1 | fleet-manager.Debian-7 -------------------------------------------------------------------------------- /init.d/fleet-manager.Ubuntu-14.04: -------------------------------------------------------------------------------- 1 | fleet-manager.Debian-7 -------------------------------------------------------------------------------- /init.d/fleet-manager.Ubuntu-16.04: -------------------------------------------------------------------------------- 1 | fleet-manager.Debian-7 -------------------------------------------------------------------------------- /init.d/fleet-manager.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Fleet Manager 3 | After=network.target 4 | 5 | [Service] 6 | ExecStart=/usr/local/sbin/fleet-manager 7 | ExecReload=/bin/kill -HUP $MAINPID 8 | Restart=always 9 | RestartSec=1 10 | 11 | [Install] 12 | WantedBy=multi-user.target 13 | -------------------------------------------------------------------------------- /init.d/hypervisor.Ubuntu-14.04: -------------------------------------------------------------------------------- 1 | hypervisor.Debian-7 -------------------------------------------------------------------------------- /init.d/hypervisor.Ubuntu-16.04: -------------------------------------------------------------------------------- 1 | hypervisor.Debian-7 -------------------------------------------------------------------------------- /init.d/hypervisor.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Hypervisor 3 | After=network.target 4 | 5 | [Service] 6 | KillMode=process 7 | ExecStart=/usr/local/sbin/hypervisor 8 | ExecStop=/usr/local/sbin/hypervisor stop 9 | ExecReload=/bin/kill -HUP $MAINPID 10 | Restart=always 11 | RestartSec=1 12 | 13 | [Install] 14 | WantedBy=multi-user.target 15 | -------------------------------------------------------------------------------- /init.d/image-unpacker.Ubuntu-12.04: -------------------------------------------------------------------------------- 1 | image-unpacker.Debian-7 -------------------------------------------------------------------------------- /init.d/image-unpacker.Ubuntu-14.04: -------------------------------------------------------------------------------- 1 | image-unpacker.Debian-7 -------------------------------------------------------------------------------- /init.d/image-unpacker.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Image Unpacker daemon 3 | After=network.target 4 | 5 | [Service] 6 | ExecStart=/usr/local/sbin/image-unpacker 7 | ExecReload=/bin/kill -HUP $MAINPID 8 | Restart=always 9 | RestartSec=1 10 | 11 | [Install] 12 | WantedBy=multi-user.target 13 | -------------------------------------------------------------------------------- /init.d/imageserver.Ubuntu-12.04: -------------------------------------------------------------------------------- 1 | imageserver.Debian-7 -------------------------------------------------------------------------------- /init.d/imageserver.Ubuntu-14.04: -------------------------------------------------------------------------------- 1 | imageserver.Debian-7 -------------------------------------------------------------------------------- /init.d/imageserver.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Dominator imageserver daemon 3 | After=network.target 4 | 5 | [Service] 6 | ExecStart=/usr/local/sbin/imageserver 7 | ExecReload=/bin/kill -HUP $MAINPID 8 | Restart=always 9 | RestartSec=1 10 | 11 | [Install] 12 | WantedBy=multi-user.target 13 | -------------------------------------------------------------------------------- /init.d/imaginator.Ubuntu-12.04: -------------------------------------------------------------------------------- 1 | imaginator.Debian-7 -------------------------------------------------------------------------------- /init.d/imaginator.Ubuntu-14.04: -------------------------------------------------------------------------------- 1 | imaginator.Debian-7 -------------------------------------------------------------------------------- /init.d/imaginator.Ubuntu-16.04: -------------------------------------------------------------------------------- 1 | imaginator.Debian-7 -------------------------------------------------------------------------------- /init.d/imaginator.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Imaginator image builder service 3 | After=network.target 4 | 5 | [Service] 6 | ExecStart=/usr/local/sbin/imaginator 7 | ExecReload=/bin/kill -HUP $MAINPID 8 | Restart=always 9 | RestartSec=1 10 | 11 | [Install] 12 | WantedBy=multi-user.target 13 | -------------------------------------------------------------------------------- /init.d/mdbd.Ubuntu-12.04: -------------------------------------------------------------------------------- 1 | mdbd.Debian-7 -------------------------------------------------------------------------------- /init.d/mdbd.Ubuntu-14.04: -------------------------------------------------------------------------------- 1 | mdbd.Debian-7 -------------------------------------------------------------------------------- /init.d/mdbd.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Dominator MDB daemon 3 | After=network.target 4 | 5 | [Service] 6 | ExecStart=/usr/local/sbin/mdbd 7 | ExecReload=/bin/kill -HUP $MAINPID 8 | Restart=always 9 | RestartSec=1 10 | 11 | [Install] 12 | WantedBy=multi-user.target 13 | -------------------------------------------------------------------------------- /init.d/subd.CentOS-6: -------------------------------------------------------------------------------- 1 | subd.Debian-7 -------------------------------------------------------------------------------- /init.d/subd.Ubuntu-12.04: -------------------------------------------------------------------------------- 1 | subd.Debian-7 -------------------------------------------------------------------------------- /init.d/subd.Ubuntu-14.04: -------------------------------------------------------------------------------- 1 | subd.Debian-7 -------------------------------------------------------------------------------- /init.d/subd.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Dominator subject daemon 3 | After=network.target 4 | 5 | [Service] 6 | ExecStart=/usr/local/sbin/subd 7 | ExecReload=/bin/kill -HUP $MAINPID 8 | Restart=always 9 | RestartSec=1 10 | 11 | [Install] 12 | WantedBy=multi-user.target 13 | -------------------------------------------------------------------------------- /init.d/virtual-machines.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Virtual Machines clean shutdown 3 | After=hypervisor.service 4 | 5 | [Service] 6 | Type=oneshot 7 | RemainAfterExit=true 8 | ExecStart=/bin/true 9 | ExecStop=/usr/local/sbin/hypervisor stop-vms-on-next-stop 10 | 11 | [Install] 12 | WantedBy=multi-user.target 13 | -------------------------------------------------------------------------------- /lib/cpulimiter/api.go: -------------------------------------------------------------------------------- 1 | package cpulimiter 2 | 3 | import ( 4 | "sync" 5 | "time" 6 | 7 | "github.com/Symantec/Dominator/lib/wsyscall" 8 | ) 9 | 10 | type CpuLimiter struct { 11 | mutex sync.Mutex 12 | confCpuPercent uint // Aggregate across all CPUs. 13 | cpuPercent uint // For a single CPU. 14 | lastProbeTime time.Time 15 | lastProbeCpuTime wsyscall.Timeval 16 | } 17 | 18 | func New(cpuPercent uint) *CpuLimiter { 19 | return newCpuLimiter(cpuPercent) 20 | } 21 | 22 | func (cl *CpuLimiter) Limit() error { 23 | return cl.limit() 24 | } 25 | 26 | func (cl *CpuLimiter) CpuPercent() uint { 27 | return cl.getConfCpuPercent() 28 | } 29 | 30 | func (cl *CpuLimiter) SetCpuPercent(cpuPercent uint) { 31 | cl.setCpuPercent(cpuPercent) 32 | } 33 | -------------------------------------------------------------------------------- /lib/errors/api.go: -------------------------------------------------------------------------------- 1 | package errors 2 | 3 | import "errors" 4 | 5 | func New(text string) error { 6 | if text == "" { 7 | return nil 8 | } 9 | return errors.New(text) 10 | } 11 | 12 | func ErrorToString(err error) string { 13 | if err == nil { 14 | return "" 15 | } 16 | return err.Error() 17 | } 18 | -------------------------------------------------------------------------------- /lib/filegen/html.go: -------------------------------------------------------------------------------- 1 | package filegen 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | ) 7 | 8 | func (m *Manager) writeHtml(writer io.Writer) { 9 | fmt.Fprintf(writer, 10 | "Number of generated files: %d
\n", 11 | len(m.pathManagers)) 12 | } 13 | -------------------------------------------------------------------------------- /lib/filegen/httpd/listGenerators.go: -------------------------------------------------------------------------------- 1 | package httpd 2 | 3 | import ( 4 | "bufio" 5 | "fmt" 6 | "net/http" 7 | ) 8 | 9 | func (s *state) listGeneratorsHandler(w http.ResponseWriter, req *http.Request) { 10 | writer := bufio.NewWriter(w) 11 | defer writer.Flush() 12 | for _, pathname := range s.manager.GetRegisteredPaths() { 13 | fmt.Fprintln(writer, pathname) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /lib/filegen/manager.go: -------------------------------------------------------------------------------- 1 | package filegen 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/log" 5 | "github.com/Symantec/Dominator/lib/mdb" 6 | "github.com/Symantec/Dominator/lib/objectserver/memory" 7 | "github.com/Symantec/Dominator/lib/srpc" 8 | proto "github.com/Symantec/Dominator/proto/filegenerator" 9 | ) 10 | 11 | type rpcType struct { 12 | manager *Manager 13 | } 14 | 15 | func newManager(logger log.Logger) *Manager { 16 | m := new(Manager) 17 | m.pathManagers = make(map[string]*pathManager) 18 | m.machineData = make(map[string]mdb.Machine) 19 | m.clients = make( 20 | map[<-chan *proto.ServerMessage]chan<- *proto.ServerMessage) 21 | m.objectServer = memory.NewObjectServer() 22 | m.logger = logger 23 | m.registerMdbGeneratorForPath("/etc/mdb.json") 24 | srpc.RegisterName("FileGenerator", &rpcType{m}) 25 | return m 26 | } 27 | -------------------------------------------------------------------------------- /lib/filegen/mdb.go: -------------------------------------------------------------------------------- 1 | package filegen 2 | 3 | import ( 4 | "bytes" 5 | "time" 6 | 7 | "github.com/Symantec/Dominator/lib/json" 8 | "github.com/Symantec/Dominator/lib/log" 9 | "github.com/Symantec/Dominator/lib/mdb" 10 | ) 11 | 12 | type jsonType struct{} 13 | 14 | func (m *Manager) registerMdbGeneratorForPath(pathname string) { 15 | close(m.registerDataGeneratorForPath(pathname, jsonType{})) 16 | } 17 | 18 | func (jsonType) Generate(machine mdb.Machine, logger log.Logger) ( 19 | []byte, time.Time, error) { 20 | buffer := new(bytes.Buffer) 21 | if err := json.WriteWithIndent(buffer, " ", machine); err != nil { 22 | return nil, time.Time{}, err 23 | } 24 | buffer.WriteString("\n") 25 | return buffer.Bytes(), time.Time{}, nil 26 | } 27 | -------------------------------------------------------------------------------- /lib/filegen/util/api.go: -------------------------------------------------------------------------------- 1 | package util 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/filegen" 5 | ) 6 | 7 | func LoadConfiguration(manager *filegen.Manager, filename string) error { 8 | return loadConfiguration(manager, filename) 9 | } 10 | -------------------------------------------------------------------------------- /lib/filesystem/get.go: -------------------------------------------------------------------------------- 1 | package filesystem 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/hash" 5 | ) 6 | 7 | func (fs *FileSystem) getObjects() map[hash.Hash]uint64 { 8 | objects := make(map[hash.Hash]uint64) 9 | for _, inode := range fs.InodeTable { 10 | if inode, ok := inode.(*RegularInode); ok { 11 | if inode.Size > 0 { 12 | objects[inode.Hash] = inode.Size 13 | } 14 | } 15 | } 16 | return objects 17 | } 18 | -------------------------------------------------------------------------------- /lib/filesystem/iterators.go: -------------------------------------------------------------------------------- 1 | package filesystem 2 | 3 | import ( 4 | "path" 5 | ) 6 | 7 | func (directory *DirectoryInode) forEachEntry(directoryName string, 8 | fn func(name string, inodeNumber uint64, inode GenericInode) error) error { 9 | for _, dirent := range directory.EntryList { 10 | name := path.Join(directoryName, dirent.Name) 11 | if err := fn(name, dirent.InodeNumber, dirent.inode); err != nil { 12 | return err 13 | } 14 | if inode, ok := dirent.inode.(*DirectoryInode); ok { 15 | if err := inode.forEachEntry(name, fn); err != nil { 16 | return err 17 | } 18 | } 19 | } 20 | return nil 21 | } 22 | 23 | func (fs *FileSystem) forEachFile( 24 | fn func(name string, inodeNumber uint64, inode GenericInode) error) error { 25 | if err := fn("/", 0, &fs.DirectoryInode); err != nil { 26 | return err 27 | } 28 | return fs.DirectoryInode.forEachEntry("/", fn) 29 | } 30 | -------------------------------------------------------------------------------- /lib/filesystem/scanner/getObject.go: -------------------------------------------------------------------------------- 1 | package scanner 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "os" 7 | "path" 8 | 9 | "github.com/Symantec/Dominator/lib/hash" 10 | ) 11 | 12 | func (fs *FileSystem) getObject(hashVal hash.Hash) ( 13 | uint64, io.ReadCloser, error) { 14 | inodes, ok := fs.HashToInodesTable()[hashVal] 15 | if !ok { 16 | return 0, nil, fmt.Errorf("object not found: %v\n", hashVal) 17 | } 18 | filename := path.Join(fs.rootDirectoryName, 19 | fs.InodeToFilenamesTable()[inodes[0]][0]) 20 | file, err := os.Open(filename) 21 | if err != nil { 22 | return 0, nil, err 23 | } 24 | fi, err := file.Stat() 25 | if err != nil { 26 | file.Close() 27 | return 0, nil, err 28 | } 29 | return uint64(fi.Size()), file, nil 30 | } 31 | -------------------------------------------------------------------------------- /lib/filesystem/tar/api.go: -------------------------------------------------------------------------------- 1 | package tar 2 | 3 | import ( 4 | "archive/tar" 5 | "io" 6 | 7 | "github.com/Symantec/Dominator/lib/filesystem" 8 | "github.com/Symantec/Dominator/lib/objectserver" 9 | ) 10 | 11 | func Encode(tarWriter *tar.Writer, fileSystem *filesystem.FileSystem, 12 | objectsGetter objectserver.ObjectsGetter) error { 13 | return encode(tarWriter, fileSystem, objectsGetter) 14 | } 15 | 16 | func Write(writer io.Writer, fileSystem *filesystem.FileSystem, 17 | objectsGetter objectserver.ObjectsGetter) error { 18 | return write(writer, fileSystem, objectsGetter) 19 | } 20 | -------------------------------------------------------------------------------- /lib/filesystem/tar/write.go: -------------------------------------------------------------------------------- 1 | package tar 2 | 3 | import ( 4 | "archive/tar" 5 | "io" 6 | 7 | "github.com/Symantec/Dominator/lib/filesystem" 8 | "github.com/Symantec/Dominator/lib/objectserver" 9 | ) 10 | 11 | func write(writer io.Writer, fileSystem *filesystem.FileSystem, 12 | objectsGetter objectserver.ObjectsGetter) error { 13 | tarWriter := tar.NewWriter(writer) 14 | if err := Encode(tarWriter, fileSystem, objectsGetter); err != nil { 15 | tarWriter.Close() 16 | return err 17 | } 18 | return tarWriter.Close() 19 | } 20 | -------------------------------------------------------------------------------- /lib/filesystem/untar/api.go: -------------------------------------------------------------------------------- 1 | package untar 2 | 3 | import ( 4 | "archive/tar" 5 | "io" 6 | 7 | "github.com/Symantec/Dominator/lib/filesystem" 8 | "github.com/Symantec/Dominator/lib/filter" 9 | "github.com/Symantec/Dominator/lib/hash" 10 | ) 11 | 12 | type Hasher interface { 13 | Hash(reader io.Reader, length uint64) (hash.Hash, error) 14 | } 15 | 16 | func Decode(tarReader *tar.Reader, hasher Hasher, filter *filter.Filter) ( 17 | *filesystem.FileSystem, error) { 18 | return decode(tarReader, hasher, filter) 19 | } 20 | -------------------------------------------------------------------------------- /lib/filesystem/util/filter.go: -------------------------------------------------------------------------------- 1 | package util 2 | 3 | import ( 4 | "os" 5 | "path/filepath" 6 | 7 | "github.com/Symantec/Dominator/lib/filter" 8 | ) 9 | 10 | func deletedFilteredFiles(rootDir string, filt *filter.Filter) error { 11 | startPos := len(rootDir) 12 | return filepath.Walk(rootDir, 13 | func(path string, fi os.FileInfo, err error) error { 14 | if err != nil { 15 | return err 16 | } 17 | if filt.Match(path[startPos:]) { 18 | if err := os.RemoveAll(path); err != nil { 19 | return err 20 | } 21 | if fi.IsDir() { 22 | return filepath.SkipDir 23 | } 24 | } 25 | return nil 26 | }) 27 | } 28 | -------------------------------------------------------------------------------- /lib/filter/merge.go: -------------------------------------------------------------------------------- 1 | package filter 2 | 3 | import ( 4 | "sort" 5 | ) 6 | 7 | func (mf *MergeableFilter) exportFilter() *Filter { 8 | if mf.filterLines == nil { 9 | return nil // Sparse filter. 10 | } 11 | filterLines := make([]string, 0, len(mf.filterLines)) 12 | for filterLine := range mf.filterLines { 13 | filterLines = append(filterLines, filterLine) 14 | } 15 | sort.Strings(filterLines) 16 | return &Filter{FilterLines: filterLines} 17 | } 18 | 19 | func (mf *MergeableFilter) merge(filter *Filter) { 20 | if filter == nil { 21 | return // Sparse filter. 22 | } 23 | if mf.filterLines == nil { 24 | mf.filterLines = make(map[string]struct{}, len(filter.FilterLines)) 25 | } 26 | for _, filterLine := range filter.FilterLines { 27 | mf.filterLines[filterLine] = struct{}{} 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lib/flags/loadflags/api.go: -------------------------------------------------------------------------------- 1 | package loadflags 2 | 3 | import ( 4 | "os" 5 | "path/filepath" 6 | ) 7 | 8 | func LoadForCli(progName string) error { 9 | return loadFlags( 10 | filepath.Join(os.Getenv("HOME"), ".config", progName)) 11 | } 12 | 13 | func LoadForDaemon(progName string) error { 14 | return loadFlags(filepath.Join("/etc", progName)) 15 | } 16 | -------------------------------------------------------------------------------- /lib/flagutil/api.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package flagutil provides utility types for the standard flag package. 3 | 4 | Package flagutil provides a collection of types to enhance the standard 5 | flag package, such as slices. 6 | */ 7 | package flagutil 8 | 9 | // A Size is an integer number of bytes that satisfies the standard library 10 | // flag.Value interface. 11 | type Size uint64 12 | 13 | // A StringList is a slice of strings that satisfies the standard library 14 | // flag.Value interface. 15 | type StringList []string 16 | 17 | // A StringToRuneMap satisfies the standard library flag.Value interface. 18 | type StringToRuneMap map[string]rune 19 | -------------------------------------------------------------------------------- /lib/flagutil/stringList.go: -------------------------------------------------------------------------------- 1 | package flagutil 2 | 3 | import ( 4 | "strings" 5 | ) 6 | 7 | func (sl *StringList) String() string { 8 | return `"` + strings.Join(*sl, ",") + `"` 9 | } 10 | 11 | func (sl *StringList) Set(value string) error { 12 | if value == "" { 13 | *sl = make(StringList, 0) 14 | } else { 15 | *sl = strings.Split(value, ",") 16 | } 17 | return nil 18 | } 19 | -------------------------------------------------------------------------------- /lib/format/api.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package format provides convenience functions for formatting. 3 | */ 4 | package format 5 | 6 | var ( 7 | TimeFormatSeconds string = "02 Jan 2006 15:04:05 MST" 8 | TimeFormatSubseconds string = "02 Jan 2006 15:04:05.99 MST" 9 | ) 10 | -------------------------------------------------------------------------------- /lib/fsbench/odirect_linux.go: -------------------------------------------------------------------------------- 1 | package fsbench 2 | 3 | import ( 4 | "os" 5 | "syscall" 6 | ) 7 | 8 | func openDirect(name string, flag int, perm os.FileMode) (file *os.File, 9 | err error) { 10 | return os.OpenFile(name, flag|syscall.O_DIRECT, perm) 11 | } 12 | -------------------------------------------------------------------------------- /lib/fsbench/stubs.go: -------------------------------------------------------------------------------- 1 | // +build !linux 2 | 3 | package fsbench 4 | 5 | import ( 6 | "os" 7 | ) 8 | 9 | func openDirect(name string, flag int, perm os.FileMode) (file *os.File, 10 | err error) { 11 | return os.OpenFile(name, flag, perm) 12 | } 13 | -------------------------------------------------------------------------------- /lib/fsutil/fallocate.go: -------------------------------------------------------------------------------- 1 | package fsutil 2 | 3 | import ( 4 | "syscall" 5 | 6 | "github.com/Symantec/Dominator/lib/wsyscall" 7 | ) 8 | 9 | func fallocate(filename string, size uint64) error { 10 | fd, err := syscall.Open(filename, syscall.O_RDWR, 0) 11 | if err != nil { 12 | return err 13 | } 14 | defer syscall.Close(fd) 15 | return wsyscall.Fallocate(fd, 0, 0, int64(size)) 16 | } 17 | -------------------------------------------------------------------------------- /lib/fsutil/load.go: -------------------------------------------------------------------------------- 1 | package fsutil 2 | 3 | import ( 4 | "bufio" 5 | "os" 6 | ) 7 | 8 | func loadLines(filename string) ([]string, error) { 9 | file, err := os.Open(filename) 10 | if err != nil { 11 | return nil, err 12 | } 13 | defer file.Close() 14 | scanner := bufio.NewScanner(file) 15 | lines := make([]string, 0) 16 | for scanner.Scan() { 17 | line := scanner.Text() 18 | if len(line) < 1 { 19 | continue 20 | } 21 | if line[0] == '#' { 22 | continue 23 | } 24 | lines = append(lines, line) 25 | } 26 | if err := scanner.Err(); err != nil { 27 | return lines, err 28 | } 29 | return lines, nil 30 | } 31 | -------------------------------------------------------------------------------- /lib/fsutil/loopback.go: -------------------------------------------------------------------------------- 1 | package fsutil 2 | 3 | import ( 4 | "fmt" 5 | "os/exec" 6 | "strings" 7 | ) 8 | 9 | func loopbackDelete(loopDevice string) error { 10 | return exec.Command("losetup", "-d", loopDevice).Run() 11 | } 12 | 13 | func loopbackSetup(filename string) (string, error) { 14 | cmd := exec.Command("losetup", "-fP", "--show", filename) 15 | output, err := cmd.CombinedOutput() 16 | if err != nil { 17 | return "", fmt.Errorf("%s: %s", err, output) 18 | } 19 | return strings.TrimSpace(string(output)), nil 20 | } 21 | -------------------------------------------------------------------------------- /lib/fsutil/makeMutable.go: -------------------------------------------------------------------------------- 1 | package fsutil 2 | 3 | import ( 4 | "os/exec" 5 | ) 6 | 7 | func makeMutable(pathname ...string) error { 8 | args := make([]string, 0, len(pathname)+2) 9 | args = append(args, "-R") 10 | args = append(args, "-ai") 11 | args = append(args, pathname...) 12 | cmd := exec.Command("chattr", args...) 13 | return cmd.Run() 14 | } 15 | -------------------------------------------------------------------------------- /lib/fsutil/readDirnames.go: -------------------------------------------------------------------------------- 1 | package fsutil 2 | 3 | import "os" 4 | 5 | func readDirnames(dirname string, ignoreMissing bool) ([]string, error) { 6 | if file, err := os.Open(dirname); err != nil { 7 | if ignoreMissing && os.IsNotExist(err) { 8 | return nil, nil 9 | } 10 | return nil, err 11 | } else { 12 | defer file.Close() 13 | dirnames, err := file.Readdirnames(-1) 14 | return dirnames, err 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /lib/fsutil/update.go: -------------------------------------------------------------------------------- 1 | package fsutil 2 | 3 | func updateFile(buffer []byte, filename string) (bool, error) { 4 | if same, err := CompareFile(buffer, filename); err != nil { 5 | return false, err 6 | } else if same { 7 | return false, nil 8 | } else { 9 | file, err := CreateRenamingWriter(filename, PublicFilePerms) 10 | if err != nil { 11 | return false, err 12 | } 13 | defer file.Close() 14 | if _, err := file.Write(buffer); err != nil { 15 | return false, err 16 | } 17 | return true, nil 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /lib/fsutil/waitFile.go: -------------------------------------------------------------------------------- 1 | package fsutil 2 | 3 | import ( 4 | "errors" 5 | "io" 6 | "os" 7 | "time" 8 | ) 9 | 10 | func waitFile(pathname string, timeout time.Duration) (io.ReadCloser, error) { 11 | stopTime := time.Now().Add(timeout) 12 | interval := time.Millisecond 13 | for { 14 | if file, err := os.Open(pathname); err != nil { 15 | if !os.IsNotExist(err) { 16 | return nil, err 17 | } 18 | } else { 19 | return file, nil 20 | } 21 | if timeout >= 0 && time.Now().After(stopTime) { 22 | return nil, errors.New("timed out waiting for file: " + pathname) 23 | } 24 | time.Sleep(interval) 25 | interval *= 2 26 | if interval > time.Second { 27 | interval = time.Second 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /lib/fsutil/watchFileWithFsNotifyStub.go: -------------------------------------------------------------------------------- 1 | // +build !linux 2 | 3 | package fsutil 4 | 5 | import ( 6 | "io" 7 | 8 | "github.com/Symantec/Dominator/lib/log" 9 | ) 10 | 11 | func watchFileWithFsNotify(pathname string, channel chan<- io.ReadCloser, 12 | logger log.Logger) bool { 13 | return false 14 | } 15 | 16 | func watchFileStopWithFsNotify() bool { return false } 17 | -------------------------------------------------------------------------------- /lib/hash/api.go: -------------------------------------------------------------------------------- 1 | package hash 2 | 3 | type Hash [64]byte 4 | 5 | func (h Hash) MarshalText() ([]byte, error) { 6 | return h.marshalText() 7 | } 8 | -------------------------------------------------------------------------------- /lib/hash/marshal.go: -------------------------------------------------------------------------------- 1 | package hash 2 | 3 | func (h Hash) marshalText() ([]byte, error) { 4 | retval := make([]byte, 0, 2*len(h)) 5 | for _, byteVal := range h { 6 | retval = append(retval, formatNibble(byteVal>>4)) 7 | retval = append(retval, formatNibble(byteVal&0xf)) 8 | } 9 | return retval, nil 10 | } 11 | 12 | func formatNibble(nibble byte) byte { 13 | if nibble < 10 { 14 | return '0' + nibble 15 | } 16 | return 'a' + nibble - 10 17 | } 18 | -------------------------------------------------------------------------------- /lib/html/footer.go: -------------------------------------------------------------------------------- 1 | package html 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "runtime" 7 | "time" 8 | 9 | "github.com/Symantec/Dominator/lib/format" 10 | ) 11 | 12 | func writeFooter(writer io.Writer) { 13 | fmt.Fprintf(writer, "Page generated at: %s with %s
\n", 14 | time.Now().Format(format.TimeFormatSeconds), 15 | runtime.Version()) 16 | } 17 | -------------------------------------------------------------------------------- /lib/html/register.go: -------------------------------------------------------------------------------- 1 | package html 2 | 3 | import ( 4 | "bufio" 5 | "fmt" 6 | "net/http" 7 | ) 8 | 9 | func registerHtmlWriterForPattern(pattern, title string, 10 | htmlWriter HtmlWriter) { 11 | http.HandleFunc(pattern, 12 | func(w http.ResponseWriter, req *http.Request) { 13 | writer := bufio.NewWriter(w) 14 | defer writer.Flush() 15 | fmt.Fprintf(writer, "%s\n", title) 16 | fmt.Fprintln(writer, "") 17 | fmt.Fprintln(writer, "
") 18 | fmt.Fprintf(writer, "

%s

\n", title) 19 | fmt.Fprintln(writer, "
") 20 | htmlWriter.WriteHtml(writer) 21 | fmt.Fprintln(writer, "") 22 | }) 23 | } 24 | -------------------------------------------------------------------------------- /lib/image/iterators.go: -------------------------------------------------------------------------------- 1 | package image 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/filesystem" 5 | "github.com/Symantec/Dominator/lib/hash" 6 | ) 7 | 8 | func (image *Image) forEachObject(objectFunc func(hash.Hash) error) error { 9 | for _, inode := range image.FileSystem.InodeTable { 10 | if inode, ok := inode.(*filesystem.RegularInode); ok { 11 | if inode.Size > 0 { 12 | if err := objectFunc(inode.Hash); err != nil { 13 | return err 14 | } 15 | } 16 | } 17 | } 18 | if image.ReleaseNotes != nil && image.ReleaseNotes.Object != nil { 19 | if err := objectFunc(*image.ReleaseNotes.Object); err != nil { 20 | return err 21 | } 22 | } 23 | if image.BuildLog != nil && image.BuildLog.Object != nil { 24 | if err := objectFunc(*image.BuildLog.Object); err != nil { 25 | return err 26 | } 27 | } 28 | return nil 29 | } 30 | -------------------------------------------------------------------------------- /lib/image/replace.go: -------------------------------------------------------------------------------- 1 | package image 2 | 3 | func (annotation *Annotation) replaceStrings(replaceFunc func(string) string) { 4 | if annotation != nil { 5 | annotation.URL = replaceFunc(annotation.URL) 6 | } 7 | } 8 | 9 | func (image *Image) replaceStrings(replaceFunc func(string) string) { 10 | image.CreatedBy = replaceFunc(image.CreatedBy) 11 | image.Filter.ReplaceStrings(replaceFunc) 12 | image.FileSystem.ReplaceStrings(replaceFunc) 13 | image.Triggers.ReplaceStrings(replaceFunc) 14 | image.ReleaseNotes.replaceStrings(replaceFunc) 15 | image.BuildLog.replaceStrings(replaceFunc) 16 | for index := range image.Packages { 17 | pkg := &image.Packages[index] 18 | pkg.replaceStrings(replaceFunc) 19 | } 20 | } 21 | 22 | func (pkg *Package) replaceStrings(replaceFunc func(string) string) { 23 | pkg.Version = replaceFunc(pkg.Version) 24 | } 25 | -------------------------------------------------------------------------------- /lib/image/sort.go: -------------------------------------------------------------------------------- 1 | package image 2 | 3 | import ( 4 | "sort" 5 | 6 | "github.com/Symantec/Dominator/lib/verstr" 7 | ) 8 | 9 | type directoryList []Directory 10 | 11 | func (list directoryList) Len() int { 12 | return len(list) 13 | } 14 | 15 | func (list directoryList) Less(i, j int) bool { 16 | return verstr.Less(list[i].Name, list[j].Name) 17 | } 18 | 19 | func (list directoryList) Swap(i, j int) { 20 | list[i], list[j] = list[j], list[i] 21 | } 22 | 23 | func sortDirectories(directories []Directory) { 24 | sort.Sort(directoryList(directories)) 25 | } 26 | -------------------------------------------------------------------------------- /lib/json/api.go: -------------------------------------------------------------------------------- 1 | package json 2 | 3 | import ( 4 | "io" 5 | "os" 6 | ) 7 | 8 | func ReadFromFile(filename string, value interface{}) error { 9 | return readFromFile(filename, value) 10 | } 11 | 12 | func WriteToFile(filename string, perm os.FileMode, indent string, 13 | value interface{}) error { 14 | return writeToFile(filename, perm, indent, value) 15 | } 16 | 17 | func WriteWithIndent(w io.Writer, indent string, value interface{}) error { 18 | return writeWithIndent(w, indent, value) 19 | } 20 | -------------------------------------------------------------------------------- /lib/json/read.go: -------------------------------------------------------------------------------- 1 | package json 2 | 3 | import ( 4 | "bufio" 5 | "encoding/json" 6 | "os" 7 | ) 8 | 9 | func readFromFile(filename string, value interface{}) error { 10 | file, err := os.Open(filename) 11 | if err != nil { 12 | return err 13 | } 14 | defer file.Close() 15 | decoder := json.NewDecoder(bufio.NewReader(file)) 16 | if err := decoder.Decode(value); err != nil { 17 | return err 18 | } 19 | return nil 20 | } 21 | -------------------------------------------------------------------------------- /lib/log/api.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | type Logger interface { 4 | Fatal(v ...interface{}) 5 | Fatalf(format string, v ...interface{}) 6 | Fatalln(v ...interface{}) 7 | Panic(v ...interface{}) 8 | Panicf(format string, v ...interface{}) 9 | Panicln(v ...interface{}) 10 | Print(v ...interface{}) 11 | Printf(format string, v ...interface{}) 12 | Println(v ...interface{}) 13 | } 14 | 15 | type DebugLogger interface { 16 | Debug(level uint8, v ...interface{}) 17 | Debugf(level uint8, format string, v ...interface{}) 18 | Debugln(level uint8, v ...interface{}) 19 | Logger 20 | } 21 | 22 | type DebugLogLevelGetter interface { 23 | GetLevel() int16 24 | } 25 | 26 | type DebugLogLevelSetter interface { 27 | SetLevel(maxLevel int16) 28 | } 29 | 30 | type FullDebugLogger interface { 31 | DebugLogger 32 | DebugLogLevelGetter 33 | DebugLogLevelSetter 34 | } 35 | -------------------------------------------------------------------------------- /lib/log/logutil/api.go: -------------------------------------------------------------------------------- 1 | package logutil 2 | 3 | import "github.com/Symantec/Dominator/lib/log" 4 | 5 | func LogMemory(logger log.DebugLogger, level int16, message string) { 6 | logMemory(logger, level, message) 7 | } 8 | -------------------------------------------------------------------------------- /lib/log/logutil/impl.go: -------------------------------------------------------------------------------- 1 | package logutil 2 | 3 | import ( 4 | "runtime" 5 | 6 | "github.com/Symantec/Dominator/lib/format" 7 | "github.com/Symantec/Dominator/lib/log" 8 | ) 9 | 10 | func logMemory(logger log.DebugLogger, level int16, message string) { 11 | var memStats runtime.MemStats 12 | runtime.ReadMemStats(&memStats) 13 | allocMem := format.FormatBytes(memStats.Alloc) 14 | sysMem := format.FormatBytes(memStats.Sys - memStats.HeapReleased) 15 | if level < 0 { 16 | logger.Printf("%s: memory: allocated: %s, system: %s\n", 17 | message, allocMem, sysMem) 18 | } else { 19 | logger.Debugf(uint8(level), "%s: memory: allocated: %s, system: %s\n", 20 | message, allocMem, sysMem) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/mdb/debug.go: -------------------------------------------------------------------------------- 1 | package mdb 2 | 3 | import ( 4 | "io" 5 | 6 | "github.com/Symantec/Dominator/lib/json" 7 | ) 8 | 9 | func (mdb *Mdb) debugWrite(w io.Writer) error { 10 | return json.WriteWithIndent(w, " ", mdb) 11 | } 12 | -------------------------------------------------------------------------------- /lib/mdb/updateFrom.go: -------------------------------------------------------------------------------- 1 | package mdb 2 | 3 | func (dest *Machine) updateFrom(source Machine) { 4 | if dest.Hostname != source.Hostname { 5 | return 6 | } 7 | if source.IpAddress != "" { 8 | dest.IpAddress = source.IpAddress 9 | } 10 | if source.RequiredImage != "" { 11 | dest.RequiredImage = source.RequiredImage 12 | dest.DisableUpdates = source.DisableUpdates 13 | } 14 | if source.PlannedImage != "" { 15 | dest.PlannedImage = source.PlannedImage 16 | } 17 | if source.OwnerGroup != "" { 18 | dest.OwnerGroup = source.OwnerGroup 19 | } 20 | if source.Tags != nil { 21 | dest.Tags = source.Tags 22 | } 23 | if source.AwsMetadata != nil { 24 | if dest.AwsMetadata == nil { 25 | dest.AwsMetadata = source.AwsMetadata 26 | } else if !compareAwsMetadata(dest.AwsMetadata, source.AwsMetadata) { 27 | dest.AwsMetadata = source.AwsMetadata 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /lib/mdb/updateFrom_test.go: -------------------------------------------------------------------------------- 1 | package mdb 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestUpdateFrom(t *testing.T) { 8 | source := makeNonzeroMachine(t) 9 | dest := &Machine{Hostname: "some.host"} 10 | dest.UpdateFrom(source) 11 | defaultMachine := &Machine{Hostname: "some.host"} 12 | if !dest.Compare(*defaultMachine) { 13 | t.Errorf("UpdateFrom(): copied data despite Hostname mismatch: %v", 14 | *dest) 15 | } 16 | dest.Hostname = "Hostname" 17 | dest.UpdateFrom(source) 18 | if !dest.Compare(source) { 19 | t.Errorf("UpdateFrom: %v != %v", *dest, source) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /lib/meminfo/api.go: -------------------------------------------------------------------------------- 1 | package meminfo 2 | 3 | type MemInfo struct { 4 | Available uint64 5 | Free uint64 6 | Total uint64 7 | } 8 | 9 | func GetMemInfo() (*MemInfo, error) { 10 | return getMemInfo() 11 | } 12 | -------------------------------------------------------------------------------- /lib/meminfo/stubs.go: -------------------------------------------------------------------------------- 1 | // +build !linux 2 | 3 | package meminfo 4 | 5 | import "syscall" 6 | 7 | func getMemInfo() (*MemInfo, error) { 8 | return nil, syscall.ENOTSUP 9 | } 10 | -------------------------------------------------------------------------------- /lib/memstats/memstats.go: -------------------------------------------------------------------------------- 1 | package memstats 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "runtime" 7 | 8 | "github.com/Symantec/Dominator/lib/format" 9 | ) 10 | 11 | func writeNamedStat(writer io.Writer, name string, value uint64) { 12 | fmt.Fprintf(writer, " %s=%s\n", name, format.FormatBytes(value)) 13 | } 14 | 15 | func WriteMemoryStats(writer io.Writer) { 16 | var memStats runtime.MemStats 17 | runtime.ReadMemStats(&memStats) 18 | fmt.Fprintln(writer, "MemStats:") 19 | writeNamedStat(writer, "Alloc", memStats.Alloc) 20 | writeNamedStat(writer, "Sys", memStats.Sys) 21 | } 22 | -------------------------------------------------------------------------------- /lib/net/configurator/update.go: -------------------------------------------------------------------------------- 1 | package configurator 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/log" 5 | ) 6 | 7 | func (netconf *NetworkConfig) update(rootDir string, 8 | logger log.DebugLogger) (bool, error) { 9 | updated := false 10 | if u, err := netconf.updateDebian(rootDir); err != nil { 11 | return updated, err 12 | } else if u { 13 | logger.Printf("updated network interfaces configuration") 14 | updated = true 15 | } 16 | if u, err := updateResolvConf(rootDir, netconf.DefaultSubnet); err != nil { 17 | return updated, err 18 | } else if u { 19 | logger.Printf("updated DNS resolver configuration") 20 | updated = true 21 | } 22 | return updated, nil 23 | } 24 | -------------------------------------------------------------------------------- /lib/net/createTapDevice.go: -------------------------------------------------------------------------------- 1 | // +build !linux 2 | 3 | package net 4 | 5 | import ( 6 | "errors" 7 | "os" 8 | ) 9 | 10 | func createTapDevice() (*os.File, string, error) { 11 | return nil, "", errors.New("tap devices not implemented on this OS") 12 | } 13 | -------------------------------------------------------------------------------- /lib/net/proxy/api.go: -------------------------------------------------------------------------------- 1 | package proxy 2 | 3 | import ( 4 | "net" 5 | ) 6 | 7 | // Dialer defines a dialer that can be use to create connections. 8 | type Dialer interface { 9 | Dial(network, address string) (net.Conn, error) 10 | } 11 | 12 | func NewDialer(proxy string, dialer *net.Dialer) (Dialer, error) { 13 | return newDialer(proxy, dialer) 14 | } 15 | -------------------------------------------------------------------------------- /lib/net/reverseconnection/common.go: -------------------------------------------------------------------------------- 1 | package reverseconnection 2 | 3 | import ( 4 | "time" 5 | ) 6 | 7 | const ( 8 | connectString = "200 Connected to ReverseDialer" 9 | urlPath = "/_ReverseDialer_/connect" 10 | ) 11 | 12 | type reverseDialerMessage struct { 13 | MinimumInterval time.Duration `json:",omitempty"` 14 | MaximumInterval time.Duration `json:",omitempty"` 15 | } 16 | -------------------------------------------------------------------------------- /lib/net/rpc/api.go: -------------------------------------------------------------------------------- 1 | package rpc 2 | 3 | import ( 4 | "net/rpc" 5 | 6 | "github.com/Symantec/Dominator/lib/net" 7 | ) 8 | 9 | // DialHTTPPath works like DialHTTPPath in net/rpc but accepts a custom 10 | // dialer. 11 | func DialHTTPPath(dialer net.Dialer, network, address, path string) ( 12 | *rpc.Client, error) { 13 | return dialHTTPPath(dialer, network, address, path) 14 | } 15 | 16 | // Dial works like Dial in net/rpc but accepts a custom dialer. 17 | func Dial(dialer net.Dialer, network, address string) (*rpc.Client, error) { 18 | return dial(dialer, network, address) 19 | } 20 | -------------------------------------------------------------------------------- /lib/net/tcpsockopt_darwin.go: -------------------------------------------------------------------------------- 1 | package net 2 | 3 | import ( 4 | "syscall" 5 | "time" 6 | ) 7 | 8 | const sysTCP_KEEPINTVL = 0x101 9 | 10 | func (conn *connection) SetKeepAlivePeriod(d time.Duration) error { 11 | // The kernel expects seconds so round to next highest second. 12 | d += (time.Second - time.Nanosecond) 13 | secs := int(d.Seconds()) 14 | err := syscall.SetsockoptInt(conn.fd, syscall.IPPROTO_TCP, 15 | sysTCP_KEEPINTVL, secs) 16 | if err != nil { 17 | return err 18 | } 19 | return syscall.SetsockoptInt(conn.fd, syscall.IPPROTO_TCP, 20 | syscall.TCP_KEEPALIVE, 2) 21 | } 22 | -------------------------------------------------------------------------------- /lib/net/tcpsockopt_unix.go: -------------------------------------------------------------------------------- 1 | // +build freebsd linux netbsd 2 | 3 | package net 4 | 5 | import ( 6 | "syscall" 7 | "time" 8 | ) 9 | 10 | func (conn *connection) SetKeepAlivePeriod(d time.Duration) error { 11 | // The kernel expects seconds so round to next highest second. 12 | d += (time.Second - time.Nanosecond) 13 | secs := int(d.Seconds()) 14 | err := syscall.SetsockoptInt(conn.fd, syscall.IPPROTO_TCP, 15 | syscall.TCP_KEEPINTVL, secs) 16 | if err != nil { 17 | return err 18 | } 19 | err = syscall.SetsockoptInt(conn.fd, syscall.IPPROTO_TCP, 20 | syscall.TCP_KEEPIDLE, secs) 21 | if err != nil { 22 | return err 23 | } 24 | return syscall.SetsockoptInt(conn.fd, syscall.IPPROTO_TCP, 25 | syscall.TCP_KEEPCNT, 2) 26 | } 27 | -------------------------------------------------------------------------------- /lib/net/terminal/client/api.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "io" 5 | ) 6 | 7 | type FlushReadWriter interface { 8 | Flush() error 9 | io.ReadWriter 10 | } 11 | 12 | func StartTerminal(conn FlushReadWriter) error { 13 | return startTerminal(conn) 14 | } 15 | -------------------------------------------------------------------------------- /lib/net/testCarrier.go: -------------------------------------------------------------------------------- 1 | package net 2 | 3 | import ( 4 | "io/ioutil" 5 | "path/filepath" 6 | ) 7 | 8 | func testCarrier(name string) bool { 9 | filename := filepath.Join(sysClassNet, name, "carrier") 10 | if data, err := ioutil.ReadFile(filename); err == nil { 11 | if len(data) > 0 && data[0] == '1' { 12 | return true 13 | } 14 | } 15 | return false 16 | } 17 | -------------------------------------------------------------------------------- /lib/net/util/api.go: -------------------------------------------------------------------------------- 1 | package util 2 | 3 | import ( 4 | "net" 5 | ) 6 | 7 | type DefaultRouteInfo struct { 8 | Address net.IP 9 | Interface string 10 | Mask net.IPMask 11 | } 12 | 13 | type ResolverConfiguration struct { 14 | Domain string 15 | Nameservers []net.IP 16 | SearchDomains []string 17 | } 18 | 19 | func GetDefaultRoute() (*DefaultRouteInfo, error) { 20 | return getDefaultRoute() 21 | } 22 | 23 | func GetMyIP() (net.IP, error) { 24 | return getMyIP() 25 | } 26 | 27 | func GetResolverConfiguration() (*ResolverConfiguration, error) { 28 | return getResolverConfiguration() 29 | } 30 | 31 | func ShrinkIP(netIP net.IP) net.IP { 32 | return shrinkIP(netIP) 33 | } 34 | -------------------------------------------------------------------------------- /lib/netspeed/api.go: -------------------------------------------------------------------------------- 1 | package netspeed 2 | 3 | func GetSpeedToAddress(address string) (uint64, bool) { 4 | return getSpeedToAddress(address) 5 | } 6 | 7 | func GetSpeedToHost(hostname string) (uint64, bool) { 8 | return getSpeedToHost(hostname) 9 | } 10 | -------------------------------------------------------------------------------- /lib/objectcache/compare.go: -------------------------------------------------------------------------------- 1 | package objectcache 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "io" 7 | ) 8 | 9 | func compareObjects(left, right ObjectCache, logWriter io.Writer) bool { 10 | if len(left) != len(right) { 11 | if logWriter != nil { 12 | fmt.Fprintf(logWriter, "left vs. right: %d vs. %d objects\n", 13 | len(left), len(right)) 14 | } 15 | return false 16 | } 17 | for index, leftHash := range left { 18 | if bytes.Compare(leftHash[:], right[index][:]) != 0 { 19 | if logWriter != nil { 20 | fmt.Fprintf(logWriter, "hash: left vs. right: %x vs. %x\n", 21 | leftHash, right[index]) 22 | } 23 | return false 24 | } 25 | } 26 | return true 27 | } 28 | -------------------------------------------------------------------------------- /lib/objectcache/mapToCache.go: -------------------------------------------------------------------------------- 1 | package objectcache 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/hash" 5 | ) 6 | 7 | func objectMapToCache(objectMap map[hash.Hash]uint64) ObjectCache { 8 | objectCache := make(ObjectCache, 0, len(objectMap)) 9 | for hashVal := range objectMap { 10 | objectCache = append(objectCache, hashVal) 11 | } 12 | return objectCache 13 | } 14 | -------------------------------------------------------------------------------- /lib/objectserver/cachingreader/html.go: -------------------------------------------------------------------------------- 1 | package cachingreader 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | 7 | "github.com/Symantec/Dominator/lib/format" 8 | ) 9 | 10 | func (objSrv *ObjectServer) writeHtml(writer io.Writer) { 11 | objSrv.rwLock.RLock() 12 | defer objSrv.rwLock.RUnlock() 13 | fmt.Fprintf(writer, 14 | "Objectcache max: %s, total: %s (%d), cached: %s, in use: %s, downloading: %s
\n", 15 | format.FormatBytes(objSrv.maxCachedBytes), 16 | format.FormatBytes(objSrv.cachedBytes+objSrv.downloadingBytes), 17 | len(objSrv.objects), 18 | format.FormatBytes(objSrv.cachedBytes), 19 | format.FormatBytes(objSrv.cachedBytes-objSrv.lruBytes), 20 | format.FormatBytes(objSrv.downloadingBytes)) 21 | } 22 | -------------------------------------------------------------------------------- /lib/objectserver/client/checkObjects.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/hash" 5 | "github.com/Symantec/Dominator/proto/objectserver" 6 | ) 7 | 8 | func (objClient *ObjectClient) checkObjects(hashes []hash.Hash) ( 9 | []uint64, error) { 10 | var request objectserver.CheckObjectsRequest 11 | request.Hashes = hashes 12 | var reply objectserver.CheckObjectsResponse 13 | client, err := objClient.getClient() 14 | if err != nil { 15 | return nil, err 16 | } 17 | err = client.RequestReply("ObjectServer.CheckObjects", request, &reply) 18 | if err != nil { 19 | return nil, err 20 | } 21 | return reply.ObjectSizes, nil 22 | } 23 | -------------------------------------------------------------------------------- /lib/objectserver/client/client.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | 7 | "github.com/Symantec/Dominator/lib/srpc" 8 | ) 9 | 10 | func (objClient *ObjectClient) close() error { 11 | if objClient.client != nil && objClient.address != "" { 12 | return objClient.client.Close() 13 | } 14 | return nil 15 | } 16 | 17 | func (objClient *ObjectClient) getClient() (*srpc.Client, error) { 18 | if objClient.client != nil { 19 | return objClient.client, nil 20 | } 21 | if objClient.address == "" { 22 | return nil, errors.New("no client address") 23 | } 24 | srpcClient, err := srpc.DialHTTP("tcp", objClient.address, 0) 25 | if err != nil { 26 | return nil, fmt.Errorf("error dialing: %s: %s", objClient.address, err) 27 | } 28 | objClient.client = srpcClient 29 | return objClient.client, nil 30 | } 31 | -------------------------------------------------------------------------------- /lib/objectserver/filesystem/delete.go: -------------------------------------------------------------------------------- 1 | package filesystem 2 | 3 | import ( 4 | "os" 5 | "path" 6 | "time" 7 | 8 | "github.com/Symantec/Dominator/lib/hash" 9 | "github.com/Symantec/Dominator/lib/objectcache" 10 | ) 11 | 12 | func (objSrv *ObjectServer) deleteObject(hashVal hash.Hash) error { 13 | filename := path.Join(objSrv.baseDir, objectcache.HashToFilename(hashVal)) 14 | if err := os.Remove(filename); err != nil { 15 | return err 16 | } 17 | objSrv.rwLock.Lock() 18 | delete(objSrv.sizesMap, hashVal) 19 | objSrv.lastMutationTime = time.Now() 20 | objSrv.rwLock.Unlock() 21 | return nil 22 | } 23 | -------------------------------------------------------------------------------- /lib/objectserver/filesystem/html.go: -------------------------------------------------------------------------------- 1 | package filesystem 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | 7 | "github.com/Symantec/Dominator/lib/format" 8 | ) 9 | 10 | func (objSrv *ObjectServer) writeHtml(writer io.Writer) { 11 | free, capacity, err := objSrv.getSpaceMetrics() 12 | if err != nil { 13 | fmt.Fprintln(writer, err) 14 | return 15 | } 16 | utilisation := float64(capacity-free) * 100 / float64(capacity) 17 | var totalBytes uint64 18 | objSrv.rwLock.RLock() 19 | numObjects := len(objSrv.sizesMap) 20 | for _, size := range objSrv.sizesMap { 21 | totalBytes += size 22 | } 23 | objSrv.rwLock.RUnlock() 24 | fmt.Fprintf(writer, 25 | "Number of objects: %d, consuming %s (FS is %.1f%% full)
\n", 26 | numObjects, format.FormatBytes(totalBytes), utilisation) 27 | } 28 | -------------------------------------------------------------------------------- /lib/objectserver/filesystem/list.go: -------------------------------------------------------------------------------- 1 | package filesystem 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/hash" 5 | ) 6 | 7 | func (objSrv *ObjectServer) listObjectSizes() map[hash.Hash]uint64 { 8 | objSrv.rwLock.RLock() 9 | defer objSrv.rwLock.RUnlock() 10 | sizesMap := make(map[hash.Hash]uint64, len(objSrv.sizesMap)) 11 | for hashVal, size := range objSrv.sizesMap { 12 | sizesMap[hashVal] = uint64(size) 13 | } 14 | return sizesMap 15 | } 16 | 17 | func (objSrv *ObjectServer) listObjects() []hash.Hash { 18 | objSrv.rwLock.RLock() 19 | defer objSrv.rwLock.RUnlock() 20 | hashes := make([]hash.Hash, 0, len(objSrv.sizesMap)) 21 | for hashVal := range objSrv.sizesMap { 22 | hashes = append(hashes, hashVal) 23 | } 24 | return hashes 25 | } 26 | -------------------------------------------------------------------------------- /lib/objectserver/filesystem/scan/api.go: -------------------------------------------------------------------------------- 1 | package scan 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/hash" 5 | ) 6 | 7 | // ScanTree will scan a directory tree for objects and will call registerFunc 8 | // for each object. Multiple calls to registerFunc may be called concurrently. 9 | func ScanTree(baseDir string, registerFunc func(hash.Hash, uint64)) error { 10 | return scanTree(baseDir, registerFunc) 11 | } 12 | -------------------------------------------------------------------------------- /lib/objectserver/memory/check.go: -------------------------------------------------------------------------------- 1 | package memory 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/hash" 5 | ) 6 | 7 | func (objSrv *ObjectServer) checkObjects(hashes []hash.Hash) ([]uint64, error) { 8 | sizesList := make([]uint64, len(hashes)) 9 | objSrv.rwLock.RLock() 10 | defer objSrv.rwLock.RUnlock() 11 | for index, hashVal := range hashes { 12 | if data, ok := objSrv.objectMap[hashVal]; ok { 13 | sizesList[index] = uint64(len(data)) 14 | } 15 | } 16 | return sizesList, nil 17 | } 18 | -------------------------------------------------------------------------------- /lib/objectserver/memory/list.go: -------------------------------------------------------------------------------- 1 | package memory 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/hash" 5 | ) 6 | 7 | func (objSrv *ObjectServer) listObjectSizes() map[hash.Hash]uint64 { 8 | objSrv.rwLock.RLock() 9 | defer objSrv.rwLock.RUnlock() 10 | sizesMap := make(map[hash.Hash]uint64, len(objSrv.objectMap)) 11 | for hashVal, data := range objSrv.objectMap { 12 | sizesMap[hashVal] = uint64(len(data)) 13 | } 14 | return sizesMap 15 | } 16 | 17 | func (objSrv *ObjectServer) listObjects() []hash.Hash { 18 | objSrv.rwLock.RLock() 19 | defer objSrv.rwLock.RUnlock() 20 | hashes := make([]hash.Hash, 0, len(objSrv.objectMap)) 21 | for hashVal := range objSrv.objectMap { 22 | hashes = append(hashes, hashVal) 23 | } 24 | return hashes 25 | } 26 | -------------------------------------------------------------------------------- /lib/objectserver/memory/new.go: -------------------------------------------------------------------------------- 1 | package memory 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/hash" 5 | ) 6 | 7 | func newObjectServer() *ObjectServer { 8 | objSrv := new(ObjectServer) 9 | objSrv.objectMap = make(map[hash.Hash][]byte) 10 | return objSrv 11 | } 12 | -------------------------------------------------------------------------------- /lib/pprof/api.go: -------------------------------------------------------------------------------- 1 | package pprof 2 | 3 | func StartCpuProfile(filename string) error { 4 | return startCpuProfile(filename) 5 | } 6 | 7 | func StopCpuProfile() { 8 | stopCpuProfile() 9 | } 10 | -------------------------------------------------------------------------------- /lib/pprof/impl.go: -------------------------------------------------------------------------------- 1 | package pprof 2 | 3 | import ( 4 | "os" 5 | "runtime/pprof" 6 | ) 7 | 8 | var ( 9 | cpuProfile *os.File 10 | ) 11 | 12 | func startCpuProfile(filename string) error { 13 | if cpuProfile != nil { 14 | panic("CPU profiling already started") 15 | } 16 | if file, err := os.Create(filename); err != nil { 17 | return err 18 | } else { 19 | if err := pprof.StartCPUProfile(file); err != nil { 20 | file.Close() 21 | return err 22 | } 23 | cpuProfile = file 24 | return nil 25 | } 26 | } 27 | 28 | func stopCpuProfile() { 29 | if cpuProfile == nil { 30 | return 31 | } 32 | pprof.StopCPUProfile() 33 | cpuProfile.Close() 34 | cpuProfile = nil 35 | } 36 | -------------------------------------------------------------------------------- /lib/queue/eventQueue.go: -------------------------------------------------------------------------------- 1 | package queue 2 | 3 | func newEventQueue() (chan<- struct{}, <-chan struct{}) { 4 | send := make(chan struct{}, 1) 5 | receive := make(chan struct{}, 1) 6 | go manageEventQueue(send, receive) 7 | return send, receive 8 | } 9 | 10 | func manageEventQueue(send <-chan struct{}, receive chan<- struct{}) { 11 | numInQueue := 0 12 | for { 13 | if numInQueue < 1 { 14 | if send == nil { 15 | close(receive) 16 | return 17 | } 18 | _, ok := <-send 19 | if !ok { 20 | close(receive) 21 | return 22 | } 23 | numInQueue++ 24 | } else { 25 | select { 26 | case receive <- struct{}{}: 27 | numInQueue-- 28 | case _, ok := <-send: 29 | if ok { 30 | numInQueue++ 31 | } else { 32 | send = nil 33 | } 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /lib/rsync/api.go: -------------------------------------------------------------------------------- 1 | package rsync 2 | 3 | import ( 4 | "io" 5 | ) 6 | 7 | type Conn interface { 8 | Flush() error 9 | io.Reader 10 | io.Writer 11 | } 12 | 13 | type Decoder interface { 14 | Decode(e interface{}) error 15 | } 16 | 17 | type Encoder interface { 18 | Encode(e interface{}) error 19 | } 20 | 21 | type Stats struct { 22 | NumRead uint64 23 | NumWritten uint64 24 | } 25 | 26 | func GetBlocks(conn Conn, decoder Decoder, encoder Encoder, reader io.Reader, 27 | writer io.WriteSeeker, totalBytes, readerBytes uint64) (Stats, error) { 28 | return getBlocks(conn, decoder, encoder, reader, writer, totalBytes, 29 | readerBytes) 30 | } 31 | 32 | func ServeBlocks(conn Conn, decoder Decoder, encoder Encoder, 33 | reader io.ReadSeeker, length uint64) error { 34 | return serveBlocks(conn, decoder, encoder, reader, length) 35 | } 36 | -------------------------------------------------------------------------------- /lib/srpc/coders.go: -------------------------------------------------------------------------------- 1 | package srpc 2 | 3 | import ( 4 | "encoding/gob" 5 | "encoding/json" 6 | "io" 7 | ) 8 | 9 | type coderMaker interface { 10 | MakeDecoder(r io.Reader) Decoder 11 | MakeEncoder(w io.Writer) Encoder 12 | } 13 | 14 | type gobCoder struct{} 15 | 16 | func (c *gobCoder) MakeDecoder(r io.Reader) Decoder { 17 | return gob.NewDecoder(r) 18 | } 19 | 20 | func (c *gobCoder) MakeEncoder(w io.Writer) Encoder { 21 | return gob.NewEncoder(w) 22 | } 23 | 24 | type jsonCoder struct{} 25 | 26 | func (c *jsonCoder) MakeDecoder(r io.Reader) Decoder { 27 | return json.NewDecoder(r) 28 | } 29 | 30 | func (c *jsonCoder) MakeEncoder(w io.Writer) Encoder { 31 | return json.NewEncoder(w) 32 | } 33 | -------------------------------------------------------------------------------- /lib/srpc/proxy/api.go: -------------------------------------------------------------------------------- 1 | package proxy 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/log" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | ) 7 | 8 | type srpcType struct { 9 | logger log.DebugLogger 10 | } 11 | 12 | func New(logger log.DebugLogger) error { 13 | return srpc.RegisterNameWithOptions("Proxy", &srpcType{logger: logger}, 14 | srpc.ReceiverOptions{ 15 | PublicMethods: []string{"Connect"}}) 16 | } 17 | -------------------------------------------------------------------------------- /lib/srpc/serverutil/api.go: -------------------------------------------------------------------------------- 1 | package serverutil 2 | 3 | import ( 4 | "sync" 5 | 6 | "github.com/Symantec/Dominator/lib/srpc" 7 | ) 8 | 9 | type PerUserMethodLimiter struct { 10 | mutex sync.Mutex 11 | perUserMethodCounts map[userMethodType]uint 12 | perUserMethodLimits map[string]uint 13 | } 14 | 15 | type userMethodType struct { 16 | method string 17 | username string 18 | } 19 | 20 | func NewPerUserMethodLimiter( 21 | perUserMethodLimits map[string]uint) *PerUserMethodLimiter { 22 | return newPerUserMethodLimiter(perUserMethodLimits) 23 | } 24 | 25 | func (limiter *PerUserMethodLimiter) BlockMethod(methodName string, 26 | authInfo *srpc.AuthInformation) (func(), error) { 27 | return limiter.blockMethod(methodName, authInfo) 28 | } 29 | -------------------------------------------------------------------------------- /lib/srpc/setupclient/impl.go: -------------------------------------------------------------------------------- 1 | package setupclient 2 | 3 | import ( 4 | "crypto/tls" 5 | 6 | "github.com/Symantec/Dominator/lib/srpc" 7 | ) 8 | 9 | func setupTls(ignoreMissingCerts bool) error { 10 | if *certDirectory == "" { 11 | return nil 12 | } 13 | // Load certificates. 14 | certs, err := srpc.LoadCertificates(*certDirectory) 15 | if err != nil { 16 | return err 17 | } 18 | if certs == nil { 19 | if ignoreMissingCerts { 20 | return nil 21 | } 22 | return srpc.ErrorMissingCertificate 23 | } 24 | // Setup client. 25 | clientConfig := new(tls.Config) 26 | clientConfig.InsecureSkipVerify = true 27 | clientConfig.MinVersion = tls.VersionTLS12 28 | clientConfig.Certificates = certs 29 | srpc.RegisterClientTlsConfig(clientConfig) 30 | return nil 31 | } 32 | -------------------------------------------------------------------------------- /lib/srpc/setupserver/api.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package setupserver assists in setting up TLS credentials for a server. 3 | 4 | Package setupserver provides convenience functions for setting up a server 5 | with TLS credentials. 6 | */ 7 | package setupserver 8 | 9 | // SetupTls loads client and server certificates from files and registers them 10 | // with the lib/srpc package. The following command-line flags are registered 11 | // with the standard flag package: 12 | // -caFile: Name of file containing the root of trust 13 | // -certFile: Name of file containing the SSL certificate 14 | // -keyFile: Name of file containing the SSL key 15 | func SetupTls() error { 16 | return setupTls(true) 17 | } 18 | 19 | // SetupTlsClientOnly loads a client certificate from files and registers it 20 | // with the lib/srpc package. 21 | func SetupTlsClientOnly() error { 22 | return setupTls(false) 23 | } 24 | -------------------------------------------------------------------------------- /lib/tags/api.go: -------------------------------------------------------------------------------- 1 | package tags 2 | 3 | type Tag struct { 4 | Key string 5 | Value string 6 | } 7 | 8 | func (tag *Tag) String() string { 9 | return tag.string() 10 | } 11 | 12 | func (tag *Tag) Set(value string) error { 13 | return tag.set(value) 14 | } 15 | 16 | type Tags map[string]string // Key: tag key, value: tag value. 17 | 18 | func (tags Tags) Copy() Tags { 19 | return tags.copy() 20 | } 21 | 22 | func (left Tags) Equal(right Tags) bool { 23 | return left.equal(right) 24 | } 25 | 26 | func (to Tags) Merge(from Tags) { 27 | to.merge(from) 28 | } 29 | 30 | func (tags *Tags) String() string { 31 | return tags.string() 32 | } 33 | 34 | func (tags *Tags) Set(value string) error { 35 | return tags.set(value) 36 | } 37 | -------------------------------------------------------------------------------- /lib/triggers/load.go: -------------------------------------------------------------------------------- 1 | package triggers 2 | 3 | import ( 4 | "encoding/json" 5 | "errors" 6 | "os" 7 | ) 8 | 9 | func load(filename string) (*Triggers, error) { 10 | file, err := os.Open(filename) 11 | if err != nil { 12 | return nil, err 13 | } 14 | defer file.Close() 15 | decoder := json.NewDecoder(file) 16 | var trig Triggers 17 | if err := decoder.Decode(&trig.Triggers); err != nil { 18 | return nil, errors.New("error decoding triggers " + err.Error()) 19 | } 20 | return &trig, nil 21 | } 22 | 23 | func decode(jsonData []byte) (*Triggers, error) { 24 | var trig Triggers 25 | if err := json.Unmarshal(jsonData, &trig.Triggers); err != nil { 26 | return nil, errors.New("error decoding triggers " + err.Error()) 27 | } 28 | return &trig, nil 29 | } 30 | -------------------------------------------------------------------------------- /lib/triggers/make.go: -------------------------------------------------------------------------------- 1 | package triggers 2 | 3 | import ( 4 | "regexp" 5 | ) 6 | 7 | func newTriggers() *Triggers { 8 | return &Triggers{} 9 | } 10 | 11 | func (triggers *Triggers) compile() error { 12 | if triggers.compiled { 13 | return nil 14 | } 15 | for _, trigger := range triggers.Triggers { 16 | trigger.matchRegexes = make([]*regexp.Regexp, len(trigger.MatchLines)) 17 | for index, line := range trigger.MatchLines { 18 | var err error 19 | trigger.matchRegexes[index], err = regexp.Compile("^" + line) 20 | if err != nil { 21 | return err 22 | } 23 | } 24 | } 25 | triggers.compiled = true 26 | return nil 27 | } 28 | -------------------------------------------------------------------------------- /lib/triggers/replace.go: -------------------------------------------------------------------------------- 1 | package triggers 2 | 3 | func (trigger *Trigger) replaceStrings(replaceFunc func(string) string) { 4 | for index, str := range trigger.MatchLines { 5 | trigger.MatchLines[index] = replaceFunc(str) 6 | } 7 | trigger.Service = replaceFunc(trigger.Service) 8 | } 9 | 10 | func (triggers *Triggers) replaceStrings(replaceFunc func(string) string) { 11 | if triggers != nil { 12 | for _, trigger := range triggers.Triggers { 13 | trigger.ReplaceStrings(replaceFunc) 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /lib/url/api.go: -------------------------------------------------------------------------------- 1 | package url 2 | 3 | import ( 4 | "net/url" 5 | "time" 6 | ) 7 | 8 | const ( 9 | OutputTypeHtml = iota 10 | OutputTypeText 11 | OutputTypeJson 12 | ) 13 | 14 | type ParsedQuery struct { 15 | Flags map[string]struct{} 16 | Table map[string]string 17 | } 18 | 19 | func ParseQuery(URL *url.URL) ParsedQuery { 20 | return parseQuery(URL) 21 | } 22 | 23 | func (pq ParsedQuery) Last() (time.Duration, error) { 24 | return pq.last() 25 | } 26 | 27 | func (pq ParsedQuery) OutputType() uint { 28 | return pq.outputType() 29 | } 30 | -------------------------------------------------------------------------------- /lib/url/parseQuery.go: -------------------------------------------------------------------------------- 1 | package url 2 | 3 | import ( 4 | "net/url" 5 | "strings" 6 | ) 7 | 8 | func parseQuery(URL *url.URL) ParsedQuery { 9 | var parsedQuery ParsedQuery 10 | parsedQuery.Flags = make(map[string]struct{}) 11 | parsedQuery.Table = make(map[string]string) 12 | for _, pair := range strings.Split(URL.RawQuery, "&") { 13 | splitPair := strings.Split(pair, "=") 14 | if len(splitPair) == 1 { 15 | parsedQuery.Flags[splitPair[0]] = struct{}{} 16 | } 17 | if len(splitPair) == 2 { 18 | parsedQuery.Table[splitPair[0]] = splitPair[1] 19 | } 20 | } 21 | return parsedQuery 22 | } 23 | -------------------------------------------------------------------------------- /lib/url/parsedQuery.go: -------------------------------------------------------------------------------- 1 | package url 2 | 3 | func (pq ParsedQuery) outputType() uint { 4 | if value, ok := pq.Table["output"]; ok { 5 | switch value { 6 | case "json": 7 | return OutputTypeJson 8 | case "text": 9 | return OutputTypeText 10 | } 11 | } 12 | return OutputTypeHtml 13 | } 14 | -------------------------------------------------------------------------------- /lib/url/urlutil/open.go: -------------------------------------------------------------------------------- 1 | package urlutil 2 | 3 | import ( 4 | "errors" 5 | "io" 6 | "net/http" 7 | "net/url" 8 | "os" 9 | ) 10 | 11 | func open(rawurl string) (io.ReadCloser, error) { 12 | u, err := url.Parse(rawurl) 13 | if err != nil { 14 | return nil, err 15 | } 16 | if u.Scheme == "file" { 17 | return os.Open(u.Path) 18 | } 19 | if u.Scheme == "http" || u.Scheme == "https" { 20 | resp, err := http.Get(rawurl) 21 | if err != nil { 22 | return nil, 23 | errors.New("error getting: " + rawurl + ": " + err.Error()) 24 | } 25 | if resp.StatusCode != http.StatusOK { 26 | return nil, 27 | errors.New("error getting: " + rawurl + ": " + resp.Status) 28 | } 29 | return resp.Body, nil 30 | } 31 | return nil, errors.New("unknown scheme: " + u.Scheme) 32 | } 33 | -------------------------------------------------------------------------------- /lib/verstr/api.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package verstr supports comparing and sorting of version strings. 3 | 4 | Version strings contain substrings of numbers which should be sorted 5 | numerically rather than lexographically. For example, "file.9.ext" and 6 | "file.10.ext" sort lexographically such that "file.10.ext" comes first which 7 | is generally not the desired result. When treated as version strings, 8 | "file.9.ext" should come first. 9 | */ 10 | package verstr 11 | 12 | // Less compares two version strings and returns true if left should be 13 | // considered lesser than right. 14 | func Less(left, right string) bool { 15 | return less(left, right) 16 | } 17 | 18 | // Sort sorts a slice of strings in-place, treating them as version strings. 19 | func Sort(list []string) { 20 | doSort(list) 21 | } 22 | -------------------------------------------------------------------------------- /lib/verstr/sort.go: -------------------------------------------------------------------------------- 1 | package verstr 2 | 3 | import ( 4 | "sort" 5 | ) 6 | 7 | type sliceWrapper []string 8 | 9 | func (list sliceWrapper) Len() int { 10 | return len(list) 11 | } 12 | 13 | func (list sliceWrapper) Less(i, j int) bool { 14 | return Less(list[i], list[j]) 15 | } 16 | 17 | func (list sliceWrapper) Swap(i, j int) { 18 | list[i], list[j] = list[j], list[i] 19 | } 20 | 21 | func doSort(list []string) { 22 | sort.Sort(sliceWrapper(list)) 23 | } 24 | -------------------------------------------------------------------------------- /lib/x509util/getUsername.go: -------------------------------------------------------------------------------- 1 | package x509util 2 | 3 | import ( 4 | "crypto/x509" 5 | ) 6 | 7 | func getUsername(cert *x509.Certificate) (string, error) { 8 | return cert.Subject.CommonName, nil 9 | } 10 | -------------------------------------------------------------------------------- /objectserver/rpcd/addObjects.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "runtime" 5 | 6 | "github.com/Symantec/Dominator/lib/srpc" 7 | "github.com/Symantec/Dominator/objectserver/rpcd/lib" 8 | ) 9 | 10 | func (t *srpcType) AddObjects(conn *srpc.Conn) error { 11 | defer runtime.GC() // An opportune time to take out the garbage. 12 | if t.replicationMaster == "" { 13 | return lib.AddObjects(conn, conn, conn, t.objectServer, t.logger) 14 | } 15 | return lib.AddObjectsWithMaster(conn, conn, conn, t.objectServer, 16 | t.replicationMaster, t.logger) 17 | } 18 | -------------------------------------------------------------------------------- /objectserver/rpcd/checkObjects.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/srpc" 5 | "github.com/Symantec/Dominator/proto/objectserver" 6 | ) 7 | 8 | func (t *srpcType) CheckObjects(conn *srpc.Conn, 9 | request objectserver.CheckObjectsRequest, 10 | reply *objectserver.CheckObjectsResponse) error { 11 | sizes, err := t.objectServer.CheckObjects(request.Hashes) 12 | if err != nil { 13 | _, err = conn.WriteString(err.Error() + "\n") 14 | return err 15 | } 16 | reply.ObjectSizes = sizes 17 | return nil 18 | } 19 | -------------------------------------------------------------------------------- /objectserver/rpcd/html.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | ) 7 | 8 | func (hw *htmlWriter) writeHtml(writer io.Writer) { 9 | fmt.Fprintf(writer, "GetObjects() RPC slots: %d out of %d
\n", 10 | len(hw.getSemaphore), cap(hw.getSemaphore)) 11 | } 12 | -------------------------------------------------------------------------------- /proto/common/messages.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | type StatusResponse struct { 4 | Success bool 5 | ErrorString string 6 | } 7 | -------------------------------------------------------------------------------- /proto/imageserver/gob.go: -------------------------------------------------------------------------------- 1 | package imageserver 2 | 3 | import ( 4 | "encoding/gob" 5 | 6 | "github.com/Symantec/Dominator/lib/filesystem" 7 | ) 8 | 9 | func init() { 10 | gob.Register(&filesystem.RegularInode{}) 11 | gob.Register(&filesystem.ComputedRegularInode{}) 12 | gob.Register(&filesystem.SymlinkInode{}) 13 | gob.Register(&filesystem.SpecialInode{}) 14 | gob.Register(&filesystem.DirectoryInode{}) 15 | } 16 | -------------------------------------------------------------------------------- /proto/imageunpacker/string.go: -------------------------------------------------------------------------------- 1 | package imageunpacker 2 | 3 | func (status StreamStatus) string() string { 4 | switch status { 5 | case StatusStreamNoDevice: 6 | return "no device" 7 | case StatusStreamNotMounted: 8 | return "not mounted" 9 | case StatusStreamMounted: 10 | return "mounted" 11 | case StatusStreamScanning: 12 | return "scanning" 13 | case StatusStreamScanned: 14 | return "scanned" 15 | case StatusStreamFetching: 16 | return "fetching" 17 | case StatusStreamUpdating: 18 | return "updating" 19 | case StatusStreamPreparing: 20 | return "preparing" 21 | case StatusStreamExporting: 22 | return "exporting" 23 | case StatusStreamNoFileSystem: 24 | return "no file-system" 25 | default: 26 | return "UNKNOWN" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /proto/imaginator/messages.go: -------------------------------------------------------------------------------- 1 | package imaginator 2 | 3 | import ( 4 | "time" 5 | 6 | "github.com/Symantec/Dominator/lib/image" 7 | ) 8 | 9 | type BuildImageRequest struct { 10 | DisableRecursiveBuild bool 11 | ExpiresIn time.Duration 12 | GitBranch string 13 | MaxSourceAge time.Duration 14 | ReturnImage bool 15 | StreamBuildLog bool 16 | StreamName string 17 | Variables map[string]string 18 | } 19 | 20 | type BuildImageResponse struct { 21 | Image *image.Image 22 | ImageName string 23 | BuildLog []byte 24 | ErrorString string 25 | } 26 | -------------------------------------------------------------------------------- /proto/installer/messages.go: -------------------------------------------------------------------------------- 1 | package installer 2 | 3 | const ( 4 | FileSystemTypeExt4 = 0 5 | ) 6 | 7 | type FileSystemType uint 8 | 9 | type Partition struct { 10 | FileSystemType FileSystemType `json:",omitempty"` 11 | MountPoint string `json:",omitempty"` 12 | MinimumFreeBytes uint64 `json:",omitempty"` 13 | } 14 | 15 | type StorageLayout struct { 16 | BootDriveLayout []Partition `json:",omitempty"` 17 | ExtraMountPointsBasename string `json:",omitempty"` 18 | Encrypt bool `json:",omitempty"` 19 | } 20 | -------------------------------------------------------------------------------- /proto/logger/messages.go: -------------------------------------------------------------------------------- 1 | package logger 2 | 3 | type DebugRequest struct { 4 | Args []string 5 | Name string 6 | Level uint8 7 | } 8 | 9 | type DebugResponse struct{} 10 | 11 | type PrintRequest struct { 12 | Args []string 13 | Name string 14 | } 15 | 16 | type PrintResponse struct{} 17 | 18 | type SetDebugLevelRequest struct { 19 | Name string 20 | Level int16 21 | } 22 | 23 | type SetDebugLevelResponse struct{} 24 | 25 | type WatchRequest struct { 26 | DebugLevel int16 27 | ExcludeRegex string // Empty: nothing excluded. Processed after includes. 28 | IncludeRegex string // Empty: everything included. 29 | Name string 30 | } 31 | 32 | type WatchResponse struct { 33 | Error string 34 | } // Log data are streamed afterwards. 35 | -------------------------------------------------------------------------------- /proto/mdbserver/messages.go: -------------------------------------------------------------------------------- 1 | package mdbserver 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/mdb" 5 | ) 6 | 7 | // The GetMdbUpdates() RPC is fully streamed. 8 | // The client sends no information to the server. 9 | // The server sends a stream of MdbUpdate messages. 10 | // At connection start, the full MDB data are presented in .MachinesToAdd and 11 | // .MachinesToUpdate and .MachinesToDelete will be nil. 12 | 13 | type MdbUpdate struct { 14 | MachinesToAdd []mdb.Machine 15 | MachinesToUpdate []mdb.Machine 16 | MachinesToDelete []string 17 | } 18 | -------------------------------------------------------------------------------- /proto/proxy/messages.go: -------------------------------------------------------------------------------- 1 | package proxy 2 | 3 | import "time" 4 | 5 | type ConnectRequest struct { 6 | Address string 7 | Network string 8 | Timeout time.Duration 9 | } 10 | 11 | type ConnectResponse struct { 12 | Error string 13 | } 14 | -------------------------------------------------------------------------------- /proto/rsync/messages.go: -------------------------------------------------------------------------------- 1 | package rsync 2 | 3 | // The GetBlocks() protocol is fully streamed. 4 | // The client sends a GetBlocksRequest to the server. 5 | // The server sends a stream of Block messages. 6 | 7 | type GetBlocksRequest struct { 8 | BlockOrder uint8 // Valid values: 9-32. 9 | NumBlocks uint64 // If zero: send a single block for the whole volume. 10 | } // lib/hash.Hash messages are streamed afterwards. 11 | 12 | type Block struct { 13 | Error string 14 | Index uint64 15 | Size uint64 // If zero: no more blocks coming. 16 | } // Block data are streamed afterwards. 17 | -------------------------------------------------------------------------------- /proto/sub/gob.go: -------------------------------------------------------------------------------- 1 | package sub 2 | 3 | import ( 4 | "encoding/gob" 5 | 6 | "github.com/Symantec/Dominator/lib/filesystem" 7 | ) 8 | 9 | func init() { 10 | gob.Register(&filesystem.RegularInode{}) 11 | gob.Register(&filesystem.SymlinkInode{}) 12 | gob.Register(&filesystem.SpecialInode{}) 13 | gob.Register(&filesystem.DirectoryInode{}) 14 | } 15 | -------------------------------------------------------------------------------- /proto/sub/string.go: -------------------------------------------------------------------------------- 1 | package sub 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func (configuration Configuration) String() string { 8 | retval := fmt.Sprintf("CpuPercent: %d\nNetworkSpeedPercent: %d\nScanSpeedPercent: %d", 9 | configuration.CpuPercent, configuration.NetworkSpeedPercent, 10 | configuration.ScanSpeedPercent) 11 | if len(configuration.ScanExclusionList) > 0 { 12 | retval += "\n" + "ScanExclusionList:" 13 | for _, exclusion := range configuration.ScanExclusionList { 14 | retval += "\n " + exclusion 15 | } 16 | } 17 | return retval 18 | } 19 | 20 | func (configuration GetConfigurationResponse) String() string { 21 | return Configuration(configuration).String() 22 | } 23 | -------------------------------------------------------------------------------- /proto/test/messages.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | type EchoRequest struct { 4 | Request string 5 | } 6 | 7 | type EchoResponse struct { 8 | Response string 9 | } 10 | -------------------------------------------------------------------------------- /scripts/image-pusher/init.wrapper: -------------------------------------------------------------------------------- 1 | #! /bin/bash --posix 2 | 3 | mount -n none -t tmpfs /mnt 4 | cd / 5 | cp -ax . /mnt 6 | if [ -d /proc/1 ]; then 7 | mount -n none -t proc /mnt/proc 8 | fi 9 | cd /mnt 10 | ln sbin/init.real init 11 | pivot_root . mnt 12 | umount /mnt/* /mnt/dev/* 13 | mount -n -o remount,rw /mnt 14 | exec chroot . /init 15 | -------------------------------------------------------------------------------- /scripts/image-pusher/subd.default: -------------------------------------------------------------------------------- 1 | PROG_ARGS="-defaultNetworkSpeedPercent=100 \ 2 | -defaultScanSpeedPercent=100 \ 3 | -maxThreads=2 \ 4 | -rootDir=/mnt \ 5 | -scanExcludeList=" 6 | 7 | mount -o remount,rw /mnt 8 | umount /mnt/* /mnt/dev/* 9 | -------------------------------------------------------------------------------- /scripts/list-methods: -------------------------------------------------------------------------------- 1 | #! /bin/bash --posix 2 | 3 | set -o nounset 4 | 5 | WGET='wget -q -O -' 6 | 7 | if [ -z "$(which wget)" ]; then 8 | WGET='curl' 9 | fi 10 | $WGET "http://$1/_goSRPC_/listMethods" && exit 11 | rc="$?" 12 | echo "Error getting list of methods" 13 | exit "$rc" 14 | -------------------------------------------------------------------------------- /sub/client/boostCpuLimit.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/srpc" 5 | "github.com/Symantec/Dominator/proto/sub" 6 | ) 7 | 8 | func boostCpuLimit(client *srpc.Client) error { 9 | request := sub.BoostCpuLimitRequest{} 10 | var reply sub.BoostCpuLimitResponse 11 | return client.RequestReply("Subd.BoostCpuLimit", request, &reply) 12 | } 13 | -------------------------------------------------------------------------------- /sub/client/cleanup.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/hash" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | "github.com/Symantec/Dominator/proto/sub" 7 | ) 8 | 9 | func cleanup(client *srpc.Client, hashes []hash.Hash) error { 10 | request := sub.CleanupRequest{hashes} 11 | var reply sub.CleanupResponse 12 | return client.RequestReply("Subd.Cleanup", request, &reply) 13 | } 14 | -------------------------------------------------------------------------------- /sub/client/fetch.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/hash" 5 | "github.com/Symantec/Dominator/lib/srpc" 6 | "github.com/Symantec/Dominator/proto/sub" 7 | ) 8 | 9 | func fetch(client *srpc.Client, serverAddress string, 10 | hashes []hash.Hash) error { 11 | request := sub.FetchRequest{ServerAddress: serverAddress, Hashes: hashes} 12 | var reply sub.FetchResponse 13 | return client.RequestReply("Subd.Fetch", request, &reply) 14 | } 15 | -------------------------------------------------------------------------------- /sub/client/getConfiguration.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/srpc" 5 | "github.com/Symantec/Dominator/proto/sub" 6 | ) 7 | 8 | func getConfiguration(client *srpc.Client) (sub.Configuration, error) { 9 | var request sub.GetConfigurationRequest 10 | var reply sub.GetConfigurationResponse 11 | err := client.RequestReply("Subd.GetConfiguration", request, &reply) 12 | return sub.Configuration(reply), err 13 | } 14 | -------------------------------------------------------------------------------- /sub/client/setConfiguration.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/srpc" 5 | "github.com/Symantec/Dominator/proto/sub" 6 | ) 7 | 8 | func setConfiguration(client *srpc.Client, config sub.Configuration) error { 9 | var request sub.SetConfigurationRequest 10 | request = sub.SetConfigurationRequest(config) 11 | var reply sub.SetConfigurationResponse 12 | return client.RequestReply("Subd.SetConfiguration", request, &reply) 13 | } 14 | -------------------------------------------------------------------------------- /sub/client/update.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/srpc" 5 | "github.com/Symantec/Dominator/proto/sub" 6 | ) 7 | 8 | func callUpdate(client *srpc.Client, request sub.UpdateRequest, 9 | reply *sub.UpdateResponse) error { 10 | return client.RequestReply("Subd.Update", request, reply) 11 | } 12 | -------------------------------------------------------------------------------- /sub/rpcd/boostCpuLimit.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/srpc" 5 | "github.com/Symantec/Dominator/proto/sub" 6 | ) 7 | 8 | func (t *rpcType) BoostCpuLimit(conn *srpc.Conn, 9 | request sub.BoostCpuLimitRequest, reply *sub.BoostCpuLimitResponse) error { 10 | t.scannerConfiguration.BoostCpuLimit(t.logger) 11 | return nil 12 | } 13 | -------------------------------------------------------------------------------- /sub/rpcd/html.go: -------------------------------------------------------------------------------- 1 | package rpcd 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | ) 7 | 8 | func (hw *HtmlWriter) writeHtml(writer io.Writer) { 9 | fmt.Fprintf(writer, "Image of last successful update: \"%s\"
\n", 10 | *hw.lastSuccessfulImageName) 11 | } 12 | -------------------------------------------------------------------------------- /sub/scanner/compare.go: -------------------------------------------------------------------------------- 1 | package scanner 2 | 3 | import ( 4 | "io" 5 | 6 | "github.com/Symantec/Dominator/lib/filesystem" 7 | "github.com/Symantec/Dominator/lib/objectcache" 8 | ) 9 | 10 | func compareFileSystems(left, right *FileSystem, logWriter io.Writer) bool { 11 | if !filesystem.CompareFileSystems(&left.FileSystem.FileSystem, 12 | &right.FileSystem.FileSystem, logWriter) { 13 | return false 14 | } 15 | return objectcache.CompareObjects(left.ObjectCache, right.ObjectCache, 16 | logWriter) 17 | } 18 | -------------------------------------------------------------------------------- /sub/scanner/limits.go: -------------------------------------------------------------------------------- 1 | package scanner 2 | 3 | import ( 4 | "github.com/Symantec/Dominator/lib/log" 5 | ) 6 | 7 | func (configuration *Configuration) boostCpuLimit(logger log.Logger) { 8 | if configuration.CpuLimiter != nil { 9 | cl := configuration.CpuLimiter 10 | if cl.CpuPercent() != 100 { 11 | logger.Println("Boosting CPU limit: 100%") 12 | } 13 | cl.SetCpuPercent(100) 14 | } 15 | } 16 | 17 | func (configuration *Configuration) restoreCpuLimit(logger log.Logger) { 18 | if configuration.CpuLimiter != nil && configuration.DefaultCpuPercent > 0 { 19 | cl := configuration.CpuLimiter 20 | if cl.CpuPercent() != configuration.DefaultCpuPercent { 21 | logger.Printf("Restoring CPU limit: %d%%\n", 22 | configuration.DefaultCpuPercent) 23 | } 24 | cl.SetCpuPercent(configuration.DefaultCpuPercent) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /user-guide/README.md: -------------------------------------------------------------------------------- 1 | # Dominator User Guide 2 | A collection of great recipies to help you set up and use the **Dominator**. 3 | 4 | - [getting started](getting-started.md) 5 | - [making images](making-images.md) 6 | - [manifest-driven image building](image-manifest.md) 7 | --------------------------------------------------------------------------------