def prepare_post_body(self):
body = dict()<EOL>body['<STR_LIT>'] = {<EOL>'<STR_LIT>': self.hostname,<EOL>'<STR_LIT>': self.zone,<EOL>'<STR_LIT:title>': self.title,<EOL>'<STR_LIT>': {}<EOL>}<EOL>for optional_field in self.optional_fields:<EOL><INDENT>if hasattr(self, optional_field):<EOL><INDENT>body['<STR_LIT>'][optional_field] = getattr(self, optional_field)<EOL><DEDENT><DEDENT>if not hasattr(self, '<STR_LIT>'):<EOL><INDENT>body['<STR_LIT>']['<STR_LIT>'] = '<STR_LIT:none>'<EOL><DEDENT>body['<STR_LIT>']['<STR_LIT>'] = {<EOL>'<STR_LIT>': []<EOL>}<EOL>storage_title_id = <NUM_LIT:0>  <EOL>for storage in self.storage_devices:<EOL><INDENT>if not hasattr(storage, '<STR_LIT>') or storage.os is None:<EOL><INDENT>storage_title_id += <NUM_LIT:1><EOL><DEDENT>storage_body = storage.to_dict()<EOL>if not hasattr(storage, '<STR_LIT:title>') or not storage.title:<EOL><INDENT>if hasattr(storage, '<STR_LIT>') and storage.os:<EOL><INDENT>storage_body['<STR_LIT:title>'] = self.hostname + '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>storage_body['<STR_LIT:title>'] = self.hostname + '<STR_LIT>' + str(storage_title_id)<EOL><DEDENT><DEDENT>if hasattr(storage, '<STR_LIT>') and storage.os:<EOL><INDENT>storage_body['<STR_LIT:action>'] = '<STR_LIT>'<EOL>storage_body['<STR_LIT>'] = OperatingSystems.get_OS_UUID(storage.os)<EOL><DEDENT>elif hasattr(storage, '<STR_LIT>'):<EOL><INDENT>storage_body['<STR_LIT:action>'] = '<STR_LIT>'<EOL>storage_body['<STR_LIT>'] = storage.uuid<EOL><DEDENT>else:<EOL><INDENT>storage_body['<STR_LIT:action>'] = '<STR_LIT>'<EOL><DEDENT>body['<STR_LIT>']['<STR_LIT>']['<STR_LIT>'].append(storage_body)<EOL><DEDENT>if hasattr(self, '<STR_LIT>') and self.ip_addresses:<EOL><INDENT>body['<STR_LIT>']['<STR_LIT>'] = {<EOL>'<STR_LIT>': [<EOL>ip.to_dict() for ip in self.ip_addresses<EOL>]<EOL>}<EOL><DEDENT>return body<EOL>
Prepare a JSON serializable dict from a Server instance with nested.

Storage instances.