1"""Reflash firmware."""
2# :license: MIT, see LICENSE for more details.
3
4import click
5
6import SoftLayer
7from SoftLayer.CLI import environment
8from SoftLayer.CLI import exceptions
9from SoftLayer.CLI import formatting
10from SoftLayer.CLI import helpers
11
12
13@click.command()
14@click.argument('identifier')
15@environment.pass_env
16def cli(env, identifier):
17    """Reflash server firmware."""
18
19    mgr = SoftLayer.HardwareManager(env.client)
20    hw_id = helpers.resolve_id(mgr.resolve_ids, identifier, 'hardware')
21    if not (env.skip_confirmations or
22            formatting.confirm('This will power off the server with id %s and '
23                               'reflash device firmware. Continue?' % hw_id)):
24        raise exceptions.CLIAbort('Aborted.')
25
26    mgr.reflash_firmware(hw_id)
27