Skip to content

Commit

Permalink
few adjustments to deployment path name
Browse files Browse the repository at this point in the history
  • Loading branch information
Costya-Y committed Sep 14, 2024
1 parent 9ec97d9 commit e254cdc
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 48 deletions.
61 changes: 20 additions & 41 deletions deployments/deployment-path.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ imports:
- cloudshell_standard: cloudshell_cloud_provider_standard_1_0_1.yaml

node_types:
vendor.resource.GCP Instance From Scratch:
vendor.resource.GCP Instance From Image:
derived_from: cloudshell.nodes.CustomDeploymentOption
description: Create a single VM instance based on Public Image from scratch
description: Create a single VM instance based on certain image from scratch, supports Public, Custom and Marketplace Images
properties:
Region:
type: string
Expand Down Expand Up @@ -45,7 +45,7 @@ node_types:
Automatic Restart:
type: string
description: "Automatically restart VM instances if they are terminated for non-user-initiated reasons"
default: "On"
default: On
constraints:
- valid_values: [ On, Off ]
tags: [user_input]
Expand Down Expand Up @@ -110,16 +110,6 @@ node_types:
description: "Custom tags per instance, Comma separated values e.g:
tag_name:tag_value1,tag_name2:tag_value2"
tags: [ user_input ]
Network:
type: string
default: ""
description: "Determines what network traffic the instance can access"
tags: [ user_input ]
Sub Network:
type: string
default: ""
description: "Assigns the instance an IPv4 address from the subnetwork’s range."
tags: [ user_input ]
Custom Tags:
type: string
default: ""
Expand All @@ -140,6 +130,11 @@ node_types:
default: false
description: "If set to False the deployment will not wait for the VM to get an IP."
tags: [ user_input ]
Refresh IP Timeout:
type: integer
description: "Timeout for waiting when obtaining IP address (in seconds)"
default: 600
tags: [ user_input ]
Add Public IP:
type: boolean
default: false
Expand Down Expand Up @@ -175,7 +170,7 @@ node_types:
default: ""
description: "The code of the GCP region to be used by this cloud provider
resource. For example, 'us-central1'."
tags: [user_input]
tags: []
Zone:
type: string
default: ""
Expand All @@ -198,40 +193,14 @@ node_types:
Automatic Restart:
type: string
description: "Automatically restart VM instances if they are terminated for non-user-initiated reasons"
default: ""
default: On
constraints:
- valid_values: [ On, Off ]
tags: [user_input]
# Disk Image Type:
# type: string
# description: "Boot Disks' image type that defines whether public or custom disk image will be used"
# default: "Public"
# constraints:
# - valid_values: [ Public, Custom ]
# tags: [user_input]
OS Project:
type: string
description: "Operation System type."
default: ""
constraints:
- valid_values:
- CenOS
- Container Optimized OS
- Debian
- Deep Learning on Linux
- Fedora CoreOS
- HPC VM Image
- openSUSE
- Red Hat Enterprise Linux
- Red Hat Enterprise Linux for SAP
- Rocky Linux
- SQL Server on Windows Server
- SUSE Linux Enterprise BYOS
- SUSE Linux Enterprise Server
- SUSE Linux Enterprise for SAP
- Ubuntu
- Ubuntu Pro
- Windows Server
tags: [user_input]
Disk Image:
type: string
Expand Down Expand Up @@ -277,6 +246,11 @@ node_types:
default: false
description: "If set to False the deployment will not wait for the VM to get an IP."
tags: [ user_input ]
Refresh IP Timeout:
type: integer
description: "Timeout for waiting when obtaining IP address (in seconds)"
default: 600
tags: [ user_input ]
Add Public IP:
type: boolean
default: false
Expand Down Expand Up @@ -327,6 +301,11 @@ node_types:
default: false
description: "If set to False the deployment will not wait for the VM to get an IP."
tags: [ user_input ]
Refresh IP Timeout:
type: integer
description: "Timeout for waiting when obtaining IP address (in seconds)"
default: 600
tags: [ user_input ]
Add Public IP:
type: boolean
default: false
Expand Down
36 changes: 29 additions & 7 deletions src/driver.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import json
from typing import TYPE_CHECKING

from cloudshell.cp.core.cancellation_manager import CancellationContextManager
Expand All @@ -17,14 +18,16 @@
from cloudshell.cp.gcp.flows.prepare_infra_flow import PrepareGCPInfraFlow
from cloudshell.cp.gcp.flows.refresh_ip_flow import GCPRefreshIPFlow
from cloudshell.cp.gcp.flows.vm_details_flow import GCPGetVMDetailsFlow
from cloudshell.cp.gcp.handlers.instance import InstanceHandler
from cloudshell.cp.gcp.helpers import constants
from cloudshell.cp.gcp.models.deploy_app import GCPDeployVMRequestActions, \
InstanceFromMachineImageDeployApp, InstanceFromTemplateDeployApp, \
InstanceFromScratchDeployApp
from cloudshell.cp.gcp.models.deployed_app import (GCPDeployedVMRequestActions,
InstanceFromScratchDeployedApp,
InstanceFromTemplateDeployedApp,
InstanceFromMachineImageDeployedApp)
InstanceFromMachineImageDeployedApp,
GCPGetVMDetailsRequestActions)
from cloudshell.cp.gcp.resource_conf import GCPResourceConfig

if TYPE_CHECKING:
Expand Down Expand Up @@ -186,7 +189,24 @@ def remote_refresh_ip(self, context, ports, cancellation_context):
).refresh_ip()

def DeleteInstance(self, context, ports):
pass
"""Called during sandbox's teardown.
"""
with LoggingSessionContext(context) as logger:
logger.info("Starting Remote Refresh IP command")
api = CloudShellSessionContext(context).get_api()
resource_config = GCPResourceConfig.from_context(
context,
api=api
)
resource = context.remote_endpoints[0]
actions = GCPDeployedVMRequestActions.from_remote_resource(
resource,
api
)
instance_data = json.loads(actions.deployed_app.vmdetails.uid)
instance_data["credentials"] = resource_config.credentials
InstanceHandler.get(**instance_data).delete()

def PrepareSandboxInfra(self, context, request, cancellation_context):
"""
Expand Down Expand Up @@ -277,14 +297,16 @@ def GetVmDetails(self, context, requests, cancellation_context):
api=api
)

for deploy_app_cls in (
InstanceFromScratchDeployApp,
for deployed_app_cls in (
InstanceFromScratchDeployedApp,
InstanceFromTemplateDeployedApp,
InstanceFromMachineImageDeployedApp,
):
GetVMDetailsRequestActions.register_deployment_path(
deploy_app_cls
GCPGetVMDetailsRequestActions.register_deployment_path(
deployed_app_cls
)

request_actions = GetVMDetailsRequestActions.from_request(
request_actions = GCPGetVMDetailsRequestActions.from_request(
request=requests,
cs_api=api
)
Expand Down

0 comments on commit e254cdc

Please sign in to comment.