Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* VDO can be created and deleted from gdeploy
- Loading branch information
Showing
12 changed files
with
1,036 additions
and
16 deletions.
There are no files selected for viewing
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,14 @@ | ||
# gdeploy -c vdo-create.conf | ||
# Creates vdo with | ||
# disk => /dev/vdb and name => test_vol_1 and size => 50G | ||
# disk => /dev/vdd and name => test_vol_2 and size => 100G | ||
# If logicalsize is omitted, entire disk is used | ||
|
||
[hosts] | ||
10.70.42.220 | ||
|
||
[vdo] | ||
action=create | ||
devices=/dev/vdb,/dev/vdd | ||
names=test_vol_1,test_vol_2 | ||
logicalsize=50G,100G |
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,14 @@ | ||
# gdeploy -c vdo-create.conf | ||
# Creates vdo with | ||
# disk => /dev/vdb and name => test_vol_1 | ||
# disk => /dev/vdd and name => test_vol_2 | ||
# vdo is created on entire disk | ||
|
||
[hosts] | ||
10.70.42.220 | ||
|
||
[vdo] | ||
action=create | ||
devices=/dev/vdb,/dev/vdd | ||
names=test_vol_1,test_vol_2 | ||
|
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,10 @@ | ||
# gdeploy -c vdo-delete.conf | ||
# Delete the vdos test_vol_1 and test_vol_2 | ||
|
||
[hosts] | ||
10.70.42.220 | ||
|
||
[vdo] | ||
action=delete | ||
names=test_vol_1,test_vol_2 | ||
|
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 |
---|---|---|
|
@@ -19,3 +19,4 @@ | |
import vg | ||
import lv | ||
import openshift_ctl | ||
import vdo |
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 @@ | ||
import vdo |
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,112 @@ | ||
{ | ||
"vdo": { | ||
"action": { | ||
"create": { | ||
"options": [ | ||
{ | ||
"required": "false", | ||
"name": "names" | ||
}, | ||
{ | ||
"required": "true", | ||
"name": "devices" | ||
}, | ||
{ | ||
"required": "false", | ||
"name": "activate", | ||
"default": "yes" | ||
}, | ||
{ | ||
"required": "false", | ||
"name": "run", | ||
"default": "yes" | ||
}, | ||
{ | ||
"required": "false", | ||
"name": "logicalsize" | ||
}, | ||
{ | ||
"required": "false", | ||
"name": "compression", | ||
"default": "enabled" | ||
}, | ||
{ | ||
"required": "no", | ||
"name": "blockmapcachesize" | ||
}, | ||
{ | ||
"required": "no", | ||
"name": "readcache", | ||
"default": "enabled" | ||
}, | ||
{ | ||
"name": "readcachesize", | ||
"required": "false" | ||
}, | ||
{ | ||
"name": "emulate512", | ||
"required": "false", | ||
"default": "disabled" | ||
}, | ||
{ | ||
"name": "slabsize", | ||
"required": "no" | ||
}, | ||
{ | ||
"name": "writepolicy", | ||
"required": "false" | ||
}, | ||
{ | ||
"name": "indexmem", | ||
"required": "false" | ||
}, | ||
{ | ||
"name": "indexmode", | ||
"required": "false" | ||
}, | ||
{ | ||
"required": "false", | ||
"name": "ackthreads" | ||
}, | ||
{ | ||
"required": "false", | ||
"name": "biothreads" | ||
}, | ||
{ | ||
"required": "false", | ||
"name": "cputhreads" | ||
}, | ||
{ | ||
"required": "false", | ||
"name": "logicalthreads" | ||
}, | ||
{ | ||
"required": "false", | ||
"name": "physicalthreads" | ||
}, | ||
{ | ||
"required": "false", | ||
"name": "mkfs", | ||
"default": "xfs" | ||
}, | ||
{ | ||
"name": "mkfs-opts", | ||
"required": "false" | ||
}, | ||
{ | ||
"required": "false", | ||
"name": "mount" | ||
} | ||
] | ||
}, | ||
"delete": { | ||
"options": [ | ||
{ | ||
"name": "names", | ||
"required": "true" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
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,62 @@ | ||
""" | ||
Add functions corresponding to each of the actions in the json file. | ||
The function should be named as follows <feature name>_<action_name> | ||
""" | ||
from gdeploylib import defaults, Helpers, Global | ||
helpers = Helpers() | ||
|
||
def vdo_create(section_dict): | ||
global helpers | ||
|
||
section_dict['state'] = 'present' | ||
disks = helpers.correct_brick_format( | ||
helpers.listify(section_dict['devices'])) | ||
vdonames = helpers.listify(section_dict.get('names')) | ||
lsize = helpers.listify(section_dict.get('logicalsize')) | ||
|
||
# Zero-fill the lszie so that logicalsize defaults to disk size if not | ||
# provided. | ||
for fi in range(len(vdonames) - len(lsize)): | ||
lsize.append('') | ||
|
||
vdolist = [] | ||
for d, n, lsize in zip(disks, vdonames, lsize): | ||
v = {} | ||
v['disk'] = d | ||
v['name'] = n | ||
v['logicalsize'] = lsize | ||
vdolist.append(v) | ||
section_dict['vdos'] = vdolist | ||
activate = section_dict.get('activate') | ||
|
||
if activate is None: | ||
data_not_found(activate) | ||
elif activate.lower() not in ['yes', 'no', 'true', 'false']: | ||
log_yes_no_error(activate) | ||
run = section_dict.get('run') | ||
if run is None: | ||
data_not_found(run) | ||
elif run.lower() not in ['yes', 'no', 'true', 'false']: | ||
log_yes_no_error(run) | ||
|
||
Global.logger.info("Creating vdo volume(s) %s" % vdonames) | ||
return section_dict, defaults.VDO_CREATE | ||
|
||
def vdo_delete(section_dict): | ||
section_dict['state'] = 'absent' | ||
section_dict['vdonames'] = helpers.listify(section_dict.get('names')) | ||
Global.logger.info("Deleteing vdo volume(s) %s"% section_dict['vdonames']) | ||
return section_dict, defaults.VDO_DELETE | ||
|
||
def data_not_found(item): | ||
global helpers | ||
msg = "Value for option %s not found." % item | ||
print "Error: %s" % msg | ||
Global.logger.error(msg) | ||
helpers.cleanup_and_quit() | ||
|
||
def log_yes_no_error(key): | ||
msg = "Error: invalid value for %s" % key | ||
print msg | ||
print "Possible values are 'yes', 'no', 'true', 'false'" | ||
Global.logger.error(msg) |
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
Oops, something went wrong.