def test_returns_None_when_subnet_is_not_managed(self): subnet = factory.make_Subnet() self.assertIsNone( find_rack_controller( make_request(factory.pick_ip_in_Subnet(subnet)) ) )
def get_enlist_preseed(self, request, version=None): """Render and return a preseed script for enlistment.""" rack_controller = find_rack_controller(request) # 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. preseed = get_enlist_preseed(request, rack_controller=rack_controller) return HttpResponse(preseed, content_type="text/plain")
def test_returns_primary_rack_when_subnet_is_managed(self): subnet = factory.make_Subnet() rack_controller = factory.make_RackController() subnet.vlan.dhcp_on = True subnet.vlan.primary_rack = rack_controller subnet.vlan.save() self.assertEquals( rack_controller.system_id, find_rack_controller( make_request(factory.pick_ip_in_Subnet(subnet))).system_id)
def read(self, request, version): check_version(version) rack_controller = find_rack_controller(request) # 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_enlist_userdata(rack_controller=rack_controller), content_type="text/plain")
def read(self, request, version): check_version(version) rack_controller = find_rack_controller(request) # 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(generate_user_data_for_status( None, NODE_STATUS.NEW, rack_controller=rack_controller, request=request, extra_content={ 'enlist_commissioning': Config.objects.get_config('enlist_commissioning'), }), content_type="text/plain")
def test_returns_None_when_unknown_subnet(self): self.assertIsNone( find_rack_controller(make_request(factory.make_ip_address())))