airflow.contrib.operators.gcp_compute_operator

Module Contents

class airflow.contrib.operators.gcp_compute_operator.GceBaseOperator(zone, resource_id, project_id=None, gcp_conn_id='google_cloud_default', api_version='v1', *args, **kwargs)[source]

Bases: airflow.models.BaseOperator

Abstract base operator for Google Compute Engine operators to inherit from.

_validate_inputs(self)[source]
execute(self, context)[source]
class airflow.contrib.operators.gcp_compute_operator.GceInstanceStartOperator(zone, resource_id, project_id=None, gcp_conn_id='google_cloud_default', api_version='v1', *args, **kwargs)[source]

Bases: airflow.contrib.operators.gcp_compute_operator.GceBaseOperator

Starts an instance in Google Compute Engine.

See also

For more information on how to use this operator, take a look at the guide: GceInstanceStartOperator

Parameters
  • zone (str) – Google Cloud Platform zone where the instance exists.

  • resource_id (str) – Name of the Compute Engine instance resource.

  • project_id (str) – Optional, Google Cloud Platform Project ID where the Compute Engine Instance exists. If set to None or missing, the default project_id from the GCP connection is used.

  • gcp_conn_id (str) – Optional, The connection ID used to connect to Google Cloud Platform. Defaults to ‘google_cloud_default’.

  • api_version (str) – Optional, API version used (for example v1 - or beta). Defaults to v1.

  • validate_body – Optional, If set to False, body validation is not performed. Defaults to False.

template_fields = ['project_id', 'zone', 'resource_id', 'gcp_conn_id', 'api_version'][source]
execute(self, context)[source]
class airflow.contrib.operators.gcp_compute_operator.GceInstanceStopOperator(zone, resource_id, project_id=None, gcp_conn_id='google_cloud_default', api_version='v1', *args, **kwargs)[source]

Bases: airflow.contrib.operators.gcp_compute_operator.GceBaseOperator

Stops an instance in Google Compute Engine.

See also

For more information on how to use this operator, take a look at the guide: GceInstanceStopOperator

Parameters
  • zone (str) – Google Cloud Platform zone where the instance exists.

  • resource_id (str) – Name of the Compute Engine instance resource.

  • project_id (str) – Optional, Google Cloud Platform Project ID where the Compute Engine Instance exists. If set to None or missing, the default project_id from the GCP connection is used.

  • gcp_conn_id (str) – Optional, The connection ID used to connect to Google Cloud Platform. Defaults to ‘google_cloud_default’.

  • api_version (str) – Optional, API version used (for example v1 - or beta). Defaults to v1.

  • validate_body – Optional, If set to False, body validation is not performed. Defaults to False.

template_fields = ['project_id', 'zone', 'resource_id', 'gcp_conn_id', 'api_version'][source]
execute(self, context)[source]
airflow.contrib.operators.gcp_compute_operator.SET_MACHINE_TYPE_VALIDATION_SPECIFICATION[source]
class airflow.contrib.operators.gcp_compute_operator.GceSetMachineTypeOperator(zone, resource_id, body, project_id=None, gcp_conn_id='google_cloud_default', api_version='v1', validate_body=True, *args, **kwargs)[source]

Bases: airflow.contrib.operators.gcp_compute_operator.GceBaseOperator

Changes the machine type for a stopped instance to the machine type specified in

the request.

See also

For more information on how to use this operator, take a look at the guide: GceSetMachineTypeOperator

Parameters
  • zone (str) – Google Cloud Platform zone where the instance exists.

  • resource_id (str) – Name of the Compute Engine instance resource.

  • body (dict) – Body required by the Compute Engine setMachineType API, as described in https://cloud.google.com/compute/docs/reference/rest/v1/instances/setMachineType#request-body

  • project_id (str) – Optional, Google Cloud Platform Project ID where the Compute Engine Instance exists. If set to None or missing, the default project_id from the GCP connection is used.

  • gcp_conn_id (str) – Optional, The connection ID used to connect to Google Cloud Platform. Defaults to ‘google_cloud_default’.

  • api_version (str) – Optional, API version used (for example v1 - or beta). Defaults to v1.

  • validate_body (bool) – Optional, If set to False, body validation is not performed. Defaults to False.

template_fields = ['project_id', 'zone', 'resource_id', 'gcp_conn_id', 'api_version'][source]
_validate_all_body_fields(self)[source]
execute(self, context)[source]
airflow.contrib.operators.gcp_compute_operator.GCE_INSTANCE_TEMPLATE_VALIDATION_PATCH_SPECIFICATION[source]
airflow.contrib.operators.gcp_compute_operator.GCE_INSTANCE_TEMPLATE_FIELDS_TO_SANITIZE = ['kind', 'id', 'name', 'creationTimestamp', 'properties.disks.sha256', 'properties.disks.kind', 'properties.disks.sourceImageEncryptionKey.sha256', 'properties.disks.index', 'properties.disks.licenses', 'properties.networkInterfaces.kind', 'properties.networkInterfaces.accessConfigs.kind', 'properties.networkInterfaces.name', 'properties.metadata.kind', 'selfLink'][source]
class airflow.contrib.operators.gcp_compute_operator.GceInstanceTemplateCopyOperator(resource_id, body_patch, project_id=None, request_id=None, gcp_conn_id='google_cloud_default', api_version='v1', validate_body=True, *args, **kwargs)[source]

Bases: airflow.contrib.operators.gcp_compute_operator.GceBaseOperator

Copies the instance template, applying specified changes.

See also

For more information on how to use this operator, take a look at the guide: GceInstanceTemplateCopyOperator

Parameters
  • resource_id (str) – Name of the Instance Template

  • body_patch (dict) – Patch to the body of instanceTemplates object following rfc7386 PATCH semantics. The body_patch content follows https://cloud.google.com/compute/docs/reference/rest/v1/instanceTemplates Name field is required as we need to rename the template, all the other fields are optional. It is important to follow PATCH semantics - arrays are replaced fully, so if you need to update an array you should provide the whole target array as patch element.

  • project_id (str) – Optional, Google Cloud Platform Project ID where the Compute Engine Instance exists. If set to None or missing, the default project_id from the GCP connection is used.

  • request_id (str) – Optional, unique request_id that you might add to achieve full idempotence (for example when client call times out repeating the request with the same request id will not create a new instance template again). It should be in UUID format as defined in RFC 4122.

  • gcp_conn_id (str) – Optional, The connection ID used to connect to Google Cloud Platform. Defaults to ‘google_cloud_default’.

  • api_version (str) – Optional, API version used (for example v1 - or beta). Defaults to v1.

  • validate_body (bool) – Optional, If set to False, body validation is not performed. Defaults to False.

template_fields = ['project_id', 'resource_id', 'request_id', 'gcp_conn_id', 'api_version'][source]
_validate_all_body_fields(self)[source]
execute(self, context)[source]
class airflow.contrib.operators.gcp_compute_operator.GceInstanceGroupManagerUpdateTemplateOperator(resource_id, zone, source_template, destination_template, project_id=None, update_policy=None, request_id=None, gcp_conn_id='google_cloud_default', api_version='beta', *args, **kwargs)[source]

Bases: airflow.contrib.operators.gcp_compute_operator.GceBaseOperator

Patches the Instance Group Manager, replacing source template URL with the destination one. API V1 does not have update/patch operations for Instance Group Manager, so you must use beta or newer API version. Beta is the default.

See also

For more information on how to use this operator, take a look at the guide: GceInstanceGroupManagerUpdateTemplateOperator

Parameters
  • resource_id (str) – Name of the Instance Group Manager

  • zone (str) – Google Cloud Platform zone where the Instance Group Manager exists.

  • source_template (str) – URL of the template to replace.

  • destination_template (str) – URL of the target template.

  • project_id (str) – Optional, Google Cloud Platform Project ID where the Compute Engine Instance exists. If set to None or missing, the default project_id from the GCP connection is used.

  • request_id (str) – Optional, unique request_id that you might add to achieve full idempotence (for example when client call times out repeating the request with the same request id will not create a new instance template again). It should be in UUID format as defined in RFC 4122.

  • gcp_conn_id (str) – Optional, The connection ID used to connect to Google Cloud Platform. Defaults to ‘google_cloud_default’.

  • api_version (str) – Optional, API version used (for example v1 - or beta). Defaults to v1.

  • validate_body (bool) – Optional, If set to False, body validation is not performed. Defaults to False.

template_fields = ['project_id', 'resource_id', 'zone', 'request_id', 'source_template', 'destination_template', 'gcp_conn_id', 'api_version'][source]
_possibly_replace_template(self, dictionary)[source]
execute(self, context)[source]

Was this entry helpful?