הצגת הזמנות או בקשות להזמנות עתידיות

במאמר הזה מוסבר איך לראות את המקומות השמורים, את הבקשות למקומות שמורים לעתיד ואת צריכת המקומות השמורים. איך בוחרים סוג הזמנה?

כשאתם צופים בהזמנות, בבקשות למקום שמור לעתיד או בשימוש בהזמנות, אתם יכולים:

  • לצפייה בהגדרות של ההזמנה הבדיקה הזו עוזרת לכם לוודא שהפרטים של ההזמנות נכונים, שהן עונות על הצרכים שלכם ולתכנן את הקיבולת.

  • קביעת מספר המופעים שניתן להשתמש בהם הבדיקה הזו עוזרת לכם לקבוע כמה מכונות של Compute Engine יכולות לצרוך את הקיבולת השמורה שלכם.

  • צפייה בצריכת ההזמנות. בבדיקה הזו אפשר לראות איזו מכונה ספציפית של Compute Engine משתמשת בנתונים ממקום שמור, או לראות רשימה של כל המכונות שמשתמשות בנתונים ממקום שמור מסוים בפרויקט.

מגבלות

אפשר לראות מקום שמור משותף או בקשה משותפת לשריון מקום שמור לעתיד רק בפרויקט שבו הם נוצרו.

לפני שמתחילים

התפקידים הנדרשים

כדי לקבל את ההרשאות שנדרשות לצפייה במקומות שמורים או בבקשות למקומות שמורים לעתיד, צריך לבקש מהאדמין להקצות לכם ב-IAM את התפקיד אדמין של Compute ‏ (roles/compute.admin) בפרויקט. כדי לקרוא הסבר על מתן תפקידים, ראו איך מנהלים את הגישה ברמת הפרויקט, התיקייה והארגון.

זהו תפקיד שמוגדר מראש וכולל את ההרשאות שנדרשות לצפייה בהזמנות או בבקשות להזמנות עתידיות. כדי לראות בדיוק אילו הרשאות נדרשות, אפשר להרחיב את הקטע ההרשאות הנדרשות:

ההרשאות הנדרשות

כדי לראות את המקומות השמורים או את הבקשות למקומות שמורים לעתיד, צריך את ההרשאות הבאות:

  • כדי לראות רשימה של מקומות שמורים: ‫compute.reservations.list בפרויקט
  • כדי לראות את רשימת הבקשות למקומות שמורים לעתיד: compute.futureReservations.list בפרויקט
  • כדי לראות את פרטי ההזמנה: compute.reservations.get בפרויקט
  • כדי לראות את הפרטים של בקשה למקום שמור לעתיד: compute.futureReservations.get בפרויקט

יכול להיות שתקבלו את ההרשאות האלה באמצעות תפקידים בהתאמה אישית או תפקידים מוגדרים מראש אחרים.

הצגת הגדרות ההזמנה

בקטעים הבאים מוסבר איך לראות את ההגדרות של המקומות השמורים או של הבקשות למקומות שמורים לעתיד.

צפייה בהזמנות

כדי לראות את ההגדרות של הזמנה אחת או יותר, משתמשים באחת מהשיטות הבאות שמתוארות בקטע הזה:

  • כדי לראות סקירה כללית של כל ההזמנות בפרויקט, אפשר להציג רשימה של ההזמנות.

  • כדי לראות את הפרטים המלאים של הזמנה אחת, צריך לפתוח את פרטי ההזמנה.

כדי לראות את השדות deleteAtTime ו-reservationSharingPolicy (תצוגה מקדימה) בהזמנה, צריך להציג את פרטי ההזמנה באמצעות Google Cloud CLI או להציג את ההזמנות באמצעות ה-API ל-REST. אם אתם לא צריכים את השדות האלה, אתם יכולים לראות את ההזמנות באחת מהאפשרויות הבאות:

המסוף

  1. פותחים את הדף Reservations במסוף Google Cloud .

    כניסה לדף Reservations

    בכרטיסייה On-demand reservations (ברירת המחדל), בטבלה מופיעה רשימה של כל המקומות השמורים, וכל עמודה בטבלה מתארת מאפיין.

  2. אופציונלי: בטבלה מקומות שמורים על פי דרישה, מבצעים אחת מהפעולות הבאות או את שתיהן:

    • כדי להציג את מספר ההזמנות המובטחות, לוחצים על Column display options...‎, מסמנים את התיבה Assured count ולוחצים על OK.

    • כדי לצמצם את רשימת ההזמנות, בשדה Filter בוחרים את המאפיינים שלפיהם רוצים לסנן את ההזמנות.

  3. כדי לראות את פרטי ההזמנה, בעמודה Name (שם), לוחצים על שם ההזמנה. ייפתח דף עם פרטי ההזמנה.

gcloud

  • כדי לראות את רשימת ההזמנות, משתמשים בפקודה gcloud compute reservations list:

    gcloud compute reservations list
    

    הפלט אמור להיראות כך:

    NAME: r-01
    IN_USE_COUNT: 0
    COUNT: 5
    ZONE: us-central1-a
    SHARE_TYPE: LOCAL
    
    NAME: r-02
    IN_USE_COUNT: 3
    COUNT: 10
    ZONE: us-central1-f
    SHARE_TYPE: LOCAL
    

    אפשר גם לצמצם את רשימת ההזמנות באמצעות ביטוי סינון, על ידי הוספת הדגל --filter:

    gcloud compute reservations list \
        --filter="FILTER_EXPRESSION"
    

    מחליפים את FILTER_EXPRESSION בביטוי סינון.

  • כדי לראות את פרטי ההזמנה, משתמשים בפקודה gcloud compute reservations describe:

    gcloud compute reservations describe RESERVATION_NAME \
        --zone=ZONE
    

    מחליפים את מה שכתוב בשדות הבאים:

    • ‫RESERVATION_NAME: השם של הזמנה קיימת.

    • ‫ZONE: האזור שבו קיימת ההזמנה.

    הפלט אמור להיראות כך:

    creationTimestamp: '2024-10-11T03:25:23.192-07:00'
    id: '4488228526648280060'
    kind: compute#reservation
    name: r-01
    selfLink: https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-a/reservations/r-01
    shareSettings:
      shareType: LOCAL
    specificReservation:
      assuredCount: '50'
      count: '50'
      inUseCount: '25'
      instanceProperties:
        machineType: n2-standard-2
    specificReservationRequired: false
    status: READY
    zone: https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-a
    

המשך

  • כדי לראות את רשימת ההזמנות, משתמשים בדוגמת הקוד הבאה:

    // Copyright 2024 Google LLC
    //
    // Licensed under the Apache License, Version 2.0 (the "License");
    // you may not use this file except in compliance with the License.
    // You may obtain a copy of the License at
    //
    //     https://www.apache.org/licenses/LICENSE-2.0
    //
    // Unless required by applicable law or agreed to in writing, software
    // distributed under the License is distributed on an "AS IS" BASIS,
    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    // See the License for the specific language governing permissions and
    // limitations under the License.
    
    package snippets
    
    import (
    	"context"
    	"fmt"
    	"io"
    
    	compute "cloud.google.com/go/compute/apiv1"
    	computepb "cloud.google.com/go/compute/apiv1/computepb"
    	"google.golang.org/api/iterator"
    )
    
    // Get list of reservations for given project in particular zone
    func listReservations(w io.Writer, projectID, zone string) error {
    	// projectID := "your_project_id"
    	// zone := "us-west3-a"
    
    	ctx := context.Background()
    	reservationsClient, err := compute.NewReservationsRESTClient(ctx)
    	if err != nil {
    		return err
    	}
    	defer reservationsClient.Close()
    
    	req := &computepb.ListReservationsRequest{
    		Project: projectID,
    		Zone:    zone,
    	}
    
    	it := reservationsClient.List(ctx, req)
    	fmt.Fprintf(w, "Instances found in zone %s:\n", zone)
    	for {
    		instance, err := it.Next()
    		if err == iterator.Done {
    			break
    		}
    		if err != nil {
    			return err
    		}
    		fmt.Fprintf(w, "- %s %d\n", instance.GetName(), instance.GetSpecificReservation().GetCount())
    	}
    
    	return nil
    }
    
    
  • כדי לראות את פרטי ההזמנה, אפשר להשתמש בדוגמת הקוד הבאה:

    // Copyright 2024 Google LLC
    //
    // Licensed under the Apache License, Version 2.0 (the "License");
    // you may not use this file except in compliance with the License.
    // You may obtain a copy of the License at
    //
    //     https://www.apache.org/licenses/LICENSE-2.0
    //
    // Unless required by applicable law or agreed to in writing, software
    // distributed under the License is distributed on an "AS IS" BASIS,
    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    // See the License for the specific language governing permissions and
    // limitations under the License.
    
    package snippets
    
    import (
    	"context"
    	"fmt"
    	"io"
    
    	compute "cloud.google.com/go/compute/apiv1"
    	computepb "cloud.google.com/go/compute/apiv1/computepb"
    )
    
    // Get certain reservation for given project and zone
    func getReservation(w io.Writer, projectID, zone, reservationName string) (*computepb.Reservation, error) {
    	// projectID := "your_project_id"
    	// zone := "us-west3-a"
    	// reservationName := "your_reservation_name"
    
    	ctx := context.Background()
    	reservationsClient, err := compute.NewReservationsRESTClient(ctx)
    	if err != nil {
    		return nil, err
    	}
    	defer reservationsClient.Close()
    
    	req := &computepb.GetReservationRequest{
    		Project:     projectID,
    		Reservation: reservationName,
    		Zone:        zone,
    	}
    
    	reservation, err := reservationsClient.Get(ctx, req)
    	if err != nil {
    		return nil, fmt.Errorf("unable to delete reservation: %w", err)
    	}
    
    	fmt.Fprintf(w, "Reservation: %s\n", reservation.GetName())
    
    	return reservation, nil
    }
    
    

Java

  • כדי להציג רשימה של ההזמנות, השתמשו בדוגמת הקוד הבאה:

    /*
     * Copyright 2024 Google LLC
     *
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     *   http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     */
    
    package compute.reservation;
    
    import com.google.cloud.compute.v1.Reservation;
    import com.google.cloud.compute.v1.ReservationsClient;
    import java.io.IOException;
    import java.util.ArrayList;
    import java.util.List;
    
    public class ListReservations {
    
      public static void main(String[] args) throws IOException {
        // TODO(developer): Replace these variables before running the sample.
        // Project ID or project number of the Cloud project you want to use.
        String project = "YOUR_PROJECT_ID";
        // Zone in which reservations are located.
        String zone = "us-central1-a";
    
        listReservations(project, zone);
      }
    
      // List all reservations in the given project and zone.
      public static List<Reservation> listReservations(String project, String zone) throws IOException {
        // Initialize client that will be used to send requests. This client only needs to be created
        // once, and can be reused for multiple requests.
        List<Reservation> listOfReservations = new ArrayList<>();
    
        try (ReservationsClient reservationsClient = ReservationsClient.create()) {
          for (Reservation reservation : reservationsClient.list(project, zone).iterateAll()) {
            listOfReservations.add(reservation);
            System.out.println("Reservation: " + reservation.getName());
          }
        }
        return listOfReservations;
      }
    }
  • כדי להציג את פרטי ההזמנה, השתמשו בדוגמת הקוד הבאה:

    /*
     * Copyright 2024 Google LLC
     *
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     */
    
    package compute.reservation;
    
    import com.google.cloud.compute.v1.Reservation;
    import com.google.cloud.compute.v1.ReservationsClient;
    import java.io.IOException;
    import java.util.concurrent.ExecutionException;
    import java.util.concurrent.TimeoutException;
    
    public class GetReservation {
    
      public static void main(String[] args)
          throws IOException, ExecutionException, InterruptedException, TimeoutException {
        // TODO(developer): Replace these variables before running the sample.
        // Project ID or project number of the Cloud project you want to use.
        String projectId = "YOUR_PROJECT_ID";
        // Name of the zone in which you want to create the reservation.
        String zone = "us-central1-a";
        // Name of the reservation you want to create.
        String reservationName = "test-reservation-name";
    
        getReservation(projectId, reservationName, zone);
      }
    
      // Retrieve a reservation with the given name in the given zone.
      public static Reservation getReservation(
          String projectId, String reservationName, String zone)
          throws IOException {
        // Initialize client that will be used to send requests. This client only needs to be created
        // once, and can be reused for multiple requests.
        try (ReservationsClient reservationsClient = ReservationsClient.create()) {
    
          // Get the reservation.
          Reservation reservation = reservationsClient.get(projectId, zone, reservationName);
    
          System.out.println("Reservation: " + reservation.getName());
          return reservation;
        }
      }
    }

Node.js

  • כדי להציג רשימה של ההזמנות, השתמשו בדוגמת הקוד הבאה:

    /*
     * Copyright 2024 Google LLC
     *
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     *     https://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     */
    
    'use strict';
    
    async function main() {
      // Import the Compute library
      const computeLib = require('@google-cloud/compute');
    
      // Instantiate a reservationsClient
      const reservationsClient = new computeLib.ReservationsClient();
    
      /**
       * TODO(developer): Update these variables before running the sample.
       */
      // The ID of the project where your reservations are located.
      const projectId = await reservationsClient.getProjectId();
      // The zone where your reservations are located.
      const zone = 'us-central1-a';
    
      async function callGetReservations() {
        const reservations = (
          await reservationsClient.list({
            project: projectId,
            zone,
          })
        )[0];
    
        console.log(JSON.stringify(reservations));
      }
    
      await callGetReservations();
    }
    
    main().catch(err => {
      console.error(err);
      process.exitCode = 1;
    });
    
  • כדי להציג את פרטי ההזמנה, השתמשו בדוגמת הקוד הבאה:

    /*
     * Copyright 2024 Google LLC
     *
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     *     https://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     */
    
    'use strict';
    
    async function main(reservationName) {
      // Import the Compute library
      const computeLib = require('@google-cloud/compute');
    
      // Instantiate a reservationsClient
      const reservationsClient = new computeLib.ReservationsClient();
    
      /**
       * TODO(developer): Update/uncomment these variables before running the sample.
       */
      // The ID of the project where your reservation is located.
      const projectId = await reservationsClient.getProjectId();
      // The zone where your reservation is located.
      const zone = 'us-central1-a';
      // The name of the reservation to return.
      // reservationName = 'reservation-01';
    
      async function callGetReservation() {
        const requestedReservation = (
          await reservationsClient.get({
            project: projectId,
            zone,
            reservation: reservationName,
          })
        )[0];
    
        console.log(JSON.stringify(requestedReservation));
      }
    
      await callGetReservation();
    }
    
    main(...process.argv.slice(2)).catch(err => {
      console.error(err);
      process.exitCode = 1;
    });
    

Python

  • כדי להציג רשימה של ההזמנות, השתמשו בדוגמת הקוד הבאה:

    # Copyright 2024 Google LLC
    #
    # Licensed under the Apache License, Version 2.0 (the "License");
    # you may not use this file except in compliance with the License.
    # You may obtain a copy of the License at
    #
    #    https://www.apache.org/licenses/LICENSE-2.0
    #
    # Unless required by applicable law or agreed to in writing, software
    # distributed under the License is distributed on an "AS IS" BASIS,
    # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    # See the License for the specific language governing permissions and
    # limitations under the License.
    
    
    # This file is automatically generated. Please do not modify it directly.
    # Find the relevant recipe file in the samples/recipes or samples/ingredients
    # directory and apply your changes there.
    
    
    from google.cloud import compute_v1
    from google.cloud.compute_v1.services.reservations.pagers import ListPager
    
    
    def list_compute_reservation(project_id: str, zone: str = "us-central1-a") -> ListPager:
        """
        Lists all compute reservations in a specified Google Cloud project and zone.
        Args:
            project_id (str): The ID of the Google Cloud project.
            zone (str): The zone of the reservations.
        Returns:
            ListPager: A pager object containing the list of reservations.
        """
    
        client = compute_v1.ReservationsClient()
    
        reservations_list = client.list(
            project=project_id,
            zone=zone,
        )
    
        for reservation in reservations_list:
            print("Name: ", reservation.name)
            print(
                "Machine type: ",
                reservation.specific_reservation.instance_properties.machine_type,
            )
        # Example response:
        # Name:  my-reservation_1
        # Machine type:  n1-standard-1
        # Name:  my-reservation_2
        # Machine type:  n1-standard-1
    
        return reservations_list
    
    
    
  • כדי לראות את פרטי ההזמנה, משתמשים בדוגמת הקוד הבאה:

    # Copyright 2024 Google LLC
    #
    # Licensed under the Apache License, Version 2.0 (the "License");
    # you may not use this file except in compliance with the License.
    # You may obtain a copy of the License at
    #
    #    https://www.apache.org/licenses/LICENSE-2.0
    #
    # Unless required by applicable law or agreed to in writing, software
    # distributed under the License is distributed on an "AS IS" BASIS,
    # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    # See the License for the specific language governing permissions and
    # limitations under the License.
    
    
    # This file is automatically generated. Please do not modify it directly.
    # Find the relevant recipe file in the samples/recipes or samples/ingredients
    # directory and apply your changes there.
    
    
    from google.cloud import compute_v1
    from google.cloud.compute_v1.types import compute
    
    
    def get_compute_reservation(
        project_id: str,
        zone: str = "us-central1-a",
        reservation_name="your-reservation-name",
    ) -> compute.Reservation:
        """
        Retrieves a compute reservation from GCP.
        Args:
            project_id (str): The ID of the Google Cloud project.
            zone (str): The zone of the reservation.
            reservation_name (str): The name of the reservation to retrieve.
        Returns:
            compute.Reservation: The reservation object retrieved from Google Cloud.
        """
    
        client = compute_v1.ReservationsClient()
    
        reservation = client.get(
            project=project_id,
            zone=zone,
            reservation=reservation_name,
        )
    
        print("Name: ", reservation.name)
        print("STATUS: ", reservation.status)
        print(reservation.specific_reservation)
        # Example response:
        # Name:  your-reservation-name
        # STATUS:  READY
        # count: 3
        # instance_properties {
        #   machine_type: "n1-standard-1"
        #   local_ssds {
        #     disk_size_gb: 375
        #     interface: "NVME"
        #   }
        # ...
    
        return reservation
    
    
    

REST

  • כדי לראות רשימה של ההזמנות, שולחים בקשת GET ל-method‏ reservations.list:

    GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/reservations
    

    מחליפים את מה שכתוב בשדות הבאים:

    • ‫PROJECT_ID: מזהה הפרויקט שבו יצרתם את ההזמנות.

    • ‫ZONE: האזור שבו קיימות ההזמנות.

    הפלט אמור להיראות כך:

    {
      "kind": "compute#reservation",
      "id": "4100668622331754141",
      "creationTimestamp": "2019-09-27T08:21:14.707-07:00",
      "selfLink": "https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-a/reservations/reservation-05",
      "zone": "https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-a",
      "name": "reservation-05",
      "specificReservation": {
        "instanceProperties": {
          "machineType": "n1-standard-2"
        },
        "count": "100",
        "inUseCount": "0",
        "assuredCount": "100"
      },
      "specificReservationRequired": false,
      "status": "READY",
      "shareSettings": {
        "shareType": "LOCAL"
      }
    },
    {
      "kind": "compute#reservation",
      "id": "2533514314332214789",
      "creationTimestamp": "2019-09-27T08:21:14.707-07:00",
      "selfLink": "https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-a/reservations/reservation-04",
      "zone": "https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-a",
      "name": "reservation-04",
      "specificReservation": {
        "instanceProperties": {
          "machineType": "n1-standard-2",
          "guestAccelerators": [
            {
              "acceleratorType": "nvidia-tesla-t4",
              "acceleratorCount": 1
            }
          ],
          "localSsds": [
            {
              "diskSizeGb": "375",
              "interface": "SCSI"
            }
          ]
        },
        "count": "50",
        "inUseCount": "25",
        "assuredCount": "50"
      },
      "specificReservationRequired": false,
      "status": "READY",
      "shareSettings": {
        "shareType": "LOCAL"
      }
    }
    

    אם רוצים לצמצם את רשימת ההזמנות באמצעות ביטוי סינון, מוסיפים את פרמטר השאילתה filter:

    GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/reservations?filter=FILTER_EXPRESSION
    

    מחליפים את FILTER_EXPRESSION בביטוי מסנן שמשתמש בערכים בקידוד URL.

  • כדי לראות את פרטי ההזמנה, שולחים בקשת GET ל-method‏ reservations.get.

    GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/reservations/RESERVATION_NAME
    

    מחליפים את מה שכתוב בשדות הבאים:

    • ‫PROJECT_ID: מזהה הפרויקט שבו יצרתם את ההזמנה.

    • ‫ZONE: האזור שבו נמצאת ההזמנה.

    • ‫RESERVATION_NAME: השם של הזמנה קיימת.

    הפלט אמור להיראות כך:

    {
      "kind": "compute#reservation",
      "id": "4488228526648280060",
      "creationTimestamp": "2024-10-11T03:25:23.192-07:00",
      "selfLink": "https://www.googleapis.com/compute/v1/projects/davide-experimental/zones/us-central1-a/reservations/r-01",
      "zone": "https://www.googleapis.com/compute/v1/projects/davide-experimental/zones/us-central1-a",
      "name": "r-01",
      "specificReservation": {
        "instanceProperties": {
          "machineType": "n2-standard-2"
        },
        "count": "50",
        "inUseCount": "25",
        "assuredCount": "50"
      },
      "specificReservationRequired": false,
      "status": "READY",
      "shareSettings": {
        "shareType": "LOCAL"
      }
    }
    

הצגת בקשות למקום שמור לעתיד

כדי לראות את ההגדרות של בקשה אחת או יותר למקומות שמורים לעתיד, אתם יכולים להשתמש באחת מהשיטות הבאות:

  • כדי לראות סקירה כללית של כל מקומות שמורים לעתיד בפרויקט, אפשר לעיין ברשימת הבקשות.

  • כדי לראות את הפרטים המלאים של בקשה אחת למקום שמור לעתיד, פותחים את פרטי הבקשה.

כדי לראות את הבקשות למקומות שמורים לעתיד, בוחרים באחת מהאפשרויות הבאות:

המסוף

  1. פותחים את הדף Reservations במסוף Google Cloud .

    כניסה לדף Reservations

  2. לוחצים על הכרטיסייה Future reservations.

    בטבלה מפורטת כל בקשה למקום שמור לעתיד, ובכל עמודה בטבלה מתואר מאפיין.

  3. אופציונלי: כדי לצמצם את רשימת הבקשות, בשדה Filter בוחרים את המאפיינים שלפיהם רוצים לסנן את הבקשות.

  4. כדי לראות את פרטי הבקשה, בעמודה Name, לוחצים על שם הבקשה. ייפתח דף עם פרטי הבקשה למקום שמור לעתיד.

gcloud

  • כדי להציג רשימה של בקשות למקום שמור לעתיד, משתמשים בפקודה gcloud compute future-reservations list:

    gcloud compute future-reservations list
    

    הפלט אמור להיראות כך:

    NAME: fr-04
    TOTAL_COUNT: 100
    START_TIME: 2025-07-20T07:00:00Z
    END_TIME: 2025-08-05T07:00:00Z
    PROCUREMENT_STATUS: FULFILLED
    ZONE: us-east1-a
    
    NAME: fr-05
    TOTAL_COUNT: 10
    START_TIME: 2025-07-20T07:00:00Z
    END_TIME: 2025-12-01T00:00:00Z
    PROCUREMENT_STATUS: PENDING_APPROVAL
    ZONE: us-west1-c
    

    אופציונלי: כדי לצמצם את רשימת הבקשות למקום שמור לעתיד באמצעות ביטוי סינון, מוסיפים את הדגל --filter:

    gcloud compute future-reservations list \
        --filter="FILTER_EXPRESSION"
    

    מחליפים את FILTER_EXPRESSION בביטוי סינון.

  • כדי לראות את הפרטים של בקשה למקום שמור לעתיד, משתמשים בפקודה gcloud compute future-reservations describe:

    gcloud compute future-reservations describe FUTURE_RESERVATION_NAME \
        --zone=ZONE
    

    מחליפים את מה שכתוב בשדות הבאים:

    • ‫FUTURE_RESERVATION_NAME: השם של בקשה קיימת למקום שמור לעתיד.

    • ‫ZONE: האזור שבו קיימת הבקשה למקום שמור לעתיד.

    הפלט אמור להיראות כך:

    autoCreatedReservationsDeleteTime: '2025-05-02T01:00:00Z'
    creationTimestamp: '2025-03-23T10:08:31.613-07:00'
    id: '5212276518668495076'
    kind: compute#futureReservation
    name: fr-01
    planningStatus: SUBMITTED
    selfLink: https://www.googleapis.com/compute/v1/projects/example-project/zones/us-central1-a/futureReservations/fr-01
    selfLinkWithId: https://www.googleapis.com/compute/v1/projects/example-project/zones/us-central1-a/futureReservations/5212276518668495076
    shareSettings:
      shareType: LOCAL
    specificSkuProperties:
      instanceProperties:
        machineType: n1-standard-64
      totalCount: '800'
    status:
      existingMatchingUsageInfo:
        count: '3'
        timestamp: '2025-03-30T01:00:00Z'
      lockTime: '2025-03-30T17:09:59.297799Z'
      procurementStatus: APPROVED
    timeWindow:
      endTime: '2025-05-02T01:00:00Z'
      startTime: '2025-04-30T17:30:00Z'
    zone: https://www.googleapis.com/compute/v1/projects/example-project/zones/us-central1-a
    

REST

  • כדי לראות רשימה של הבקשות למקומות שמורים לעתיד, שולחים בקשת GET אל ה-method‏ futureReservations.list:

    GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/futureReservations
    

    מחליפים את מה שכתוב בשדות הבאים:

    • ‫PROJECT_ID: המזהה של הפרויקט שבו יצרתם את בקשות המקום השמור לעתיד.

    • ‫ZONE: האזור שבו נמצאות הבקשות למקומות שמורים לעתיד.

    הפלט אמור להיראות כך:

    {
      "id": "projects/my-project/zones/us-east1-a/futureReservations",
      "items": [
        {
          "id": "743865190848184978",
          "creationTimestamp": "2025-03-23T18:16:45.274-07:00",
          "selfLink": "https://www.googleapis.com/compute/v1/projects/my-project/zones/us-east1-a/futureReservations/fr-base",
          "selfLinkWithId": "https://www.googleapis.com/compute/v1/projects/my-project/zones/us-east1-a/futureReservations/743865190848184978",
          "zone": "https://www.googleapis.com/compute/v1/projects/my-project/zones/us-east1-a",
          "name": "fr-base",
          "specificSkuProperties": {
            "instanceProperties": {
              "machineType": "n1-standard-1"
            },
            "totalCount": "100"
          },
          "planningStatus": "SUBMITTED",
          "timeWindow": {
            "endTime": "2025-05-02T01:00:00Z",
            "startTime": "2025-04-30T17:30:00Z"
          },
          "status": {
            "procurementStatus": "FULFILLED",
            "lockTime": "2025-03-30T07:00:00Z",
            "existingMatchingUsageInfo": {
              "count": "3",
              "timestamp": "2025-03-30T01:00:00Z"
            }
          },
          "kind": "compute#futureReservation"
        },
        ...
      ],
      "selfLink": "https://www.googleapis.com/compute/v1/projects/my-project/zones/us-east1-a/futureReservations",
      "etag": "AnzKY34l-cvvV-JnniESJ0dtQvQ=/hvc4jaHpxFAZmOt1FVtKNgzZu-M=",
      "kind": "compute#futureReservationsListResponse"
    }
    

    אופציונלי: כדי לשפר רשימה של בקשות להזמנות עתידיות באמצעות ביטוי סינון, כוללים את filter הפרמטר של שאילתה:

    GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/aggregated/futureReservations?filter=FILTER_EXPRESSION
    

    מחליפים את FILTER_EXPRESSION בביטוי סינון שמשתמש בערכים בקידוד URL.

  • כדי לראות את הפרטים של בקשה למקום שמור לעתיד, שולחים בקשת GET ל-method‏ futureReservations.get:

    GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/futureReservations/FUTURE_RESERVATION_NAME
    

    מחליפים את מה שכתוב בשדות הבאים:

    • ‫PROJECT_ID: מזהה הפרויקט שבו יצרתם את בקשת המקום השמור לעתיד.

    • ‫ZONE: האזור שבו קיימת הבקשה למקום שמור לעתיד.

    • ‫FUTURE_RESERVATION_NAME: השם של בקשה קיימת למקום שמור לעתיד.

    הפלט אמור להיראות כך:

    {
      "autoCreatedReservationsDeleteTime": "2025-05-02T01:00:00Z",
      "creationTimestamp": "2025-03-23T10:08:31.613-07:00",
      "id": "5212276518668495076",
      "kind": "compute#futureReservation",
      "name": "fr-01",
      "planningStatus": "SUBMITTED",
      "selfLink": "https://www.googleapis.com/compute/v1/projects/example-project/zones/us-central1-a/futureReservations/fr-01",
      "selfLinkWithId": "https://www.googleapis.com/compute/v1/projects/example-project/zones/us-central1-a/futureReservations/5212276518668495076",
      "shareSettings": {
        "shareType": "LOCAL"
      },
      "specificSkuProperties": {
        "instanceProperties": {
          "machineType": "n1-standard-64"
        },
        "totalCount": "800"
      },
      "status": {
        "lockTime": "2025-03-30T17:09:59.297799Z",
        "procurementStatus": "APPROVED",
        "existingMatchingUsageInfo": {
          "count": "3",
          "timestamp": "2025-03-30T01:00:00Z"
        }
      },
      "timeWindow": {
        "endTime": "2025-05-02T01:00:00Z",
        "startTime": "2025-04-30T17:30:00Z"
      },
      "zone": "https://www.googleapis.com/compute/v1/projects/example-project/zones/us-central1-a"
    }
    

קביעת מספר המופעים שניתן להשתמש בהם

כדי לקבוע את מספר המכונות לחישוב שיכולות לנצל את הקיבולת המוזמנת, אפשר לבצע אחת מהפעולות הבאות:

מופעים מתכלים בהזמנה

כשמציגים את פרטי ההזמנה, אפשר לראות כמה מכונות צורכות את ההזמנה וכמה מכונות יכולות לצרוך אותה, על ידי בדיקת השדות הבאים:

  • מספר מובטח (assuredCount): מספר המכונות שמוזמנות פיזית באזור של ההזמנה. המספר הזה כולל את המכונות ששמורות לפרויקט שלכם, ולכל פרויקט ששותפה איתו הזמנה משותפת.

  • ‫Total count (count): מספר המכונות השמורות שצוינו בהזמנה. המספר הזה צריך להיות זהה למספר המובטח.

  • ‫Machines in use (inUseCount): מספר המכונות שפועלות בפרויקט, או בפרויקט שההזמנה המשותפת משותפת איתו, שצורכות את ההזמנה.

לדוגמה, אם המספר המובטח (assuredCount) והמספר הכולל (count) הם 50, ומספר המכונות שצורכות את ההזמנה (inUseCount) הוא 25, אז 25 מכונות נוספות יכולות לצרוך את ההזמנה לפני שהיא תנוצל במלואה.

מכונות שניתן להשתמש בהן בבקשה למקום שמור לעתיד

אתם יכולים לראות את מספר המכונות ש-Compute Engine מתכנן לשריין בשעת ההתחלה של בקשה למקום שמור לעתיד שנמצאת בטיוטה, בהמתנה או שאושרה.

המספר הזה תלוי בזיקה להזמנה של הבקשה:

  • ‫Automatically consumed reservations: כדי לקבוע את המספר הזה, מבצעים את הפעולות הבאות:

    1. תוכלו לראות כמה מופעים פעילים והזמנות שלא נוצלו בפרויקט שלכם ובפרויקטים של צרכנים תואמים למאפייני הבקשה.

    2. מחסירים את מספר ההתאמות מהמספר הכולל (total count) בבקשה.

  • Specifically targeted reservations: המספר הזה שווה למספר הכולל בבקשה למקום שמור לעתיד. ‫Compute Engine לא מפחית את מספר המכונות הווירטואליות הפעילות או את מספר ההזמנות הקיימות.

אתם יכולים לקבוע את מספר המכונות שניתן לצרוך לבקשה אחת או לכמה בקשות בבת אחת. כדי לשלוח כמה בקשות, צריך להשתמש Google Cloud במסוף או ב-API בארכיטקטורת REST. לבקשות בודדות, בוחרים אחת מהאפשרויות הבאות:

המסוף

  1. פותחים את הדף Reservations במסוף Google Cloud .

    כניסה לדף Reservations

  2. לוחצים על הכרטיסייה Future reservations. בטבלה מפורטות כל הבקשות למקומות שמורים לעתיד, וכל עמודה בטבלה מתארת מאפיין.

  3. כדי לקבוע את מספר המכונות ש-Compute Engine מתכנן לשמור בשעת ההתחלה, מבצעים אחת מהפעולות הבאות:

    • בקשות שנוצלו באופן אוטומטי: מחסירים את הערך בעמודה Matching count מהערך בעמודה Total count. בהתאם למספר הכולל, בעמודה Matching count תופיע אחת מהאזהרות הבאות:

      • מספר ההתאמות הוא אפס: אין בפרויקט מכונות תואמות שפועלות או הזמנות שלא נוצלו, או בכל פרויקט אחר שהבקשה משותפת איתו.

      • מספר המכונות התואמות שווה למספר הכולל: המערכת של Compute Engine לא תשמור מכונות לבקשה שלכם בשעת ההתחלה שלה.

      אם משנים בקשה או יוצרים מופעים או הזמנות חדשים שתואמים לבקשה, מערכת Compute Engine מעדכנת את העמודה מספר התוצאות התואמות תוך 30 דקות.

    • הזמנות שמטורגטות באופן ספציפי: בודקים את העמודה Total count. מערכת Compute Engine מקצה את המספר המלא הזה.

  4. אופציונלי: כדי לבדוק מתי העמודה Matching count עודכנה לאחרונה בבקשה, מבצעים את הפעולות הבאות:

    1. בעמודה Name, לוחצים על שם הבקשה. ייפתח דף עם פרטי הבקשה למקום שמור לעתיד.

    2. בקטע Resource details, בודקים את השדה Last matching usage evaluation time.

gcloud

  1. כדי לראות את הפרטים של בקשה למקום שמור לעתיד, משתמשים בפקודה gcloud compute future-reservations describe:

    gcloud compute future-reservations describe FUTURE_RESERVATION_NAME \
        --zone=ZONE
    

    מחליפים את מה שכתוב בשדות הבאים:

    • ‫FUTURE_RESERVATION_NAME: השם של בקשה קיימת למקום שמור לעתיד.

    • ‫ZONE: האזור שבו נמצאת הבקשה למקום שמור לעתיד.

    בפלט, מחפשים את השדות count ו-totalCount:

    ...
    specificSkuProperties:
      ...
      totalCount: '100'
    status:
      existingMatchingUsageInfo:
        count: '50'
        timestamp: '2025-03-30T01:00:00Z'
      ...
      procurementStatus: DRAFTING
    ...
    
  2. מחשבים את מספר המכונות שניתן להשתמש בהן ש-Compute Engine מתכנן לשריין בשעת ההתחלה של הבקשה על סמך ההתאמה של המקום השמור:

    • בקשות שנוצלו באופן אוטומטי: מחסירים את count מ-totalCount. לדוגמה, אם הערך של count הוא 50 והערך של totalCount הוא 100, אז Compute Engine מתכנן להקצות 50 מכונות בזמן ההתחלה. אם משנים את הבקשה, או יוצרים מכונות או הזמנות חדשות שתואמות לבקשה, מערכת Compute Engine מעדכנת את השדה existingMatchingUsageInfo תוך 30 דקות. כדי לבדוק מתי השדה הזה עודכן לאחרונה, בודקים את הערך של existingMatchingUsageInfo.timestamp.

    • הזמנות שמכוונות למשאבים ספציפיים: מערכת Compute Engine מתכננת להזמין את הערך שצוין בשדה totalCount בשעת ההתחלה של הבקשה.

REST

  1. כדי לראות רשימה של הבקשות למקומות שמורים לעתיד, שולחים בקשת GET אל ה-method‏ futureReservations.list. בכתובת ה-URL של הבקשה, כוללים את הפרמטר של השאילתה filter ומציינים שרוצים להציג רק את השדות name,‏ specificSkuProperties ו-status:

    GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/futureReservations?fields=items.name,items.specificSkuProperties,items.status
    

    מחליפים את מה שכתוב בשדות הבאים:

    • ‫PROJECT_ID: מזהה הפרויקט שבו יצרתם את הבקשות למקומות שמורים לעתיד.

    • ‫ZONE: האזור שבו נמצאת הבקשה למקום שמור לעתיד.

    בפלט, מחפשים את השדות count ו-totalCount לכל טיוטה, בקשה בהמתנה לאישור או בקשה שאושרה:

    {
      "items": [
        {
          "specificSkuProperties": {
            ...
            totalCount: "100"
          },
          "name": "fr-01",
          "status": {
            "procurementStatus": "APPROVED",
            ...
            existingMatchingUsageInfo: {
              count: "50",
              "timestamp": "2025-01-22T07:54:26.295Z"
            }
          }
        },
        {
          "specificSkuProperties": {
            ...
            totalCount: "20"
          },
          "name": "fr-02",
          "status": {
            "procurementStatus": "DRAFTING",
            ...
            existingMatchingUsageInfo: {
              "count": "2",
              "timestamp": "2025-01-22T07:54:26.295Z"
            }
          }
        }
      ]
    }
    
  2. מחשבים את מספר המכונות שניתן להשתמש בהן ש-Compute Engine מתכנן לשריין בשעת ההתחלה של הבקשה על סמך ההתאמה של המקום השמור:

    • בקשות שנצרכו אוטומטית: מחסרים את count מ-totalCount. לדוגמה, אם count הוא 50 ו-totalCount הוא 100, מערכת Compute Engine מתכננת לשריין 50 מכונות וירטואליות בשעת ההתחלה. אם משנים את הבקשה, או יוצרים מכונות או הזמנות חדשות שתואמות לבקשה, מערכת Compute Engine מעדכנת את השדה existingMatchingUsageInfo תוך 30 דקות. כדי לבדוק מתי השדה הזה עודכן לאחרונה, בודקים את הערך של existingMatchingUsageInfo.timestamp.

    • הזמנות שמכוונות למשאבים ספציפיים: מערכת Compute Engine מתכננת להזמין את הערך שצוין בשדה totalCount בשעת ההתחלה של הבקשה.

מכונות שניתנות לשימוש בבקשה למקום שמור לעתיד במצב לוח שנה

כשפותחים את הפרטים של בקשה לשמירת מקום לעתיד, אפשר לראות כמה מכונות וירטואליות של Compute Engine מתוכננות להקצאה בזמן ההתחלה של הבקשה. המערכת של Compute Engine יוצרת את מספר המכונות שצוין בבקשה, בלי קשר למספר המכונות התואמות בפרויקט שלכם או בכל פרויקט שהבקשה משותפת איתו.

איך רואים את נתוני הצריכה של הזמנות

בכל פעם שמכונה לצורכי מחשוב צורכת הזמנה, אפשר לראות את הפרטים הבאים:

איך רואים את ההזמנה שבה המכונה משתמשת

כדי לראות את ההזמנה שמופעלת על ידי מופע, בוחרים באחת מהאפשרויות הבאות:

המסוף

  1. נכנסים לדף VM instances במסוף Google Cloud .

    כניסה לדף VM instances

  2. לוחצים על שם המכונה שמשתמשת בהזמנה שרוצים לראות.

  3. בקטע Basic information, בשדה Consumed reservation מופיע שם המכונה שמשתמשת במשאבים שהוקצו.

gcloud

כדי לראות את ההזמנה שמוקצה למכונה, משתמשים בפקודה gcloud compute instances describe עם הדגל --flatten=resourceStatus.reservationConsumptionInfo:

gcloud compute instances describe INSTANCE_NAME \
    --flatten=resourceStatus.reservationConsumptionInfo \
    --zone=ZONE

מחליפים את מה שכתוב בשדות הבאים:

  • ‫INSTANCE_NAME: שם המכונה.
  • ‫ZONE: האזור שבו נמצאת המכונה.

הפלט אמור להיראות כך:

consumedReservation: https://www.googleapis.com/compute/v1/projects/example-project/zones/us-central1-c/reservations/example-reservation

REST

כדי לראות את המקום השמור שהמכונה צורכת, שולחים בקשת GET אל ה-method‏ instances.get. בכתובת ה-URL של הבקשה, מוסיפים את פרמטר השאילתה fields שמוגדר לערך resourceStatus.reservationConsumptionInfo:

GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/INSTANCE_NAME?fields=resourceStatus.reservationConsumptionInfo

מחליפים את מה שכתוב בשדות הבאים:

  • ‫PROJECT_ID: מזהה הפרויקט שבו נמצא המכונה.
  • ‫ZONE: האזור שבו נמצאת המכונה.
  • ‫INSTANCE_NAME: השם של המכונה.

התגובה אמורה להיראות כך:

{
  "resourceStatus": {
    "reservationConsumptionInfo": {
      "consumedReservation": "https://www.googleapis.com/compute/v1/projects/example-project/zones/us-central1-a/reservations/example-reservation"
    }
  }
}

צפייה ברשימת המכונות הווירטואליות שצורכות הזמנה

אפשר לראות רשימה של מופעים שצורכים הזמנה בפרויקט יחיד. במקומות שמורים משותפים, ה-method הזו מחזירה רק את המכונות בפרויקט שציינתם, ולא כוללת מכונות מפרויקטים אחרים של צרכנים שצורכים את אותו מקום שמור.

כדי לראות את המכונות שצורכות מקום שמור, בוחרים באחת מהאפשרויות הבאות:

gcloud

כדי לראות את המכונות הווירטואליות שצורכות את ההזמנה, משתמשים בפקודה gcloud compute instances list עם הדגל --filter שמוגדר להזמנה שרוצים לראות:

gcloud compute instances list \
    --project=CONSUMER_PROJECT_ID \
    --zones=ZONE \
    --filter="resourceStatus.reservationConsumptionInfo.consumedReservation:https://www.googleapis.com/compute/v1/projects/HOST_PROJECT_ID/zones/ZONE/reservations/RESERVATION_NAME"

מחליפים את מה שכתוב בשדות הבאים:

  • ‫CONSUMER_PROJECT_ID: מזהה הפרויקט שבו נעשה שימוש בהזמנה.
  • ‫ZONE: האזור שבו נמצאים ההזמנה והמכונות.
  • ‫HOST_PROJECT_ID: מזהה הפרויקט שבו נוצרה ההזמנה (אם הוא שונה מהפרויקט של הצרכן).
  • ‫RESERVATION_NAME: שם ההזמנה.

הפלט אמור להיראות כך:

NAME               ZONE           MACHINE_TYPE  PREEMPTIBLE  INTERNAL_IP  EXTERNAL_IP     STATUS
my-e2-instance     us-central1-c  e2-medium                  10.128.0.61  35.239.208.172  RUNNING
my-e2-instance-02  us-central1-c  e2-medium                  10.128.0.62  104.154.31.123  RUNNING
my-e2-instance-03  us-central1-c  e2-medium                  10.128.0.63  34.171.90.254   RUNNING

REST

כדי לראות את המכונות שצורכות נתונים בהזמנה, שולחים בקשת GET אל ה-method‏ instances.list. בכתובת ה-URL של הבקשה, מוסיפים את הפרמטר filter של השאילתה, מוגדר לשם ההזמנה שרוצים לראות:

GET https://compute.googleapis.com/compute/v1/projects/CONSUMER_PROJECT_ID/zones/ZONE/instances?filter=resourceStatus.reservationConsumptionInfo.consumedReservation%3D%22.*%2Fprojects%2FHOST_PROJECT_ID%2Fzones%2FZONE%2Freservations%2FRESERVATION_NAME%22

מחליפים את מה שכתוב בשדות הבאים:

  • ‫CONSUMER_PROJECT_ID: מזהה הפרויקט שבו נעשה שימוש בהזמנה.
  • ‫ZONE: האזור שבו נמצאים ההזמנה והמכונות.
  • ‫HOST_PROJECT_ID: מזהה הפרויקט שבו נוצרה ההזמנה (אם הוא שונה מהפרויקט של הצרכן).
  • ‫RESERVATION_NAME: השם של ההזמנה.

תופיע תגובה שדומה לזו:

{
  "kind": "compute#instanceList",
  "id": "projects/example-project/zones/us-central1-a/instances",
  "items": [
    {
      ...
      "name": "example-instance-01",
      ...
      "resourceStatus": {
        "scheduling": {},
        "reservationConsumptionInfo": {
          "consumedReservation": "https://www.googleapis.com/compute/v1/projects/example-project/zones/us-central1-a/reservations/example-reservation"
        }
      }
    },
    {
      ...
      "name": "example-instance-02",
      ...
      "resourceStatus": {
        "scheduling": {},
        "reservationConsumptionInfo": {
          "consumedReservation": "https://www.googleapis.com/compute/v1/projects/example-project/zones/us-central1-a/reservations/example-reservation"
        }
      },
      ...
    }
  ],
  "selfLink": "https://www.googleapis.com/compute/v1/projects/example-project/zones/us-central1-a/instances"
}

המאמרים הבאים