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

Commit

Permalink
merged staging into master
Browse files Browse the repository at this point in the history
  • Loading branch information
vktrrdk committed Nov 2, 2020
2 parents c8953b5 + 427bc38 commit b5a485d
Show file tree
Hide file tree
Showing 8 changed files with 596 additions and 102 deletions.
19 changes: 0 additions & 19 deletions .dependabot/config.yml

This file was deleted.

21 changes: 21 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
target-branch: "dev"
reviewers:
- "dweinholz"
- "eKatchko"
- "vktrrdk"
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "weekly"
target-branch: "dev"
reviewers:
- "dweinholz"
- "eKatchko"
- "vktrrdk"

60 changes: 56 additions & 4 deletions VirtualMachineService/VirtualMachineHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1973,11 +1973,16 @@ def get_cluster_status(self, cluster_id):
response = req.get(
url=request_url, json=body, headers=headers, verify=self.PRODUCTION
)
# LOG.info("Cluster {} status: {} ".format(cluster_id, response.content))
LOG.info("Cluster {} status: {} ".format(cluster_id, response.content))
json_resp = response.json(strict=False)
LOG.info(json_resp)
json_resp["log"] = str(json_resp["log"])
json_resp["msg"] = str(json_resp["msg"])
try:
json_resp["log"] = str(json_resp["log"])
except:
pass
try:
json_resp["msg"] = str(json_resp["msg"])
except:
pass

return json_resp

Expand Down Expand Up @@ -2017,6 +2022,52 @@ def get_clusters_info(self):
infos = response.json()["info"]
return infos

def scale_up_cluster(
self, cluster_id, image, flavor, count, names, start_idx, batch_index
):
cluster_info = self.get_cluster_info(cluster_id=cluster_id)
image = self.get_image(image=image)
flavor = self.get_flavor(flavor=flavor)
network = self.get_network()
openstack_ids = []
for i in range(count):
metadata = {
"bibigrid-id": cluster_info.cluster_id,
"user": cluster_info.user,
"worker-batch": str(batch_index),
"name": names[i],
"worker-index": str(start_idx + i),
}
fileDir = os.path.dirname(os.path.abspath(__file__))
deactivate_update_script_file = os.path.join(
fileDir, "scripts/bash/mount.sh"
)
with open(deactivate_update_script_file, "r") as file:
deactivate_update_script = file.read()
deactivate_update_script = encodeutils.safe_encode(
deactivate_update_script.encode("utf-8")
)

LOG.info("Create cluster machine: {}".format(metadata))

server = self.conn.create_server(
name=names[i],
image=image.id,
flavor=flavor.id,
network=[network.id],
userdata=deactivate_update_script,
key_name=cluster_info.key_name,
meta=metadata,
availability_zone=self.AVAIALABILITY_ZONE,
security_groups=cluster_info.group_id,
)
LOG.info("Created cluster machine:{}".format(server["id"]))

openstack_ids.append(server["id"])
LOG.info(openstack_ids)

return {"openstack_ids": openstack_ids}

def get_cluster_info(self, cluster_id):
infos = self.get_clusters_info()
for info in infos:
Expand Down Expand Up @@ -2255,6 +2306,7 @@ def delete_server(self, openstack_id):
sec
for sec in security_groups
if sec.name != self.DEFAULT_SECURITY_GROUP
and not "bibigrid" in sec.name
]
if security_groups is not None:
for sg in security_groups:
Expand Down
9 changes: 8 additions & 1 deletion VirtualMachineService/VirtualMachineService-remote
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
# Autogenerated by Thrift Compiler (0.13.0)
# Autogenerated by Thrift Compiler (0.12.0)
#
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
#
Expand Down Expand Up @@ -73,6 +73,7 @@ if len(sys.argv) <= 1 or sys.argv[1] == '--help':
print(' get_servers_by_ids( server_ids)')
print(' string check_server_task_state(string openstack_id)')
print(' get_servers_by_bibigrid_id(string bibigrid_id)')
print(' scale_up_cluster(string cluster_id, string image, string flavor, int count, names, int start_idx, int batch_idx)')
print(' ClusterInfo get_cluster_info(string cluster_id)')
print(' get_cluster_status(string cluster_id)')
print(' VM get_server(string openstack_id)')
Expand Down Expand Up @@ -463,6 +464,12 @@ elif cmd == 'get_servers_by_bibigrid_id':
sys.exit(1)
pp.pprint(client.get_servers_by_bibigrid_id(args[0],))

elif cmd == 'scale_up_cluster':
if len(args) != 7:
print('scale_up_cluster requires 7 args')
sys.exit(1)
pp.pprint(client.scale_up_cluster(args[0], args[1], args[2], eval(args[3]), eval(args[4]), eval(args[5]), eval(args[6]),))

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

0 comments on commit b5a485d

Please sign in to comment.