Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweaks #39

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 27 additions & 6 deletions AnsiblePlaybooks/meerkat/deploy.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,38 @@ locals {
vm_ids = [ for val in openstack_compute_instance_v2.Instance : val.id]
vm_names = [ for val in openstack_compute_instance_v2.Instance : val.name]
vm_ips = [for val in openstack_compute_instance_v2.Instance : val.access_ip_v4]
vm_images = [ for val in openstack_compute_instance_v2.Instance : val.image_name]
vm_flavors = [ for val in openstack_compute_instance_v2.Instance : val.flavor_name]
}

##############################################################################
### Deploy manila shares
##############################################################################
resource "openstack_sharedfilesystem_share_v2" "share" {
count = var.deploy_volume
name = "meerkat"
description = "manila terraform share"
share_proto = "CEPHFS"
size = var.share_size * length(openstack_compute_instance_v2.Instance)
}

locals {
share_ids = [ for val in openstack_sharedfilesystem_share_v2.share : val.id]
share_paths = [ for val in openstack_sharedfilesystem_share_v2.share : val.export_locations[0].path]
}

resource "openstack_sharedfilesystem_share_access_v2" "share_access" {
share_id = openstack_sharedfilesystem_share_v2.share.id
count = var.deploy_manila
depends_on = [openstack_sharedfilesystem_share_v2.share]
share_id = local.share_ids[count.index]
access_type = "cephx"
access_to = "${var.user}"
access_to = "meerkat-manila"
access_level = "rw"
}

locals {
share_access_key = [for val in openstack_sharedfilesystem_share_access_v2.share_access : val.access_key]
}


##############################################################################
Expand Down Expand Up @@ -90,12 +103,20 @@ resource "openstack_compute_volume_attach_v2" "vol_attach" {
##############################################################################
### Run ansible playbook
##############################################################################
### Run playbook normally
resource "null_resource" "ansible_playbook" {
depends_on = [openstack_compute_instance_v2.Instance, openstack_sharedfilesystem_share_v2.share, openstack_sharedfilesystem_share_access_v2.share_access, openstack_blockstorage_volume_v3.volumes, openstack_compute_volume_attach_v2.vol_attach]
count = length(openstack_compute_instance_v2.Instance)
depends_on = [openstack_compute_instance_v2.Instance, openstack_blockstorage_volume_v3.volumes, openstack_compute_volume_attach_v2.vol_attach]
count = length(openstack_compute_instance_v2.Instance) * (var.deploy_manila == 0 ? 1 : 0)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this line do?

provisioner "local-exec" {
command = "ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i staging-openstack.yaml -l ${local.vm_names[count.index]} ${var.playbook_path}"
# command = "ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i staging-openstack.yaml -l ${local.vm_names[count.index]} ${var.playbook_path} --extra-vars 'share_path=${openstack_sharedfilesystem_share_v2.share.export_locations[0].path} access_key=${openstack_sharedfilesystem_share_access_v2.share_access.access_key} vm_count=${count.index}'"
command = "ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i staging-openstack.yaml -l ${local.vm_names[count.index]} ${var.playbook_path} --extra-vars 'image=${local.vm_images[count.index]} flavor=${local.vm_flavors[count.index]}'"
}
}

### Run playbook if deployed manila share, and pass on share information to ansible with --extra-vars
resource "null_resource" "ansible_playbook_manila" {
depends_on = [openstack_compute_instance_v2.Instance, openstack_blockstorage_volume_v3.volumes, openstack_compute_volume_attach_v2.vol_attach, openstack_sharedfilesystem_share_v2.share, openstack_sharedfilesystem_share_access_v2.share_access]
count = length(openstack_compute_instance_v2.Instance) * (var.deploy_manila)
provisioner "local-exec" {
command = "ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i staging-openstack.yaml -l ${local.vm_names[count.index]} ${var.playbook_path} --extra-vars 'image=${local.vm_images[count.index]} flavor=${local.vm_flavors[count.index]} share_path=${local.share_paths[0]} access_key=${local.share_access_key[0]} vm_count=${count.index}'"
}
}
6 changes: 3 additions & 3 deletions AnsiblePlaybooks/meerkat/roles/attach_manila/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
- name: Mount ephemeral SMB volume
ansible.posix.mount:
src: "{{ share_path }}"
path: /mnt/manila{{ vm_count }}
opts: "name={{ user }},secret={{ access_key }}"
path: /home/{{ user }}/manila{{ vm_count }}
opts: "name=meerkat-manila,secret={{ access_key }}"
fstype: ceph
state: ephemeral
become: true

- name: change manila folder owner
ansible.builtin.file:
path: /mnt/manila{{ vm_count }}
path: /home/{{ user }}/manila{{ vm_count }}
owner: "{{ user }}"
mode: '0664'
become: true
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ output=$(cargo +1.78.0 run --release)
fft_single=$(echo "$output" | grep -ioP "Completed iterations: +(?)\d+(?:\.\d+)?" | head -1 | grep -ioP "\d+(?:\.\d+)?")
fft_multi=$(echo "$output" | grep -ioP "Completed iterations: +(?)\d+(?:\.\d+)?" | tail -n1 | grep -ioP "\d+(?:\.\d+)?")

# Get VM infor
server_UUID=$(curl http://169.254.169.254/openstack/latest/meta_data.json -s | grep -ioP .{8}-.{4}-.{4}-.{4}-.{12})
vm_info=$(openstack server show $server_UUID --os-cloud openstack)
#hypervisor=$(echo $vm_info | grep -ioP "\w*.nubes.rl.ac.uk" | head -1)
flavor=$(echo $vm_info | grep -ioP "flavor\s\|\s\S*" | cut -c 10-)
image=$(echo $vm_info | grep -ioP "image\s\|\s\S*" | cut -c 9-)
# VM info
flavor="{{ flavor }}"
image="{{ image }}"


DB="https://{{ db_ip }}:{{ db_port }}/write"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#!/bin/bash
set -euo pipefail

server_UUID=$(curl http://169.254.169.254/openstack/latest/meta_data.json -s | grep -ioP .{8}-.{4}-.{4}-.{4}-.{12})
vm_info=$(openstack server show $server_UUID --os-cloud openstack)
#hypervisor=$(echo $vm_info | grep -ioP "\w*.nubes.rl.ac.uk" | head -1)
FLAVOR=$(echo $vm_info | grep -ioP "flavor\s\|\s\S*" | cut -c 10-)
IMAGE=$(echo $vm_info | grep -ioP "image\s\|\s\S*" | cut -c 9-)
# VM info
FLAVOR="{{ flavor }}"
IMAGE="{{ image }}"


NUM_CORES=$(nproc)
CPU_NAME=$(lscpu | grep 'Model name' | cut -f 2 -d ":" | awk '{$1=$1}1' | tr " " _)
Expand All @@ -19,4 +18,6 @@ RUN_TIME=$((END_TIME - START_TIME))

SCORE=$(jq '.score' $RESULTS_FILE)

curl -v -H 'Content-Type: application/json' -d 'hepscore,flavour='$FLAVOR',image='$IMAGE',num_cores='$NUM_CORES',cpu_name='$CPU_NAME',UUID='$server_UUID' score='$SCORE',run_time='$RUN_TIME'' -X POST 'http://{{ db_ip }}:{{ db_port }}/write'
DB="https://{{ db_ip }}:{{ db_port }}/write"

curl -H "Authorization: Basic `echo -n "{{ db_username }}:{{ db_password }}" | base64`" -d 'hepscore,flavour='$FLAVOR',image='$IMAGE' score='$SCORE',run_time='$RUN_TIME'' -X POST $DB --insecure

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is --insecure being used here?

Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
shell: ./benchmark.sh -p /mnt/volume -s volume

- name: Run manila share benchmark
shell: ./benchmark.sh -p /mnt/manila -s manila
shell: ./benchmark.sh -p /home/{{ user }}/manila{{ vm_count }} -s manila
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,9 @@ benchmark_and_send_data () {
send_data
}

# Get VM infor
server_UUID=$(curl http://169.254.169.254/openstack/latest/meta_data.json -s | grep -ioP .{8}-.{4}-.{4}-.{4}-.{12})
vm_info=$(openstack server show $server_UUID --os-cloud openstack)
#hypervisor=$(echo $vm_info | grep -ioP "\w*.nubes.rl.ac.uk" | head -1)
flavor=$(echo $vm_info | grep -ioP "flavor\s\|\s\S*" | cut -c 10-)
image=$(echo $vm_info | grep -ioP "image\s\|\s\S*" | cut -c 9-)
# VM info
flavor="{{ flavor }}"
image="{{ image }}"

DB="https://{{ db_ip }}:{{ db_port }}/write"

Expand Down