func deleteUnreferencedObjects(client *srpc.Client, percentage uint8, bytes uint64) error { request := imageserver.DeleteUnreferencedObjectsRequest{percentage, bytes} var reply imageserver.DeleteUnreferencedObjectsResponse return client.RequestReply("ImageServer.DeleteUnreferencedObjects", request, &reply) }
func fetch(srpcClient *srpc.Client, hashesFilename string) error { hashesFile, err := os.Open(hashesFilename) if err != nil { return err } defer hashesFile.Close() scanner := bufio.NewScanner(hashesFile) serverAddress := fmt.Sprintf("%s:%d", *objectServerHostname, *objectServerPortNum) hashes := make([]hash.Hash, 0) for scanner.Scan() { hashval, err := objectcache.FilenameToHash(scanner.Text()) if err != nil { return err } hashes = append(hashes, hashval) } if err := scanner.Err(); err != nil { return err } return srpcClient.RequestReply("Subd.Fetch", sub.FetchRequest{ ServerAddress: serverAddress, Wait: true, Hashes: hashes}, &sub.FetchResponse{}) }
func configureSubs(client *srpc.Client) error { var request dominator.ConfigureSubsRequest var reply dominator.ConfigureSubsResponse request.ScanSpeedPercent = *scanSpeedPercent request.NetworkSpeedPercent = *networkSpeedPercent request.ScanExclusionList = scanExcludeList return client.RequestReply("Dominator.ConfigureSubs", request, &reply) }
func disableUpdates(client *srpc.Client, reason string) error { if reason == "" { return errors.New("cannot disable updates: no reason given") } var request dominator.DisableUpdatesRequest var reply dominator.DisableUpdatesResponse request.Reason = reason return client.RequestReply("Dominator.DisableUpdates", request, &reply) }
func checkImage(client *srpc.Client, name string) (bool, error) { request := imageserver.CheckImageRequest{name} var reply imageserver.CheckImageResponse err := client.RequestReply("ImageServer.CheckImage", request, &reply) if err != nil { return false, err } return reply.ImageExists, nil }
func setDefaultImage(client *srpc.Client, imageName string) error { var request dominator.SetDefaultImageRequest var reply dominator.SetDefaultImageResponse request.ImageName = imageName if err := client.RequestReply("Dominator.SetDefaultImage", request, &reply); err != nil { return err } return nil }
func getSubsConfiguration(client *srpc.Client) error { var request dominator.GetSubsConfigurationRequest var reply dominator.GetSubsConfigurationResponse if err := client.RequestReply("Dominator.GetSubsConfiguration", request, &reply); err != nil { return err } fmt.Println(sub.Configuration(reply)) return nil }
func getDefaultImage(client *srpc.Client) error { var request dominator.GetDefaultImageRequest var reply dominator.GetDefaultImageResponse if err := client.RequestReply("Dominator.GetDefaultImage", request, &reply); err != nil { return err } if reply.ImageName != "" { fmt.Println(reply.ImageName) } return nil }
func setConfiguration(client *srpc.Client, config sub.Configuration) error { var request sub.SetConfigurationRequest request = sub.SetConfigurationRequest(config) var reply sub.SetConfigurationResponse return client.RequestReply("Subd.SetConfiguration", request, &reply) }
func fetch(client *srpc.Client, serverAddress string, hashes []hash.Hash) error { request := sub.FetchRequest{ServerAddress: serverAddress, Hashes: hashes} var reply sub.FetchResponse return client.RequestReply("Subd.Fetch", request, &reply) }
func addImage(client *srpc.Client, name string, img *image.Image) error { request := imageserver.AddImageRequest{name, img} var reply imageserver.AddImageResponse return client.RequestReply("ImageServer.AddImage", request, &reply) }
func callUpdate(client *srpc.Client, request sub.UpdateRequest, reply *sub.UpdateResponse) error { return client.RequestReply("Subd.Update", request, reply) }
func getConfiguration(client *srpc.Client) (sub.Configuration, error) { var request sub.GetConfigurationRequest var reply sub.GetConfigurationResponse err := client.RequestReply("Subd.GetConfiguration", request, &reply) return sub.Configuration(reply), err }
func deleteImage(client *srpc.Client, name string) error { request := imageserver.DeleteImageRequest{name} var reply imageserver.DeleteImageResponse return client.RequestReply("ImageServer.DeleteImage", request, &reply) }
func chownDirectory(client *srpc.Client, dirname, ownerGroup string) error { request := imageserver.ChangeOwnerRequest{DirectoryName: dirname, OwnerGroup: ownerGroup} var reply imageserver.ChangeOwnerResponse return client.RequestReply("ImageServer.ChownDirectory", request, &reply) }
func cleanup(client *srpc.Client, hashes []hash.Hash) error { request := sub.CleanupRequest{hashes} var reply sub.CleanupResponse return client.RequestReply("Subd.Cleanup", request, &reply) }
func clearSafetyShutoff(client *srpc.Client, subHostname string) error { var request dominator.ClearSafetyShutoffRequest var reply dominator.ClearSafetyShutoffResponse request.Hostname = subHostname return client.RequestReply("Dominator.ClearSafetyShutoff", request, &reply) }