예제 #1
0
파일: plugin.py 프로젝트: Juniper/neutron
    def _process_provider_create(self, network):
        segments = []

        if any(attributes.is_attr_set(network.get(f))
               for f in (provider.NETWORK_TYPE, provider.PHYSICAL_NETWORK,
                         provider.SEGMENTATION_ID)):
            # Verify that multiprovider and provider attributes are not set
            # at the same time.
            if attributes.is_attr_set(network.get(mpnet.SEGMENTS)):
                raise mpnet.SegmentsSetInConjunctionWithProviders()

            network_type = self._get_attribute(network, provider.NETWORK_TYPE)
            physical_network = self._get_attribute(network,
                                                   provider.PHYSICAL_NETWORK)
            segmentation_id = self._get_attribute(network,
                                                  provider.SEGMENTATION_ID)
            segments = [{provider.NETWORK_TYPE: network_type,
                         provider.PHYSICAL_NETWORK: physical_network,
                         provider.SEGMENTATION_ID: segmentation_id}]
        elif attributes.is_attr_set(network.get(mpnet.SEGMENTS)):
            segments = network[mpnet.SEGMENTS]
        else:
            return

        return [self._process_provider_segment(s) for s in segments]
예제 #2
0
 def _process_provider_create(self, network):
     if any(attributes.is_attr_set(network.get(attr))
            for attr in provider.ATTRIBUTES):
         # Verify that multiprovider and provider attributes are not set
         # at the same time.
         if attributes.is_attr_set(network.get(mpnet.SEGMENTS)):
             raise mpnet.SegmentsSetInConjunctionWithProviders()
         segment = self._get_provider_segment(network)
         return [self._process_provider_segment(segment)]
     elif attributes.is_attr_set(network.get(mpnet.SEGMENTS)):
         segments = [self._process_provider_segment(s)
                     for s in network[mpnet.SEGMENTS]]
         mpnet.check_duplicate_segments(segments, self.is_partial_segment)
         return segments