--- /dev/null
+##############################################################################
+# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+---
+# Sample benchmark task config file
+# measure storage performance using fio
+#
+# For this sample just like running the command below on the test vm and
+# getting benchmark info back to the yardstick.
+#
+# sudo fio -filename=/home/ubuntu/data.raw -bs=4k -ipdepth=1 -rw=rw \
+# -ramp_time=10 -runtime=60 -name=yardstick-fio -ioengine=libaio \
+# -direct=1 -group_reporting -numjobs=1 -time_based \
+# --output-format=json
+
+schema: "yardstick:task:0.1"
+
+{% set rw = rw or "randrw" %}
+{% set bs = bs or "8k" %}
+{% set size = size or "100g" %}
+{% set rwmixwrite = rwmixwrite or "50" %}
+{% set numjobs = numjobs or "1" %}
+{% set direct = direct or "1" %}
+
+scenarios:
+-
+ type: Fio
+ options:
+ filename: /dev/vdb
+ bs: {{bs}}
+ rw: {{rw}}
+ size: {{size}}
+ rwmixwrite: {{rwmixwrite}}
+ numjobs: {{numjobs}}
+ direct: {{direct}}
+ ramp_time: 10
+
+ host: fio.fio_volume
+
+ runner:
+ type: Duration
+ duration: 60
+ interval: 1
+
+ sla:
+ read_bw: 6000
+ read_iops: 1500
+ read_lat: 500.1
+ write_bw: 6000
+ write_iops: 1500
+ write_lat: 500.1
+ action: monitor
+
+context:
+ name: fio_volume
+ image: yardstick-image
+ flavor: yardstick-flavor
+ user: ubuntu
+ servers:
+ fio:
+ volume:
+ name: fio-volume
+ size: 200
+ volume_mountpoint: "/dev/vdb"
+ floating_ip: true
+ networks:
+ test:
+ cidr: "10.0.1.0/24"
+ port_security_enabled: true
self.placement_groups.append(pg)
pg.add_member(self.stack_name)
+ self.volume = None
+ if "volume" in attrs:
+ self.volume = attrs.get("volume")
+
+ self.volume_mountpoint = None
+ if "volume_mountpoint" in attrs:
+ self.volume_mountpoint = attrs.get("volume_mountpoint")
+
# support servergroup attr
self.server_group = None
sg = attrs.get("server_group")
else:
self.flavor_name = self.flavor
+ if self.volume:
+ if isinstance(self.volume, dict):
+ self.volume["name"] = \
+ self.volume.setdefault("name", server_name + "-volume")
+ template.add_volume(**self.volume)
+ template.add_volume_attachment(server_name, self.volume["name"],
+ mountpoint=self.volume_mountpoint)
+ else:
+ template.add_volume_attachment(server_name, self.volume,
+ mountpoint=self.volume_mountpoint)
+
template.add_server(server_name, self.image, flavor=self.flavor_name,
flavors=self.context.flavors,
ports=port_name_list,
from keystoneauth1 import loading
from keystoneauth1 import session
+from cinderclient import client as cinderclient
from novaclient import client as novaclient
from glanceclient import client as glanceclient
from neutronclient.neutron import client as neutronclient
return api_version
+def get_cinder_client_version(): # pragma: no cover
+ try:
+ api_version = os.environ['OS_VOLUME_API_VERSION']
+ except KeyError:
+ return DEFAULT_API_VERSION
+ else:
+ log.info("OS_VOLUME_API_VERSION is set in env as '%s'", api_version)
+ return api_version
+
+
+def get_cinder_client(): # pragma: no cover
+ sess = get_session()
+ return cinderclient.Client(get_cinder_client_version(), session=sess)
+
+
def get_nova_client_version(): # pragma: no cover
try:
api_version = os.environ['OS_COMPUTE_API_VERSION']
def get_image_id(glance_client, image_name): # pragma: no cover
images = glance_client.images.list()
return next((i.id for i in images if i.name == image_name), None)
+
+
+# *********************************************
+# CINDER
+# *********************************************
+def get_volume_id(volume_name): # pragma: no cover
+ volumes = get_cinder_client().volumes.list()
+ return next((v.id for v in volumes if v.name == volume_name), None)
'value': {'get_resource': name}
}
+ def add_volume(self, name, size=10):
+ """add to the template a volume description"""
+ log.debug("adding Cinder::Volume '%s' size '%d' ", name, size)
+
+ self.resources[name] = {
+ 'type': 'OS::Cinder::Volume',
+ 'properties': {'name': name,
+ 'size': size}
+ }
+
+ self._template['outputs'][name] = {
+ 'description': 'Volume %s ID' % name,
+ 'value': {'get_resource': name}
+ }
+
+ def add_volume_attachment(self, server_name, volume_name, mountpoint=None):
+ """add to the template an association of volume to instance"""
+ log.debug("adding Cinder::VolumeAttachment server '%s' volume '%s' ", server_name,
+ volume_name)
+
+ name = "%s-%s" % (server_name, volume_name)
+
+ volume_id = op_utils.get_volume_id(volume_name)
+ if not volume_id:
+ volume_id = {'get_resource': volume_name}
+ self.resources[name] = {
+ 'type': 'OS::Cinder::VolumeAttachment',
+ 'properties': {'instance_uuid': {'get_resource': server_name},
+ 'volume_id': volume_id}
+ }
+
+ if mountpoint:
+ self.resources[name]['properties']['mountpoint'] = mountpoint
+
def add_network(self, name, physical_network='physnet1', provider=None,
segmentation_id=None, port_security_enabled=None):
"""add to the template a Neutron Net"""