Exemplo n.º 1
0
def delete_sfc_clfs():
    t = os_tacker.get_tacker_client()
    sfc_clfs = os_tacker.list_sfc_classifiers(t)
    if sfc_clfs is None:
        return
    for sfc_clf in sfc_clfs:
        logger.info("Removing sfc classifier: {0}".format(sfc_clf))
        os_tacker.delete_sfc_classifier(t, sfc_clf_id=sfc_clf)
Exemplo n.º 2
0
def remove_tacker_sfc_classifiers(tacker_client, default_sfc_classifiers):
    logger.debug("Removing Tacker SFC classifiers...")
    sfc_clfs = os_tacker.list_sfc_classifiers(tacker_client,
                                              verbose=True)['sfc_classfiers']
    if sfc_clfs is None:
        logger.debug("There are no Tacker SFC classifiers in the deployment.")
        return

    for sfc_clf in sfc_clfs:
        sfc_clf_name = sfc_clf['name']
        sfc_clf_id = sfc_clf['id']
        logger.debug("'%s', ID=%s " % (sfc_clf_name, sfc_clf_id))
        if (sfc_clf_id not in default_sfc_classifiers
                and sfc_clf_name not in default_sfc_classifiers.values()):
            logger.debug(" Removing '%s'..." % sfc_clf_name)
            deleted = os_tacker.delete_sfc_classifier(tacker_client,
                                                      sfc_clf_id=sfc_clf_id)
            if deleted is not None:
                logger.debug("  > Done!")
            else:
                logger.error("There has been a problem removing the "
                             "SFC classifier '%s'(%s)..." %
                             (sfc_clf_name, sfc_clf_id))
        else:
            logger.debug("   > this is a default SFC classifier and will "
                         "NOT be deleted.")
Exemplo n.º 3
0
 def test_delete_sfc_classifier(self):
     with mock.patch('functest.utils.openstack_tacker.get_sfc_'
                     'classifier_id',
                     return_value=self.sfc_clf), \
             mock.patch.object(self.tacker_client, 'delete_sfc_classifier',
                               return_value=self.sfc_clf):
         cl = self.sfc_clf
         resp = openstack_tacker.delete_sfc_classifier(self.tacker_client,
                                                       sfc_clf_id='sfc_id',
                                                       sfc_clf_name=cl)
         self.assertEqual(resp, cl)
Exemplo n.º 4
0
 def test_delete_sfc_classifier_exception(self, mock_logger_error):
     with mock.patch('functest.utils.openstack_tacker.get_sfc_'
                     'classifier_id',
                     return_value=self.sfc_clf), \
             mock.patch.object(self.tacker_client, 'delete_sfc_classifier',
                               side_effect=Exception):
         cl = self.sfc_clf
         resp = openstack_tacker.delete_sfc_classifier(self.tacker_client,
                                                       sfc_clf_id='sfc_id',
                                                       sfc_clf_name=cl)
         self.assertIsNone(resp)
         self.assertTrue(mock_logger_error.called)
Exemplo n.º 5
0
def delete_classifier_and_acl(tacker_client, clf_name, odl_ip, odl_port):
    os_tacker.delete_sfc_classifier(tacker_client, sfc_clf_name=clf_name)
    delete_odl_acl(odl_ip,
                   odl_port,
                   'ietf-access-control-list:ipv4-acl',
                   clf_name)