Skip to content

Commit

Permalink
docs(samples): Samples for custom vm types (#155)
Browse files Browse the repository at this point in the history
* chore(docs): Adding samples for Custom VM Types.

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
  • Loading branch information
3 people authored Dec 14, 2021
1 parent a5c090e commit ac01d82
Show file tree
Hide file tree
Showing 5 changed files with 736 additions and 6 deletions.
7 changes: 5 additions & 2 deletions packages/google-cloud-compute/samples/snippets/quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

# [START compute_instances_create]
# [START compute_instances_delete]
import re
import sys

# [START compute_instances_list]
Expand Down Expand Up @@ -149,8 +150,10 @@ def create_instance(
instance = compute_v1.Instance()
instance.name = instance_name
instance.disks = [disk]
full_machine_type_name = f"zones/{zone}/machineTypes/{machine_type}"
instance.machine_type = full_machine_type_name
if re.match(r"^zones/[a-z\d\-]+/machineTypes/[a-z\d\-]+$", machine_type):
instance.machine_type = machine_type
else:
instance.machine_type = f"zones/{zone}/machineTypes/{machine_type}"
instance.network_interfaces = [network_interface]

# Prepare the request to insert an instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# 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.

import re
import sys
from typing import List

Expand Down Expand Up @@ -194,8 +194,10 @@ def create_with_disks(
instance = compute_v1.Instance()
instance.name = instance_name
instance.disks = disks
full_machine_type_name = f"zones/{zone}/machineTypes/{machine_type}"
instance.machine_type = full_machine_type_name
if re.match(r"^zones/[a-z\d\-]+/machineTypes/[a-z\d\-]+$", machine_type):
instance.machine_type = machine_type
else:
instance.machine_type = f"zones/{zone}/machineTypes/{machine_type}"
instance.network_interfaces = [network_interface]

# Shielded Instance settings
Expand Down
Loading

0 comments on commit ac01d82

Please sign in to comment.