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

Commit

Permalink
Dev (#147)
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
eKatchko authored Oct 8, 2019
2 parents 7e0ee8b + 2b1800f commit 74b9698
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 10 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## (2019-10-08)

### Bug Fixes

* **delete-vm:**
* deletes all security groups of server with the same name

### Features

* **bioconda:** init .bashrc and create alias for environment (#141)

## (2019-09-11)


Expand Down
22 changes: 15 additions & 7 deletions VirtualMachineService/VirtualMachineHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from .ancon.Playbook import Playbook

from openstack import connection
from openstack import exceptions
from deprecated import deprecated
from keystoneauth1.identity import v3
from keystoneauth1 import session
Expand Down Expand Up @@ -1138,13 +1139,20 @@ def delete_server(self, openstack_id):
raise serverNotFoundException
self.logger.info(server)
self.logger.info(server.name)
security_group = self.conn.network.find_security_group(name_or_id=openstack_id)
if security_group:
self.logger.info("Delete security group {}".format(openstack_id))
self.conn.compute.remove_security_group_from_server(server=server,
security_group=security_group)
self.conn.network.delete_security_group(security_group)
self.conn.compute.delete_server(server)
try:
security_groups = self.conn.network.security_groups(name=openstack_id)
except Exception as e:
self.logger.exception(e)
if security_groups is not None:
for sg in security_groups:
self.logger.info("Delete security group {0}".format(openstack_id))
self.conn.compute.remove_security_group_from_server(server=server,
security_group=sg)
self.conn.network.delete_security_group(sg)
self.conn.compute.delete_server(server)
else:
return False


return True
except Exception as e:
Expand Down
17 changes: 14 additions & 3 deletions VirtualMachineService/ancon/playbooks/bioconda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,33 @@
executable: /bin/bash
when: added_channels.stdout.find('conda-forge') == -1

- name: Init .bashrc for conda
shell: "timeout 1m bash -c 'source {{ bioconda_folders.conda_dir }}/bin/activate && conda init'"
args:
executable: /bin/bash

- name: Check for environment
shell: "timeout 1m bash -c 'source {{ bioconda_folders.conda_dir }}/bin/activate && conda info -e'"
register: added_envs

- name: Create alias for environment
shell: "echo $ALIAS_VARIABLE > ~/.bash_aliases"
environment:
ALIAS_VARIABLE: 'alias {{ bioconda_tools.env | quote }}="conda activate {{ bioconda_tools.env | quote }}"'
when: added_envs.stdout.find(bioconda_tools.env) == -1

- name: Create environment
shell: "timeout 2m bash -c 'source {{ bioconda_folders.conda_dir }}/bin/activate && conda create --yes -n {{ bioconda_tools.env }}'"
shell: "timeout 2m bash -c 'source {{ bioconda_folders.conda_dir }}/bin/activate && conda create --yes -n {{ bioconda_tools.env | quote}}'"
args:
executable: /bin/bash
when: added_envs.stdout.find(bioconda_tools.env) == -1

- name: Check for installed packages
shell: "timeout 1m bash -c 'source {{ bioconda_folders.conda_dir }}/bin/activate && conda activate {{ bioconda_tools.env }} && conda list'"
shell: "timeout 1m bash -c 'source {{ bioconda_folders.conda_dir }}/bin/activate && conda activate {{ bioconda_tools.env | quote}} && conda list'"
register: added_packages

- name: Install chosen packages
shell: "timeout {{ bioconda_tools.timeout_length }} bash -c 'source {{ bioconda_folders.conda_dir }}/bin/activate && conda activate {{ bioconda_tools.env }} && conda install --yes {{ item.key }}={{ item.value.version }}={{ item.value.build }}'"
shell: "timeout {{ bioconda_tools.timeout_length }} bash -c 'source {{ bioconda_folders.conda_dir }}/bin/activate && conda activate {{ bioconda_tools.env | quote}} && conda install --yes {{ item.key }}={{ item.value.version }}={{ item.value.build }}'"
args:
executable: /bin/bash
loop: "{{ q('dict', bioconda_tools.packages) }}"
Expand Down

0 comments on commit 74b9698

Please sign in to comment.