Exemplo n.º 1
0
  def Run(self, args):
    """Issues the request necessary for adding the network."""
    holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
    client = holder.client
    messages = client.messages

    network_utils.CheckRangeLegacyModeOrRaise(args)

    network_ref = self.NETWORK_ARG.ResolveAsResource(args, holder.resources)
    self._network_name = network_ref.Name()
    network_resource = networks_utils.CreateNetworkResourceFromArgs(
        messages=messages,
        network_ref=network_ref,
        network_args=args)

    request = (
        client.apitools_client.networks,
        'Insert',
        client.messages.ComputeNetworksInsertRequest(
            network=network_resource, project=network_ref.project)
    )
    response = client.MakeRequests([request])[0]

    resource = resource_projector.MakeSerializable(response)
    resource['x_gcloud_subnet_mode'] = networks_utils.GetSubnetMode(response)
    resource['x_gcloud_bgp_routing_mode'] = networks_utils.GetBgpRoutingMode(
        response)
    return resource
Exemplo n.º 2
0
    def Run(self, args):
        """Issues the request necessary for adding the network."""
        holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
        client = holder.client
        messages = client.messages

        network_utils.CheckRangeLegacyModeOrRaise(args)

        network_ref = self.NETWORK_ARG.ResolveAsResource(
            args, holder.resources)
        self._network_name = network_ref.Name()
        network_resource = networks_utils.CreateNetworkResourceFromArgs(
            messages=messages,
            network_ref=network_ref,
            network_args=args,
            support_firewall_order=self._support_firewall_order)

        request = (client.apitools_client.networks, 'Insert',
                   client.messages.ComputeNetworksInsertRequest(
                       network=network_resource, project=network_ref.project))
        response = client.MakeRequests([request])

        resource_dict = resource_projector.MakeSerializable(response[0])
        return networks_utils.AddModesForListFormat(resource_dict)