#NEWLINE# @ contract #NEWLINE# def init_db( sql_connection ) : #NEWLINE# #INDENT# ' Initialize the database.\n\n    :param sql_connection: A database connection URL.\n     :type sql_connection: str\n\n    :return: The initialized database.\n     :rtype: *\n    ' #NEWLINE# engine = create_engine ( sql_connection ) #NEWLINE# metadata = MetaData ( ) #NEWLINE# metadata . bind = engine #NEWLINE# hosts = Table ( 'hosts' , metadata , Column ( 'id' , Integer , primary_key = True ) , Column ( 'hostname' , String ( 255 ) , nullable = False ) , Column ( 'cpu_mhz' , Integer , nullable = False ) , Column ( 'cpu_cores' , Integer , nullable = False ) , Column ( 'ram' , Integer , nullable = False ) ) #NEWLINE# host_resource_usage = Table ( 'host_resource_usage' , metadata , Column ( 'id' , Integer , primary_key = True ) , Column ( 'host_id' , Integer , ForeignKey ( 'hosts.id' ) , nullable = False ) , Column ( 'timestamp' , DateTime , default = func . now ( ) ) , Column ( 'cpu_mhz' , Integer , nullable = False ) ) #NEWLINE# vms = Table ( 'vms' , metadata , Column ( 'id' , Integer , primary_key = True ) , Column ( 'uuid' , String ( 36 ) , nullable = False ) ) #NEWLINE# vm_resource_usage = Table ( 'vm_resource_usage' , metadata , Column ( 'id' , Integer , primary_key = True ) , Column ( 'vm_id' , Integer , ForeignKey ( 'vms.id' ) , nullable = False ) , Column ( 'timestamp' , DateTime , default = func . now ( ) ) , Column ( 'cpu_mhz' , Integer , nullable = False ) ) #NEWLINE# vm_migrations = Table ( 'vm_migrations' , metadata , Column ( 'id' , Integer , primary_key = True ) , Column ( 'vm_id' , Integer , ForeignKey ( 'vms.id' ) , nullable = False ) , Column ( 'host_id' , Integer , ForeignKey ( 'hosts.id' ) , nullable = False ) , Column ( 'timestamp' , DateTime , default = func . now ( ) ) ) #NEWLINE# host_states = Table ( 'host_states' , metadata , Column ( 'id' , Integer , primary_key = True ) , Column ( 'host_id' , Integer , ForeignKey ( 'hosts.id' ) , nullable = False ) , Column ( 'timestamp' , DateTime , default = func . now ( ) ) , Column ( 'state' , Integer , nullable = False ) ) #NEWLINE# host_overload = Table ( 'host_overload' , metadata , Column ( 'id' , Integer , primary_key = True ) , Column ( 'host_id' , Integer , ForeignKey ( 'hosts.id' ) , nullable = False ) , Column ( 'timestamp' , DateTime , default = func . now ( ) ) , Column ( 'overload' , Integer , nullable = False ) ) #NEWLINE# metadata . create_all ( ) #NEWLINE# connection = engine . connect ( ) #NEWLINE# db = Database ( connection , hosts , host_resource_usage , vms , vm_resource_usage , vm_migrations , host_states , vm_resource_usage ) #NEWLINE# return db