Skip to content

Commit

Permalink
added implementation for adding volumes to permanent workers (they ar…
Browse files Browse the repository at this point in the history
…e not deleted)
  • Loading branch information
XaverStiensmeier committed Sep 27, 2024
1 parent 9b2814a commit 0938e4c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
12 changes: 10 additions & 2 deletions bibigrid/core/actions/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,17 +235,25 @@ def start_vpn_or_master(self, configuration, provider): # pylint: disable=too-m
volume["mount_point"] = mount["mountPoint"]
self.log.debug(f"Added mount point {mount['mountPoint']} of attached volume to configuration.")

def start_workers(self, worker, worker_count, configuration, provider):
def start_workers(self, worker, worker_count, configuration, provider): # pylint: disable=too-many-locals
name = WORKER_IDENTIFIER(cluster_id=self.cluster_id, additional=worker_count)
self.log.info(f"Starting server {name} on {provider.cloud_specification['identifier']}.")
flavor = worker["type"]
network = configuration["network"]
image = image_selection.select_image(provider, worker["image"], self.log,
configuration.get("fallbackOnOtherImage"))

self.log.info("Creating volumes ...")
volumes = []
for i, attach_volume in enumerate(worker.get("attachVolumes", [])):
volume_name = f"{name}-{i}"
self.log.debug(f"Created volume {volume_name}")
volume = provider.create_volume(volume_name, attach_volume.get("size", 50))
volumes.append(volume)

# create a server and block until it is up and running
server = provider.create_server(name=name, flavor=flavor, key_name=self.key_name, image=image, network=network,
volumes=None, security_groups=configuration["security_groups"], wait=True,
volumes=volumes, security_groups=configuration["security_groups"], wait=True,
boot_from_volume=worker.get("bootFromVolume",
configuration.get("bootFromVolume", False)),
boot_volume=worker.get("bootVolume", configuration.get("bootVolume")),
Expand Down
3 changes: 3 additions & 0 deletions bibigrid/openstack/openstack_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,3 +339,6 @@ def get_server(self, name_or_id):
@return:
"""
return self.conn.get_server(name_or_id)

def create_volume(self, name, size):
return self.conn.create_volume(size, name=name)

0 comments on commit 0938e4c

Please sign in to comment.