def check_dm_state(self):
     try:
         dm_cs = DMCassandraDB.getInstance()
         if dm_cs:
             self.assertTrue(True)
     except:
         self.assertTrue(False)
    def test_dm_cassandra(self):
        #wait for dm
        self.check_dm_state()
        dm_cs = DMCassandraDB.getInstance()
        ip_addr = '10.0.0.1/32'
        lo0_ip_addr = '20.0.0.1/32'
        key = 'pr-uuid' + ':' + 'vn-uuid' + ':' + 'sub-prefix'
        dm_cs.add(dm_cs._PR_VN_IP_CF, key,
                  {DMUtils.get_ip_cs_column_name('irb'): ip_addr})
        dm_cs.add(dm_cs._PR_VN_IP_CF, key,
                  {DMUtils.get_ip_cs_column_name('lo0'): lo0_ip_addr})
        dm_cs.init_pr_map()

        key_value = dm_cs.get_one_col(dm_cs._PR_VN_IP_CF, key,
                                      DMUtils.get_ip_cs_column_name('irb'))
        if key_value != ip_addr:
            self.assertTrue(False)
        key_value = dm_cs.get_one_col(dm_cs._PR_VN_IP_CF, key,
                                      DMUtils.get_ip_cs_column_name('lo0'))
        if key_value != lo0_ip_addr:
            self.assertTrue(False)

        # delete one column
        dm_cs.delete(dm_cs._PR_VN_IP_CF, key,
                     [DMUtils.get_ip_cs_column_name('lo0')])

        try:
            key_value = dm_cs.get_one_col(dm_cs._PR_VN_IP_CF, key,
                                          DMUtils.get_ip_cs_column_name('lo0'))
            if key_value is not None:
                self.assertTrue(False)
        except NoIdError:
            pass

        key_value = dm_cs.get_one_col(dm_cs._PR_VN_IP_CF, key,
                                      DMUtils.get_ip_cs_column_name('irb'))
        if key_value != ip_addr:
            self.assertTrue(False)

        return