def test_delete_sfc_classifier_missing_sfc_name(self):
     with self.assertRaises(Exception) as context:
         openstack_tacker.delete_vnf(self.tacker_client,
                                     sfc_clf_id=None,
                                     sfc_clf_name=None)
         msg = 'You need to provide an SFCclassifier id or name'
         self.assertTrue(msg in context)
Beispiel #2
0
def delete_vnfs():
    t = os_tacker.get_tacker_client()
    vnfs = os_tacker.list_vnfs(t)
    if vnfs is None:
        return
    for vnf in vnfs:
        logger.info("Removing vnf: {0}".format(vnf))
        os_tacker.delete_vnf(t, vnf_id=vnf)
 def test_delete_vnf(self):
     with mock.patch('functest.utils.openstack_tacker.get_vnf_id',
                     return_value=self.vnf), \
             mock.patch.object(self.tacker_client, 'delete_vnf',
                               return_value=self.vnf):
         resp = openstack_tacker.delete_vnf(self.tacker_client,
                                            vnf_id='vnf_id',
                                            vnf_name=self.vnf)
         self.assertEqual(resp, self.vnf)
 def test_delete_vnf_exception(self, mock_logger_error):
     with mock.patch('functest.utils.openstack_tacker.get_vnf_id',
                     return_value=self.vnf), \
             mock.patch.object(self.tacker_client, 'delete_vnf',
                               side_effect=Exception):
         resp = openstack_tacker.delete_vnf(self.tacker_client,
                                            vnf_id=None,
                                            vnf_name=None)
         self.assertIsNone(resp)
         self.assertTrue(mock_logger_error.called)
Beispiel #5
0
def remove_tacker_vnfs(tacker_client, default_vnfs):
    logger.debug("Removing Tacker VNFs...")
    vnfs = os_tacker.list_vnfs(tacker_client, verbose=True)['vnfs']
    if vnfs is None:
        logger.debug("There are no Tacker VNFs in the deployment. ")
        return

    for vnf in vnfs:
        vnf_name = vnf['name']
        vnf_id = vnf['id']
        logger.debug("'%s', ID=%s " % (vnf_name, vnf_id))
        if (vnf_id not in default_vnfs
                and vnf_name not in default_vnfs.values()):
            logger.debug(" Removing '%s'..." % vnf_name)
            deleted = os_tacker.delete_vnf(tacker_client, vnf_id=vnf_id)
            if deleted is not None:
                logger.debug("  > Done!")
            else:
                logger.error("There has been a problem removing the "
                             "VNF '%s'(%s)..." % (vnf_name, vnf_id))
        else:
            logger.debug("   > this is a default VNF and will "
                         "NOT be deleted.")