from yardstick import ssh
from yardstick.common import constants
from yardstick.common import exceptions
+from yardstick.common import utils as common_utils
from yardstick.common import yaml_loader
from yardstick.network_services.utils import PciAddress
from yardstick.network_services.helpers.cpu import CpuSysCores
<vcpu cpuset='{cpuset}'>{vcpu}</vcpu>
{cputune}
<os>
- <type arch="x86_64" machine="pc-i440fx-xenial">hvm</type>
+ <type arch="x86_64" machine="{machine}">hvm</type>
<boot dev="hd" />
</os>
<features>
EOF
"""
+NETWORK_DATA_TEMPLATE = """
+cat > {network_file} <<EOF
+#cloud-config
+version: 2
+ethernets:
+ ens3:
+ match:
+ macaddress: {mac_address}
+ addresses:
+ - {ip_address}
+EOF
+"""
+
WAIT_FOR_BOOT = 30
return vm_pci
@classmethod
- def add_ovs_interface(cls, vpath, port_num, vpci, vports_mac, xml_str):
+ def add_ovs_interface(cls, vpath, port_num, vpci, vports_mac, xml_str,
+ queues):
"""Add a DPDK OVS 'interface' XML node in 'devices' node
<devices>
model.set('type', 'virtio')
driver = ET.SubElement(interface, 'driver')
- driver.set('queues', '4')
+ driver.set('queues', str(queues))
host = ET.SubElement(driver, 'host')
host.set('mrg_rxbuf', 'off')
cpuset = Libvirt.pin_vcpu_for_perf(connection, hw_socket)
cputune = extra_spec.get('cputune', '')
+ machine = extra_spec.get('machine_type', 'pc-i440fx-xenial')
mac = StandaloneContextHelper.get_mac_address(0x00)
image = cls.create_snapshot_qemu(connection, index,
flavor.get("images", None))
memory=memory, vcpu=vcpu, cpu=cpu,
numa_cpus=numa_cpus,
socket=socket, threads=threads,
- vm_image=image, cpuset=cpuset, cputune=cputune)
+ vm_image=image, cpuset=cpuset,
+ machine=machine, cputune=cputune)
# Add CD-ROM device
vm_xml = Libvirt.add_cdrom(cdrom_img, vm_xml)
return ET.tostring(root)
@staticmethod
- def gen_cdrom_image(connection, file_path, vm_name, vm_user, key_filename):
+ def gen_cdrom_image(connection, file_path, vm_name, vm_user, key_filename, mac, ip):
"""Generate ISO image for CD-ROM """
user_config = [" - name: {user_name}",
meta_data = "/tmp/meta-data"
user_data = "/tmp/user-data"
+ network_data = "/tmp/network-config"
with open(".".join([key_filename, "pub"]), "r") as pub_key_file:
pub_key_str = pub_key_file.read().rstrip()
user_conf = os.linesep.join(user_config).format(pub_key_str=pub_key_str, user_name=vm_user)
cmd_lst = [
"touch %s" % meta_data,
USER_DATA_TEMPLATE.format(user_file=user_data, host=vm_name, user_config=user_conf),
- "genisoimage -output {0} -volid cidata -joliet -r {1} {2}".format(file_path,
- meta_data,
- user_data),
- "rm {0} {1}".format(meta_data, user_data),
+ NETWORK_DATA_TEMPLATE.format(network_file=network_data, mac_address=mac,
+ ip_address=ip),
+ "genisoimage -output {0} -volid cidata -joliet -r {1} {2} {3}".format(file_path,
+ meta_data,
+ user_data,
+ network_data),
+ "rm {0} {1} {2}".format(meta_data, user_data, network_data),
]
for cmd in cmd_lst:
LOG.info(cmd)
ip = cls.get_mgmt_ip(connection, node["mac"], mgmtip, node)
if ip:
node["ip"] = ip
+ client = ssh.SSH.from_node(node)
+ LOG.debug("OS version: %s",
+ common_utils.get_os_version(client))
+ LOG.debug("Kernel version: %s",
+ common_utils.get_kernel_version(client))
+ vnfs_data = common_utils.get_sample_vnf_info(client)
+ for vnf_name, vnf_data in vnfs_data.items():
+ LOG.debug("VNF name: '%s', commit ID/branch: '%s'",
+ vnf_name, vnf_data["branch_commit"])
+ LOG.debug("%s", vnf_data["md5_result"])
return nodes
@classmethod
- def check_update_key(cls, connection, node, vm_name, id_name, cdrom_img):
+ def check_update_key(cls, connection, node, vm_name, id_name, cdrom_img, mac):
# Generate public/private keys if private key file is not provided
user_name = node.get('user')
if not user_name:
key_filename = ''.join(
[constants.YARDSTICK_ROOT_PATH,
'yardstick/resources/files/yardstick_key-',
- id_name])
+ id_name, '-', vm_name])
ssh.SSH.gen_keys(key_filename)
node['key_filename'] = key_filename
# Update image with public key
key_filename = node.get('key_filename')
- Libvirt.gen_cdrom_image(connection, cdrom_img, vm_name, user_name, key_filename)
+ ip_netmask = "{0}/{1}".format(node.get('ip'), node.get('netmask'))
+ ip_netmask = "{0}/{1}".format(node.get('ip'),
+ IPNetwork(ip_netmask).prefixlen)
+ Libvirt.gen_cdrom_image(connection, cdrom_img, vm_name, user_name, key_filename, mac,
+ ip_netmask)
return node
for key, vfs in vnf["network_ports"].items():
if key == "mgmt":
- mgmtip = str(IPNetwork(vfs['cidr']).ip)
+ mgmt_cidr = IPNetwork(vfs['cidr'])
continue
vf = ports[vfs[0]]
})
index = index + 1
- return mgmtip, interfaces
+ return mgmt_cidr, interfaces
@classmethod
def generate_vnf_instance(cls, flavor, ports, ip, key, vnf, mac):
- mgmtip, interfaces = cls.build_vnf_interfaces(vnf, ports)
+ mgmt_cidr, interfaces = cls.build_vnf_interfaces(vnf, ports)
result = {
- "ip": mgmtip,
+ "ip": str(mgmt_cidr.ip),
+ "netmask": str(mgmt_cidr.netmask),
"mac": mac,
"host": ip,
"user": flavor.get('user', 'root'),