~andreserl/maas/lp1073462_fence_cdu_power_type

« back to all changes in this revision

Viewing changes to src/metadataserver/api.py

[r=julian-edwards][bug=][author=jtv] Metadata API extension: maas-commissioning-scripts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
__metaclass__ = type
13
13
__all__ = [
14
14
    'AnonMetaDataHandler',
 
15
    'CommissioningScriptsHandler',
15
16
    'IndexHandler',
16
17
    'MetaDataHandler',
17
18
    'UserDataHandler',
56
57
from maasserver.utils import find_nodegroup
57
58
from maasserver.utils.orm import get_one
58
59
from metadataserver.models import (
 
60
    CommissioningScript,
59
61
    NodeCommissionResult,
60
62
    NodeKey,
61
63
    NodeUserData,
156
158
class VersionIndexHandler(MetadataViewHandler):
157
159
    """Listing for a given metadata version."""
158
160
    create = update = delete = None
159
 
    fields = ('meta-data', 'user-data')
 
161
    fields = ('maas-commissioning-scripts', 'meta-data', 'user-data')
160
162
 
161
163
    # States in which a node is allowed to signal commissioning status.
162
164
    # (Only in Commissioning state, however, will it have any effect.)
341
343
            return HttpResponse(status=httplib.NOT_FOUND)
342
344
 
343
345
 
 
346
class CommissioningScriptsHandler(MetadataViewHandler):
 
347
    """Return a tar archive containing the commissioning scripts."""
 
348
 
 
349
    def read(self, request, version, mac=None):
 
350
        check_version(version)
 
351
        return HttpResponse(
 
352
            CommissioningScript.objects.get_archive(),
 
353
            mimetype='application/tar')
 
354
 
 
355
 
344
356
class EnlistMetaDataHandler(OperationsHandler):
345
357
    """this has to handle the 'meta-data' portion of the meta-data api
346
358
    for enlistment only.  It should mimic the read-only portion