示例#1
0
 def get_preseed(self, request, version=None, system_id=None):
     """Render and return a preseed script for the given node."""
     node = get_object_or_404(Node, system_id=system_id)
     # XXX: Set a charset for text/plain. Django automatically encodes
     # non-binary content using DEFAULT_CHARSET (which is UTF-8 by default)
     # but only sets the charset parameter in the content-type header when
     # a content-type is NOT provided.
     return HttpResponse(get_preseed(node), content_type="text/plain")
示例#2
0
 def get_context_data(self, **kwargs):
     context = super(NodePreseedView, self).get_context_data(**kwargs)
     node = self.get_object()
     # Display the preseed content exactly as generated by
     # `get_preseed`.  This will be rendered in a <pre> tag.
     context['preseed'] = mark_safe(get_preseed(node))
     context['is_commissioning'] = (
         node.status == NODE_STATUS.COMMISSIONING)
     return context
示例#3
0
文件: nodes.py 项目: cloudbase/maas
 def get_context_data(self, **kwargs):
     context = super(NodePreseedView, self).get_context_data(**kwargs)
     node = self.get_object()
     # Display the preseed content exactly as generated by
     # `get_preseed`.  This will be rendered in a <pre> tag.
     context['preseed'] = mark_safe(get_preseed(node))
     context['is_commissioning'] = (
         node.status == NODE_STATUS.COMMISSIONING)
     return context
示例#4
0
 def test_preseedview_node_displays_message_if_commissioning(self):
     node = factory.make_node(
         owner=self.logged_in_user, status=NODE_STATUS.COMMISSIONING,
         )
     node_preseed_link = reverse('node-preseed-view', args=[node.system_id])
     response = self.client.get(node_preseed_link)
     self.assertThat(
         response.content,
         ContainsAll([get_preseed(node), "This node is commissioning."]))
示例#5
0
 def test_compose_preseed_url_links_to_preseed_for_node(self):
     node = factory.make_node()
     response = self.client.get(compose_preseed_url(node))
     self.assertEqual(
         (httplib.OK, get_preseed(node)),
         (response.status_code, response.content))
示例#6
0
 def test_get_preseed_returns_commissioning_preseed(self):
     node = factory.make_node(status=NODE_STATUS.COMMISSIONING)
     preseed = get_preseed(node)
     self.assertIn('#cloud-config', preseed)
示例#7
0
 def test_get_preseed_returns_default_preseed(self):
     node = factory.make_node()
     preseed = get_preseed(node)
     self.assertIn('preseed/late_command', preseed)
示例#8
0
文件: api.py 项目: cloudbase/maas
 def get_preseed(self, request, version=None, system_id=None):
     """Render and return a preseed script for the given node."""
     node = get_object_or_404(Node, system_id=system_id)
     return HttpResponse(get_preseed(node), mimetype="text/plain")
示例#9
0
 def test_compose_preseed_url_links_to_preseed_for_node(self):
     node = factory.make_node()
     response = self.client.get(compose_preseed_url(node))
     self.assertEqual((httplib.OK, get_preseed(node)),
                      (response.status_code, response.content))
示例#10
0
 def test_get_preseed_returns_commissioning_preseed(self):
     node = factory.make_node(status=NODE_STATUS.COMMISSIONING)
     preseed = get_preseed(node)
     self.assertIn('#cloud-config', preseed)
示例#11
0
 def test_get_preseed_returns_curtin_preseed(self):
     node = factory.make_node()
     node.use_fastpath_installer()
     preseed = get_preseed(node)
     curtin_url = reverse('curtin-metadata')
     self.assertIn(curtin_url, preseed)
示例#12
0
 def test_get_preseed_returns_default_preseed(self):
     node = factory.make_node()
     preseed = get_preseed(node)
     self.assertIn('preseed/late_command', preseed)
示例#13
0
 def test_preseedview_node_displays_preseed_data(self):
     node = factory.make_node(owner=self.logged_in_user)
     node_preseed_link = reverse('node-preseed-view', args=[node.system_id])
     response = self.client.get(node_preseed_link)
     self.assertIn(get_preseed(node), response.content)