def Run(self, args): holder = base_classes.ComputeApiHolder(self.ReleaseTrack()) client = holder.client network_ref = flags.NetworkArgument().ResolveAsResource( args, holder.resources, scope_lister=compute_flags.GetDefaultScopeLister(client)) request = client.messages.ComputeNetworksGetEffectiveFirewallsRequest( **network_ref.AsDict()) responses = client.MakeRequests([(client.apitools_client.networks, 'GetEffectiveFirewalls', request)]) res = responses[0] org_firewall = [] network_firewall = [] if hasattr(res, 'firewalls'): network_firewall = self.SortNetworkFirewallRules( client, res.firewalls) if hasattr(res, 'organizationFirewalls'): for sp in res.organizationFirewalls: org_firewall_rule = self.SortOrgFirewallRules(client, sp.rules) org_firewall.append( client.messages. NetworksGetEffectiveFirewallsResponseOrganizationFirewallPolicy( id=sp.id, rules=org_firewall_rule)) return client.messages.NetworksGetEffectiveFirewallsResponse( organizationFirewalls=org_firewall, firewalls=network_firewall)
def Args(cls, parser): parser.display_info.AddFormat(flags.DEFAULT_LIST_FORMAT) cls.NETWORK_ARG = flags.NetworkArgument() cls.NETWORK_ARG.AddArgument(parser) parser.add_argument( '--description', help='An optional, textual description for the network.') parser.add_argument( '--mode', metavar='NETWORK_TYPE', choices={ 'auto': ('Subnets are created automatically. This is the recommended ' 'selection.'), 'custom': 'Create subnets manually.', 'legacy': ('Create an old style network that has a range and cannot have ' 'subnets.'), }, required=False, help='The network type.') parser.add_argument('--range', help="""\ Specifies the IPv4 address range of legacy mode networks. The range must be specified in CIDR format: [](http://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing) This flag only works if mode is legacy. """)
def Args(cls, parser): cls.NETWORK_ARG = flags.NetworkArgument() cls.NETWORK_ARG.AddArgument(parser) parser.add_argument( '--description', help='An optional, textual description for the network.') parser.add_argument( '--mode', metavar='NETWORK_TYPE', choices={ 'auto': ( 'Subnets are created automatically. This is the recommended ' 'selection.'), 'custom': 'Create subnets manually.', 'legacy': ( 'Create an old style network that has a range and cannot have ' 'subnets.'), }, required=False, help='The network type.') range_arg = parser.add_argument( '--range', help='Specifies the IPv4 address range of this network.') range_arg.detailed_help = """\
def Args(cls, parser): parser.display_info.AddFormat(flags.DEFAULT_LIST_FORMAT) cls.NETWORK_ARG = flags.NetworkArgument() cls.NETWORK_ARG.AddArgument(parser, operation_type='create') network_utils.AddCreateBaseArgs(parser) network_utils.AddCreateSubnetModeArg(parser) network_utils.AddCreateBgpRoutingModeArg(parser)
def Args(cls, parser): parser.display_info.AddFormat(flags.DEFAULT_LIST_FORMAT) cls.NETWORK_ARG = flags.NetworkArgument() cls.NETWORK_ARG.AddArgument(parser, operation_type='create') network_utils.AddCreateBaseArgs(parser) # TODO(b/64980447): Deprecate this arg and use --subnet-mode instead. network_utils.AddCreateModeArg(parser)
def Args(cls, parser): parser.display_info.AddFormat(flags.DEFAULT_LIST_FORMAT) cls.NETWORK_ARG = flags.NetworkArgument() cls.NETWORK_ARG.AddArgument(parser, operation_type='create') network_utils.AddCreateBaseArgs(parser) network_utils.AddCreateSubnetModeArg(parser) network_utils.AddCreateBgpRoutingModeArg(parser) network_utils.AddMtuArg(parser) network_utils.AddInternalIpv6RangeArg(parser) network_utils.AddEnableUlaInternalIpv6Arg(parser) parser.display_info.AddCacheUpdater(flags.NetworksCompleter)
def Run(self, args): holder = base_classes.ComputeApiHolder(self.ReleaseTrack()) client = holder.client network_ref = flags.NetworkArgument().ResolveAsResource( args, holder.resources, scope_lister=compute_flags.GetDefaultScopeLister(client)) request = client.messages.ComputeNetworksGetEffectiveFirewallsRequest( **network_ref.AsDict()) responses = client.MakeRequests([(client.apitools_client.networks, 'GetEffectiveFirewalls', request)]) return responses[0]
def Args(cls, parser): cls.NETWORK_ARG = flags.NetworkArgument() cls.NETWORK_ARG.AddArgument(parser) network_utils.AddUpdateArgsAlpha(parser)
def Args(parser): flags.NetworkArgument().AddArgument( parser, operation_type='get effective firewalls') parser.display_info.AddFormat( firewalls_utils.EFFECTIVE_FIREWALL_LIST_FORMAT) lister.AddBaseListerArgs(parser)
def Run(self, args): holder = base_classes.ComputeApiHolder(self.ReleaseTrack()) client = holder.client network_ref = flags.NetworkArgument().ResolveAsResource( args, holder.resources, scope_lister=compute_flags.GetDefaultScopeLister(client)) request = client.messages.ComputeNetworksGetEffectiveFirewallsRequest( **network_ref.AsDict()) responses = client.MakeRequests([(client.apitools_client.networks, 'GetEffectiveFirewalls', request)]) res = responses[0] org_firewall = [] network_firewall = [] all_firewall_policy = [] if hasattr(res, 'firewalls'): network_firewall = firewalls_utils.SortNetworkFirewallRules( client, res.firewalls) if hasattr(res, 'firewallPolicys') and res.firewallPolicys: for fp in res.firewallPolicys: firewall_policy_rule = firewalls_utils.SortFirewallPolicyRules( client, fp.rules) fp_response = ( client.messages. NetworksGetEffectiveFirewallsResponseEffectiveFirewallPolicy( name=fp.name, rules=firewall_policy_rule, type=fp.type)) all_firewall_policy.append(fp_response) elif hasattr(res, 'organizationFirewalls'): for sp in res.organizationFirewalls: org_firewall_rule = firewalls_utils.SortOrgFirewallRules( client, sp.rules) org_firewall.append( client.messages. NetworksGetEffectiveFirewallsResponseOrganizationFirewallPolicy( id=sp.id, rules=org_firewall_rule)) if args.IsSpecified('format') and args.format == 'json': if org_firewall: return client.messages.NetworksGetEffectiveFirewallsResponse( organizationFirewalls=org_firewall, firewalls=network_firewall, firewallPolicys=all_firewall_policy) else: return client.messages.NetworksGetEffectiveFirewallsResponse( firewalls=network_firewall, firewallPolicys=all_firewall_policy) result = [] for fp in all_firewall_policy: result.extend( firewalls_utils.ConvertFirewallPolicyRulesToEffectiveFwRules( client, fp, True)) for sp in org_firewall: result.extend( firewalls_utils. ConvertOrgSecurityPolicyRulesToEffectiveFwRules(sp)) result.extend( firewalls_utils.ConvertNetworkFirewallRulesToEffectiveFwRules( network_firewall)) return result
def Args(parser): Delete.NETWORK_ARG = flags.NetworkArgument(plural=True) Delete.NETWORK_ARG.AddArgument(parser, operation_type='delete') parser.display_info.AddCacheUpdater(flags.NetworksCompleter)
def Args(cls, parser): cls.NETWORK_ARG = flags.NetworkArgument() cls.NETWORK_ARG.AddArgument(parser) base.ASYNC_FLAG.AddToParser(parser) network_utils.AddUpdateArgs(parser)
def Args(parser): Delete.NETWORK_ARG = flags.NetworkArgument(plural=True) Delete.NETWORK_ARG.AddArgument(parser, operation_type='delete')
def Args(parser): Describe.NETWORK_ARG = flags.NetworkArgument() Describe.NETWORK_ARG.AddArgument(parser, operation_type='describe')
def Args(parser): flags.NetworkArgument().AddArgument( parser, operation_type='get effective firewalls')
def Args(cls, parser): parser.display_info.AddFormat(flags.ALPHA_LIST_FORMAT) cls.NETWORK_ARG = flags.NetworkArgument() cls.NETWORK_ARG.AddArgument(parser) network_utils.AddCreateAlphaArgs(parser)