You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by da...@apache.org on 2014/07/28 17:41:24 UTC
[07/18] Marvin + test changes from master Signed-off-by:
SrikanteswaraRao Talluri
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/tools/marvin/marvin/config/test_data.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/config/test_data.py b/tools/marvin/marvin/config/test_data.py
new file mode 100644
index 0000000..1a29ed9
--- /dev/null
+++ b/tools/marvin/marvin/config/test_data.py
@@ -0,0 +1,629 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+test_data = {
+ "region": {
+ "regionid": "2",
+ "regionname": "Region2",
+ "regionendpoint": "http://region2:8080/client"
+ },
+ "zone": "NA",
+ "hypervisor": "XenServer",
+ "deleteDC": True,
+ "vdomain": {
+ "name": "domain"
+ },
+ "email": "test@test.com",
+ "gateway": "172.1.1.1",
+ "netmask": "255.255.255.0",
+ "startip": "172.1.1.10",
+ "endip": "172.1.1.20",
+ "regionid": "1",
+ "vlan": "10",
+ "isportable": "true",
+
+ "project": {
+ "name": "Project",
+ "displaytext": "Test project"
+ },
+ "account": {
+ "email": "test-account@test.com",
+ "firstname": "test",
+ "lastname": "test",
+ "username": "test-account",
+ "password": "password"
+ },
+ "small": {
+ "displayname": "testserver",
+ "username": "root",
+ "password": "password",
+ "ssh_port": 22,
+ "hypervisor": "XenServer",
+ "privateport": 22,
+ "publicport": 22,
+ "protocol": 'TCP',
+ },
+ "medium": {
+ "displayname": "testserver",
+ "username": "root",
+ "password": "password",
+ "ssh_port": 22,
+ "hypervisor": 'XenServer',
+ "privateport": 22,
+ "publicport": 22,
+ "protocol": 'TCP',
+ },
+ "service_offering": {
+ "name": "Tiny Instance",
+ "displaytext": "Tiny Instance",
+ "cpunumber": 1,
+ "cpuspeed": 100, # in MHz
+ "memory": 128, # In MBs
+ },
+ "service_offerings": {
+ "name": "Tiny Instance",
+ "displaytext": "Tiny Instance",
+ "cpunumber": 1,
+ "cpuspeed": 100,
+ "memory": 128,
+
+ "tiny": {
+ "name": "Tiny Instance",
+ "displaytext": "Tiny Instance",
+ "cpunumber": 1,
+ "cpuspeed": 100,
+ "memory": 128,
+ },
+ "small": {
+ "name": "Small Instance",
+ "displaytext": "Small Instance",
+ "cpunumber": 1,
+ "cpuspeed": 100,
+ "memory": 256
+ },
+ "medium": {
+ "name": "Medium Instance",
+ "displaytext": "Medium Instance",
+ "cpunumber": 1,
+ "cpuspeed": 100,
+ "memory": 256,
+ },
+ "big": {
+ "name": "BigInstance",
+ "displaytext": "BigInstance",
+ "cpunumber": 1,
+ "cpuspeed": 100,
+ "memory": 512,
+ }
+ },
+ "disk_offering": {
+ "name": "Disk offering",
+ "displaytext": "Disk offering",
+ "disksize": 1
+ },
+ 'resized_disk_offering': {
+ "displaytext": "Resized",
+ "name": "Resized",
+ "disksize": 3
+ },
+ "network": {
+ "name": "Test Network",
+ "displaytext": "Test Network",
+ "acltype": "Account",
+ },
+ "network2": {
+ "name": "Test Network Shared",
+ "displaytext": "Test Network Shared",
+ "vlan": 1201,
+ "gateway": "172.16.15.1",
+ "netmask": "255.255.255.0",
+ "startip": "172.16.15.21",
+ "endip": "172.16.15.41",
+ "acltype": "Account",
+ },
+ "network_offering": {
+ "name": 'Test Network offering',
+ "displaytext": 'Test Network offering',
+ "guestiptype": 'Isolated',
+ "supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding',
+ "traffictype": 'GUEST',
+ "availability": 'Optional',
+ "serviceProviderList": {
+ "Dhcp": 'VirtualRouter',
+ "Dns": 'VirtualRouter',
+ "SourceNat": 'VirtualRouter',
+ "PortForwarding": 'VirtualRouter',
+ },
+ },
+ "nw_off_isolated_persistent": {
+ "name": 'Test Nw off isolated persistent',
+ "displaytext": 'Test Nw off isolated persistent',
+ "guestiptype": 'Isolated',
+ "supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding',
+ "traffictype": 'GUEST',
+ "isPersistent": 'True',
+ "availability": 'Optional',
+ "serviceProviderList": {
+ "Dhcp": 'VirtualRouter',
+ "Dns": 'VirtualRouter',
+ "SourceNat": 'VirtualRouter',
+ "PortForwarding": 'VirtualRouter',
+ },
+ },
+ "isolated_network_offering": {
+ "name": "Network offering-DA services",
+ "displaytext": "Network offering-DA services",
+ "guestiptype": "Isolated",
+ "supportedservices":
+ "Dhcp,Dns,SourceNat,PortForwarding,Vpn,Firewall,Lb,UserData,StaticNat",
+ "traffictype": "GUEST",
+ "availability": "Optional'",
+ "serviceProviderList": {
+ "Dhcp": "VirtualRouter",
+ "Dns": "VirtualRouter",
+ "SourceNat": "VirtualRouter",
+ "PortForwarding": "VirtualRouter",
+ "Vpn": "VirtualRouter",
+ "Firewall": "VirtualRouter",
+ "Lb": "VirtualRouter",
+ "UserData": "VirtualRouter",
+ "StaticNat": "VirtualRouter"
+ }
+ },
+ "isolated_network": {
+ "name": "Isolated Network",
+ "displaytext": "Isolated Network"
+ },
+ "virtual_machine": {
+ "displayname": "Test VM",
+ "username": "root",
+ "password": "password",
+ "ssh_port": 22,
+ "privateport": 22,
+ "publicport": 22,
+ "protocol": "TCP",
+ "affinity": {
+ "name": "webvms",
+ "type": "host anti-affinity",
+ },
+ },
+ "virtual_machine2": {
+ "name": "testvm2",
+ "displayname": "Test VM2",
+ },
+ "virtual_machine3": {
+ "name": "testvm3",
+ "displayname": "Test VM3",
+ },
+ "server_without_disk": {
+ "displayname": "Test VM-No Disk",
+ "username": "root",
+ "password": "password",
+ "ssh_port": 22,
+ "hypervisor": 'XenServer',
+ "privateport": 22,
+ "publicport": 22,
+ "protocol": 'TCP',
+ },
+ "shared_network": {
+ "name": "MySharedNetwork - Test",
+ "displaytext": "MySharedNetwork",
+ "vlan": "",
+ "gateway": "",
+ "netmask": "",
+ "startip": "",
+ "endip": "",
+ "acltype": "Domain",
+ "scope": "all"
+ },
+ "shared_network_offering_sg": {
+ "name": "MySharedOffering-sg",
+ "displaytext": "MySharedOffering-sg",
+ "guestiptype": "Shared",
+ "supportedservices": "Dhcp,Dns,UserData,SecurityGroup",
+ "specifyVlan": "False",
+ "specifyIpRanges": "False",
+ "traffictype": "GUEST",
+ "serviceProviderList": {
+ "Dhcp": "VirtualRouter",
+ "Dns": "VirtualRouter",
+ "UserData": "VirtualRouter",
+ "SecurityGroup": "SecurityGroupProvider"
+ }
+ },
+ "shared_network_sg": {
+ "name": "Shared-Network-SG-Test",
+ "displaytext": "Shared-Network_SG-Test",
+ "networkofferingid": "1",
+ "vlan": "",
+ "gateway": "",
+ "netmask": "255.255.255.0",
+ "startip": "",
+ "endip": "",
+ "acltype": "Domain",
+ "scope": "all"
+ },
+ "vpc_offering": {
+ "name": "VPC off",
+ "displaytext": "VPC off",
+ "supportedservices":
+ "Dhcp,Dns,SourceNat,PortForwarding,Vpn,Lb,UserData,StaticNat,NetworkACL"
+ },
+ "vpc": {
+ "name": "TestVPC",
+ "displaytext": "TestVPC",
+ "cidr": "10.0.0.1/24"
+ },
+ "clusters": {
+ 0: {
+ "clustername": "Xen Cluster",
+ "clustertype": "CloudManaged",
+ "hypervisor": "XenServer",
+ },
+ 1: {
+ "clustername": "KVM Cluster",
+ "clustertype": "CloudManaged",
+ "hypervisor": "KVM",
+ },
+ 2: {
+ "hypervisor": 'VMware',
+ "clustertype": 'ExternalManaged',
+ "username": 'administrator',
+ "password": 'fr3sca',
+ "url": 'http://192.168.100.17/CloudStack-Clogeny-Pune/Pune-1',
+ "clustername": 'VMWare Cluster',
+ },
+ },
+ "hosts": {
+ "xenserver": {
+ "hypervisor": 'XenServer',
+ "clustertype": 'CloudManaged',
+ "url": 'http://192.168.100.211',
+ "username": "root",
+ "password": "fr3sca",
+ },
+ "kvm": {
+ "hypervisor": 'KVM',
+ "clustertype": 'CloudManaged',
+ "url": 'http://192.168.100.212',
+ "username": "root",
+ "password": "fr3sca",
+ },
+ "vmware": {
+ "hypervisor": 'VMware',
+ "clustertype": 'ExternalManaged',
+ "url": 'http://192.168.100.203',
+ "username": "administrator",
+ "password": "fr3sca",
+ },
+ },
+ "network_offering_shared": {
+ "name": 'Test Network offering shared',
+ "displaytext": 'Test Network offering Shared',
+ "guestiptype": 'Shared',
+ "supportedservices": 'Dhcp,Dns,UserData',
+ "traffictype": 'GUEST',
+ "specifyVlan": "True",
+ "specifyIpRanges": "True",
+ "serviceProviderList": {
+ "Dhcp": 'VirtualRouter',
+ "Dns": 'VirtualRouter',
+ "UserData": 'VirtualRouter',
+ },
+ },
+ "nw_off_persistent_RVR": {
+ "name": 'Network offering-RVR services',
+ "displaytext": 'Network off-RVR services',
+ "guestiptype": 'Isolated',
+ "supportedservices":
+ 'Vpn,Dhcp,Dns,SourceNat,PortForwarding,Firewall,Lb,UserData,StaticNat',
+ "traffictype": 'GUEST',
+ "isPersistent": 'True',
+ "availability": 'Optional',
+ "serviceProviderList": {
+ "Vpn": 'VirtualRouter',
+ "Dhcp": 'VirtualRouter',
+ "Dns": 'VirtualRouter',
+ "SourceNat": 'VirtualRouter',
+ "PortForwarding": 'VirtualRouter',
+ "Firewall": 'VirtualRouter',
+ "Lb": 'VirtualRouter',
+ "UserData": 'VirtualRouter',
+ "StaticNat": 'VirtualRouter',
+ },
+ "serviceCapabilityList": {
+ "SourceNat": {
+ "SupportedSourceNatTypes": "peraccount",
+ "RedundantRouter": "true",
+ },
+ "lb": {
+ "SupportedLbIsolation": "dedicated"
+ },
+ },
+ },
+ "nw_off_isolated_persistent_netscaler": {
+ "name": 'Netscaler',
+ "displaytext": 'Netscaler',
+ "guestiptype": 'Isolated',
+ "supportedservices":
+ 'Dhcp,Dns,SourceNat,PortForwarding,Vpn,Firewall,Lb,UserData,StaticNat',
+ "traffictype": 'GUEST',
+ "isPersistent": 'True',
+ "availability": 'Optional',
+ "serviceProviderList": {
+ "Dhcp": 'VirtualRouter',
+ "Dns": 'VirtualRouter',
+ "SourceNat": 'VirtualRouter',
+ "PortForwarding": 'VirtualRouter',
+ "Vpn": 'VirtualRouter',
+ "Firewall": 'VirtualRouter',
+ "Lb": 'Netscaler',
+ "UserData": 'VirtualRouter',
+ "StaticNat": 'VirtualRouter',
+ },
+
+ },
+ "nw_off_persistent_VPCVR_NoLB": {
+ "name": 'VPC Network offering',
+ "displaytext": 'VPC Network off',
+ "guestiptype": 'Isolated',
+ "supportedservices":
+ 'Vpn,Dhcp,Dns,SourceNat,PortForwarding,UserData,StaticNat,NetworkACL',
+ "traffictype": 'GUEST',
+ "availability": 'Optional',
+ "isPersistent": 'True',
+ "useVpc": 'on',
+ "serviceProviderList": {
+ "Vpn": 'VpcVirtualRouter',
+ "Dhcp": 'VpcVirtualRouter',
+ "Dns": 'VpcVirtualRouter',
+ "SourceNat": 'VpcVirtualRouter',
+ "PortForwarding": 'VpcVirtualRouter',
+ "UserData": 'VpcVirtualRouter',
+ "StaticNat": 'VpcVirtualRouter',
+ "NetworkACL": 'VpcVirtualRouter'
+ },
+
+ },
+ "network_offering_internal_lb": {
+ "name": "Network offering for internal lb service",
+ "displaytext": "Network offering for internal lb service",
+ "guestiptype": "Isolated",
+ "traffictype": "Guest",
+ "supportedservices":
+ "Vpn,Dhcp,Dns,Lb,UserData,SourceNat,StaticNat,PortForwarding,NetworkACL",
+ "serviceProviderList": {
+ "Dhcp": "VpcVirtualRouter",
+ "Dns": "VpcVirtualRouter",
+ "Vpn": "VpcVirtualRouter",
+ "UserData": "VpcVirtualRouter",
+ "Lb": "InternalLbVM",
+ "SourceNat": "VpcVirtualRouter",
+ "StaticNat": "VpcVirtualRouter",
+ "PortForwarding": "VpcVirtualRouter",
+ "NetworkACL": "VpcVirtualRouter",
+ },
+ "serviceCapabilityList": {
+ "SourceNat": {"SupportedSourceNatTypes": "peraccount"},
+ "Lb": {"lbSchemes": "internal", "SupportedLbIsolation": "dedicated"}
+ }
+ },
+ "natrule": {
+ "privateport": 22,
+ "publicport": 2222,
+ "protocol": "TCP"
+ },
+ "lbrule": {
+ "name": "SSH",
+ "alg": "roundrobin",
+ "privateport": 22,
+ "publicport": 2222,
+ "protocol": 'TCP'
+ },
+ "iso": {
+ "displaytext": "Test ISO",
+ "name": "ISO",
+ "url": "http://people.apache.org/~tsp/dummy.iso",
+ "bootable": False,
+ "ispublic": False,
+ "ostype": "CentOS 5.6 (64-bit)",
+ },
+ "iso1": {
+ "displaytext": "Test ISO 1",
+ "name": "ISO 1",
+ "url": "http://people.apache.org/~tsp/dummy.iso",
+ "isextractable": True,
+ "isfeatured": True,
+ "ispublic": True,
+ "ostype": "CentOS 5.6 (64-bit)",
+ },
+ "iso2": {
+ "displaytext": "Test ISO 2",
+ "name": "ISO 2",
+ "url": "http://people.apache.org/~tsp/dummy.iso",
+ "isextractable": True,
+ "isfeatured": True,
+ "ispublic": True,
+ "ostype": "CentOS 5.6 (64-bit)",
+ "mode": 'HTTP_DOWNLOAD',
+ },
+ "isfeatured": True,
+ "ispublic": True,
+ "isextractable": True,
+ "bootable": True,
+ "passwordenabled": True,
+
+ "template": {
+ "displaytext": "xs",
+ "name": "xs",
+ "passwordenabled": False,
+ },
+ "template_2": {
+ "displaytext": "Public Template",
+ "name": "Public template",
+ "ostype": "CentOS 5.6 (64-bit)",
+ "isfeatured": True,
+ "ispublic": True,
+ "isextractable": True,
+ "mode": "HTTP_DOWNLOAD",
+ },
+ "templatefilter": 'self',
+
+ "templates": {
+ "displaytext": 'Template',
+ "name": 'Template',
+ "ostype": "CentOS 5.3 (64-bit)",
+ "templatefilter": 'self',
+ },
+ "security_group": {"name": "custom_Sec_Grp"},
+ "ingress_rule": {
+ "protocol": "TCP",
+ "startport": "22",
+ "endport": "22",
+ "cidrlist": "0.0.0.0/0"
+ },
+ "vpncustomergateway": {
+ "ipsecpsk": "secreatKey",
+ "ikepolicy": "aes128-sha1",
+ "ikelifetime": "86400",
+ "esppolicy": "aes128-sha1",
+ "epslifetime": "3600",
+ "dpd": "false"
+ },
+ "ostype": "CentOS 5.6 (64-bit)",
+ "sleep": 90,
+ "timeout": 10,
+ "page": 1,
+ "pagesize": 2,
+ "listall": 'true',
+ "advanced_sg": {
+ "zone": {
+ "name": "",
+ "dns1": "8.8.8.8",
+ "internaldns1": "192.168.100.1",
+ "networktype": "Advanced",
+ "securitygroupenabled": "true"
+ },
+ "securitygroupenabled": "true"
+ },
+ "vlan": "10",
+ "portableiprange_vlan": {
+ "part": ["4090-4091", "4092-4095"],
+ "full": "4090-4095"
+ },
+ "nfs": {
+ "url": "nfs://nfs/export/automation/1/testprimary",
+ "name": "Primary XEN"
+ },
+ "iscsi": {
+ "url":
+ "iscsi://192.168.100.21/iqn.2012-01.localdomain.clo-cstack-cos6:iser/1",
+ "name": "Primary iSCSI"
+ },
+ "volume": {"diskname": "Test Volume"},
+ "custom_volume": {
+ "customdisksize": 1,
+ "diskname": "Custom disk",
+ },
+ "upload_volume": {
+ "diskname": "UploadVol",
+ "format": "VHD",
+ "url":
+ "http://10.147.28.7/templates/393d3550-05ef-330f-9b8c-745b0e699759.vhd",
+ "checksum": "",
+ },
+ "recurring_snapshot": {
+ "maxsnaps": 2,
+ "timezone": "US/Arizona",
+ },
+ "volume_offerings": {
+ 0: {"diskname": "TestDiskServ"},
+ },
+ "diskdevice": ['/dev/vdc', '/dev/vdb', '/dev/hdb', '/dev/hdc',
+ '/dev/xvdd', '/dev/cdrom', '/dev/sr0', '/dev/cdrom1'],
+
+ # test_vpc_vpn.py
+ "vpn_user": {
+ "username": "test",
+ "password": "password",
+ },
+ "vpc": {
+ "name": "vpc_vpn",
+ "displaytext": "vpc-vpn",
+ "cidr": "10.1.1.0/24"
+ },
+ "ntwk": {
+ "name": "tier1",
+ "displaytext": "vpc-tier1",
+ "gateway": "10.1.1.1",
+ "netmask": "255.255.255.192"
+ },
+ "vpc2": {
+ "name": "vpc2_vpn",
+ "displaytext": "vpc2-vpn",
+ "cidr": "10.2.1.0/24"
+ },
+ "ntwk2": {
+ "name": "tier2",
+ "displaytext": "vpc-tier2",
+ "gateway": "10.2.1.1",
+ "netmask": "255.255.255.192"
+ },
+ "server": {
+ "displayname": "TestVM",
+ "username": "root",
+ "password": "password",
+ "ssh_port": 22,
+ "hypervisor": 'XenServer',
+ "privateport": 22,
+ "publicport": 22,
+ "protocol": 'TCP'
+ },
+ "privateport": 22,
+ "publicport": 22,
+ "protocol": 'TCP',
+ "forvirtualnetwork": "true",
+ "customdisksize": 1,
+ "diskname": "Test Volume",
+ "portableIpRange": {
+ "gateway": "10.223.252.195",
+ "netmask": "255.255.255.192",
+ "startip": "10.223.252.196",
+ "endip": "10.223.252.197",
+ "vlan": "1001"
+ },
+ "sparse": {
+ "name": "Sparse Type Disk offering",
+ "displaytext":
+ "Sparse Type Disk offering",
+ "disksize": 1, # in GB
+ "provisioningtype": "sparse"
+ },
+ "fat": {
+ "name": "Fat Type Disk offering",
+ "displaytext":
+ "Fat Type Disk offering",
+ "disksize": 1, # in GB
+ "provisioningtype": "fat"
+ },
+ "sparse_disk_offering": {
+ "displaytext": "Sparse",
+ "name": "Sparse",
+ "provisioningtype": "sparse",
+ "disksize": 1
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/tools/marvin/marvin/configGenerator.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/configGenerator.py b/tools/marvin/marvin/configGenerator.py
index 0b4a0a1..68ec24e 100644
--- a/tools/marvin/marvin/configGenerator.py
+++ b/tools/marvin/marvin/configGenerator.py
@@ -20,9 +20,12 @@ import os
from optparse import OptionParser
import jsonHelper
from marvin.codes import *
+from marvin.cloudstackException import GetDetailExceptionInfo
+from marvin.config.test_data import test_data
class managementServer(object):
+
def __init__(self):
self.mgtSvrIp = None
self.port = 8096
@@ -34,6 +37,7 @@ class managementServer(object):
class dbServer(object):
+
def __init__(self):
self.dbSvr = None
self.port = 3306
@@ -50,8 +54,7 @@ class configuration(object):
class logger(object):
def __init__(self):
- '''TestCase/TestClient'''
- self.logFolderPath = None
+ self.LogFolderPath = None
class cloudstackConfiguration(object):
@@ -61,6 +64,7 @@ class cloudstackConfiguration(object):
self.dbSvr = None
self.globalConfig = []
self.logger = None
+ self.TestData = None
class zone(object):
@@ -83,6 +87,7 @@ class zone(object):
class trafficType(object):
+
def __init__(self, typ, labeldict=None):
self.typ = typ # Guest/Management/Public
if labeldict:
@@ -95,6 +100,7 @@ class trafficType(object):
class pod(object):
+
def __init__(self):
self.gateway = None
self.name = None
@@ -109,6 +115,7 @@ class pod(object):
class VmwareDc(object):
+
def __init__(self):
self.zoneid = None
self.name = None
@@ -118,6 +125,7 @@ class VmwareDc(object):
class cluster(object):
+
def __init__(self):
self.clustername = None
self.clustertype = None
@@ -132,6 +140,7 @@ class cluster(object):
class host(object):
+
def __init__(self):
self.hypervisor = None
self.password = None
@@ -149,6 +158,7 @@ class host(object):
class physicalNetwork(object):
+
def __init__(self):
self.name = None
self.tags = []
@@ -163,6 +173,7 @@ class physicalNetwork(object):
class provider(object):
+
def __init__(self, name=None):
self.name = name
self.state = None
@@ -173,6 +184,7 @@ class provider(object):
class network(object):
+
def __init__(self):
self.displaytext = None
self.name = None
@@ -185,6 +197,7 @@ class network(object):
class iprange(object):
+
def __init__(self):
'''tagged/untagged'''
self.gateway = None
@@ -198,12 +211,14 @@ class iprange(object):
class primaryStorage(object):
+
def __init__(self):
self.name = None
self.url = None
class secondaryStorage(object):
+
def __init__(self):
self.url = None
self.provider = None
@@ -211,6 +226,7 @@ class secondaryStorage(object):
class cacheStorage(object):
+
def __init__(self):
self.url = None
self.provider = None
@@ -218,6 +234,7 @@ class cacheStorage(object):
class s3(object):
+
def __init__(self):
self.accesskey = None
self.secretkey = None
@@ -230,6 +247,7 @@ class s3(object):
class netscaler(object):
+
def __init__(self, hostname=None, username='nsroot', password='nsroot'):
self.hostname = hostname
self.username = username
@@ -246,11 +264,12 @@ class netscaler(object):
def __repr__(self):
req = zip(self.__dict__.keys(), self.__dict__.values())
- return self.hostname+"?" + "&".join(["=".join([r[0], r[1]])
- for r in req])
+ return self.hostname + "?" + "&".join(["=".join([r[0], r[1]])
+ for r in req])
class srx(object):
+
def __init__(self, hostname=None, username='root', password='admin'):
self.hostname = hostname
self.username = username
@@ -269,11 +288,12 @@ class srx(object):
def __repr__(self):
req = zip(self.__dict__.keys(), self.__dict__.values())
- return self.hostname+"?" + "&".join(["=".join([r[0], r[1]])
- for r in req])
+ return self.hostname + "?" + "&".join(["=".join([r[0], r[1]])
+ for r in req])
class bigip(object):
+
def __init__(self, hostname=None, username='root', password='default'):
self.hostname = hostname
self.username = username
@@ -290,14 +310,14 @@ class bigip(object):
def __repr__(self):
req = zip(self.__dict__.keys(), self.__dict__.values())
- return self.hostname+"?" + "&".join(["=".join([r[0], r[1]])
- for r in req])
+ return self.hostname + "?" + "&".join(["=".join([r[0], r[1]])
+ for r in req])
class ConfigManager(object):
'''
- @Name: configManager
+ @Name: ConfigManager
@Desc: 1. It provides the basic configuration facilities to marvin.
2. User can just add configuration files for his tests, deployment
etc, under one config folder before running their tests.
@@ -328,16 +348,21 @@ class ConfigManager(object):
"getConfig" API,once configObj is returned.
'''
- def __init__(self):
- # Joining path with current directory will avoid relative path issue
- # It will take correct path irrespective of from where the test case is run
- dirPath = os.path.dirname(__file__)
- self.filePath = os.path.join(dirPath, 'config/config.cfg')
- self.parsedDict = None
- if self.__verifyFile(self.filePath) is not False:
- self.parsedDict = self.__parseConfig(self.filePath)
-
- def __parseConfig(self, file):
+ def __init__(self, cfg_file=None):
+ self.__filePath = cfg_file
+ self.__parsedCfgDict = None
+ '''
+ Set the Configuration
+ '''
+ self.__setConfig()
+
+ def __setConfig(self):
+ if not self.__verifyFile():
+ dirPath = os.path.dirname(__file__)
+ self.__filePath = str(os.path.join(dirPath, "config/test_data.py"))
+ self.__parsedCfgDict = self.__parseConfig()
+
+ def __parseConfig(self):
'''
@Name : __parseConfig
@Description: Parses the Input configuration Json file
@@ -348,36 +373,38 @@ class ConfigManager(object):
'''
config_dict = None
try:
- configlines = []
- with open(file, 'r') as fp:
- for line in fp:
- if len(line) != 0:
+ if self.__filePath.endswith(".py"):
+ config_dict = test_data
+ else:
+ configLines = []
+ with open(file, 'r') as fp:
+ for line in fp:
ws = line.strip()
- if ws[0] not in ["#"]:
- configlines.append(ws)
- config_dict = json.loads("\n".join(configlines))
- except Exception, e:
- #Will replace with log once we have logging done
- print "\n Exception occurred under __parseConfig", e
+ if not ws.startswith("#"):
+ configLines.append(ws)
+ config = json.loads("\n".join(configLines))
+ config_dict = config
+ except Exception as e:
+ # Will replace with log once we have logging done
+ print "\n Exception occurred under ConfigManager:__parseConfig" \
+ " :%s", GetDetailExceptionInfo(e)
finally:
return config_dict
- def __verifyFile(self, file):
+ def __verifyFile(self):
'''
@Name : __parseConfig
@Description: Parses the Input configuration Json file
and returns a dictionary from the file.
- @Input : file NA
+ @Input : NA
@Output : True or False based upon file input validity
and availability
'''
- if file is None or file == '':
+ if self.__filePath is None or self.__filePath == '':
return False
- if os.path.exists(file) is False:
- return False
- return True
+ return os.path.exists(self.__filePath)
- def __getSectionData(self, return_dict, section=None):
+ def getSectionData(self, section=None):
'''
@Name: getSectionData
@Desc: Gets the Section data of a particular section
@@ -386,43 +413,29 @@ class ConfigManager(object):
section to be returned from this dict
@Output:Section matching inside the parsed data
'''
- if return_dict is not None:
- inp = return_dict
- elif self.parsedDict is None:
+ if self.__parsedCfgDict is None or section is None:
+ print "\nEither Parsed Dictionary is None or Section is None"
return INVALID_INPUT
- else:
- inp = self.parsedDict
-
if section is not None:
- return inp.get(section)
- else:
- return inp
+ return self.__parsedCfgDict.get(section)
- def getConfig(self, file_path=None, section=None):
+ def getConfig(self):
'''
- @Name: getConfig
- @Desc : Parses and converts the given configuration file to dictionary
- @Input : file_path: path where the configuration needs to be passed
- section: specific section inside the file
- @Output: INVALID_INPUT: This value is returned if the input
- is invalid or not able to be parsed
- Parsed configuration dictionary from json file
+ @Name : getConfig
+ @Desc : Returns the Parsed Dictionary of Config Provided
+ @Input : NA
+ @Output: ParsedDict if successful if cfg file provided is valid
+ None if cfg file is invalid or not able to be parsed
'''
- ret = None
- if file not in [None, '']:
- if self.__verifyFile(file_path) is False:
- return INVALID_INPUT
- else:
- ret = self.__parseConfig(file_path)
- return self.__getSectionData(ret, section)
+ return self.__parsedCfgDict
def getDeviceUrl(obj):
req = zip(obj.__dict__.keys(), obj.__dict__.values())
if obj.hostname:
- return "http://" + obj.hostname+"?" + "&".join(["=".join([r[0],
- r[1]])
- for r in req])
+ return "http://" + obj.hostname + "?" + "&".join(["=".join([r[0],
+ r[1]])
+ for r in req])
else:
return None
@@ -437,11 +450,11 @@ def descSetupInBasicMode():
z.dns2 = "8.8.4.4"
z.internaldns1 = "192.168.110.254"
z.internaldns2 = "192.168.110.253"
- z.name = "test"+str(l)
+ z.name = "test" + str(l)
z.networktype = 'Basic'
z.securitygroupenabled = 'True'
- #If security groups are reqd
+ # If security groups are reqd
sgprovider = provider()
sgprovider.broadcastdomainrange = 'Pod'
sgprovider.name = 'SecurityGroupProvider'
@@ -467,15 +480,15 @@ def descSetupInBasicMode():
ip = iprange()
ip.gateway = p.gateway
ip.netmask = p.netmask
- ip.startip = "192.168.%d.%d" % (i, j*20)
- ip.endip = "192.168.%d.%d" % (i, j*20+10)
+ ip.startip = "192.168.%d.%d" % (i, j * 20)
+ ip.endip = "192.168.%d.%d" % (i, j * 20 + 10)
p.guestIpRanges.append(ip)
'''add 10 clusters'''
for j in range(2):
c = cluster()
- c.clustername = "test"+str(l)+str(i) + str(j)
+ c.clustername = "test" + str(l) + str(i) + str(j)
c.clustertype = "CloudManaged"
c.hypervisor = "Simulator"
@@ -484,15 +497,16 @@ def descSetupInBasicMode():
h = host()
h.username = "root"
h.password = "password"
- memory = 8*1024*1024*1024
- localstorage = 1*1024*1024*1024*1024
+ memory = 8 * 1024 * 1024 * 1024
+ localstorage = 1 * 1024 * 1024 * 1024 * 1024
h.url = "http://sim/%d%d%d%d" % (l, i, j, k)
c.hosts.append(h)
'''add 2 primary storages'''
for m in range(2):
primary = primaryStorage()
- primary.name = "primary"+str(l) + str(i) + str(j) + str(m)
+ primary.name = "primary" + \
+ str(l) + str(i) + str(j) + str(m)
primary.url = "nfs://localhost/path%s" % (str(l) + str(i) +
str(j) + str(m))
c.primaryStorages.append(primary)
@@ -504,7 +518,7 @@ def descSetupInBasicMode():
'''add two secondary'''
for i in range(5):
secondary = secondaryStorage()
- secondary.url = "nfs://localhost/path"+str(l) + str(i)
+ secondary.url = "nfs://localhost/path" + str(l) + str(i)
z.secondaryStorages.append(secondary)
zs.zones.append(z)
@@ -546,7 +560,7 @@ def descSetupInEipMode():
z.dns2 = "8.8.4.4"
z.internaldns1 = "192.168.110.254"
z.internaldns2 = "192.168.110.253"
- z.name = "test"+str(l)
+ z.name = "test" + str(l)
z.networktype = 'Basic'
ips = iprange()
@@ -557,7 +571,7 @@ def descSetupInEipMode():
ips.netmask = "255.255.255.0"
z.ipranges.append(ips)
- #If security groups are reqd
+ # If security groups are reqd
sgprovider = provider()
sgprovider.broadcastdomainrange = 'Pod'
sgprovider.name = 'SecurityGroupProvider'
@@ -591,15 +605,15 @@ def descSetupInEipMode():
ip = iprange()
ip.gateway = p.gateway
ip.netmask = p.netmask
- ip.startip = "192.168.%d.%d" % (i, j*20)
- ip.endip = "192.168.%d.%d" % (i, j*20+10)
+ ip.startip = "192.168.%d.%d" % (i, j * 20)
+ ip.endip = "192.168.%d.%d" % (i, j * 20 + 10)
p.guestIpRanges.append(ip)
'''add 10 clusters'''
for j in range(2):
c = cluster()
- c.clustername = "test"+str(l)+str(i) + str(j)
+ c.clustername = "test" + str(l) + str(i) + str(j)
c.clustertype = "CloudManaged"
c.hypervisor = "Simulator"
@@ -614,7 +628,8 @@ def descSetupInEipMode():
'''add 2 primary storages'''
for m in range(2):
primary = primaryStorage()
- primary.name = "primary"+str(l) + str(i) + str(j) + str(m)
+ primary.name = "primary" + \
+ str(l) + str(i) + str(j) + str(m)
primary.url = "nfs://localhost/path%s" % (str(l) + str(i)
+ str(j)
+ str(m))
@@ -627,7 +642,7 @@ def descSetupInEipMode():
'''add two secondary'''
for i in range(5):
secondary = secondaryStorage()
- secondary.url = "nfs://localhost/path"+str(l) + str(i)
+ secondary.url = "nfs://localhost/path" + str(l) + str(i)
z.secondaryStorages.append(secondary)
zs.zones.append(z)
@@ -667,7 +682,7 @@ def descSetupInAdvancedMode():
z.dns2 = "8.8.4.4"
z.internaldns1 = "192.168.110.254"
z.internaldns2 = "192.168.110.253"
- z.name = "test"+str(l)
+ z.name = "test" + str(l)
z.networktype = 'Advanced'
z.guestcidraddress = "10.1.1.0/24"
z.vlan = "100-2000"
@@ -703,7 +718,7 @@ def descSetupInAdvancedMode():
'''add 10 clusters'''
for j in range(2):
c = cluster()
- c.clustername = "test"+str(l)+str(i) + str(j)
+ c.clustername = "test" + str(l) + str(i) + str(j)
c.clustertype = "CloudManaged"
c.hypervisor = "Simulator"
@@ -714,7 +729,7 @@ def descSetupInAdvancedMode():
h.password = "password"
memory = 8 * 1024 * 1024 * 1024
localstorage = 1 * 1024 * 1024 * 1024 * 1024
- #h.url = "http://sim/%d%d%d%d/cpucore=1&cpuspeed=8000&\
+ # h.url = "http://sim/%d%d%d%d/cpucore=1&cpuspeed=8000&\
# memory=%d&localstorage=%d"%(l, i, j, k, memory,
# localstorage)
h.url = "http://sim/%d%d%d%d" % (l, i, j, k)
@@ -723,8 +738,9 @@ def descSetupInAdvancedMode():
'''add 2 primary storages'''
for m in range(2):
primary = primaryStorage()
- primary.name = "primary"+str(l) + str(i) + str(j) + str(m)
- #primary.url = "nfs://localhost/path%s/size=%d" %
+ primary.name = "primary" + \
+ str(l) + str(i) + str(j) + str(m)
+ # primary.url = "nfs://localhost/path%s/size=%d" %
# (str(l) + str(i) + str(j) + str(m), size)
primary.url = "nfs://localhost/path%s" % (str(l) + str(i)
+ str(j)
@@ -738,7 +754,7 @@ def descSetupInAdvancedMode():
'''add two secondary'''
for i in range(5):
secondary = secondaryStorage()
- secondary.url = "nfs://localhost/path"+str(l) + str(i)
+ secondary.url = "nfs://localhost/path" + str(l) + str(i)
z.secondaryStorages.append(secondary)
'''add default public network'''
@@ -788,7 +804,7 @@ def descSetupInAdvancedsgMode():
z.dns2 = "8.8.4.4"
z.internaldns1 = "192.168.110.254"
z.internaldns2 = "192.168.110.253"
- z.name = "test"+str(l)
+ z.name = "test" + str(l)
z.networktype = 'Advanced'
z.vlan = "100-2000"
z.securitygroupenabled = "true"
@@ -797,7 +813,7 @@ def descSetupInAdvancedsgMode():
pn.name = "test-network"
pn.traffictypes = [trafficType("Guest"), trafficType("Management")]
- #If security groups are reqd
+ # If security groups are reqd
sgprovider = provider()
sgprovider.broadcastdomainrange = 'ZONE'
sgprovider.name = 'SecurityGroupProvider'
@@ -817,7 +833,7 @@ def descSetupInAdvancedsgMode():
'''add 10 clusters'''
for j in range(2):
c = cluster()
- c.clustername = "test"+str(l)+str(i) + str(j)
+ c.clustername = "test" + str(l) + str(i) + str(j)
c.clustertype = "CloudManaged"
c.hypervisor = "Simulator"
@@ -828,17 +844,18 @@ def descSetupInAdvancedsgMode():
h.password = "password"
memory = 8 * 1024 * 1024 * 1024
localstorage = 1 * 1024 * 1024 * 1024 * 1024
- #h.url = "http://sim/%d%d%d%d/cpucore=1&cpuspeed=8000&\
- #memory=%d&localstorage=%d" % (l, i, j, k, memory,
- #localstorage)
+ # h.url = "http://sim/%d%d%d%d/cpucore=1&cpuspeed=8000&\
+ # memory=%d&localstorage=%d" % (l, i, j, k, memory,
+ # localstorage)
h.url = "http://sim/%d%d%d%d" % (l, i, j, k)
c.hosts.append(h)
'''add 2 primary storages'''
for m in range(2):
primary = primaryStorage()
- primary.name = "primary"+str(l) + str(i) + str(j) + str(m)
- #primary.url = "nfs://localhost/path%s/size=%d" % \
+ primary.name = "primary" + \
+ str(l) + str(i) + str(j) + str(m)
+ # primary.url = "nfs://localhost/path%s/size=%d" % \
#(str(l) + str(i) + str(j) + str(m), size)
primary.url = "nfs://localhost/path%s" % \
(str(l) + str(i) + str(j) + str(m))
@@ -851,7 +868,7 @@ def descSetupInAdvancedsgMode():
'''add two secondary'''
for i in range(5):
secondary = secondaryStorage()
- secondary.url = "nfs://localhost/path"+str(l) + str(i)
+ secondary.url = "nfs://localhost/path" + str(l) + str(i)
z.secondaryStorages.append(secondary)
'''add default guest network'''
@@ -901,18 +918,19 @@ def generate_setup_config(config, file=None):
def getSetupConfig(file):
- if not os.path.exists(file):
- raise IOError("config file %s not found. \
- please specify a valid config file" % file)
- config = cloudstackConfiguration()
- configLines = []
- with open(file, 'r') as fp:
- for line in fp:
- ws = line.strip()
- if not ws.startswith("#"):
- configLines.append(ws)
- config = json.loads("\n".join(configLines))
- return jsonHelper.jsonLoader(config)
+ try:
+ config = cloudstackConfiguration()
+ configLines = []
+ with open(file, 'r') as fp:
+ for line in fp:
+ ws = line.strip()
+ if not ws.startswith("#"):
+ configLines.append(ws)
+ config = json.loads("\n".join(configLines))
+ return jsonHelper.jsonLoader(config)
+ except Exception as e:
+ print "\nException Occurred under getSetupConfig %s" % \
+ GetDetailExceptionInfo(e)
if __name__ == "__main__":
parser = OptionParser()
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/tools/marvin/marvin/dbConnection.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/dbConnection.py b/tools/marvin/marvin/dbConnection.py
index 99014ab..66c6cb1 100644
--- a/tools/marvin/marvin/dbConnection.py
+++ b/tools/marvin/marvin/dbConnection.py
@@ -20,12 +20,13 @@ import contextlib
from mysql import connector
from mysql.connector import errors
from contextlib import closing
-import cloudstackException
+from marvin import cloudstackException
import sys
import os
-class dbConnection(object):
+class DbConnection(object):
+
def __init__(self, host="localhost", port=3306, user='cloud',
passwd='cloud', db='cloud'):
self.host = host
@@ -51,7 +52,7 @@ class dbConnection(object):
try:
resultRow = cursor.fetchall()
except errors.InterfaceError:
- #Raised on empty result - DML
+ # Raised on empty result - DML
resultRow = []
return resultRow
@@ -68,7 +69,7 @@ class dbConnection(object):
return self.execute(sqls)
if __name__ == "__main__":
- db = dbConnection()
+ db = DbConnection()
'''
try:
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/tools/marvin/marvin/deployAndRun.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/deployAndRun.py b/tools/marvin/marvin/deployAndRun.py
index 56747a7..d3b6b86 100644
--- a/tools/marvin/marvin/deployAndRun.py
+++ b/tools/marvin/marvin/deployAndRun.py
@@ -15,13 +15,13 @@
# specific language governing permissions and limitations
# under the License.
-from tcExecuteEngine import TestCaseExecuteEngine
+from .tcExecuteEngine import TestCaseExecuteEngine
import sys
import os
import traceback
import time
from argparse import ArgumentParser
-from marvinInit import MarvinInit
+from .marvinInit import MarvinInit
from marvin.codes import (SUCCESS,
FAILED,
EXCEPTION,
@@ -96,7 +96,7 @@ def startMarvin(cfg_file, load_flag):
else:
print "\nMarvin Initialization Failed"
exit(1)
- except Exception, e:
+ except Exception as e:
print "\n Exception occurred while starting Marvin %s" % str(e)
exit(1)