cinder-volume-setup revision 4935
8574d86b9ec3be36b7f54ed0547a0ee5d60dbd6bnd# Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
8574d86b9ec3be36b7f54ed0547a0ee5d60dbd6bnd# Licensed under the Apache License, Version 2.0 (the "License"); you may
8574d86b9ec3be36b7f54ed0547a0ee5d60dbd6bnd# not use this file except in compliance with the License. You may obtain
8574d86b9ec3be36b7f54ed0547a0ee5d60dbd6bnd# a copy of the License at
8574d86b9ec3be36b7f54ed0547a0ee5d60dbd6bnd# Unless required by applicable law or agreed to in writing, software
8574d86b9ec3be36b7f54ed0547a0ee5d60dbd6bnd# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
8574d86b9ec3be36b7f54ed0547a0ee5d60dbd6bnd# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
8574d86b9ec3be36b7f54ed0547a0ee5d60dbd6bnd# License for the specific language governing permissions and limitations
8574d86b9ec3be36b7f54ed0547a0ee5d60dbd6bnd# under the License.
8574d86b9ec3be36b7f54ed0547a0ee5d60dbd6bndfrom subprocess import CalledProcessError, Popen, PIPE, check_call
1ac39787115a288f5e848344b1b1e8dccb1c58f1nd """ retrieves the setting for 'zfs_volume_base' from Cinder's conf file in
1ac39787115a288f5e848344b1b1e8dccb1c58f1nd order to set it up properly for Cinder to use.
8574d86b9ec3be36b7f54ed0547a0ee5d60dbd6bnd # check if the SAN storage is used.
8574d86b9ec3be36b7f54ed0547a0ee5d60dbd6bnd # The script only handles the setup for local access as it needs to
8574d86b9ec3be36b7f54ed0547a0ee5d60dbd6bnd # run in the remote node in the SAN environment.
8574d86b9ec3be36b7f54ed0547a0ee5d60dbd6bnd # retrieve the top-level dataset or just get the default (rpool/cinder)
8574d86b9ec3be36b7f54ed0547a0ee5d60dbd6bnd # look to see if the dataset exists
8574d86b9ec3be36b7f54ed0547a0ee5d60dbd6bnd # the dataset doesn't exist, so go create it
1462ff536f1b939bb337766b2056109c29664c4erbowen check_call(["/usr/sbin/zfs", "create", "-p", top_ds])
8574d86b9ec3be36b7f54ed0547a0ee5d60dbd6bnd # get the mountpoint
8574d86b9ec3be36b7f54ed0547a0ee5d60dbd6bnd cmd = ["/usr/sbin/zfs", "get", "-H", "-o", "value", "mountpoint", top_ds]
8574d86b9ec3be36b7f54ed0547a0ee5d60dbd6bnd print "unable to determine mountpoint of %s: %s" % (top_ds, error)
8574d86b9ec3be36b7f54ed0547a0ee5d60dbd6bnd p = Popen(["/usr/bin/ls", "-dv", mountpoint], stdout=PIPE, stderr=PIPE)
8574d86b9ec3be36b7f54ed0547a0ee5d60dbd6bnd if "user:cinder:add_subdirectory/append_data:allow" not in output:
8574d86b9ec3be36b7f54ed0547a0ee5d60dbd6bnd # set an ACL to all mountpoint access
8574d86b9ec3be36b7f54ed0547a0ee5d60dbd6bnd print "ACL creation for mountpoint access of "
8574d86b9ec3be36b7f54ed0547a0ee5d60dbd6bnd # set delegation
8574d86b9ec3be36b7f54ed0547a0ee5d60dbd6bnd print "delegation of %s to 'cinder' failed: %s" % (top_ds, err)