Created
August 30, 2017 16:59
-
-
Save j-griffith/304e29628638bf8ac851e7c0c620d5c7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/storage_drivers/solidfire_san.go b/storage_drivers/solidfire_san.go | |
index b8807fd..47a5d20 100644 | |
--- a/storage_drivers/solidfire_san.go | |
+++ b/storage_drivers/solidfire_san.go | |
@@ -557,3 +557,34 @@ func (d *SolidfireSANStorageDriver) GetVolume(name string) (sfapi.Volume, error) | |
} | |
return vols[0], nil | |
} | |
+ | |
+// UpdateAttachmentCounter is used for ref counting attachments to a volume. Valid options for action | |
+// are "increment", "decrement", "reset", all other arguments will simply return the current count | |
+func (d *SolidfireSANStorageDriver) UpdateAttachmentCounter(name , action string) int64 { | |
+ v, err := d.GetVolume(name) | |
+ attrs, _ := v.Attributes.(map[string]interface{}) | |
+ | |
+ // TODO(jdg): type-checking? | |
+ currentCount := attrs["attachmentCount"].(int64) | |
+ refresh = true | |
+ if action == "reset" { | |
+ currentCount = 0 | |
+ log.Debugf("reseting current attachment count to 0: %v", currentCount) | |
+ } else if action == "increment" { | |
+ currentCount += 1 | |
+ log.Debugf("incrementing current attachment count to: %v", currentCount) | |
+ } else if action == "decrement" { | |
+ currentCount -= 1 | |
+ log.Debugf("decrementing current attachment count to: %v", currentCount) | |
+ } else { | |
+ refresh = false | |
+ log.Debugf("returning unmodified attachment count: %v", currentCount) | |
+ } | |
+ | |
+ if refresh == true { | |
+ // refresh the attributes on the volume | |
+ | |
+ } | |
+ return currentCount | |
+ | |
+} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment