| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- // Copyright 2019 Yunion
- //
- // Licensed under the Apache License, Version 2.0 (the "License");
- // you may not use this file except in compliance with the License.
- // You may obtain a copy of the License at
- //
- // http://www.apache.org/licenses/LICENSE-2.0
- //
- // Unless required by applicable law or agreed to in writing, software
- // distributed under the License is distributed on an "AS IS" BASIS,
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- // See the License for the specific language governing permissions and
- // limitations under the License.
- package options
- import (
- "strings"
- "yunion.io/x/log"
- common_options "yunion.io/x/onecloud/pkg/cloudcommon/options"
- "yunion.io/x/onecloud/pkg/cloudcommon/pending_delete"
- )
- type SImageOptions struct {
- common_options.HostCommonOptions `"s3_bucket_name->default":"onecloud-images" "s3_bucket_lifecycle_keep_day->default":"0"`
- common_options.DBOptions
- pending_delete.SPendingDeleteOptions
- DefaultImageQuota int `default:"10" help:"Common image quota per tenant, default 10"`
- PortV2 int `help:"Listening port for region V2"`
- FilesystemStoreDatadir string `help:"Directory that the Filesystem backend store writes image data to"`
- TorrentStoreDir string `help:"directory to store image torrent files"`
- EnableTorrentService bool `help:"Enable torrent service" default:"false"`
- TargetImageFormats []string `help:"target image formats that the system will automatically convert to" default:"qcow2"`
- TorrentClientPath string `help:"path to torrent executable" default:"/opt/yunion/bin/torrent"`
- DefaultImageServiceHomeDir string `help:"Default image service home dir" default:"/opt/cloud/workspace/data/glance"`
- // DeployServerSocketPath string `help:"Deploy server listen socket path" default:"/var/run/onecloud/deploy.sock"`
- StorageDriver string `help:"image backend storage" default:"local" choices:"s3|local"`
- S3MountPoint string `help:"s3fs mount point" default:"/opt/cloud/workspace/data/glance/s3images"`
- S3CheckImageStatus bool `help:"Enable s3 check image status"`
- S3SignVersion string `help:"signing version"`
- S3UploadPartSizeMb int64 `help:"s3 upload part size in MB, default to 50MB" default:"50"`
- S3UploadParallel int `help:"s3 upload parallel count" default:"4"`
- S3DirectDownload bool `help:"enable s3 direct download" default:"true"`
- ImageStreamWorkerCount int `help:"Image stream worker count" default:"10"`
- VerifyImageStatusIntervalMinutes int `help:"verify image status periodically, default 15 minutes" default:"15"`
- }
- var (
- Options SImageOptions
- )
- func OnOptionsChange(oldO, newO interface{}) bool {
- oldOpts := oldO.(*SImageOptions)
- newOpts := newO.(*SImageOptions)
- changed := false
- if common_options.OnCommonOptionsChange(&oldOpts.CommonOptions, &newOpts.CommonOptions) {
- changed = true
- }
- if common_options.OnDBOptionsChange(&oldOpts.DBOptions, &newOpts.DBOptions) {
- changed = true
- }
- if oldOpts.PendingDeleteCheckSeconds != newOpts.PendingDeleteCheckSeconds {
- if !oldOpts.IsSlaveNode {
- changed = true
- }
- }
- return changed
- }
- func (opt SImageOptions) HasValidS3Options() bool {
- msg := []string{}
- if len(opt.S3Endpoint) <= 0 {
- msg = append(msg, "s3_endpoint is required")
- }
- if len(opt.S3AccessKey) <= 0 {
- msg = append(msg, "s3_access_key is required")
- }
- if len(opt.S3SecretKey) <= 0 {
- msg = append(msg, "s3_secret_key is required")
- }
- if len(opt.S3BucketName) <= 0 {
- msg = append(msg, "s3_bucket_name is required")
- }
- if len(msg) > 0 {
- log.Errorf("invalid s3 options: %s", strings.Join(msg, ", "))
- return false
- }
- return true
- }
|