Ejemplo n.º 1
0
Archivo: api.py Proyecto: zhangrb/maas
 def read(self, request, version, mac=None):
     check_version(version)
     node = get_queried_node(request, for_mac=mac)
     try:
         # When a node is deploying, cloud-init's request
         # for user-data is when MAAS hands the node
         # off to a user.
         if node.status == NODE_STATUS.DEPLOYING:
             if node.install_kvm:
                 # Rather than ending deployment here, note that we're
                 # installing a KVM pod.
                 node.agent_name = "maas-kvm-pod"
                 node.save()
             else:
                 # MAAS currently considers a machine "Deployed" when the
                 # cloud-init user data is requested. Note that this doesn't
                 # mean the machine is ready for use yet; cloud-init will
                 # also send a 'finish' event for the 'modules-final'
                 # activity name. However, that check is ambiguous because
                 # it occurs both when curtin is installing, and when
                 # the machine reboots to finish its deployment.
                 node.end_deployment()
         # If this node is supposed to be powered off, serve the
         # 'poweroff' userdata.
         if node.get_boot_purpose() == 'poweroff':
             user_data = generate_user_data_for_poweroff(node=node,
                                                         request=request)
         else:
             user_data = NodeUserData.objects.get_user_data(node)
         return HttpResponse(user_data,
                             content_type='application/octet-stream')
     except NodeUserData.DoesNotExist:
         logger.info("No user data registered for node named %s" %
                     node.hostname)
         return HttpResponse(status=int(http.client.NOT_FOUND))
Ejemplo n.º 2
0
 def read(self, request, version, mac=None):
     check_version(version)
     node = get_queried_node(request, for_mac=mac)
     try:
         return HttpResponse(
             NodeUserData.objects.get_user_data(node),
             mimetype='application/octet-stream')
     except NodeUserData.DoesNotExist:
         logger.info(
             "No user data registered for node named %s" % node.hostname)
         return HttpResponse(status=httplib.NOT_FOUND)
Ejemplo n.º 3
0
 def read(self, request, version, mac=None):
     check_version(version)
     node = get_queried_node(request, for_mac=mac)
     try:
         # When a node is deploying, cloud-init's request
         # for user-data is when MAAS hands the node
         # off to a user.
         if node.status == NODE_STATUS.DEPLOYING:
             node.end_deployment()
         # If this node is supposed to be powered off, serve the
         # 'poweroff' userdata.
         if node.get_boot_purpose() == 'poweroff':
             user_data = generate_user_data_for_poweroff(node=node)
         else:
             user_data = NodeUserData.objects.get_user_data(node)
         return HttpResponse(user_data,
                             content_type='application/octet-stream')
     except NodeUserData.DoesNotExist:
         logger.info("No user data registered for node named %s" %
                     node.hostname)
         return HttpResponse(status=int(http.client.NOT_FOUND))