Ejemplo n.º 1
0
    def _YieldPrintableResourcesOnErrors(self, args):
        request = self.messages.DeploymentmanagerResourcesListRequest(
            project=dm_base.GetProject(),
            deployment=args.deployment,
        )

        paginated_resources = dm_api_util.YieldWithHttpExceptions(
            list_pager.YieldFromList(self.client.resources,
                                     request,
                                     field='resources',
                                     limit=args.limit,
                                     batch_size=args.page_size))
        for resource in paginated_resources:
            if resource.update:
                resource.update.intent = dm_api_util.GetActionResourceIntent(
                    resource.update.intent, resource.update.runtimePolicies)
            yield resource
Ejemplo n.º 2
0
 def testGetActionResourceIntent(self):
     self.assertEqual(
         'none/NOT_RUN',
         dm_api_util.GetActionResourceIntent('none', ['DELETE']))
     self.assertEqual('none',
                      dm_api_util.GetActionResourceIntent('none', None))
     self.assertEqual('/NOT_RUN',
                      dm_api_util.GetActionResourceIntent('', ['DELETE']))
     self.assertEqual('', dm_api_util.GetActionResourceIntent('', None))
     self.assertEqual(
         'PATCH/TO_RUN',
         dm_api_util.GetActionResourceIntent('PATCH',
                                             ['UPDATE_ALWAYS', 'DELETE']))
     self.assertEqual(
         'PATCH/NOT_RUN',
         dm_api_util.GetActionResourceIntent('PATCH', ['CREATE']))
     self.assertEqual('PATCH',
                      dm_api_util.GetActionResourceIntent('PATCH', None))
     self.assertEqual(
         'UPDATE/TO_RUN',
         dm_api_util.GetActionResourceIntent(
             'UPDATE', ['UPDATE_ON_CHANGE', 'DELETE']))
     self.assertEqual(
         'UPDATE/NOT_RUN',
         dm_api_util.GetActionResourceIntent('UPDATE', ['CREATE']))
     self.assertEqual('UPDATE',
                      dm_api_util.GetActionResourceIntent('UPDATE', None))
     self.assertEqual(
         'DELETE/TO_RUN',
         dm_api_util.GetActionResourceIntent(
             'DELETE', ['UPDATE_ON_CHANGE', 'DELETE']))
     self.assertEqual(
         'DELETE/NOT_RUN',
         dm_api_util.GetActionResourceIntent('DELETE', ['UPDATE_ALWAYS']))
     self.assertEqual('DELETE',
                      dm_api_util.GetActionResourceIntent('DELETE', None))
     self.assertEqual(
         'CREATE_OR_ACQUIRE/TO_RUN',
         dm_api_util.GetActionResourceIntent(
             'CREATE_OR_ACQUIRE', ['UPDATE_ON_CHANGE', 'CREATE']))
     self.assertEqual(
         'CREATE_OR_ACQUIRE/NOT_RUN',
         dm_api_util.GetActionResourceIntent('CREATE_OR_ACQUIRE',
                                             ['DELETE']))
     self.assertEqual(
         'CREATE_OR_ACQUIRE',
         dm_api_util.GetActionResourceIntent('CREATE_OR_ACQUIRE', None))
     self.assertEqual(
         'ACQUIRE/NOT_RUN',
         dm_api_util.GetActionResourceIntent(
             'ACQUIRE', ['UPDATE_ON_CHANGE', 'CREATE']))
     self.assertEqual('ACQUIRE',
                      dm_api_util.GetActionResourceIntent('ACQUIRE', None))