583
586
content_type='text/plain')
585
588
@operation(idempotent=False)
589
def restore_networking_configuration(self, request, system_id):
590
"""Reset a machine's networking options to its initial state.
592
Returns 404 if the machine is not found.
593
Returns 403 if the user does not have permission to reset the machine.
595
machine = self.model.objects.get_node_or_404(
596
system_id=system_id, user=request.user,
597
perm=NODE_PERMISSION.ADMIN)
598
if machine.status != NODE_STATUS.READY:
599
raise NodeStateViolation(
600
"Machine must be in a ready state to restore networking "
602
machine.set_initial_networking_configuration()
603
return reload_object(machine)
605
@operation(idempotent=False)
606
def restore_storage_configuration(self, request, system_id):
607
"""Reset a machine's storage options to its initial state.
609
Returns 404 if the machine is not found.
610
Returns 403 if the user does not have permission to reset the machine.
612
machine = self.model.objects.get_node_or_404(
613
system_id=system_id, user=request.user,
614
perm=NODE_PERMISSION.ADMIN)
615
if machine.status != NODE_STATUS.READY:
616
raise NodeStateViolation(
617
"Machine must be in a ready state to restore storage "
619
machine.set_default_storage_layout()
620
return reload_object(machine)
622
@operation(idempotent=False)
623
def restore_default_configuration(self, request, system_id):
624
"""Reset a machine's configuration to its initial state.
626
Returns 404 if the machine is not found.
627
Returns 403 if the user does not have permission to reset the machine.
629
machine = self.model.objects.get_node_or_404(
630
system_id=system_id, user=request.user,
631
perm=NODE_PERMISSION.ADMIN)
632
if machine.status != NODE_STATUS.READY:
633
raise NodeStateViolation(
634
"Machine must be in a ready state to restore default "
635
"networking and storage configuration.")
636
machine.set_default_storage_layout()
637
machine.set_initial_networking_configuration()
638
return reload_object(machine)
640
@operation(idempotent=False)
586
641
def mark_broken(self, request, system_id):
587
642
"""Mark a node as 'broken'.