def testAllScopes(self): resource_registry = resources.REGISTRY.Clone() resource_registry.RegisterApiByName('compute', 'v1') project = resource_registry.Parse( 'https://compute.googleapis.com/compute/v1/projects/lister-project') args = MockArgs( filter=None, page_size=None, limit=None, names=None, regexp=None, zones=[], regions=[], ) frontend = lister.ParseMultiScopeFlags(args, resource_registry) self.assertEqual(args.filter, None) self.assertIsNone(frontend.filter) self.assertIsNone(frontend.max_results) self.assertEqual(frontend.scope_set, lister.AllScopes( projects=[project], zonal=True, regional=True))
def Run(self, args): args.GetDisplayInfo().AddTransforms({ 'description': _TransformShareSettings, }) if args.share_settings: args.GetDisplayInfo().AddFormat("""\ table( name, zone.basename(), description, nodeTemplate.basename(), size:label=NODES, shareSettings.description() )""") else: args.GetDisplayInfo().AddFormat("""\ table( name, zone.basename(), description, nodeTemplate.basename(), size:label=NODES, shareSettings.yesno(yes="true", no="false"):label=SHARED )""") holder = base_classes.ComputeApiHolder(self.ReleaseTrack()) client = holder.client request_data = lister.ParseMultiScopeFlags(args, holder.resources) list_implementation = lister.MultiScopeLister( client, aggregation_service=client.apitools_client.nodeGroups) return lister.Invoke(request_data, list_implementation)
def Run(self, args): holder = base_classes.ComputeApiHolder(self.ReleaseTrack()) client = holder.client request_data = lister.ParseMultiScopeFlags(args, holder.resources) list_implementation = lister.MultiScopeLister( client, aggregation_service=client.apitools_client.nodeGroups) return lister.Invoke(request_data, list_implementation)
def Run(self, args): holder = base_classes.ComputeApiHolder(self.ReleaseTrack()) client = holder.client request_data = lister.ParseMultiScopeFlags(args, holder.resources) list_implementation = lister.MultiScopeLister( client, regional_service=client.apitools_client.regionSslCertificates, global_service=client.apitools_client.sslCertificates, aggregation_service=client.apitools_client.sslCertificates, return_partial_success=self._return_partial_success) return lister.Invoke(request_data, list_implementation)
def _Run(args, holder): """Issues request necessary to list forwarding rules.""" client = holder.client request_data = lister.ParseMultiScopeFlags(args, holder.resources) list_implementation = lister.MultiScopeLister( client, regional_service=client.apitools_client.forwardingRules, global_service=client.apitools_client.globalForwardingRules, aggregation_service=client.apitools_client.forwardingRules) return lister.Invoke(request_data, list_implementation)
def Run(self, args): holder = base_classes.ComputeApiHolder(self.ReleaseTrack()) client = holder.client request_data = lister.ParseMultiScopeFlags(args, holder.resources) list_implementation = lister.MultiScopeLister( client, regional_service=client.apitools_client.publicDelegatedPrefixes, global_service=client.apitools_client. globalPublicDelegatedPrefixes, aggregation_service=client.apitools_client.publicDelegatedPrefixes) return lister.Invoke(request_data, list_implementation)
def Run(self, args): holder = base_classes.ComputeApiHolder(self.ReleaseTrack()) client = holder.client request_data = lister.ParseMultiScopeFlags(args, holder.resources) list_implementation = lister.MultiScopeLister( client, zonal_service=client.apitools_client.instanceGroups, regional_service=client.apitools_client.regionInstanceGroups, aggregation_service=client.apitools_client.instanceGroups) return self.ComputeDynamicProperties( args, lister.Invoke(request_data, list_implementation), holder)
def Run(self, args): holder = base_classes.ComputeApiHolder(self.ReleaseTrack()) client = holder.client request_data = lister.ParseMultiScopeFlags(args, holder.resources) list_implementation = lister.MultiScopeLister( client, zonal_service=client.apitools_client.networkEndpointGroups, regional_service=client.apitools_client.regionNetworkEndpointGroups if self.support_regional_scope else None, global_service=client.apitools_client.globalNetworkEndpointGroups if self.support_global_scope else None, aggregation_service=client.apitools_client.networkEndpointGroups) return lister.Invoke(request_data, list_implementation)
def _Run(args, holder, include_l7_internal_load_balancing): """Issues requests necessary to list URL maps.""" client = holder.client if include_l7_internal_load_balancing: request_data = lister.ParseMultiScopeFlags(args, holder.resources) list_implementation = lister.MultiScopeLister( client, regional_service=client.apitools_client.regionUrlMaps, global_service=client.apitools_client.urlMaps, aggregation_service=client.apitools_client.urlMaps) else: request_data = lister.ParseNamesAndRegexpFlags(args, holder.resources) list_implementation = lister.GlobalLister( client, client.apitools_client.urlMaps) return lister.Invoke(request_data, list_implementation)
def Run(self, args): query = resource_filter.Compile(self._GetInventoryFilterQuery(args)) holder = base_classes.ComputeApiHolder(self.ReleaseTrack()) client = holder.client request_data = lister.ParseMultiScopeFlags(args, holder.resources) list_implementation = lister.MultiScopeLister( client, zonal_service=client.apitools_client.instances, aggregation_service=client.apitools_client.instances) instances_iterator = lister.Invoke(request_data, list_implementation) instances = list(instances_iterator) responses = self._GetAllGuestInventoryGuestAttributes(holder, instances) return self._GetInventoryFilteredInstances(instances, responses, query)
def _Run(args, holder, include_l7_internal_load_balancing, return_partial_success): """Issues requests necessary to list Target HTTPS Proxies.""" client = holder.client if include_l7_internal_load_balancing: request_data = lister.ParseMultiScopeFlags(args, holder.resources) list_implementation = lister.MultiScopeLister( client, regional_service=client.apitools_client.regionTargetHttpsProxies, global_service=client.apitools_client.targetHttpsProxies, aggregation_service=client.apitools_client.targetHttpsProxies, return_partial_success=return_partial_success) else: request_data = lister.ParseNamesAndRegexpFlags(args, holder.resources) list_implementation = lister.GlobalLister( client, client.apitools_client.targetHttpsProxies) return lister.Invoke(request_data, list_implementation)
def Run(self, args): holder = base_classes.ComputeApiHolder(self.ReleaseTrack()) client = holder.client request_data = lister.ParseMultiScopeFlags(args, holder.resources) list_implementation = lister.MultiScopeLister( client=client, regional_service=client.apitools_client.subnetworks, aggregation_service=client.apitools_client.subnetworks) for resource in lister.Invoke(request_data, list_implementation): if args.network is None: yield resource elif 'network' in resource: network_ref = holder.resources.Parse(resource['network']) if network_ref.Name() == args.network: yield resource
def Run(self, args): holder = base_classes.ComputeApiHolder(self.ReleaseTrack()) client = holder.client request_data = lister.ParseMultiScopeFlags(args, holder.resources) list_implementation = lister.MultiScopeLister( client, zonal_service=client.apitools_client.instanceGroupManagers, regional_service=client.apitools_client.regionInstanceGroupManagers, aggregation_service=client.apitools_client.instanceGroupManagers) migs = lister.Invoke(request_data, list_implementation) (self._had_errors, results) = managed_instance_groups_utils.AddAutoscaledPropertyToMigs( list(migs), client, holder.resources) return results
def testGlobal(self): resource_registry = resources.REGISTRY.Clone() resource_registry.RegisterApiByName('compute', 'v1') project = resource_registry.Parse( 'https://compute.googleapis.com/compute/v1/projects/lister-project') args = MockArgs( filter=None, page_size=None, limit=None, names=None, regexp=None, ) setattr(args, 'global', True) # global is a keyword frontend = lister.ParseMultiScopeFlags(args, resource_registry) self.assertIsNone(args.filter) self.assertIsNone(frontend.filter) self.assertIsNone(frontend.max_results) self.assertEqual(frontend.scope_set, lister.GlobalScope([project]))