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

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
vktrrdk committed Mar 13, 2020
2 parents 367bf1b + 9a50bb4 commit 4f07e45
Show file tree
Hide file tree
Showing 10 changed files with 302 additions and 2 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@

## (2020-03-13)


#### Features

* **Volume:** added resizing
* **mosh:** playbook for installing mosh

## (2020-02-27)


Expand Down
32 changes: 32 additions & 0 deletions VirtualMachineService/VirtualMachineHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,38 @@ def create_mount_init_script(self, volume_id):
init_script = base64.b64encode(text).decode("utf-8")
return init_script

def get_api_token(self):
auth_url = self.conn.endpoint_for("identity")
self.logger.info(auth_url)
auth = {
"auth": {
"identity": {
"methods": ["password"],
"password": {
"user": {
"name": self.USERNAME,
"domain": {"name": self.USER_DOMAIN_NAME},
"password": self.PASSWORD,
}
},
}
}
}
res = req.post(url=auth_url + "/auth/tokens?nocatalog", json=auth)
self.logger.info(res.headers)
return res.headers["X-Subject-Token"]

def resize_volume(self, volume_id, size):
token = self.get_api_token()
vol3 = self.conn.endpoint_for("volumev3")
header = {"X-Auth-Token": str(token)}
body = {"os-extend": {"new_size": size}}
url = vol3 + "/volumes/" + volume_id + "/action"
res = req.post(url=url, json=body, headers=header)
self.logger.info(res.status_code)
self.logger.info(res.content)
return int(res.status_code)

def create_volume(self, volume_name, volume_storage, metadata):
"""
Create volume.
Expand Down
1 change: 1 addition & 0 deletions VirtualMachineService/VirtualMachineServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def catch_shutdown(signal, frame):
click.echo("Server is running on port {}".format(PORT))
handler = VirtualMachineHandler(CONFIG_FILE)
processor = Processor(handler)
processor.resize_volume("1e4d223a-b450-47f8-b7f1-52df40e4c39b", 2)
transport = TSSLSocket.TSSLServerSocket(host=HOST, port=PORT, certfile=CERTFILE)
tfactory = TTransport.TBufferedTransportFactory()
pfactory = TBinaryProtocol.TBinaryProtocolFactory()
Expand Down
7 changes: 7 additions & 0 deletions VirtualMachineService/VirtualMachineService-remote
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ if len(sys.argv) <= 1 or sys.argv[1] == '--help':
print(' get_Images_by_filter( filter_json)')
print(' Volume get_volume(string volume_id)')
print(' get_volumes_by_ids( volume_ids)')
print(' int resize_volume(string volume_id, int size)')
print(' bool delete_server(string openstack_id)')
print(' add_metadata_to_server(string servername, metadata)')
print(' delete_metadata_from_server(string servername, keys)')
Expand Down Expand Up @@ -232,6 +233,12 @@ elif cmd == 'get_volumes_by_ids':
sys.exit(1)
pp.pprint(client.get_volumes_by_ids(eval(args[0]),))

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

elif cmd == 'delete_server':
if len(args) != 1:
print('delete_server requires 1 args')
Expand Down
228 changes: 228 additions & 0 deletions VirtualMachineService/VirtualMachineService.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions VirtualMachineService/ancon/Playbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
RSTUDIO = "rstudio"
GUACAMOLE = "guacamole"
JUPYTERNOTEBOOK = "jupyternotebook"
OPTIONAL = "optional"
MOSH = "mosh"

ALL_TEMPLATES = [BIOCONDA, THEIA, RSTUDIO, GUACAMOLE, JUPYTERNOTEBOOK]

Expand Down Expand Up @@ -130,6 +132,10 @@ def load_vars():
for k, v in playbook_vars.items():
if k == "template_version":
data[playbook_name + "_vars"][k] = v
if playbook_name == OPTIONAL:
for k, v in playbook_vars.items():
if k == MOSH:
data[playbook_name + "_defined"][k] = v

playbook_yml = "/{0}.yml".format(playbook_name)
playbook_var_yml = "/{0}_vars_file.yml".format(playbook_name)
Expand Down
11 changes: 11 additions & 0 deletions VirtualMachineService/ancon/playbooks/optional.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
- name: Wait for automatic system updates 1
shell: while sudo fuser /var/lib/dpkg/lock >/dev/null 2>&1; do sleep 1; done;

- name: Wait for automatic system updates 2
shell: while sudo fuser /var/lib/dpkg/lock-frontend >/dev/null 2>&1; do sleep 1; done;

- name: Installing MOSH
apt:
name: mosh
state: present
when: optional_defined.mosh is defined
2 changes: 2 additions & 0 deletions VirtualMachineService/ancon/playbooks/optional_vars_file.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
optional_defined:
mosh:
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
rstudio_vars:
template_version:
DEFAULT_USER: ubuntu
DEFAULT_PASSWORD_HASHED: $6$iRrIJogrR0N2ZVdb$oL5XzFqcTC.O3g4DS945a5K7nRvO0LqY.ugyjDINUA347qRYXe1YXag8cRlLf9PVwmNrRYU3LTNGyCIPbFvz4/
DEFAULT_PASSWORD_HASHED: $6$rounds=656000$kDXfaoylNAAH4hiN$Se1C7um7OW7ETs.L19uy1xn9SJjtjHylbF.Xv/YhRWilSyzDcX7nSajMth8LgZNiRJmO3.wBxcYeJnsgW4CLL1
Loading

0 comments on commit 4f07e45

Please sign in to comment.