Example #1
0
    def create_ns(descriptor_type, descriptor_id, data_ns):
        try:
            client = Client()
            if descriptor_type == 'nsd':
                result = client.ns_create(data_ns)
            else:
                return False

        except Exception as e:
            log.exception(e)
            result = False
        return result
Example #2
0
    def download_pkg(descriptor_id, descriptor_type):
        try:
            client = Client()
            if descriptor_type == 'nsd':
                result = client.get_nsd_pkg(descriptor_id)
            elif descriptor_type == 'vnfd':
                result = client.get_vnfd_pkg(descriptor_id)
            else:
                return False

        except Exception as e:
            log.exception(e)
            result = False
        return result
Example #3
0
    def get_descriptor(descriptor_id, type_descriptor):
        """Returns a specific descriptor"""
        try:
            client = Client()
            if type_descriptor == 'nsd':
                result = client.nsd_get(descriptor_id)

            elif type_descriptor == 'vnfd':
                result = client.vnfd_get(descriptor_id)

        except Exception as e:
            log.exception(e)
            result = {}

        return result
Example #4
0
    def get_descriptors(type_descriptor):
        """Returns all descriptors of a given type"""
        log.debug("Get %s descriptors", type_descriptor)
        try:
            client = Client()
            if type_descriptor == 'nsd':
                result = client.nsd_list()

            elif type_descriptor == 'vnfd':
                result = client.vnfd_list()

        except Exception as e:
            log.exception(e)
            result = {}
        return result
Example #5
0
    def get_package_files_list(type_descriptor, descriptor_id):
        try:
            client = Client()
            if type_descriptor == 'nsd':
                result = client.nsd_artifacts(descriptor_id)
            elif type_descriptor == 'vnfd':
                result = client.vnf_packages_artifacts(descriptor_id)
            else:
                return False
            result = yaml.load(result)

        except Exception as e:
            log.exception(e)
            result = False

        return result
Example #6
0
    def delete_descriptor(type_descriptor, descriptor_id):
        log.debug('Delete descriptor')
        try:
            client = Client()
            if type_descriptor == 'nsd':
                result = client.nsd_delete(descriptor_id)
            elif type_descriptor == 'vnfd':
                result = client.vnfd_delete(descriptor_id)

            else:
                log.debug('Create descriptor: Unknown data type')
                return False

        except Exception as e:
            log.exception(e)
            result = False
        return result
Example #7
0
    def create_descriptor(descriptor_name, type_descriptor, new_data, data_type, file_uploaded):
        """Creates a descriptor of a given type from a json or yaml representation

        Returns the descriptor id or False
        """
        log.debug('Create descriptor')

        try:
            client = Client()
            if type_descriptor == 'nsd':
                result = client.nsd_onboard(file_uploaded)
            elif type_descriptor == 'vnfd':
                result = client.vnfd_onboard(file_uploaded)

            else:
                log.debug('Create descriptor: Unknown data type')
                return False

        except Exception as e:
            log.exception(e)
            result = False
        return result
Example #8
0
    def edit_descriptor(type_descriptor, descriptor_id, new_data, data_type):
        log.debug("Edit descriptor")
        try:
            client = Client()
            if type_descriptor == 'nsd':
                if data_type == 'yaml':
                    new_data = yaml.load(new_data)
                elif data_type == 'json':
                    new_data = json.loads(new_data)
                result = client.nsd_update(descriptor_id, new_data)
            elif type_descriptor == 'vnfd':
                if data_type == 'yaml':
                    new_data = yaml.load(new_data)
                elif data_type == 'json':
                    new_data = json.loads(new_data)
                result = client.vnfd_update(descriptor_id, new_data)

            else:
                log.debug('Create descriptor: Unknown data type')
                return False
        except Exception as e:
            log.exception(e)
            result = False
        return result
Example #9
0
    def get_overview_data():
        client = Client()
        nsd = client.nsd_list()
        vnfd = client.vnfd_list()
        ns = client.ns_list()
        vnf = client.vnf_list()
        result = {
            'owner': '-',
            'name': '-',
            'updated_date': '-',
            'info': '-',
            'type': 'osm',
            'nsd': len(nsd) if nsd else 0,
            'vnfd': len(vnfd) if vnfd else 0,
            'ns': len(ns) if ns else 0,
            'vnf': len(vnf) if vnf else 0,
        }

        return result