Beispiel #1
0
def _get_vnflcm_interface(context, interface, vnf_instance, flavour_id):
    '''Gets the interface found in vnfd

        ...
            node_templates:
                VNF:
                    interfaces:
                        Vnflcm:
                            <interface>
    '''
    interface_value = None
    vnfd_dict = _get_vnfd_dict(context, vnf_instance.vnfd_id, flavour_id)

    if not isinstance(vnfd_dict, dict):
        raise exceptions.InvalidContentType(msg="VNFD not valid")

    if vnfd_dict.get('topology_template'):
        topology_template = vnfd_dict.get('topology_template')
        if topology_template.get('node_templates'):
            node_templates = topology_template.get('node_templates')
            if node_templates.get('VNF'):
                vnf = node_templates.get('VNF')
                if vnf.get('interfaces'):
                    interfaces = vnf.get('interfaces')
                    if interfaces.get('Vnflcm'):
                        vnflcm = interfaces.get('Vnflcm')
                        if vnflcm:
                            interface_value = vnflcm.get(interface)

    return interface_value
Beispiel #2
0
    def get_deserialize_handler(self, content_type):
        handlers = {
            'application/json': JSONDeserializer(),
        }

        try:
            return handlers[content_type]
        except Exception:
            raise exception.InvalidContentType(content_type=content_type)
Beispiel #3
0
    def _get_serialize_handler(self, content_type):
        handlers = {
            'application/json': JSONDictSerializer(),
            'application/xml': XMLDictSerializer(self.metadata),
        }

        try:
            return handlers[content_type]
        except Exception:
            raise exception.InvalidContentType(content_type=content_type)
Beispiel #4
0
 def get_body_deserializer(self, content_type):
     try:
         return self.body_deserializers[content_type]
     except (KeyError, TypeError):
         raise exception.InvalidContentType(content_type=content_type)