nova-compute revision 6852
285bfe946c2d54928b272270dd5eef9041b24271Timo Sirainen# Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
285bfe946c2d54928b272270dd5eef9041b24271Timo Sirainen# Licensed under the Apache License, Version 2.0 (the "License"); you may
285bfe946c2d54928b272270dd5eef9041b24271Timo Sirainen# not use this file except in compliance with the License. You may obtain
285bfe946c2d54928b272270dd5eef9041b24271Timo Sirainen# a copy of the License at
285bfe946c2d54928b272270dd5eef9041b24271Timo Sirainen# Unless required by applicable law or agreed to in writing, software
285bfe946c2d54928b272270dd5eef9041b24271Timo Sirainen# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
803d5e00922fd90af4bb5d529eed7af37ea8174aTimo Sirainen# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
c281d6630970d51a0e017366be9d86a061303d4bAki Tuomi# License for the specific language governing permissions and limitations
c281d6630970d51a0e017366be9d86a061303d4bAki Tuomi# under the License.
864e580b625a632c0e5a7b0591ffd0e707f276f4Timo Sirainenfrom subprocess import CalledProcessError, Popen, PIPE, check_call
864e580b625a632c0e5a7b0591ffd0e707f276f4Timo Sirainen # get the root pool name
864e580b625a632c0e5a7b0591ffd0e707f276f4Timo Sirainen cmd = ['/usr/sbin/zfs', 'list', '-Ho', 'name', '/']
c281d6630970d51a0e017366be9d86a061303d4bAki Tuomi print "unable to determine root pool name: %s" % (error)
864e580b625a632c0e5a7b0591ffd0e707f276f4Timo Sirainen # the default directory doesn't exist, create a new dataset for it
864e580b625a632c0e5a7b0591ffd0e707f276f4Timo Sirainen check_call(['/usr/bin/pfexec', '/usr/sbin/zfs', 'create', '-p',
c281d6630970d51a0e017366be9d86a061303d4bAki Tuomi # retrieve dataset path for suspend images
285bfe946c2d54928b272270dd5eef9041b24271Timo Sirainen # retrieve the suspend path or just get the default
285bfe946c2d54928b272270dd5eef9041b24271Timo Sirainen suspend_default_path = '/var/share/zones/SYSsuspend'
864e580b625a632c0e5a7b0591ffd0e707f276f4Timo Sirainen suspend_path = parser.get('solariszones', 'zones_suspend_path')
20b857d3114dd228a7066193c88c45519c252343Timo Sirainen ret = _create_dataset(suspend_path, 'VARSHARE/zones/SYSsuspend')
285bfe946c2d54928b272270dd5eef9041b24271Timo Sirainen # the user specified a path, but it doesn't exist
285bfe946c2d54928b272270dd5eef9041b24271Timo Sirainen print "Zones suspend path %s does not exist" % (suspend_path)
285bfe946c2d54928b272270dd5eef9041b24271Timo Sirainen # retrieve the image cache path or just get the default
285bfe946c2d54928b272270dd5eef9041b24271Timo Sirainen imagecache_default_path = '/var/share/nova/images'
285bfe946c2d54928b272270dd5eef9041b24271Timo Sirainen imagecache_path = parser.get('solariszones', 'glancecache_dirname')
285bfe946c2d54928b272270dd5eef9041b24271Timo Sirainen if imagecache_path == imagecache_default_path:
285bfe946c2d54928b272270dd5eef9041b24271Timo Sirainen ret = _create_dataset(imagecache_path, 'VARSHARE/nova/images')
285bfe946c2d54928b272270dd5eef9041b24271Timo Sirainen check_call(['/usr/bin/pfexec', '/usr/bin/chown', 'nova:nova',