diff --git a/CHANGELOG.md b/CHANGELOG.md index c6425e1f..770de496 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/VirtualMachineService/VirtualMachineHandler.py b/VirtualMachineService/VirtualMachineHandler.py index 1e9b7344..6abc5613 100644 --- a/VirtualMachineService/VirtualMachineHandler.py +++ b/VirtualMachineService/VirtualMachineHandler.py @@ -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 @@ -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: diff --git a/VirtualMachineService/ancon/playbooks/bioconda.yml b/VirtualMachineService/ancon/playbooks/bioconda.yml index 99881ea1..ada6f8b8 100644 --- a/VirtualMachineService/ancon/playbooks/bioconda.yml +++ b/VirtualMachineService/ancon/playbooks/bioconda.yml @@ -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) }}"