def test_do_volume_target_delete_multi_error(self):
     client_mock = mock.MagicMock()
     args = mock.MagicMock()
     args.volume_target = ['uuid1', 'uuid2']
     client_mock.volume_target.delete.side_effect = [
         exceptions.ClientException('error'), None
     ]
     self.assertRaises(exceptions.ClientException,
                       vt_shell.do_volume_target_delete, client_mock, args)
     self.assertEqual(
         [mock.call('uuid1'), mock.call('uuid2')],
         client_mock.volume_target.delete.call_args_list)
예제 #2
0
def do_portgroup_delete(cc, args):
    """Delete a portgroup."""
    failures = []
    for p in args.portgroup:
        try:
            cc.portgroup.delete(p)
            print('Deleted portgroup %s' % p)
        except exceptions.ClientException as e:
            failures.append(
                _("Failed to delete portgroup %(pg)s: %(error)s") % {
                    'pg': p,
                    'error': e
                })
    if failures:
        raise exceptions.ClientException("\n".join(failures))
예제 #3
0
def do_node_delete(cc, args):
    """Unregister node(s) from the Ironic service.

    Returns errors for any nodes that could not be unregistered.
    """

    failures = []
    for n in args.node:
        try:
            cc.node.delete(n)
            print(_('Deleted node %s') % n)
        except exceptions.ClientException as e:
            failures.append(_("Failed to delete node %(node)s: %(error)s")
                            % {'node': n, 'error': e})
    if failures:
        raise exceptions.ClientException("\n".join(failures))
def do_volume_target_delete(cc, args):
    """Delete a volume target."""
    failures = []
    for vt in args.volume_target:
        try:
            cc.volume_target.delete(vt)
            print(_('Deleted volume target %s') % vt)
        except exceptions.ClientException as e:
            failures.append(
                _("Failed to delete volume target %(vt)s: "
                  "%(error)s") % {
                      'vt': vt,
                      'error': e
                  })
    if failures:
        raise exceptions.ClientException("\n".join(failures))
def do_volume_connector_delete(cc, args):
    """Delete a volume connector."""
    failures = []
    for vc in args.volume_connector:
        try:
            cc.volume_connector.delete(vc)
            print(_('Deleted volume connector %s') % vc)
        except exceptions.ClientException as e:
            failures.append(
                _("Failed to delete volume connector %(vc)s: "
                  "%(error)s") % {
                      'vc': vc,
                      'error': e
                  })
    if failures:
        raise exceptions.ClientException("\n".join(failures))
예제 #6
0
def do_node_delete(cc, args):
    """Unregister node(s) from the Ironic service.

    :raises: ClientException, if error happens during the delete
    """

    failures = []
    for n in args.node:
        try:
            cc.node.delete(n)
            print(_('Deleted node %s') % n)
        except exceptions.ClientException as e:
            failures.append(_("Failed to delete node %(node)s: %(error)s")
                            % {'node': n, 'error': e})
    if failures:
        raise exceptions.ClientException("\n".join(failures))