Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #281 from deNBI/feature/slurm
Browse files Browse the repository at this point in the history
fix(Slurm):added to config
  • Loading branch information
dweinholz authored Apr 16, 2020
2 parents c75247a + 2585f3e commit 33f2405
Show file tree
Hide file tree
Showing 8 changed files with 495 additions and 5 deletions.
42 changes: 38 additions & 4 deletions VirtualMachineService/VirtualMachineHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def __init__(self, config):
try:
self.BIBIGRID_URL = cfg["bibigrid"]["bibigrid_url"]
self.SUB_NETWORK = cfg["bibigrid"]["sub_network"]
self.BIBIGRID_MODES = cfg["bibigrid"]["bibigrid_modes"]
self.logger.info(
msg="Bibigrd url loaded: {0}".format(self.BIBIGRID_URL)
)
Expand Down Expand Up @@ -1697,6 +1698,23 @@ def add_udp_security_group(self, server_id):

return True

def detach_ip_from_server(self, server_id, floating_ip):
self.logger.info(
"Detaching floating ip {} from server {}".format(floating_ip, server_id)
)
try:
self.conn.compute.remove_floating_ip_from_server(
server=server_id, address=floating_ip
)
return True
except Exception:
self.logger.exception(
"Could not detach floating ip {} from server {}".format(
floating_ip, server_id
)
)
return False

def get_servers_by_bibigrid_id(self, bibigrid_id):
filters = {"bibigrid_id": bibigrid_id, "name": bibigrid_id}
servers = self.conn.list_servers(filters=filters)
Expand Down Expand Up @@ -1740,20 +1758,33 @@ def get_cluster_status(self, cluster_id):
response = req.get(
url=request_url, json=body, headers=headers, verify=self.PRODUCTION
)
self.logger.info("Cluster {} status: ".format(cluster_id, response.content))
self.logger.info("Cluster {} status: {} ".format(cluster_id, response.content))
return response.json()

def get_cluster_info(self, cluster_id):

def bibigrid_available(self):
if not self.BIBIGRID_URL:
return False
try:
self.get_clusters_info()
return True
except Exception:
self.logger.exception("Bibigrid is offline")
return False

def get_clusters_info(self):
headers = {"content-Type": "application/json"}
body = {"mode": "openstack"}
request_url = self.BIBIGRID_URL + "list"
self.logger.info(request_url)

response = req.get(
url=request_url, json=body, headers=headers, verify=self.PRODUCTION
)
self.logger.info(response.json())
infos = response.json()["info"]
return infos

def get_cluster_info(self, cluster_id):
infos = self.get_clusters_info()
for info in infos:
self.logger.info(cluster_id)
self.logger.info(info)
Expand Down Expand Up @@ -1802,7 +1833,10 @@ def start_cluster(self, public_key, master_instance, worker_instances, user):
"availabilityZone": self.AVAIALABILITY_ZONE,
"masterInstance": master_instance,
"workerInstances": wI,
"useMasterWithPublicIp": False
}
for mode in self.BIBIGRID_MODES:
body.update({mode: True})
request_url = self.BIBIGRID_URL + "create"
response = req.post(
url=request_url, json=body, headers=headers, verify=self.PRODUCTION
Expand Down
14 changes: 14 additions & 0 deletions VirtualMachineService/VirtualMachineService-remote
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ if len(sys.argv) <= 1 or sys.argv[1] == '--help':
print(' string add_floating_ip_to_server(string openstack_id, string network)')
print(' bool create_connection(string username, string password, string auth_url, string user_domain_name, string project_domain_name)')
print(' start_server_without_playbook(string flavor, string image, string public_key, string servername, metadata, bool https, bool http, resenv, volume_ids_path_new, volume_ids_path_attach)')
print(' bool bibigrid_available()')
print(' bool detach_ip_from_server(string server_id, string floating_ip)')
print(' start_server_with_mounted_volume(string flavor, string image, string public_key, string servername, metadata, bool https, bool http, resenv, volume_ids_path_new, volume_ids_path_attach)')
print(' start_server(string flavor, string image, string public_key, string servername, metadata, string diskspace, string volumename, bool https, bool http, resenv)')
print(' start_server_with_custom_key(string flavor, string image, string servername, metadata, bool http, bool https, resenv, volume_ids_path_new, volume_ids_path_attach)')
Expand Down Expand Up @@ -275,6 +277,18 @@ elif cmd == 'start_server_without_playbook':
sys.exit(1)
pp.pprint(client.start_server_without_playbook(args[0], args[1], args[2], args[3], eval(args[4]), eval(args[5]), eval(args[6]), eval(args[7]), eval(args[8]), eval(args[9]),))

elif cmd == 'bibigrid_available':
if len(args) != 0:
print('bibigrid_available requires 0 args')
sys.exit(1)
pp.pprint(client.bibigrid_available())

elif cmd == 'detach_ip_from_server':
if len(args) != 2:
print('detach_ip_from_server requires 2 args')
sys.exit(1)
pp.pprint(client.detach_ip_from_server(args[0], args[1],))

elif cmd == 'start_server_with_mounted_volume':
if len(args) != 10:
print('start_server_with_mounted_volume requires 10 args')
Expand Down
Loading

0 comments on commit 33f2405

Please sign in to comment.