#!/usr/bin/python

# Copyright (c) 2019 Arista Networks, Inc.  All rights reserved.
# Arista Networks, Inc. Confidential and Proprietary.

from Ark import getPlatform
import Tac

def getSid():
   import re

   with open( '/proc/cmdline', 'r' ) as f:
      m = re.search( r"sid=(\w+)", f.read() )
      if m:
         return m.group( 1 )
   return None

EXCLUDED_PLATFORMS = [
   'baremetal',
   'ceoslab',
   'dropbear',
   'veos',
]

EXCLUDED_SID = []

MODPROBE = "/sbin/modprobe"

def modprobeDmamem():
   platform = getPlatform()

   if platform in EXCLUDED_PLATFORMS:
      return

   sid = getSid()

   if sid in EXCLUDED_SID:
      return

   Tac.run( [ MODPROBE, "dmamem_mod" ] )

if __name__ == "__main__":
   modprobeDmamem()
