Example #1
0
 def _load_sw_images(self, db_sw_images=_NO_DATA_SENTINEL):
     if db_sw_images is _NO_DATA_SENTINEL:
         vnf_deployment_flavour = self.get_by_id(
             self._context, self.id, expected_attrs=['software_images'])
         if 'software_images' in vnf_deployment_flavour:
             self.software_images = vnf_deployment_flavour.software_images
             self.software_images.obj_reset_changes(recursive=True)
             self.obj_reset_changes(['software_images'])
         else:
             self.software_images = (
                 objects.VnfSoftwareImagesList(objects=[]))
     elif db_sw_images:
         self.software_images = base.obj_make_list(
             self._context, objects.VnfSoftwareImagesList(
                 self._context),
             objects.VnfSoftwareImage, db_sw_images)
         self.obj_reset_changes(['software_images'])
    def test_create_with_software_images(self):
        software_images = objects.VnfSoftwareImage(**fakes.software_image)
        fake_software_images = objects.VnfSoftwareImagesList(
            objects=[software_images])
        flavour_data = fakes.vnf_deployment_flavour
        flavour_data.update({'software_images': fake_software_images})
        flavour_data.update({'package_uuid': self.vnf_package.id})
        vnf_deployment_flavour_obj = objects.VnfDeploymentFlavour(
            context=self.context, **flavour_data)

        vnf_deployment_flavour_obj.create()
        self.assertTrue(vnf_deployment_flavour_obj.id)
Example #3
0
def return_vnf_package_with_deployment_flavour():
    vnf_package = objects.VnfPackage._from_db_object(context,
                                                     objects.VnfPackage(),
                                                     return_vnf_package(),
                                                     expected_attrs=None)
    vnf_package_deployment_flavour = \
        objects.VnfDeploymentFlavour._from_db_object(
            context, objects.VnfDeploymentFlavour(),
            return_vnf_deployment_flavour(), expected_attrs=None)
    vnf_software_image = objects.VnfSoftwareImage._from_db_object(
        context,
        objects.VnfSoftwareImage(),
        return_vnf_software_image(),
        expected_attrs=None)
    vnf_software_image_list = objects.VnfSoftwareImagesList()
    vnf_software_image_list.objects = [vnf_software_image]
    vnf_package_deployment_flavour.software_images = vnf_software_image_list
    vnf_package_deployment_flavour_list = objects.VnfDeploymentFlavoursList()
    vnf_package_deployment_flavour_list.objects = \
        [vnf_package_deployment_flavour]
    vnf_package.vnf_deployment_flavours = vnf_package_deployment_flavour_list
    return vnf_package