本文整理汇总了Golang中github.com/rancher/convoy/util.ObjectLoad函数的典型用法代码示例。如果您正苦于以下问题:Golang ObjectLoad函数的具体用法?Golang ObjectLoad怎么用?Golang ObjectLoad使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ObjectLoad函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: GetVolumeInfo
func (d *Driver) GetVolumeInfo(id string) (map[string]string, error) {
d.mutex.Lock()
defer d.mutex.Unlock()
volume := d.blankVolume(id)
if err := util.ObjectLoad(volume); err != nil {
return nil, err
}
ebsVolume, err := d.ebsService.GetVolume(volume.EBSID)
if err != nil {
return nil, err
}
iops := ""
if ebsVolume.Iops != nil {
iops = strconv.FormatInt(*ebsVolume.Iops, 10)
}
info := map[string]string{
"Device": volume.Device,
"MountPoint": volume.MountPoint,
"UUID": volume.UUID,
"EBSVolumeID": volume.EBSID,
"AvailiablityZone": *ebsVolume.AvailabilityZone,
"CreatedTime": (*ebsVolume.CreateTime).Format(time.RubyDate),
"Size": strconv.FormatInt(*ebsVolume.Size*GB, 10),
"State": *ebsVolume.State,
"Type": *ebsVolume.VolumeType,
"IOPS": iops,
}
return info, nil
}
开发者ID:PaulCharlton,项目名称:convoy,代码行数:32,代码来源:ebs.go
示例2: GetVolumeInfo
func (d *Driver) GetVolumeInfo(id string) (map[string]string, error) {
d.mutex.RLock()
defer d.mutex.RUnlock()
volume := d.blankVolume(id)
if err := util.ObjectLoad(volume); err != nil {
return nil, err
}
gVolume := d.gVolumes[volume.VolumePool]
if gVolume == nil {
return nil, fmt.Errorf("Cannot find volume pool %v", volume.VolumePool)
}
size := "-1"
prepareForVM := strconv.FormatBool(volume.PrepareForVM)
if volume.PrepareForVM {
size = strconv.FormatInt(volume.Size, 10)
}
return map[string]string{
OPT_VOLUME_NAME: volume.Name,
"Path": volume.Path,
OPT_MOUNT_POINT: volume.MountPoint,
OPT_SIZE: size,
OPT_PREPARE_FOR_VM: prepareForVM,
OPT_VOLUME_CREATED_TIME: volume.CreatedTime,
"GlusterFSVolume": volume.VolumePool,
"GlusterFSServers": fmt.Sprintf("%v", gVolume.Servers),
}, nil
}
开发者ID:alwang1234,项目名称:convoy,代码行数:31,代码来源:glusterfs.go
示例3: CreateSnapshot
func (d *Driver) CreateSnapshot(req Request) error {
d.mutex.Lock()
defer d.mutex.Unlock()
id := req.Name
volumeID, err := util.GetFieldFromOpts(OPT_VOLUME_NAME, req.Options)
if err != nil {
return err
}
volume := d.blankVolume(volumeID)
if err := util.ObjectLoad(volume); err != nil {
return err
}
if _, exists := volume.Snapshots[id]; exists {
return fmt.Errorf("Snapshot %v already exists for volume %v", id, volumeID)
}
snapFile := d.getSnapshotFilePath(id, volumeID)
if err := util.MkdirIfNotExists(filepath.Dir(snapFile)); err != nil {
return err
}
if err := util.CompressDir(volume.Path, snapFile); err != nil {
return err
}
volume.Snapshots[id] = Snapshot{
Name: id,
CreatedTime: util.Now(),
VolumeUUID: volumeID,
FilePath: snapFile,
}
return util.ObjectSave(volume)
}
开发者ID:alwang1234,项目名称:convoy,代码行数:32,代码来源:vfs_storage.go
示例4: CreateSnapshot
func (d *Driver) CreateSnapshot(id, volumeID string) error {
d.mutex.Lock()
defer d.mutex.Unlock()
volume := d.blankVolume(volumeID)
if err := util.ObjectLoad(volume); err != nil {
return err
}
if _, exists := volume.Snapshots[id]; exists {
return fmt.Errorf("Snapshot %v already exists for volume %v", id, volumeID)
}
snapFile := d.getSnapshotFilePath(id, volumeID)
if err := util.MkdirIfNotExists(filepath.Dir(snapFile)); err != nil {
return err
}
if err := util.CompressDir(volume.Path, snapFile); err != nil {
return err
}
volume.Snapshots[id] = Snapshot{
UUID: id,
VolumeUUID: volumeID,
FilePath: snapFile,
}
return util.ObjectSave(volume)
}
开发者ID:PaulCharlton,项目名称:convoy,代码行数:25,代码来源:vfs_storage.go
示例5: ListSnapshot
func (d *Driver) ListSnapshot(opts map[string]string) (map[string]map[string]string, error) {
var (
volumeIDs []string
err error
)
d.mutex.RLock()
defer d.mutex.RUnlock()
snapshots := make(map[string]map[string]string)
specifiedVolumeID, _ := util.GetFieldFromOpts(OPT_VOLUME_NAME, opts)
if specifiedVolumeID != "" {
volumeIDs = []string{
specifiedVolumeID,
}
} else {
volumeIDs, err = d.listVolumeNames()
if err != nil {
return nil, err
}
}
for _, volumeID := range volumeIDs {
volume := d.blankVolume(volumeID)
if err := util.ObjectLoad(volume); err != nil {
return nil, err
}
for snapshotID := range volume.Snapshots {
snapshots[snapshotID], err = d.getSnapshotInfo(snapshotID, volumeID)
if err != nil {
return nil, err
}
}
}
return snapshots, nil
}
开发者ID:alwang1234,项目名称:convoy,代码行数:34,代码来源:devmapper.go
示例6: MountVolume
func (d *Driver) MountVolume(id string, opts map[string]string) (string, error) {
volume := d.blankVolume(id)
if err := util.ObjectLoad(volume); err != nil {
return "", err
}
dev, err := d.GetVolumeDevice(id)
if err != nil {
return "", err
}
specifiedPoint := opts[convoydriver.OPT_MOUNT_POINT]
mountPoint, err := d.getVolumeMountPoint(id, specifiedPoint)
if err != nil {
return "", err
}
if volume.MountPoint != "" && volume.MountPoint != mountPoint {
return "", fmt.Errorf("volume %v already mounted at %v, but asked to mount at %v", id, volume.MountPoint, mountPoint)
}
if !mounted(dev, mountPoint) {
log.Debugf("Volume %v is not mounted, mount it now to %v", id, mountPoint)
_, err = util.Execute(MOUNT_BINARY, []string{dev, mountPoint})
if err != nil {
return "", err
}
}
volume.MountPoint = mountPoint
if err := util.ObjectSave(volume); err != nil {
return "", err
}
return mountPoint, nil
}
开发者ID:ppawiggers,项目名称:convoy,代码行数:31,代码来源:devmapper.go
示例7: deactivatePool
func (d *Driver) deactivatePool() error {
dev := d.Device
volumeIDs, err := dev.listVolumeIDs()
if err != nil {
return err
}
for _, id := range volumeIDs {
volume := d.blankVolume(id)
if err := util.ObjectLoad(volume); err != nil {
return err
}
if err := d.removeDevice(id); err != nil {
return err
}
log.WithFields(logrus.Fields{
LOG_FIELD_EVENT: LOG_EVENT_ACTIVATE,
LOG_FIELD_VOLUME: id,
}).Debug("Deactivated volume device")
}
if err := removePool(dev.ThinpoolDevice); err != nil {
return err
}
log.Debug("Deactivate the pool ", dev.ThinpoolDevice)
return nil
}
开发者ID:ppawiggers,项目名称:convoy,代码行数:27,代码来源:devmapper.go
示例8: MountPoint
func (d *Driver) MountPoint(id string) (string, error) {
volume := d.blankVolume(id)
if err := util.ObjectLoad(volume); err != nil {
return "", err
}
return volume.MountPoint, nil
}
开发者ID:ppawiggers,项目名称:convoy,代码行数:7,代码来源:devmapper.go
示例9: MountVolume
func (d *Driver) MountVolume(id string, opts map[string]string) (string, error) {
volume := d.blankVolume(id)
if err := util.ObjectLoad(volume); err != nil {
return "", err
}
if err := volume.Stack(d).MoveController(); err != nil {
log.Errorf("Failed to move controller to %s", d.containerName)
return "", err
}
mountPoint, err := util.VolumeMount(volume, opts[convoydriver.OPT_MOUNT_POINT], false)
if err != nil {
return "", err
}
if volume.PrepareForVM {
if err := util.MountPointPrepareImageFile(mountPoint, volume.Size); err != nil {
return "", err
}
}
if err := util.ObjectSave(volume); err != nil {
return "", err
}
return mountPoint, nil
}
开发者ID:srenkens,项目名称:convoy,代码行数:28,代码来源:longhorn.go
示例10: ListSnapshot
func (d *Driver) ListSnapshot(opts map[string]string) (map[string]map[string]string, error) {
var (
volumeIDs []string
err error
)
snapshots := make(map[string]map[string]string)
specifiedVolumeID := opts["VolumeID"]
if specifiedVolumeID != "" {
volumeIDs = []string{
specifiedVolumeID,
}
} else {
volumeIDs, err = d.listVolumeIDs()
if err != nil {
return nil, err
}
}
for _, volumeID := range volumeIDs {
volume := d.blankVolume(volumeID)
if err := util.ObjectLoad(volume); err != nil {
return nil, err
}
for snapshotID := range volume.Snapshots {
snapshots[snapshotID], err = d.GetSnapshotInfo(snapshotID, volumeID)
if err != nil {
return nil, err
}
}
}
return snapshots, nil
}
开发者ID:ppawiggers,项目名称:convoy,代码行数:31,代码来源:devmapper.go
示例11: DeleteVolume
func (d *Driver) DeleteVolume(req Request) error {
d.mutex.Lock()
defer d.mutex.Unlock()
id := req.Name
opts := req.Options
volume := d.blankVolume(id)
if err := util.ObjectLoad(volume); err != nil {
return err
}
if volume.MountPoint != "" {
return fmt.Errorf("Cannot delete volume %v. It is still mounted", id)
}
referenceOnly, _ := strconv.ParseBool(opts[OPT_REFERENCE_ONLY])
if !referenceOnly {
log.Debugf("Cleaning up volume %v", id)
gVolume := d.gVolumes[d.DefaultVolumePool]
if err := util.VolumeMountPointDirectoryRemove(gVolume, volume.Name); err != nil {
return err
}
}
return util.ObjectDelete(volume)
}
开发者ID:alwang1234,项目名称:convoy,代码行数:25,代码来源:glusterfs.go
示例12: MountVolume
func (d *Driver) MountVolume(req Request) (string, error) {
d.mutex.Lock()
defer d.mutex.Unlock()
id := req.Name
opts := req.Options
volume := d.blankVolume(id)
if err := util.ObjectLoad(volume); err != nil {
return "", err
}
specifiedPoint := opts[OPT_MOUNT_POINT]
if specifiedPoint != "" {
return "", fmt.Errorf("GlusterFS doesn't support specified mount point")
}
if volume.MountPoint == "" {
volume.MountPoint = volume.Path
}
if volume.PrepareForVM {
if err := util.MountPointPrepareImageFile(volume.MountPoint, volume.Size); err != nil {
return "", err
}
}
if err := util.ObjectSave(volume); err != nil {
return "", err
}
return volume.MountPoint, nil
}
开发者ID:alwang1234,项目名称:convoy,代码行数:29,代码来源:glusterfs.go
示例13: DeleteVolume
func (d *Driver) DeleteVolume(id string, opts map[string]string) error {
d.mutex.Lock()
defer d.mutex.Unlock()
volume := d.blankVolume(id)
if err := util.ObjectLoad(volume); err != nil {
return err
}
referenceOnly, _ := strconv.ParseBool(opts[convoydriver.OPT_REFERENCE_ONLY])
if err := d.ebsService.DetachVolume(volume.EBSID); err != nil {
if !referenceOnly {
return err
}
//Ignore the error, remove the reference
log.Warnf("Unable to detached %v(%v) due to %v, but continue with removing the reference",
id, volume.EBSID, err)
} else {
log.Debugf("Detached %v(%v) from %v", id, volume.EBSID, volume.Device)
}
if !referenceOnly {
if err := d.ebsService.DeleteVolume(volume.EBSID); err != nil {
return err
}
log.Debugf("Deleted %v(%v)", id, volume.EBSID)
}
return util.ObjectDelete(volume)
}
开发者ID:PaulCharlton,项目名称:convoy,代码行数:29,代码来源:ebs.go
示例14: MountVolume
func (d *Driver) MountVolume(id string, opts map[string]string) (string, error) {
d.mutex.Lock()
defer d.mutex.Unlock()
volume := d.blankVolume(id)
if err := util.ObjectLoad(volume); err != nil {
return "", err
}
specifiedPoint := opts[convoydriver.OPT_MOUNT_POINT]
if specifiedPoint != "" {
return "", fmt.Errorf("VFS doesn't support specified mount point")
}
if volume.MountPoint == "" {
volume.MountPoint = volume.Path
}
if volume.PrepareForVM {
if err := util.MountPointPrepareImageFile(volume.MountPoint, volume.Size); err != nil {
return "", err
}
}
if err := util.ObjectSave(volume); err != nil {
return "", err
}
return volume.MountPoint, nil
}
开发者ID:PaulCharlton,项目名称:convoy,代码行数:26,代码来源:vfs_storage.go
示例15: GetVolumeDevice
func (d *Driver) GetVolumeDevice(id string) (string, error) {
volume := d.blankVolume(id)
if err := util.ObjectLoad(volume); err != nil {
return "", err
}
return filepath.Join(DM_DIR, id), nil
}
开发者ID:versus,项目名称:convoy,代码行数:8,代码来源:backup.go
示例16: GetVolumeDevice
func (d *Driver) GetVolumeDevice(id string) (string, error) {
volume := d.blankVolume(id)
if err := util.ObjectLoad(volume); err != nil {
return "", err
}
return volume.GetDevice()
}
开发者ID:PaulCharlton,项目名称:convoy,代码行数:8,代码来源:devmapper.go
示例17: Init
func Init(root string, config map[string]string) (convoydriver.ConvoyDriver, error) {
dev := &Device{
Root: root,
}
exists, err := util.ObjectExists(dev)
if err != nil {
return nil, err
}
if exists {
if err := util.ObjectLoad(dev); err != nil {
return nil, err
}
} else {
if err := util.MkdirIfNotExists(root); err != nil {
return nil, err
}
path := config[VFS_PATH]
if path == "" {
return nil, fmt.Errorf("VFS driver base path unspecified")
}
if err := util.MkdirIfNotExists(path); err != nil {
return nil, err
}
dev = &Device{
Root: root,
Path: path,
}
if _, exists := config[VFS_DEFAULT_VOLUME_SIZE]; !exists {
config[VFS_DEFAULT_VOLUME_SIZE] = DEFAULT_VOLUME_SIZE
}
volumeSize, err := util.ParseSize(config[VFS_DEFAULT_VOLUME_SIZE])
if err != nil || volumeSize == 0 {
return nil, fmt.Errorf("Illegal default volume size specified")
}
dev.DefaultVolumeSize = volumeSize
}
// For upgrade case
if dev.DefaultVolumeSize == 0 {
dev.DefaultVolumeSize, err = util.ParseSize(DEFAULT_VOLUME_SIZE)
if err != nil || dev.DefaultVolumeSize == 0 {
return nil, fmt.Errorf("Illegal default volume size specified")
}
}
if err := util.ObjectSave(dev); err != nil {
return nil, err
}
d := &Driver{
mutex: &sync.RWMutex{},
Device: *dev,
}
return d, nil
}
开发者ID:PaulCharlton,项目名称:convoy,代码行数:58,代码来源:vfs_storage.go
示例18: MountPoint
func (d *Driver) MountPoint(req Request) (string, error) {
id := req.Name
volume := d.blankVolume(id)
if err := util.ObjectLoad(volume); err != nil {
return "", err
}
return volume.MountPoint, nil
}
开发者ID:alwang1234,项目名称:convoy,代码行数:9,代码来源:ebs.go
示例19: CreateSnapshot
func (d *Driver) CreateSnapshot(req Request) error {
var err error
d.mutex.Lock()
defer d.mutex.Unlock()
id := req.Name
volumeID, err := util.GetFieldFromOpts(OPT_VOLUME_NAME, req.Options)
if err != nil {
return err
}
volume := d.blankVolume(volumeID)
if err := util.ObjectLoad(volume); err != nil {
return err
}
devID, err := d.allocateDevID()
if err != nil {
return err
}
snapshot, exists := volume.Snapshots[id]
if exists {
return generateError(logrus.Fields{
LOG_FIELD_VOLUME: volumeID,
LOG_FIELD_SNAPSHOT: id,
}, "Already has snapshot with name")
}
log.WithFields(logrus.Fields{
LOG_FIELD_REASON: LOG_REASON_START,
LOG_FIELD_EVENT: LOG_EVENT_CREATE,
LOG_FIELD_OBJECT: LOG_OBJECT_SNAPSHOT,
LOG_FIELD_SNAPSHOT: id,
LOG_FIELD_VOLUME: volumeID,
DM_LOG_FIELD_VOLUME_DEVID: volume.DevID,
DM_LOG_FIELD_SNAPSHOT_DEVID: devID,
}).Debugf("Creating snapshot")
err = devicemapper.CreateSnapDevice(d.ThinpoolDevice, devID, volumeID, volume.DevID)
if err != nil {
return err
}
log.Debugf("Created snapshot device")
snapshot = Snapshot{
Name: id,
CreatedTime: util.Now(),
DevID: devID,
Activated: false,
}
volume.Snapshots[id] = snapshot
if err := util.ObjectSave(volume); err != nil {
return err
}
return nil
}
开发者ID:alwang1234,项目名称:convoy,代码行数:57,代码来源:devmapper.go
示例20: GetVolumeInfo
func (d *Driver) GetVolumeInfo(id string) (map[string]string, error) {
volume := d.blankVolume(id)
if err := util.ObjectLoad(volume); err != nil {
return nil, err
}
return map[string]string{
"Size": strconv.FormatInt(volume.Size, 10),
convoydriver.OPT_PREPARE_FOR_VM: strconv.FormatBool(volume.PrepareForVM),
}, nil
}
开发者ID:srenkens,项目名称:convoy,代码行数:10,代码来源:longhorn.go
注:本文中的github.com/rancher/convoy/util.ObjectLoad函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论