631
632
def start_commissioning(self, user):
632
633
"""Install OS and self-test a new node."""
633
634
# Avoid circular imports.
635
from metadataserver.commissioning.user_data import generate_user_data
634
636
from metadataserver.models import NodeCommissionResult
636
path = settings.COMMISSIONING_SCRIPT
637
if not os.path.exists(path):
638
raise ValidationError(
639
"Commissioning script is missing: %s" % path)
640
with open(path, 'r') as f:
641
commissioning_user_data = f.read()
638
commissioning_user_data = generate_user_data(nodegroup=self.nodegroup)
643
639
NodeCommissionResult.objects.clear_results(self)
644
640
self.status = NODE_STATUS.COMMISSIONING
645
641
self.owner = user
721
def get_effective_kernel_options(self):
722
"""Determine any special kernel parameters for this node.
724
:return: (tag, kernel_options)
725
tag is a Tag object or None. If None, the kernel_options came from
727
kernel_options, a string indicating extra kernel_options that
728
should be used when booting this node. May be None if no tags match
729
and no global setting has been configured.
731
# First, see if there are any tags associated with this node that has a
732
# custom kernel parameter
733
tags = self.tags.filter(kernel_opts__isnull=False)
734
tags = tags.order_by('name')[:1]
737
return tag, tag.kernel_opts
738
global_value = Config.objects.get_config('kernel_opts')
739
return None, global_value
726
742
def work_queue(self):
727
743
"""The name of the queue for tasks specific to this node."""
796
812
def set_hardware_details(self, xmlbytes):
797
813
"""Set the `lshw -xml` output"""
798
814
update_hardware_details(self, xmlbytes, Tag.objects)
816
def should_use_traditional_installer(self):
817
"""Should this node be installed with the traditional installer?
819
By default, nodes should be installed with the default installer, so
820
this returns `False`.
822
return self.tags.filter(name="use-traditional-installer").exists()
824
def should_use_default_installer(self):
825
"""Should this node be installed with the default installer?
827
By default, nodes should be installed with the default installer, the
828
Fast Path installer, so this returns `True`.
830
return not self.should_use_traditional_installer()
832
def use_traditional_installer(self):
833
"""Set this node to be installed with the traditional installer.
835
By default, nodes should be installed with the Fast Path installer.
837
:raises: :class:`RuntimeError` when the `use-traditional-installer`
838
tag is defined *with* an expression. The reason is that the tag
839
evaluation machinery will eventually ignore whatever changes you
840
make with this method.
842
uti_tag, _ = Tag.objects.get_or_create(
843
name="use-traditional-installer")
844
if uti_tag.definition != "":
846
"The use-traditional-installer tag is defined with an "
847
"expression. This expression much be updated to make this "
848
"node boot with the traditional installer.")
849
self.tags.add(uti_tag)
851
def use_default_installer(self):
852
"""Set this node to be installed with the default installer.
854
By default, nodes should be installed with the Fast Path installer.
856
:raises: :class:`RuntimeError` when the `use-traditional-installer`
857
tag is defined *with* an expression. The reason is that the tag
858
evaluation machinery will eventually ignore whatever changes you
859
make with this method.
861
uti_tag, _ = Tag.objects.get_or_create(
862
name="use-traditional-installer")
863
if uti_tag.definition != "":
865
"The use-traditional-installer tag is defined with an "
866
"expression. This expression much be updated to prevent "
867
"this node from booting with the traditional installer.")
868
self.tags.remove(uti_tag)