def test_serialize_get_console_request_to_xml(self): request_obj = GetVncConsole(type="novnc") xml_serialized_request = request_obj.serialize("xml") expected_xml = ('<?xml version=\'1.0\' encoding=\'UTF-8\'?>' '<os-getVNCConsole type="novnc" />') self.assertEqual(xml_serialized_request, expected_xml.replace("\n", " "))
def get_vnc_console(self, server_id, vnc_type, requestslib_kwargs=None): """ @summary: Returns Console for a server @param server_id: The id of an existing server @type server_id: String @param vnc_type: Type of console, i.e, novnc, xvnc @type vnc_type: String @return: A console for the server @rtype: Requests.response """ request = GetVncConsole(type=vnc_type) url = '{base_url}/servers/{server_id}/action'.format( base_url=self.url, server_id=server_id) resp = self.request('POST', url, response_entity_type=VncConsole, request_entity=request, requestslib_kwargs=requestslib_kwargs) return resp
def test_serialize_get_console_request_to_json(self): request_obj = GetVncConsole(type="novnc") json_serialized_request = request_obj.serialize("json") expected_json = '{"os-getVNCConsole": {"type": "novnc"}}' self.assertEqual(json_serialized_request, expected_json)