def test_list_vnfds_verbose(self):
     with mock.patch.object(self.tacker_client,
                            'list_vnfds',
                            return_value=self.vnfdlist):
         resp = openstack_tacker.list_vnfds(self.tacker_client,
                                            verbose=True)
         self.assertEqual(resp, self.vnfdlist)
Example #2
0
def get_tacker_vnfds(tacker_client):
    logger.debug("Getting Tacker VNFDs...")
    dic_vnfds = {}
    vnfds = os_tacker.list_vnfds(tacker_client, verbose=True)['vnfds']
    if not (vnfds is None or len(vnfds) == 0):
        for vnfd in vnfds:
            dic_vnfds.update({vnfd['id']: vnfd['name']})
    return {'vnfds': dic_vnfds}
Example #3
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)
 def test_list_vnfds_exception(self, mock_logger_error):
     with mock.patch.object(self.tacker_client,
                            'list_vnfds',
                            side_effect=Exception):
         resp = openstack_tacker.list_vnfds(self.tacker_client,
                                            verbose=False)
         mock_logger_error.assert_called_once_with(
             test_utils.SubstrMatch("Error"
                                    " [list"
                                    "_vnfds("
                                    "tacker_"
                                    "client)]:"))
         self.assertIsNone(resp)
Example #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.")