Exemplo n.º 1
0
def delete_vnfds():
    t = os_tacker.get_tacker_client()
    vnfds = os_tacker.list_vnfds(t)
    if vnfds is None:
        return
    for vnfd in vnfds:
        logger.info("Removing vnfd: {0}".format(vnfd))
        os_tacker.delete_vnfd(t, vnfd_id=vnfd)
Exemplo n.º 2
0
 def test_delete_vnfd(self):
     with mock.patch('functest.utils.openstack_tacker.get_vnfd_id',
                     return_value=self.vnfd), \
             mock.patch.object(self.tacker_client, 'delete_vnfd',
                               return_value=self.vnfd):
         resp = openstack_tacker.delete_vnfd(self.tacker_client,
                                             vnfd_id='vnfd_id',
                                             vnfd_name=self.vnfd)
         self.assertEqual(resp, self.vnfd)
Exemplo n.º 3
0
 def test_delete_vnfd_exception(self, mock_logger_error):
     with mock.patch('functest.utils.openstack_tacker.get_vnfd_id',
                     return_value=self.vnfd), \
             mock.patch.object(self.tacker_client, 'delete_vnfd',
                               side_effect=Exception):
         resp = openstack_tacker.delete_vnfd(self.tacker_client,
                                             vnfd_id=None,
                                             vnfd_name=None)
         self.assertIsNone(resp)
         self.assertTrue(mock_logger_error.called)
Exemplo n.º 4
0
 def test_delete_vnfd_missing_vnfd_name(self):
     with mock.patch('functest.utils.openstack_tacker.get_vnfd_id',
                     return_value=self.vnfd), \
             self.assertRaises(Exception) as context:
         resp = openstack_tacker.delete_vnfd(self.tacker_client,
                                             vnfd_id=None,
                                             vnfd_name=None)
         self.assertIsNone(resp)
         msg = 'You need to provide VNFD id or VNFD name'
         self.assertTrue(msg in context)
Exemplo n.º 5
0
def remove_tacker_vnfds(tacker_client, default_vnfds):
    logger.debug("Removing Tacker VNFDs...")
    vnfds = os_tacker.list_vnfds(tacker_client, verbose=True)['vnfds']
    if vnfds is None:
        logger.debug("There are no Tacker VNFDs in the deployment. ")
        return

    for vnfd in vnfds:
        vnfd_name = vnfd['name']
        vnfd_id = vnfd['id']
        logger.debug("'%s', ID=%s " % (vnfd_name, vnfd_id))
        if (vnfd_id not in default_vnfds
                and vnfd_name not in default_vnfds.values()):
            logger.debug(" Removing '%s'..." % vnfd_name)
            deleted = os_tacker.delete_vnfd(tacker_client, vnfd_id=vnfd_id)
            if deleted is not None:
                logger.debug("  > Done!")
            else:
                logger.error("There has been a problem removing the "
                             "VNFD '%s'(%s)..." % (vnfd_name, vnfd_id))
        else:
            logger.debug("   > this is a default VNFD and will "
                         "NOT be deleted.")