diff options
author | Mofassir Arif <mofassir@gmail.com> | 2015-10-22 12:39:37 -0700 |
---|---|---|
committer | Mofassir Arif <mofassir@gmail.com> | 2015-11-05 06:17:02 -0800 |
commit | 95bf8a8c96b2be94512e042f3f3c82edcbebf84d (patch) | |
tree | 7c7d1acd4dd596e84699a18d04e6ba2790e6fec2 /func | |
parent | ed6de63572d92bb5af8be22ced0a749400f4d3d4 (diff) |
Python Framework for QTIP
Dhrystone Whetstone and DPI benchmarks have been implemented
CLI arguments have been implemented
test case are sorted based on category such as compute,network and storage
glance and heat client have been used to generate the stack.
automatic upload of QTIP image and delete function for existing stack before
creating new stack has been implemented
system information collecton and result generation has been implemented
JIRA: QTIP-17
Signed-off-by: Mofassir Arif <mofassir_arif@dell.com>
Change-Id: I4b7b134017723c30c771cc14d2edce33fcb8ba00
Diffstat (limited to 'func')
-rw-r--r-- | func/__init__.py | 0 | ||||
-rw-r--r-- | func/__init__.pyc | bin | 0 -> 145 bytes | |||
-rw-r--r-- | func/cli.py | 60 | ||||
-rw-r--r-- | func/cli.pyc | bin | 0 -> 2097 bytes | |||
-rw-r--r-- | func/create_zones.py | 117 | ||||
-rw-r--r-- | func/create_zones.pyc | bin | 0 -> 3912 bytes | |||
-rw-r--r-- | func/driver.py | 29 | ||||
-rw-r--r-- | func/driver.pyc | bin | 0 -> 1068 bytes | |||
-rw-r--r-- | func/env_setup.py | 160 | ||||
-rw-r--r-- | func/env_setup.pyc | bin | 0 -> 5113 bytes | |||
-rw-r--r-- | func/fetchimg.py | 30 | ||||
-rw-r--r-- | func/fetchimg.pyc | bin | 0 -> 1073 bytes | |||
-rw-r--r-- | func/spawn_vm.py | 263 | ||||
-rw-r--r-- | func/spawn_vm.pyc | bin | 0 -> 8366 bytes | |||
-rw-r--r-- | func/validate_yaml.py | 32 | ||||
-rw-r--r-- | func/validate_yaml.pyc | bin | 0 -> 777 bytes |
16 files changed, 691 insertions, 0 deletions
diff --git a/func/__init__.py b/func/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/func/__init__.py diff --git a/func/__init__.pyc b/func/__init__.pyc Binary files differnew file mode 100644 index 00000000..d217b489 --- /dev/null +++ b/func/__init__.pyc diff --git a/func/cli.py b/func/cli.py new file mode 100644 index 00000000..235040b5 --- /dev/null +++ b/func/cli.py @@ -0,0 +1,60 @@ +############################################################################## +# Copyright (c) 2015 Dell Inc 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 +############################################################################## + +import sys +import os +from func.env_setup import Env_setup +from func.driver import Driver +from func.spawn_vm import SpawnVM +import argparse + + +class cli(): + + def __init__(self): + + parser = argparse.ArgumentParser() + + parser.add_argument('-s ', '--suite', help='compute network storage ') + parser.add_argument('-b', '--benchmark', + help='''COMPUTE: + dhrystone_serial.yaml \n + dhrystone_paralle.yaml \n + whetstone_serial.yaml \n + whetstone_parllel.yaml \n + dpi_serial.yaml \n + dpi_paralle.yaml \n + ssl_serial.yaml \n + ssl_parallel.yaml ''') + args = parser.parse_args() + if not (args.suite or args.benchmark): + parser.error('Not enough arguments, -h, --help ') + sys.exit(0) + if (args.suite and args.benchmark): + obj = Env_setup() + if os.path.isfile( + './test_cases/' + + args.suite + + '/' + + args.benchmark): + + [benchmark, roles, vm_info] = obj.parse( + './test_cases/' + args.suite + '/' + args.benchmark) + + if len(vm_info) != 0: + vmObj = SpawnVM(vm_info) + + obj.callpingtest() + obj.callsshtest() + obj.updateAnsible() + dvr = Driver() + dvr.drive_bench(benchmark, obj.roles_dict.items()) + else: + print (args.benchmark, ' is not a Template in the Directory - \ + Enter a Valid file name. or use qtip.py -h for list') diff --git a/func/cli.pyc b/func/cli.pyc Binary files differnew file mode 100644 index 00000000..3a09e907 --- /dev/null +++ b/func/cli.pyc diff --git a/func/create_zones.py b/func/create_zones.py new file mode 100644 index 00000000..92ce43fe --- /dev/null +++ b/func/create_zones.py @@ -0,0 +1,117 @@ +############################################################################## +# Copyright (c) 2015 Dell Inc 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 +############################################################################## + + + +from keystoneclient.auth.identity import v2 +from keystoneclient import session +from novaclient import client +import os +from collections import defaultdict + + +class create_zones: + + def __init__(self): + print 'Creating Zones' + self._keystone_client = None + self._nova_client = None + + def _get_keystone_client(self): + '''returns a keystone client instance''' + + if self._keystone_client is None: + ''' + self._keystone_client = keystoneclient.v2_0.client.Client( + auth_url=os.environ.get('OS_AUTH_URL'), + username=os.environ.get('OS_USERNAME'), + password=os.environ.get('OS_PASSWORD'), + tenant_name=os.environ.get('OS_TENANT_NAME')) + ''' + auth = v2.Password(auth_url=os.environ.get('OS_AUTH_URL'), + username=os.environ.get('OS_USERNAME'), + password=os.environ.get('OS_PASSWORD'), + tenant_name=os.environ.get('OS_TENANT_NAME')) + + sess = session.Session(auth=auth) + + return sess + + def _get_nova_client(self): + if self._nova_client is None: + keystone = self._get_keystone_client() + self._nova_client = client.Client('2', session=keystone) + return self._nova_client + + def check_aggregate(self, nova, agg_name): + list1 = nova.aggregates.list() + + agg_name_exist = False + for x in list1: + + if x.name == agg_name: + agg_name_exist = True + return agg_name_exist + + def get_aggregate_id(self, nova, agg_name): + list1 = nova.aggregates.list() + agg_id = 0 + agg_name_exist = False + for x in list1: + if x.name == agg_name: + agg_id = x.id + return agg_id + + def check_host_added_to_aggregate(self, nova, agg_id, hostname): + host_added = False + list1 = nova.aggregates.get_details(agg_id) + + nme = str(list1.hosts) + if(hostname in nme): + host_added = True + return host_added + + def del_agg(self, nova, id, host): + + nova.aggregates.remove_host(id, host) + nova.aggregates.delete(id) + + def create_agg(self, D): + nova = self._get_nova_client() + hyper_list = nova.hypervisors.list() + hostnA = [] + zone_machine = defaultdict(list) + + x = 0 + for x in range(len(hyper_list)): + + hostnA.append(hyper_list[x].service['host']) + hostnA[x] = str(hostnA[x]) + + hostnA.sort() + for k in D: + + zone_machine[k].append(' ') + + for x in range(len(zone_machine)): + if not self.check_aggregate(nova, hostnA[x]): + agg_idA = nova.aggregates.create(hostnA[x], D[x]) + nova.aggregates.add_host(aggregate=agg_idA, host=hostnA[x]) + + else: + + id1 = self.get_aggregate_id(nova, hostnA[x]) + self.del_agg(nova, id1, hostnA[x]) + agg_idA = nova.aggregates.create(hostnA[x], D[x]) + id1 = self.get_aggregate_id(nova, hostnA[x]) + + if not self.check_host_added_to_aggregate( + nova, id1, hostnA[x]): + + nova.aggregates.add_host(aggregate=id1, host=hostnA[x]) diff --git a/func/create_zones.pyc b/func/create_zones.pyc Binary files differnew file mode 100644 index 00000000..4faf6abd --- /dev/null +++ b/func/create_zones.pyc diff --git a/func/driver.py b/func/driver.py new file mode 100644 index 00000000..45ec3fa2 --- /dev/null +++ b/func/driver.py @@ -0,0 +1,29 @@ +############################################################################## +# Copyright (c) 2015 Dell Inc 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 +############################################################################## + + + +import os + + +class Driver: + + def __init__(self): + print "Class driver initialized\n" + + def drive_bench(self, benchmark, roles): + result_dir = '$PWD/results' + benchmark_name = benchmark + '.yaml' + print roles + for k, v in roles: + print k + run_play = 'ansible-playbook -s $PWD/benchmarks/playbooks/{0} --extra-vars "Dest_dir={1} role={2}" -vvv'.format( + benchmark_name, result_dir, k) + + status = os.system(run_play) diff --git a/func/driver.pyc b/func/driver.pyc Binary files differnew file mode 100644 index 00000000..0ad3c584 --- /dev/null +++ b/func/driver.pyc diff --git a/func/env_setup.py b/func/env_setup.py new file mode 100644 index 00000000..919df176 --- /dev/null +++ b/func/env_setup.py @@ -0,0 +1,160 @@ +############################################################################## +# Copyright (c) 2015 Dell Inc 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 +############################################################################## + + + + + +import os +import sys +from collections import defaultdict +import yaml +import time +import paramiko + +class Env_setup(): + roles_ip_list = [] # ROLE and its corresponding IP address list + ip_pw_list = [] # IP and password, this will be used to ssh + roles_dict = defaultdict(list) + ip_pw_dict = defaultdict(list) + vm_parameters = defaultdict(list) + benchmark = '' + + def __init__(self): + print '\nParsing class initiated\n' +# obj1 = SpawnVM() + + def writeTofile(self, role): + fname2 = open('/etc/ansible/hosts', 'w') + print role.items() + for k in role: + fname2.write('[' + k + ']\n') + num = len(role[k]) + for x in range(num): + fname2.write(role[k][x] + '\n') + fname2.close + + def sshtest(self, lister): + print 'list: ',lister + for k, v in lister: + ipvar = k + pwvar = v + print '\nBeginning SSH Test!\n' + if v != '': + print ('\nSSH->>>>> %s\n' % k) + time.sleep(2) + + ssh_c = 'ssh-keyscan {0} >> ~/.ssh/known_hosts'.format(k) + + os.system(ssh_c) + ssh_cmd = 'expect ./data/ssh_exch.exp {0} {1}'.format( + ipvar, pwvar) + res = os.system(ssh_cmd) + ''' + for infinity in range(10000): + try : + ssh = paramiko.SSHClient() + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + ssh.connect(hostname = k , username = 'root', password = v) + stdin, stdout, stderr = ssh.exec_command('ls') + print('SSH successful') + break + except: + print 'Retrying SSH' + time.sleep(1) + ''' + if v == '': + print ('SSH->>>>>', k) + ssh_c = 'ssh-keyscan {0} >> ~/.ssh/known_hosts'.format(k) + + time.sleep(3) + os.system(ssh_c) + + for infinity in range(10000): + try : + ssh = paramiko.SSHClient() + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + ssh.connect(hostname = k ) + stdin, stdout, stderr = ssh.exec_command('ls') + break + except: + print 'Retrying SSH' + + def pingtest(self, lister): + pingFlag = 0 + + for k, v in lister.iteritems(): + time.sleep(10) + for val in v: + ipvar = val + ping_cmd = 'ping -D -c1 {0}'.format(ipvar) + while os.system(ping_cmd) != 0: + print '\nWaiting for machine\n' + time.sleep(10) + pingFlag = 0 + print ('\n\n %s is UP \n\n ' % ipvar) + + def GetHostMachineinfo(self, Hosttag): + num = len(Hosttag) + offset = len(self.roles_ip_list) + + for x in range(num): + hostlabel = 'machine_' + str(x + 1) + self.roles_ip_list.insert( + offset, (Hosttag[hostlabel]['role'], Hosttag[hostlabel]['ip'])) + self.ip_pw_list.insert( + offset, (Hosttag[hostlabel]['ip'], Hosttag[hostlabel]['pw'])) + + def GetVirtualMachineinfo(self, Virtualtag): + num = len(Virtualtag) + + for x in range(num): + hostlabel = 'virtualmachine_' + str(x + 1) + for k, v in Virtualtag[hostlabel].iteritems(): + self.vm_parameters[k].append(v) + + def parse(self, configfilepath): + try: + fname = open(configfilepath, 'r+') + doc = yaml.load(fname) +# valid_file = validate_yaml.Validate_Yaml(doc) + fname.close() + for scenario in doc: + self.benchmark = doc['Scenario']['benchmark'] + if doc['Context']['Virtual_Machines']: + self.GetVirtualMachineinfo(doc['Context']['Virtual_Machines']) + if doc['Context']['Host_Machines']: + self.GetHostMachineinfo(doc['Context']['Host_Machines']) + + # num = len(doc['Context']['Vir_Machines']) + # for x in range(num): + # lab = 'host_machine'+ str(x+1) + # self.roles_ip_list.insert(x,(doc[lab]['role'],doc[lab]['ip'])) + # self.ip_pw_list.insert(x,(doc[lab]['ip'],doc[lab]['pw'])) + for k, v in self.roles_ip_list: + self.roles_dict[k].append(v) + for k, v in self.ip_pw_list: + self.ip_pw_dict[k].append(v) + return ( + self.benchmark, + self.roles_dict.items(), + self.vm_parameters) + except KeyboardInterrupt: + fname.close() + print 'ConfigFile Closed: exiting!' + sys.exit(0) + + def updateAnsible(self): + self.writeTofile(self.roles_dict) + + def callpingtest(self): + self.pingtest(self.roles_dict) + + def callsshtest(self): + self.sshtest(self.ip_pw_list) diff --git a/func/env_setup.pyc b/func/env_setup.pyc Binary files differnew file mode 100644 index 00000000..0f9c1433 --- /dev/null +++ b/func/env_setup.pyc diff --git a/func/fetchimg.py b/func/fetchimg.py new file mode 100644 index 00000000..106dc7e8 --- /dev/null +++ b/func/fetchimg.py @@ -0,0 +1,30 @@ +############################################################################## +# Copyright (c) 2015 Dell Inc 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 +############################################################################## + + + +import os +import time + + +class FetchImg: + + def __init__(self): + print 'Fetching Image!' + print 'Fetching QTIP_VM Image' + + def download(self): + time.sleep(2) + os.system( + 'cd ./Temp_Img && wget http://artifacts.opnfv.org/qtip/QTIP_CentOS.qcow2') + + filepath = './Temp_Img/QTIP_CentOS.qcow2' + while not os.path.isfile(filepath): + time.sleep(10) + print 'Download Completed!' diff --git a/func/fetchimg.pyc b/func/fetchimg.pyc Binary files differnew file mode 100644 index 00000000..0c0b228d --- /dev/null +++ b/func/fetchimg.pyc diff --git a/func/spawn_vm.py b/func/spawn_vm.py new file mode 100644 index 00000000..a9dada2e --- /dev/null +++ b/func/spawn_vm.py @@ -0,0 +1,263 @@ +############################################################################## +# Copyright (c) 2015 Dell Inc 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 +############################################################################## + + + +import os +import sys +from collections import defaultdict +from func.env_setup import Env_setup +from func.fetchimg import FetchImg +import yaml +import heatclient.client +import keystoneclient +import glanceclient +from novaclient import client +import time +import json + + +from func.create_zones import create_zones + + +class SpawnVM(Env_setup): + vm_role_ip_dict = defaultdict(list) + + def __init__(self, vm_info): + print 'SpawnVM Class initiated' + + # def setupVM(self,vm_info): + vm_role_ip_dict = vm_info.copy() + print 'Generating Heat Template\n' + self._keystone_client = None + self._heat_client = None + self._glance_client = None + self._nova_client = None + nova =self. _get_nova_client() + azoneobj = create_zones() + azoneobj.create_agg(vm_info['availability_zone']) + + self.Heat_template1 = self.HeatTemplate_vm(vm_info) + self.create_stack(vm_role_ip_dict, self.Heat_template1) + + def HeatTemplate_vm(self, vm_params): + try: + with open('./heat/SampleHeat.yaml', 'r+') as H_temp: + Heat_Dic = yaml.load(H_temp) + except yaml.YAMLError as exc: + if hasattr(exc, 'problem_mark'): + mark = exc.problem_mark + print 'Error in qtip/heat/SampleHeat.yaml at: (%s,%s)' % (mark.line + 1, mark.column + 1) + print 'EXITING PROGRAM. Correct File and restart' + sys.exit(0) + fopen = open('/root/.ssh/id_rsa.pub', 'r') + fopenstr = fopen.read() + fopenstr = fopenstr.rstrip() + scriptcmd = '#!/bin/bash \n echo {0} >> foo.txt \n echo {1} >> /root/.ssh/authorized_keys'.format( + fopenstr, fopenstr) + + Heat_Dic['heat_template_version'] = '2014-10-16' + Heat_Dic['resources']['KeyPairSavePrivate'] = { + 'type': 'OS::Nova::KeyPair', + 'properties': { + 'save_private_key': 'true', + 'name': 'my_key' + } + } + for x in range(1, len(vm_params['availability_zone']) + 1): + avail_zone = vm_params['availability_zone'][x - 1] + img = vm_params['OS_image'][x - 1] + flavor = vm_params['flavor'][x - 1] + + Heat_Dic['parameters']['availability_zone_' +str(x)] = { + 'description': 'Availability Zone of the instance', + 'default': avail_zone, + 'type': 'string' + + } + + Heat_Dic['resources'][ + 'public_port_' + + str(x)] = { + 'type': 'OS::Neutron::Port', + 'properties': { + 'network': {'get_resource': 'private_network'}, + 'security_groups': [{ 'get_resource': 'demo1_security_Group'}], + 'fixed_ips': [ + { + 'subnet_id': {'get_resource': 'private_subnet'}}]}} + + Heat_Dic['resources']['floating_ip_' + str(x)] = { + 'type': 'OS::Neutron::FloatingIP', + 'properties': { + 'floating_network': {'get_param': 'public_network'}}} + + Heat_Dic['resources']['floating_ip_assoc_' + str(x)] = { + 'type': 'OS::Neutron::FloatingIPAssociation', + 'properties': { + 'floatingip_id': {'get_resource': 'floating_ip_' + str(x)}, + 'port_id': {'get_resource': 'public_port_' + str(x)}}} + + Heat_Dic['resources']['my_instance_' + str(x)] = { + 'type': 'OS::Nova::Server', + 'properties': { + 'image': img, + 'networks': + [{'port': {'get_resource': 'public_port_' + str(x)}}], + 'flavor': flavor, + 'availability_zone': avail_zone, + 'name': 'QTIP_Instance_' + str(x), + 'key_name': {'get_resource': 'KeyPairSavePrivate'}, + 'user_data_format': 'RAW', + 'user_data': scriptcmd}} + + Heat_Dic['resources']['demo1_security_Group'] = { + 'type': 'OS::Neutron::SecurityGroup', + 'properties': { + 'name': 'demo1_security_Group', + 'rules': [{ + 'protocol': 'tcp', + 'port_range_min': 22, + 'port_range_max': 22}, + {'protocol': 'icmp'}]}} + + Heat_Dic['outputs']['instance_ip_' +str(x)] = { + 'description': 'IP address of the instance', + 'value': {'get_attr': ['floating_ip_' + str(x), 'floating_ip_address']}} + + Heat_Dic['outputs']['availability_instance_' + str(x)] = { + 'description': 'Availability Zone of the Instance', + 'value': { 'get_param': 'availability_zone_'+str(x)}} + + + Heat_Dic['outputs']['KeyPair_PublicKey'] = { + 'description': 'Private Key', + 'value': {'get_attr': ['KeyPairSavePrivate', 'private_key']} + } + del Heat_Dic['outputs']['description'] + return Heat_Dic + + def _get_keystone_client(self): + '''returns a keystone client instance''' + + if self._keystone_client is None: + self._keystone_client = keystoneclient.v2_0.client.Client( + auth_url=os.environ.get('OS_AUTH_URL'), + username=os.environ.get('OS_USERNAME'), + password=os.environ.get('OS_PASSWORD'), + tenant_name=os.environ.get('OS_TENANT_NAME')) + return self._keystone_client + + def _get_nova_client(self): + if self._nova_client is None: + keystone = self._get_keystone_client() + self._nova_client = client.Client('2', token=keystone.auth_token) + return self._nova_client + + def _get_heat_client(self): + '''returns a heat client instance''' + if self._heat_client is None: + keystone = self._get_keystone_client() + heat_endpoint = keystone.service_catalog.url_for( + service_type='orchestration') + self._heat_client = heatclient.client.Client( + '1', endpoint=heat_endpoint, token=keystone.auth_token) + return self._heat_client + + def _get_glance_client(self): + if self._glance_client is None: + keystone = self._get_keystone_client() + glance_endpoint = keystone.service_catalog.url_for( + service_type='image') + self._glance_client = glanceclient.Client( + '2', glance_endpoint, token=keystone.auth_token) + return self._glance_client + + def create_stack(self, vm_role_ip_dict, Heat_template): + + stackname = 'QTIP' + heat = self._get_heat_client() + glance = self._get_glance_client() + + available_images = [] + for image_list in glance.images.list(): + + available_images.append(image_list.name) + + if 'QTIP_CentOS' in available_images: + print 'Image Present' + + elif 'QTIP_CentOS' not in available_images: + fetchImage = FetchImg() + fetchImage.download() + print 'Uploading Image to Glance. Please wait' + qtip_image = glance.images.create( + name='QTIP_CentOS', + visibility='public', + disk_format='qcow2', + container_format='bare') + qtip_image = glance.images.upload( + qtip_image.id, open('./Temp_Img/QTIP_CentOS.qcow2')) + json_temp = json.dumps(Heat_template) +# cluster_body = { +# "stack_name": stackname, +# "template": Heat_template +# } + for checks in range(3): + for prev_stacks in heat.stacks.list(): + + if prev_stacks.stack_name == 'QTIP': + print 'QTIP Stacks exists.\nDeleting Existing Stack' + heat.stacks.delete('QTIP') + time.sleep(10) + + print '\nStack Creating Started\n' + + try: + heat.stacks.create(stack_name=stackname, template=Heat_template) + + except: + print 'Create Failed :( ' + + cluster_detail = heat.stacks.get(stackname) + while(cluster_detail.status != 'COMPLETE'): + if cluster_detail.status == 'IN_PROGRESS': + print 'Stack Creation in Progress' + cluster_detail = heat.stacks.get(stackname) + time.sleep(10) + print 'Stack Created' + print 'Getting Public IP(s)' + zone = [] + s=0 + for vm in range(len(vm_role_ip_dict['OS_image'])): + + for I in cluster_detail.outputs: + availabilityKey = 'availability_instance_'+str(vm+1) + + if I['output_key'] == availabilityKey: + zone.insert(s,str(I['output_value'])) + s=s+1 + + for i in cluster_detail.outputs: + instanceKey = "instance_ip_" + str(vm + 1) + + if i['output_key'] == instanceKey: + + Env_setup.roles_dict[vm_role_ip_dict['role'][ + vm]].append(str(i['output_value'])) + + Env_setup.ip_pw_list.append( + (str(i['output_value']),'')) + if i['output_key'] == 'KeyPair_PublicKey': + sshkey = str(i['output_value']) + + with open('/root/.ssh/my_key.pem', 'w') as fopen: + fopen.write(sshkey) + fopen.close() + print Env_setup.ip_pw_list diff --git a/func/spawn_vm.pyc b/func/spawn_vm.pyc Binary files differnew file mode 100644 index 00000000..8e6ce8f1 --- /dev/null +++ b/func/spawn_vm.pyc diff --git a/func/validate_yaml.py b/func/validate_yaml.py new file mode 100644 index 00000000..c0df4d87 --- /dev/null +++ b/func/validate_yaml.py @@ -0,0 +1,32 @@ +############################################################################## +# Copyright (c) 2015 Dell Inc 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 +############################################################################## + + + +import yaml +import os + + +class Validate_Yaml(): + + def __init__(self, doc): + + print 'Validating YAML CONFIG FILE' + + if not doc['Scenario']: + print '\nScenario Field missing\n' + if not doc['Scenario']['benchmark']: + print '\nBenchmark field missing' + if not doc['Scenario']['pointless']: + print '\nBabyeating anumal' + if not doc['Context']: + print '\nEntire Context is missing' + if not doc['Context']['Host_Machine']: + print '\nNo Host Machine' + if not doc['Context']['Host_Machine']['machine_1'] diff --git a/func/validate_yaml.pyc b/func/validate_yaml.pyc Binary files differnew file mode 100644 index 00000000..9a560316 --- /dev/null +++ b/func/validate_yaml.pyc |