# vim: tabstop=4 shiftwidth=4 softtabstop=4
#
# Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
#

"""
Service monitor DB to store VM, SI information
"""
import inspect

from cfgm_common import jsonutils as json
from cfgm_common.vnc_object_db import VncObjectDBClient
from sandesh_common.vns.constants import SVC_MONITOR_KEYSPACE_NAME

class ServiceMonitorDB(VncObjectDBClient):

    _KEYSPACE = SVC_MONITOR_KEYSPACE_NAME
    _SVC_SI_CF = 'service_instance_table'
    _POOL_CF = 'pool_table'
    _LB_CF = 'loadbalancer_table'
    _HM_CF = 'healthmonitor_table'

    def __init__(self, args, logger):
        self._db_logger = logger

        keyspaces = {
            self._KEYSPACE: {
                self._SVC_SI_CF: {},
                self._POOL_CF: {},
                self._LB_CF: {},
                self._HM_CF: {},
            }
        }

        cred = None
        if (args.cassandra_user is not None and
            args.cassandra_password is not None):
            cred={'username':args.cassandra_user,
                  'password':args.cassandra_password}

        super(ServiceMonitorDB, self).__init__(args.cassandra_server_list,
                                               args.cluster_id,
                                               keyspaces,