Skip to content
Permalink
Browse files

Add ability to mark volume as protected

  • Loading branch information
subuk committed Nov 23, 2019
1 parent a9e8ec4 commit 34a70c847a58e11b7ea5891aada03e3c6b4b8105
Showing with 13 additions and 3 deletions.
  1. +1 −0 bootstrap/bootstrap.go
  2. +1 −0 compute/volume.go
  3. +1 −0 config/config.go
  4. +3 −0 libvirt/volume_repository.go
  5. +5 −3 templates/volume/list.html
  6. +2 −0 vmango.dist.conf
@@ -29,6 +29,7 @@ func Web(configFilename string) {
OsName: image.OsName,
OsVersion: image.OsVersion,
OsArch: libcompute.NewArch(image.OsArch),
Protected: image.Protected,
}
}

@@ -8,6 +8,7 @@ type VolumeMetadata struct {
OsName string
OsVersion string
OsArch Arch
Protected bool
}

type Volume struct {
@@ -33,6 +33,7 @@ type ImageConfig struct {
OsName string `hcl:"os_name"`
OsVersion string `hcl:"os_version"`
OsArch string `hcl:"os_arch"`
Protected bool `hcl:"protected"`
}

type SubscribeConfig struct {
@@ -337,6 +337,9 @@ func (repo *VolumeRepository) Delete(path string) error {
if err != nil {
return util.NewError(err, "cannot lookup storage volume")
}
if md, ok := repo.metadata[path]; ok && md.Protected {
return fmt.Errorf("volume is protected")
}
if err := virVolume.Delete(libvirt.STORAGE_VOL_DELETE_NORMAL); err != nil {
return util.NewError(err, "cannot delete volume")
}
@@ -74,9 +74,11 @@ <h4 class="card-title">Volumes</h4>
{{ end }}
</td>
<td>
<a title="Clone" href="{{ Url "volume-clone-form" "path" .Path }}">C</a> |
<a title="Resize" href="{{ Url "volume-resize-form" "path" .Path }}">R</a> |
<a title="Delete" style="color: red;" href="{{ Url "volume-delete-form" "path" .Path }}">D</a>
<a title="Clone" href="{{ Url "volume-clone-form" "path" .Path }}">C</a>
| <a title="Resize" href="{{ Url "volume-resize-form" "path" .Path }}">R</a>
{{ if not .Metadata.Protected }}
| <a title="Delete" style="color: red;" href="{{ Url "volume-delete-form" "path" .Path }}">D</a>
{{ end }}
</td>
</tr>
{{ end }}
@@ -24,12 +24,14 @@ image "/var/lib/libvirt/images/CentOS-7-x86_64-GenericCloud-1901.qcow2" {
os_name = "Centos"
os_version = "7"
os_arch = "x86_64"
protected = true
}

image "/var/lib/libvirt/images/ubuntu-18.04-minimal-cloudimg-amd64.img" {
os_name = "Ubuntu"
os_version = "18.04"
os_arch = "x86_64"
protected = true
}

# Run script when new vm created

0 comments on commit 34a70c8

Please sign in to comment.
You can’t perform that action at this time.