1
# Copyright (C) 2016 Canonical Ltd.
3
# Author: Wesley Wiedenmeier <wesley.wiedenmeier@canonical.com>
5
# Curtin is free software: you can redistribute it and/or modify it under
6
# the terms of the GNU Affero General Public License as published by the
7
# Free Software Foundation, either version 3 of the License, or (at your
8
# option) any later version.
10
# Curtin is distributed in the hope that it will be useful, but WITHOUT ANY
11
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
15
# You should have received a copy of the GNU Affero General Public License
16
# along with Curtin. If not, see <http://www.gnu.org/licenses/>.
18
from curtin import block
19
from . import populate_one_subcmd
22
def clear_holders_main(args):
24
wrapper for clear_holders accepting cli args
26
if (not all(block.is_block_device(device) for device in args.devices) or
27
len(args.devices) == 0):
28
raise ValueError('invalid devices specified')
29
block.clear_holders.start_clear_holders_deps()
30
block.clear_holders.clear_holders(args.devices, try_preserve=args.preserve)
32
print('ran clear_holders attempting to preserve data. however, '
33
'hotplug support for some devices may cause holders to restart ')
34
block.clear_holders.assert_clear(args.devices)
39
{'help': 'devices to free', 'default': [], 'nargs': '+'}),
40
(('-p', '--preserve'),
41
{'help': 'try to shut down holders without erasing anything',
42
'default': False, 'action': 'store_true'}),
47
def POPULATE_SUBCMD(parser):
48
populate_one_subcmd(parser, CMD_ARGUMENTS, clear_holders_main)