def testAddAdvertisement_multiRanges(self): # Start with a router in custom mode. orig = router_test_utils.CreateEmptyCustomRouterMessage(self.messages) updated = copy.deepcopy(orig) ranges = [ self.messages.RouterAdvertisedIpRange(range='10.10.10.10/30', description=''), self.messages.RouterAdvertisedIpRange(range='10.10.10.20/30', description='custom-range'), ] updated.bgp.advertisedIpRanges = ranges self.ExpectGet(orig) self.ExpectPatch(updated) self.ExpectOperationsPolling() self.ExpectGet(updated) self.Run(""" compute routers update my-router --region us-central1 --add-advertisement-ranges=10.10.10.10/30,10.10.10.20/30=custom-range """) self.AssertOutputEquals('') self.AssertErrContains('Updating router [my-router]')
def testRemoveAdvertisementGroups_groupNotFoundError(self): # Start with a router in custom mode. orig = router_test_utils.CreateEmptyCustomRouterMessage(self.messages) self.ExpectGet(orig) error_msg = 'Advertised group ALL_SUBNETS not found on this router.' with self.AssertRaisesExceptionMatches(router_utils.GroupNotFoundError, error_msg): self.Run(""" compute routers update my-router --region us-central1 --remove-advertisement-groups=ALL_SUBNETS """)
def testUpdateAdvertisements_peerNotFoundError(self): self.SelectApi(self.track, self.api_version) orig = router_test_utils.CreateEmptyCustomRouterMessage(self.messages) self.ExpectGet(orig) error_msg = ('peer `nonexistent-peer` not found') with self.AssertRaisesExceptionMatches(router_utils.PeerNotFoundError, error_msg): self.Run(""" compute routers update-bgp-peer my-router --region us-central1 --peer-name=nonexistent-peer --set-advertisement-groups=ALL_SUBNETS """)
def testUpdateAdvertisements_customWithDefaultError(self): self.SelectApi(self.track, self.api_version) orig = router_test_utils.CreateEmptyCustomRouterMessage(self.messages) self.ExpectGet(orig) error_msg = ('Cannot specify custom advertisements for a router with ' 'default mode.') with self.AssertRaisesExceptionMatches(router_utils.CustomWithDefaultError, error_msg): self.Run(""" compute routers update my-router --region us-central1 --advertisement-mode=DEFAULT --set-advertisement-groups=ALL_SUBNETS --set-advertisement-ranges=10.10.10.10/30=custom-range,10.10.10.20/30 """)
def testAddAdvertisement_groups(self): # Start with a router in custom mode. orig = router_test_utils.CreateEmptyCustomRouterMessage(self.messages) updated = copy.deepcopy(orig) groups = [(self.messages.RouterBgp. AdvertisedGroupsValueListEntryValuesEnum.ALL_SUBNETS)] updated.bgp.advertisedGroups = groups self.ExpectGet(orig) self.ExpectPatch(updated) self.ExpectOperationsPolling() self.ExpectGet(updated) self.Run(""" compute routers update my-router --region us-central1 --add-advertisement-groups=ALL_SUBNETS """) self.AssertOutputEquals('') self.AssertErrContains('Updating router [my-router]')