21
from maasserver.api import OperationsResource
22
21
from maasserver.api_auth import api_auth
22
from maasserver.api_support import OperationsResource
23
23
from metadataserver.api import (
24
24
AnonMetaDataHandler,
25
CommissioningScriptsHandler,
25
26
EnlistMetaDataHandler,
26
27
EnlistUserDataHandler,
27
28
EnlistVersionIndexHandler,
40
41
VersionIndexHandler, authentication=api_auth)
41
42
index_handler = OperationsResource(
42
43
IndexHandler, authentication=api_auth)
44
commissioning_scripts_handler = OperationsResource(
45
CommissioningScriptsHandler, authentication=api_auth)
45
48
# Handlers for anonymous metadata operations.
58
61
enlist_version_index_handler = OperationsResource(EnlistVersionIndexHandler)
60
63
# Normal metadata access, available to a node querying its own metadata.
65
# The URL patterns must tolerate redundant leading slashes, because
66
# cloud-init tends to add these.
61
67
node_patterns = patterns(
64
# could-init adds additional slashes in front of urls.
65
70
r'^/*(?P<version>[^/]+)/meta-data/(?P<item>.*)$',
67
72
name='metadata-meta-data'),
69
# could-init adds additional slashes in front of urls.
70
74
r'^/*(?P<version>[^/]+)/user-data$', user_data_handler,
71
75
name='metadata-user-data'),
73
# could-init adds additional slashes in front of urls.
76
# Commissioning scripts. This is a blatant MAAS extension to the
77
# metadata API, hence the "maas-" prefix.
78
# Scripts are returned as a tar arhive, but the format is not
79
# reflected in the http filename. The response's MIME type is
80
# definitive. We may yet choose to compress the file, without
81
# changing its name on the API.
83
r'^/*(?P<version>[^/]+)/maas-commissioning-scripts',
84
commissioning_scripts_handler, name='commissioning-scripts'),
74
86
r'^/*(?P<version>[^/]+)/', version_index_handler,
75
87
name='metadata-version'),
77
# could-init adds additional slashes in front of urls.
78
89
r'^/*', index_handler, name='metadata'),