示例#1
0
 def _process_provider_create(self, network):
     if any(validators.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 validators.is_attr_set(network.get(mpnet_apidef.SEGMENTS)):
             raise mpnet_exc.SegmentsSetInConjunctionWithProviders()
         segment = self._get_provider_segment(network)
         return [self._process_provider_segment(segment)]
     elif validators.is_attr_set(network.get(mpnet_apidef.SEGMENTS)):
         segments = [self._process_provider_segment(s)
                     for s in network[mpnet_apidef.SEGMENTS]]
         mpnet_apidef.check_duplicate_segments(
             segments, self.is_partial_segment)
         return segments
示例#2
0
 def _process_provider_create(self, network):
     if any(validators.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 validators.is_attr_set(network.get(mpnet_apidef.SEGMENTS)):
             raise mpnet_exc.SegmentsSetInConjunctionWithProviders()
         segment = self._get_provider_segment(network)
         return [self._process_provider_segment(segment)]
     elif validators.is_attr_set(network.get(mpnet_apidef.SEGMENTS)):
         segments = [self._process_provider_segment(s)
                     for s in network[mpnet_apidef.SEGMENTS]]
         mpnet_apidef.check_duplicate_segments(
             segments, self.is_partial_segment)
         return segments
    def test_check_duplicate_segments_with_dups_and_partial(self):
        def _seg_partial(seg):
            return seg[provider_net.PHYSICAL_NETWORK] == 'pn0'

        self.assertIsNone(
            multiprovidernet.check_duplicate_segments(
                [
                    test_mpnet._build_segment('nt0', 'pn0', 2),
                    test_mpnet._build_segment('nt1', 'pn1', 2)
                ],
                is_partial_func=_seg_partial))
 def test_check_duplicate_segments_no_dups(self):
     self.assertIsNone(
         multiprovidernet.check_duplicate_segments([
             test_mpnet._build_segment('nt0', 'pn0', 2),
             test_mpnet._build_segment('nt0', 'pn0', 3)
         ]))