Skip to content

Commit dc35c0b

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents 74b2273 + 482a07c commit dc35c0b

File tree

12 files changed

+1835
-7
lines changed

12 files changed

+1835
-7
lines changed

ci/scripts/test_imports.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ test_import "azure" "import dask_cloudprovider.azure"
2020
test_import "digitalocean" "import dask_cloudprovider.digitalocean"
2121
test_import "gcp" "import dask_cloudprovider.gcp"
2222
test_import "ibm" "import dask_cloudprovider.ibm"
23+
test_import "openstack" "import dask_cloudprovider.openstack"

dask_cloudprovider/cloudprovider.yaml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,18 @@ cloudprovider:
130130
worker_cpu: "2.0"
131131
worker_mem: 8G
132132
worker_threads: 1
133-
133+
134+
openstack:
135+
region: "RegionOne" # The name of the region where resources will be allocated in OpenStack. List available regions using: `openstack region list`.
136+
size: null # Openstack flavors define the compute, memory, and storage capacity of computing instances. List available flavors using: `openstack flavor list`
137+
auth_url: null # The authentication URL for the OpenStack Identity service (Keystone). Example: https://cloud.example.com:5000
138+
application_credential_id: null # The application credential id created in OpenStack. Create application credentials using: openstack application credential create
139+
application_credential_secret: null # The secret associated with the application credential ID for authentication.
140+
auth_type: "v3applicationcredential" # The type of authentication used, typically "v3applicationcredential" for using OpenStack application credentials.
141+
network_id: null # The unique identifier for the internal/private network in OpenStack where the cluster VMs will be connected. List available networks using: `openstack network list`
142+
image: null # The OS image name or id to use for the VM. List available images using: `openstack image list`
143+
keypair_name: null # The name of the SSH keypair used for instance access. Ensure you have created a keypair or use an existing one. List available keypairs using: `openstack keypair list`
144+
security_group: null # The security group name that defines firewall rules for instances. List available security groups using: `openstack security group list`
145+
external_network_id: null # The ID of the external network used for assigning floating IPs. List available external networks using: `openstack network list --external`
146+
create_floating_ip: false # Specifies whether to assign a floating IP to each instance, enabling external access. Set to `True` if external connectivity is needed.
147+
docker_image: "daskdev/dask:latest" # docker image to use

dask_cloudprovider/gcp/instances.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import json
55

66
import sqlite3
7+
from typing import Optional, Any, Dict
78

89
import dask
910
from dask.utils import tmpfile
@@ -106,7 +107,6 @@ def __init__(
106107
self.instance_labels = _instance_labels
107108

108109
self.general_zone = "-".join(self.zone.split("-")[:2]) # us-east1-c -> us-east1
109-
110110
self.service_account = service_account or self.config.get("service_account")
111111

112112
def create_gcp_config(self):
@@ -494,6 +494,8 @@ class GCPCluster(VMCluster):
494494
service_account: str
495495
Service account that all VMs will run under.
496496
Defaults to the default Compute Engine service account for your GCP project.
497+
service_account_credentials: Optional[Dict[str, Any]]
498+
Service account credentials to create the compute engine Vms
497499
498500
Examples
499501
--------
@@ -587,9 +589,10 @@ def __init__(
587589
debug=False,
588590
instance_labels=None,
589591
service_account=None,
592+
service_account_credentials: Optional[Dict[str, Any]] = None,
590593
**kwargs,
591594
):
592-
self.compute = GCPCompute()
595+
self.compute = GCPCompute(service_account_credentials)
593596

594597
self.config = dask.config.get("cloudprovider.gcp", {})
595598
self.auto_shutdown = (
@@ -641,9 +644,17 @@ def __init__(
641644

642645

643646
class GCPCompute:
644-
"""Wrapper for the ``googleapiclient`` compute object."""
647+
"""
648+
Wrapper for the ``googleapiclient`` compute object.
649+
650+
Attributes
651+
----------
652+
service_account_credentials: Optional[dict]
653+
Service account credentials to create the compute engine Vms
654+
"""
645655

646-
def __init__(self):
656+
def __init__(self, service_account_credentials: Optional[dict[str, Any]] = None):
657+
self.service_account_credentials = service_account_credentials or {}
647658
self._compute = self.refresh_client()
648659

649660
def refresh_client(self):
@@ -654,6 +665,13 @@ def refresh_client(self):
654665
os.environ["GOOGLE_APPLICATION_CREDENTIALS"],
655666
scopes=["https://www.googleapis.com/auth/cloud-platform"],
656667
)
668+
elif self.service_account_credentials:
669+
import google.oauth2.service_account # google-auth
670+
671+
creds = google.oauth2.service_account.Credentials.from_service_account_info(
672+
self.service_account_credentials,
673+
scopes=["https://www.googleapis.com/auth/cloud-platform"],
674+
)
657675
else:
658676
import google.auth.credentials # google-auth
659677

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .instances import OpenStackCluster

0 commit comments

Comments
 (0)