#NEWLINE# def add_host( mac , name = None , ip = None , ddns = False , group = None , supersede_host = False ) : #NEWLINE# #INDENT# '\n    Add a host object for the given mac.\n\n    CLI Example:\n\n    .. code-block:: bash\n\n        salt dhcp-server omapi.add_host ab:ab:ab:ab:ab:ab name=host1\n\n    Add ddns-hostname and a fixed-ip statements:\n\n    .. code-block:: bash\n\n        salt dhcp-server omapi.add_host ab:ab:ab:ab:ab:ab name=host1 ip=10.1.1.1 ddns=true\n    ' #NEWLINE# statements = '' #NEWLINE# o = _conn ( ) #NEWLINE# msg = omapi . OmapiMessage . open ( b'host' ) #NEWLINE# msg . message . append ( ( 'create' , struct . pack ( '!I' , 1 ) ) ) #NEWLINE# msg . message . append ( ( 'exclusive' , struct . pack ( '!I' , 1 ) ) ) #NEWLINE# msg . obj . append ( ( 'hardware-address' , omapi . pack_mac ( mac ) ) ) #NEWLINE# msg . obj . append ( ( 'hardware-type' , struct . pack ( '!I' , 1 ) ) ) #NEWLINE# if ip : #NEWLINE# #INDENT# msg . obj . append ( ( 'ip-address' , omapi . pack_ip ( ip ) ) ) #NEWLINE# #UNINDENT# if name : #NEWLINE# #INDENT# msg . obj . append ( ( 'name' , group ) ) #NEWLINE# #UNINDENT# if group : #NEWLINE# #INDENT# msg . obj . append ( ( 'group' , group ) ) #NEWLINE# #UNINDENT# if supersede_host : #NEWLINE# #INDENT# statements += 'option host-name "{0}"; ' . format ( name ) #NEWLINE# #UNINDENT# if ( ddns and name ) : #NEWLINE# #INDENT# statements += 'ddns-hostname "{0}"; ' . format ( name ) #NEWLINE# #UNINDENT# if statements : #NEWLINE# #INDENT# msg . obj . append ( ( 'statements' , statements ) ) #NEWLINE# #UNINDENT# response = o . query_server ( msg ) #NEWLINE# if ( response . opcode != omapi . OMAPI_OP_UPDATE ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# return True