forked from gluster/glusterd2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gd2 plugin: added a plugin for block volume management
- added APIs for creation,deleting and listing block volumes. - added pluggable interface for block volume providers. Refer Design Doc: gluster#1319 Signed-off-by: Oshank Kumar <[email protected]>
- Loading branch information
Oshank Kumar
committed
Jan 3, 2019
1 parent
5dd1254
commit 40c83bf
Showing
17 changed files
with
1,361 additions
and
71 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package volume | ||
|
||
const ( | ||
// BlockHosted is plugin name for FilterBlockHostedVolumes | ||
BlockHosted = "block-hosted" | ||
) | ||
|
||
// Filter will receive a slice of *Volinfo and filters out the undesired one and return slice of desired one only | ||
type Filter func([]*Volinfo) []*Volinfo | ||
|
||
var filters = make(map[string]Filter) | ||
|
||
// InstallFilter will register a custom Filter | ||
func InstallFilter(name string, f Filter) { | ||
filters[name] = f | ||
} | ||
|
||
// ApplyFilters applies all registered filters passed in the args to a slice of *Volinfo | ||
func ApplyFilters(volumes []*Volinfo, names ...string) []*Volinfo { | ||
for _, name := range names { | ||
if filter, found := filters[name]; found { | ||
volumes = filter(volumes) | ||
} | ||
} | ||
return volumes | ||
} | ||
|
||
// ApplyCustomFilters applies all custom filter to a slice of *Volinfo | ||
func ApplyCustomFilters(volumes []*Volinfo, filters ...Filter) []*Volinfo { | ||
for _, filter := range filters { | ||
volumes = filter(volumes) | ||
} | ||
|
||
return volumes | ||
} | ||
|
||
// FilterBlockHostedVolumes filters out volume which are suitable for hosting block volume | ||
func FilterBlockHostedVolumes(volumes []*Volinfo) []*Volinfo { | ||
var volInfos []*Volinfo | ||
for _, volume := range volumes { | ||
val, found := volume.Metadata["block-hosting"] | ||
if found && val == "yes" { | ||
volInfos = append(volInfos, volume) | ||
} | ||
} | ||
return volInfos | ||
} | ||
|
||
func init() { | ||
InstallFilter(BlockHosted, FilterBlockHostedVolumes) | ||
} |
Oops, something went wrong.