3 # Copyright (c) 2018 Kontron and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 """vGPU testcase implementation."""
12 from __future__ import division
16 from functest.core import singlevm
19 class vGPU(singlevm.SingleVm2):
20 """OpenStack vGPU Test Case."""
22 __logger = logging.getLogger(__name__)
24 filename = ('/home/opnfv/functest/images/'
25 'ubuntu-16.04-server-cloudimg-amd64-disk1.img')
29 flavor_extra_specs = {'resources:VGPU': '1'}
31 ssh_connect_loops = 12
32 create_server_timeout = 300
34 def __init__(self, **kwargs):
35 """Initialize vGPU testcase object."""
36 if "case_name" not in kwargs:
37 kwargs["case_name"] = "vgpu"
38 super(vGPU, self).__init__(**kwargs)
42 Test if the vGPU exist.
44 (_, stdout, stderr) = self.ssh.exec_command('lspci')
45 lspci_output = stdout.read()
46 self.__logger.debug("output:\n%s", stdout.read())
47 self.__logger.debug("error:\n%s", stderr.read())
48 if ('VGA compatible controller: Intel' in lspci_output or
49 'VGA compatible controller: Nvidia' in lspci_output):
50 self.__logger.info("The VM have a vGPU")
53 self.__logger.error("The VM haven't any vGPU")