From 98267f4e343d66166e2bb3c8b1f9dc22b29142c4 Mon Sep 17 00:00:00 2001 From: eKatchko <47833533+eKatchko@users.noreply.github.com> Date: Sat, 5 Oct 2019 14:22:25 +0200 Subject: [PATCH 1/3] feature(conda): init .bashrc and create alias for environment (#141) --- .../ancon/playbooks/bioconda.yml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) 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) }}" From 4e97a4bf1c49a2a9b2a8a9a2b1fdc8494f6908e2 Mon Sep 17 00:00:00 2001 From: eKatchko <47833533+eKatchko@users.noreply.github.com> Date: Tue, 8 Oct 2019 12:57:17 +0200 Subject: [PATCH 2/3] Fix/delete all sg (#146) * saving * fix(vm): deletes all security groups of server with the same name * logger.info to logger.exception --- .../VirtualMachineHandler.py | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) 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: From 2b1800f666b64e6c1d17c4bf8822a8400c58481f Mon Sep 17 00:00:00 2001 From: Ewgenij Katchko Date: Tue, 8 Oct 2019 13:01:23 +0200 Subject: [PATCH 3/3] update changelog --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) 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)