items/zfs_pool: support raidz2 and raidz3
This commit is contained in:
parent
05e8d83ebf
commit
59c1cb8551
1 changed files with 10 additions and 4 deletions
|
@ -18,12 +18,12 @@ def create_mirrors(node, path, mirrors):
|
|||
node.run("zfs unmount {}".format(quote(path)))
|
||||
|
||||
|
||||
def create_raidz(node, path, devices):
|
||||
def create_raidz(node, path, devices, raid='raidz'):
|
||||
cmd = ""
|
||||
actual_targets = []
|
||||
for device in devices:
|
||||
actual_targets.append(quote(prepare_blockdevice(node, device)))
|
||||
cmd += "raidz {} ".format(" ".join(actual_targets))
|
||||
cmd += "{} {} ".format(raid, " ".join(actual_targets))
|
||||
|
||||
node.run("zpool create {} {}".format(quote(path), cmd))
|
||||
node.run("zfs unmount {}".format(quote(path)))
|
||||
|
@ -95,6 +95,8 @@ class ZFSPool(Item):
|
|||
'device': None,
|
||||
'mirrors': None,
|
||||
'raidz': None,
|
||||
'raidz2': None,
|
||||
'raidz3': None,
|
||||
}
|
||||
ITEM_TYPE_NAME = "zfs_pool"
|
||||
|
||||
|
@ -129,6 +131,10 @@ class ZFSPool(Item):
|
|||
create_mirrors(self.node, self.name, self.attributes['mirrors'])
|
||||
elif self.attributes['raidz'] is not None:
|
||||
create_raidz(self.node, self.name, self.attributes['raidz'])
|
||||
elif self.attributes['raidz2'] is not None:
|
||||
create_raidz(self.node, self.name, self.attributes['raidz'], 'raidz2')
|
||||
elif self.attributes['raidz2'] is not None:
|
||||
create_raidz(self.node, self.name, self.attributes['raidz'], 'raidz3')
|
||||
|
||||
def sdict(self):
|
||||
# We don't care about the device if the pool already exists.
|
||||
|
@ -168,13 +174,13 @@ class ZFSPool(Item):
|
|||
@classmethod
|
||||
def validate_attributes(cls, bundle, item_id, attributes):
|
||||
device_config = []
|
||||
for key in ('device', 'mirrors', 'raidz'):
|
||||
for key in ('device', 'mirrors', 'raidz', 'raidz2', 'raidz3'):
|
||||
device_config.append(attributes.get(key))
|
||||
device_config = [key for key in device_config if key is not None]
|
||||
if len(device_config) != 1:
|
||||
raise BundleError(_(
|
||||
"{item} on node {node} must have exactly one of "
|
||||
"'device', 'mirrors', or 'raidz'"
|
||||
"'device', 'mirrors', 'raidz', 'raidz2' or 'raidz3'"
|
||||
).format(
|
||||
item=item_id,
|
||||
node=bundle.node.name,
|
||||
|
|
Loading…
Reference in a new issue