cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t..@apache.org
Subject [09/50] [abbrv] git commit: updated refs/heads/marvin_refactor to b784012
Date Mon, 18 Nov 2013 08:50:16 GMT
marvin-refactor: move the deployment helpers to deployer module

deployer module will contain all the helper modules used for json
description of data center and will also feature the export module for
exporting a datacenter in to json

Signed-off-by: Prasanna Santhanam <tsp@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/44b3edcf
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/44b3edcf
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/44b3edcf

Branch: refs/heads/marvin_refactor
Commit: 44b3edcf7500e5ecd3b773e7ad50a687d64517df
Parents: fac014d
Author: Prasanna Santhanam <tsp@apache.org>
Authored: Sat Sep 7 10:55:12 2013 +0530
Committer: Prasanna Santhanam <tsp@apache.org>
Committed: Thu Oct 31 13:54:22 2013 +0530

----------------------------------------------------------------------
 tools/marvin/marvin/configGenerator.py          | 873 -------------------
 tools/marvin/marvin/deployDataCenter.py         | 623 -------------
 tools/marvin/marvin/deployer/__init__.py        |  16 +
 tools/marvin/marvin/deployer/configGenerator.py | 873 +++++++++++++++++++
 .../marvin/marvin/deployer/deployDataCenter.py  | 623 +++++++++++++
 5 files changed, 1512 insertions(+), 1496 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/44b3edcf/tools/marvin/marvin/configGenerator.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/configGenerator.py b/tools/marvin/marvin/configGenerator.py
deleted file mode 100644
index 0cfad30..0000000
--- a/tools/marvin/marvin/configGenerator.py
+++ /dev/null
@@ -1,873 +0,0 @@
-# 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.
-
-import json
-import os
-from optparse import OptionParser
-import jsonHelper
-
-
-class managementServer(object):
-    def __init__(self):
-        self.mgtSvrIp = None
-        self.port = 8096
-        self.apiKey = None
-        self.securityKey = None
-        self.useHttps = None
-        self.certCAPath = None
-        self.certPath = None
-
-
-class dbServer(object):
-    def __init__(self):
-        self.dbSvr = None
-        self.port = 3306
-        self.user = "cloud"
-        self.passwd = "cloud"
-        self.db = "cloud"
-
-
-class configuration(object):
-    def __init__(self):
-        self.name = None
-        self.value = None
-
-
-class logger(object):
-    def __init__(self):
-        '''TestCase/TestClient'''
-        self.name = None
-        self.file = None
-
-
-class cloudstackConfiguration(object):
-    def __init__(self):
-        self.zones = []
-        self.mgtSvr = []
-        self.dbSvr = None
-        self.globalConfig = []
-        self.logger = []
-
-
-class zone(object):
-    def __init__(self):
-        self.dns1 = None
-        self.internaldns1 = None
-        self.name = None
-        '''Basic or Advanced'''
-        self.networktype = None
-        self.dns2 = None
-        self.internaldns2 = None
-        self.securitygroupenabled = None
-        self.localstorageenabled = None
-        '''default public network, in advanced mode'''
-        self.ipranges = []
-        self.physical_networks = []
-        self.pods = []
-        self.secondaryStorages = []
-        self.cacheStorages = []
-
-
-class traffictype(object):
-    def __init__(self, typ, labeldict=None):
-        self.typ = typ  # Guest/Management/Public
-        if labeldict:
-            self.xen = labeldict['xen'] if 'xen' in labeldict.keys() else None
-            self.kvm = labeldict['kvm'] if 'kvm' in labeldict.keys() else None
-            self.vmware = labeldict['vmware']\
-                if 'vmware' in labeldict.keys() else None
-            self.simulator = labeldict['simulator']\
-                if 'simulator' in labeldict.keys() else None
-        #{
-        #    'xen' : 'cloud-xen',
-        #    'kvm' : 'cloud-kvm',
-        #    'vmware' : 'cloud-vmware'
-        #}
-
-
-class pod(object):
-    def __init__(self):
-        self.gateway = None
-        self.name = None
-        self.netmask = None
-        self.startip = None
-        self.endip = None
-        self.zoneid = None
-        self.clusters = []
-        self.vmwaredc = []
-        '''Used in basic network mode'''
-        self.guestIpRanges = []
-
-
-class VmwareDc(object):
-    def __init__(self):
-        self.zoneid = None
-        self.name = None
-        self.vcenter = None
-        self.username = None
-        self.password = None
-
-
-class cluster(object):
-    def __init__(self):
-        self.clustername = None
-        self.clustertype = None
-        self.hypervisor = None
-        self.zoneid = None
-        self.podid = None
-        self.password = None
-        self.url = None
-        self.username = None
-        self.hosts = []
-        self.primaryStorages = []
-
-
-class host(object):
-    def __init__(self):
-        self.hypervisor = None
-        self.password = None
-        self.url = None
-        self.username = None
-        self.zoneid = None
-        self.podid = None
-        self.clusterid = None
-        self.clustername = None
-        self.cpunumber = None
-        self.cpuspeed = None
-        self.hostmac = None
-        self.hosttags = None
-        self.memory = None
-
-
-class physical_network(object):
-    def __init__(self):
-        self.name = None
-        self.tags = []
-        self.traffictypes = []
-        self.broadcastdomainrange = 'Zone'
-        self.vlan = None
-        self.isolationmethods = []
-        '''enable default virtual router provider'''
-        vrouter = provider()
-        vrouter.name = 'VirtualRouter'
-        self.providers = [vrouter]
-
-
-class provider(object):
-    def __init__(self, name=None):
-        self.name = name
-        self.state = None
-        self.broadcastdomainrange = 'ZONE'
-        self.zoneid = None
-        self.servicelist = []
-        self.devices = []
-
-
-class network(object):
-    def __init__(self):
-        self.displaytext = None
-        self.name = None
-        self.zoneid = None
-        self.acltype = None
-        self.domainid = None
-        self.networkdomain = None
-        self.networkofferingid = None
-        self.ipranges = []
-
-
-class iprange(object):
-    def __init__(self):
-        '''tagged/untagged'''
-        self.gateway = None
-        self.netmask = None
-        self.startip = None
-        self.endip = None
-        self.vlan = None
-        '''for account specific '''
-        self.account = None
-        self.domain = None
-
-
-class primaryStorage(object):
-    def __init__(self):
-        self.name = None
-        self.url = None
-
-
-class secondaryStorage(object):
-    def __init__(self):
-        self.url = None
-        self.provider = None
-        self.details = None
-
-
-class cacheStorage(object):
-    def __init__(self):
-        self.url = None
-        self.provider = None
-        self.details = None
-
-
-class s3(object):
-    def __init__(self):
-        self.accesskey = None
-        self.secretkey = None
-        self.bucket = None
-        self.endpoint = None
-        self.sockettimeout = None
-        self.connectiontimeout = None
-        self.maxerrorrety = None
-        self.usehttps = None
-
-
-class netscaler(object):
-    def __init__(self, hostname=None, username='nsroot', password='nsroot'):
-        self.hostname = hostname
-        self.username = username
-        self.password = password
-        self.networkdevicetype = 'NetscalerVPXLoadBalancer'
-        self.publicinterface = '1/1'
-        self.privateinterface = '1/1'
-        self.numretries = '2'
-        self.lbdevicecapacity = '50'
-        self.lbdevicededicated = 'false'
-
-    def getUrl(self):
-        return repr(self)
-
-    def __repr__(self):
-        req = zip(self.__dict__.keys(), self.__dict__.values())
-        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
-        self.password = password
-        self.networkdevicetype = 'JuniperSRXFirewall'
-        self.publicinterface = '1/1'
-        self.privateinterface = '1/1'
-        self.numretries = '2'
-        self.fwdevicededicated = 'false'
-        self.timeout = '300'
-        self.publicnetwork = 'untrusted'
-        self.privatenetwork = 'trusted'
-
-    def getUrl(self):
-        return repr(self)
-
-    def __repr__(self):
-        req = zip(self.__dict__.keys(), self.__dict__.values())
-        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
-        self.password = password
-        self.networkdevicetype = 'F5BigIpLoadBalancer'
-        self.publicinterface = '1/1'
-        self.privateinterface = '1/1'
-        self.numretries = '2'
-        self.lbdevicededicated = 'false'
-        self.lbdevicecapacity = '50'
-
-    def getUrl(self):
-        return repr(self)
-
-    def __repr__(self):
-        req = zip(self.__dict__.keys(), self.__dict__.values())
-        return self.hostname+"?" + "&".join(["=".join([r[0], r[1]])
-                                             for r in req])
-
-
-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])
-    else:
-        return None
-
-
-def describe_setup_in_basic_mode():
-    '''sample code to generate setup configuration file'''
-    zs = cloudstackConfiguration()
-
-    for l in range(1):
-        z = zone()
-        z.dns1 = "8.8.8.8"
-        z.dns2 = "8.8.4.4"
-        z.internaldns1 = "192.168.110.254"
-        z.internaldns2 = "192.168.110.253"
-        z.name = "test"+str(l)
-        z.networktype = 'Basic'
-        z.securitygroupenabled = 'True'
-
-        #If security groups are reqd
-        sgprovider = provider()
-        sgprovider.broadcastdomainrange = 'Pod'
-        sgprovider.name = 'SecurityGroupProvider'
-
-        pn = physical_network()
-        pn.name = "test-network"
-        pn.traffictypes = [traffictype("Guest"), traffictype("Management")]
-        pn.providers.append(sgprovider)
-
-        z.physical_networks.append(pn)
-
-        '''create 10 pods'''
-        for i in range(2):
-            p = pod()
-            p.name = "test" + str(l) + str(i)
-            p.gateway = "192.168.%d.1" % i
-            p.netmask = "255.255.255.0"
-            p.startip = "192.168.%d.150" % i
-            p.endip = "192.168.%d.220" % i
-
-            '''add two pod guest ip ranges'''
-            for j in range(2):
-                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)
-
-                p.guestIpRanges.append(ip)
-
-            '''add 10 clusters'''
-            for j in range(2):
-                c = cluster()
-                c.clustername = "test"+str(l)+str(i) + str(j)
-                c.clustertype = "CloudManaged"
-                c.hypervisor = "Simulator"
-
-                '''add 10 hosts'''
-                for k in range(2):
-                    h = host()
-                    h.username = "root"
-                    h.password = "password"
-                    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.url = "nfs://localhost/path%s" % (str(l) + str(i) +
-                                                              str(j) + str(m))
-                    c.primaryStorages.append(primary)
-
-                p.clusters.append(c)
-
-            z.pods.append(p)
-
-        '''add two secondary'''
-        for i in range(5):
-            secondary = secondaryStorage()
-            secondary.url = "nfs://localhost/path"+str(l) + str(i)
-            z.secondaryStorages.append(secondary)
-
-        zs.zones.append(z)
-
-    '''Add one mgt server'''
-    mgt = managementServer()
-    mgt.mgtSvrIp = "localhost"
-    zs.mgtSvr.append(mgt)
-
-    '''Add a database'''
-    db = dbServer()
-    db.dbSvr = "localhost"
-
-    zs.dbSvr = db
-
-    '''add global configuration'''
-    global_settings = {'expunge.delay': '60',
-                       'expunge.interval': '60',
-                       'expunge.workers': '3',
-                       }
-    for k, v in global_settings.iteritems():
-        cfg = configuration()
-        cfg.name = k
-        cfg.value = v
-        zs.globalConfig.append(cfg)
-
-    ''''add loggers'''
-    testClientLogger = logger()
-    testClientLogger.name = "TestClient"
-    testClientLogger.file = "/tmp/testclient.log"
-
-    testCaseLogger = logger()
-    testCaseLogger.name = "TestCase"
-    testCaseLogger.file = "/tmp/testcase.log"
-
-    zs.logger.append(testClientLogger)
-    zs.logger.append(testCaseLogger)
-
-    return zs
-
-
-def describe_setup_in_eip_mode():
-    """
-    Setting up an EIP/ELB enabled zone with netscaler provider
-    """
-    zs = cloudstackConfiguration()
-
-    for l in range(1):
-        z = zone()
-        z.dns1 = "8.8.8.8"
-        z.dns2 = "8.8.4.4"
-        z.internaldns1 = "192.168.110.254"
-        z.internaldns2 = "192.168.110.253"
-        z.name = "test"+str(l)
-        z.networktype = 'Basic'
-
-        ips = iprange()
-        ips.vlan = "49"
-        ips.startip = "10.147.49.200"
-        ips.endip = "10.147.49.250"
-        ips.gateway = "10.147.49.1"
-        ips.netmask = "255.255.255.0"
-        z.ipranges.append(ips)
-
-        #If security groups are reqd
-        sgprovider = provider()
-        sgprovider.broadcastdomainrange = 'Pod'
-        sgprovider.name = 'SecurityGroupProvider'
-
-        nsprovider = provider()
-        nsprovider.name = 'Netscaler'
-        ns = netscaler()
-        ns.hostname = '10.147.40.100'
-        nsprovider.devices.append(ns)
-
-        pn = physical_network()
-        pn.name = "test-network"
-        pn.traffictypes = [traffictype("Guest",
-                                       {"xen": "cloud-guest"}),
-                           traffictype("Management"),
-                           traffictype("Public", {"xen": "cloud-public"})]
-        pn.providers.extend([sgprovider, nsprovider])
-        z.physical_networks.append(pn)
-
-        '''create 10 pods'''
-        for i in range(2):
-            p = pod()
-            p.name = "test" + str(l) + str(i)
-            p.gateway = "192.168.%d.1" % i
-            p.netmask = "255.255.255.0"
-            p.startip = "192.168.%d.150" % i
-            p.endip = "192.168.%d.220" % i
-
-            '''add two pod guest ip ranges'''
-            for j in range(2):
-                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)
-
-                p.guestIpRanges.append(ip)
-
-            '''add 10 clusters'''
-            for j in range(2):
-                c = cluster()
-                c.clustername = "test"+str(l)+str(i) + str(j)
-                c.clustertype = "CloudManaged"
-                c.hypervisor = "Simulator"
-
-                '''add 10 hosts'''
-                for k in range(2):
-                    h = host()
-                    h.username = "root"
-                    h.password = "password"
-                    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" % (str(l) + str(i)
-                                                              + str(j)
-                                                              + str(m))
-                    c.primaryStorages.append(primary)
-
-                p.clusters.append(c)
-
-            z.pods.append(p)
-
-        '''add two secondary'''
-        for i in range(5):
-            secondary = secondaryStorage()
-            secondary.url = "nfs://localhost/path"+str(l) + str(i)
-            z.secondaryStorages.append(secondary)
-
-        zs.zones.append(z)
-
-    '''Add one mgt server'''
-    mgt = managementServer()
-    mgt.mgtSvrIp = "localhost"
-    zs.mgtSvr.append(mgt)
-
-    '''Add a database'''
-    db = dbServer()
-    db.dbSvr = "localhost"
-
-    zs.dbSvr = db
-
-    '''add global configuration'''
-    global_settings = {'expunge.delay': '60',
-                       'expunge.interval': '60',
-                       'expunge.workers': '3',
-                       }
-    for k, v in global_settings.iteritems():
-        cfg = configuration()
-        cfg.name = k
-        cfg.value = v
-        zs.globalConfig.append(cfg)
-
-    ''''add loggers'''
-    testClientLogger = logger()
-    testClientLogger.name = "TestClient"
-    testClientLogger.file = "/tmp/testclient.log"
-
-    testCaseLogger = logger()
-    testCaseLogger.name = "TestCase"
-    testCaseLogger.file = "/tmp/testcase.log"
-
-    zs.logger.append(testClientLogger)
-    zs.logger.append(testCaseLogger)
-
-    return zs
-
-
-def describe_setup_in_advanced_mode():
-    '''sample code to generate setup configuration file'''
-    zs = cloudstackConfiguration()
-
-    for l in range(1):
-        z = zone()
-        z.dns1 = "8.8.8.8"
-        z.dns2 = "8.8.4.4"
-        z.internaldns1 = "192.168.110.254"
-        z.internaldns2 = "192.168.110.253"
-        z.name = "test"+str(l)
-        z.networktype = 'Advanced'
-        z.guestcidraddress = "10.1.1.0/24"
-        z.vlan = "100-2000"
-
-        pn = physical_network()
-        pn.name = "test-network"
-        pn.traffictypes = [traffictype("Guest"), traffictype("Management"),
-                           traffictype("Public")]
-
-        vpcprovider = provider('VpcVirtualRouter')
-
-        nsprovider = provider('Netscaler')
-        nsprovider.devices.append(netscaler(hostname='10.147.40.100'))
-
-        srxprovider = provider('JuniperSRX')
-        srxprovider.devices.append(srx(hostname='10.147.40.3'))
-
-        f5provider = provider('F5BigIp')
-        f5provider.devices.append(bigip(hostname='10.147.40.3'))
-
-        pn.providers.extend([vpcprovider, nsprovider, srxprovider, f5provider])
-        z.physical_networks.append(pn)
-
-        '''create 10 pods'''
-        for i in range(2):
-            p = pod()
-            p.name = "test" + str(l) + str(i)
-            p.gateway = "192.168.%d.1" % i
-            p.netmask = "255.255.255.0"
-            p.startip = "192.168.%d.200" % i
-            p.endip = "192.168.%d.220" % i
-
-            '''add 10 clusters'''
-            for j in range(2):
-                c = cluster()
-                c.clustername = "test"+str(l)+str(i) + str(j)
-                c.clustertype = "CloudManaged"
-                c.hypervisor = "Simulator"
-
-                '''add 10 hosts'''
-                for k in range(2):
-                    h = host()
-                    h.username = "root"
-                    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" % (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" %
-                    #    (str(l) + str(i) + str(j) + str(m), size)
-                    primary.url = "nfs://localhost/path%s" % (str(l) + str(i)
-                                                              + str(j)
-                                                              + str(m))
-                    c.primaryStorages.append(primary)
-
-                p.clusters.append(c)
-
-            z.pods.append(p)
-
-        '''add two secondary'''
-        for i in range(5):
-            secondary = secondaryStorage()
-            secondary.url = "nfs://localhost/path"+str(l) + str(i)
-            z.secondaryStorages.append(secondary)
-
-        '''add default public network'''
-        ips = iprange()
-        ips.vlan = "26"
-        ips.startip = "172.16.26.2"
-        ips.endip = "172.16.26.100"
-        ips.gateway = "172.16.26.1"
-        ips.netmask = "255.255.255.0"
-        z.ipranges.append(ips)
-
-        zs.zones.append(z)
-
-    '''Add one mgt server'''
-    mgt = managementServer()
-    mgt.mgtSvrIp = "localhost"
-    zs.mgtSvr.append(mgt)
-
-    '''Add a database'''
-    db = dbServer()
-    db.dbSvr = "localhost"
-
-    zs.dbSvr = db
-
-    '''add global configuration'''
-    global_settings = {'expunge.delay': '60',
-                       'expunge.interval': '60',
-                       'expunge.workers': '3',
-                       }
-    for k, v in global_settings.iteritems():
-        cfg = configuration()
-        cfg.name = k
-        cfg.value = v
-        zs.globalConfig.append(cfg)
-
-    ''''add loggers'''
-    testClientLogger = logger()
-    testClientLogger.name = "TestClient"
-    testClientLogger.file = "/tmp/testclient.log"
-
-    testCaseLogger = logger()
-    testCaseLogger.name = "TestCase"
-    testCaseLogger.file = "/tmp/testcase.log"
-
-    zs.logger.append(testClientLogger)
-    zs.logger.append(testCaseLogger)
-
-    return zs
-
-'''sample code to generate setup configuration file'''
-
-
-def describe_setup_in_advancedsg_mode():
-    zs = cloudstackConfiguration()
-
-    for l in range(1):
-        z = zone()
-        z.dns1 = "8.8.8.8"
-        z.dns2 = "8.8.4.4"
-        z.internaldns1 = "192.168.110.254"
-        z.internaldns2 = "192.168.110.253"
-        z.name = "test"+str(l)
-        z.networktype = 'Advanced'
-        z.vlan = "100-2000"
-        z.securitygroupenabled = "true"
-
-        pn = physical_network()
-        pn.name = "test-network"
-        pn.traffictypes = [traffictype("Guest"), traffictype("Management")]
-
-        #If security groups are reqd
-        sgprovider = provider()
-        sgprovider.broadcastdomainrange = 'ZONE'
-        sgprovider.name = 'SecurityGroupProvider'
-
-        pn.providers.append(sgprovider)
-        z.physical_networks.append(pn)
-
-        '''create 10 pods'''
-        for i in range(2):
-            p = pod()
-            p.name = "test" + str(l) + str(i)
-            p.gateway = "192.168.%d.1" % i
-            p.netmask = "255.255.255.0"
-            p.startip = "192.168.%d.200" % i
-            p.endip = "192.168.%d.220" % i
-
-            '''add 10 clusters'''
-            for j in range(2):
-                c = cluster()
-                c.clustername = "test"+str(l)+str(i) + str(j)
-                c.clustertype = "CloudManaged"
-                c.hypervisor = "Simulator"
-
-                '''add 10 hosts'''
-                for k in range(2):
-                    h = host()
-                    h.username = "root"
-                    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" % (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" % \
-                        #(str(l) + str(i) + str(j) + str(m), size)
-                    primary.url = "nfs://localhost/path%s" % \
-                        (str(l) + str(i) + str(j) + str(m))
-                    c.primaryStorages.append(primary)
-
-                p.clusters.append(c)
-
-            z.pods.append(p)
-
-        '''add two secondary'''
-        for i in range(5):
-            secondary = secondaryStorage()
-            secondary.url = "nfs://localhost/path"+str(l) + str(i)
-            z.secondaryStorages.append(secondary)
-
-        '''add default guest network'''
-        ips = iprange()
-        ips.vlan = "26"
-        ips.startip = "172.16.26.2"
-        ips.endip = "172.16.26.100"
-        ips.gateway = "172.16.26.1"
-        ips.netmask = "255.255.255.0"
-        z.ipranges.append(ips)
-
-        zs.zones.append(z)
-
-    '''Add one mgt server'''
-    mgt = managementServer()
-    mgt.mgtSvrIp = "localhost"
-    zs.mgtSvr.append(mgt)
-
-    '''Add a database'''
-    db = dbServer()
-    db.dbSvr = "localhost"
-
-    zs.dbSvr = db
-
-    '''add global configuration'''
-    global_settings = {'expunge.delay': '60',
-                       'expunge.interval': '60',
-                       'expunge.workers': '3',
-                       }
-    for k, v in global_settings.iteritems():
-        cfg = configuration()
-        cfg.name = k
-        cfg.value = v
-        zs.globalConfig.append(cfg)
-
-    ''''add loggers'''
-    testClientLogger = logger()
-    testClientLogger.name = "TestClient"
-    testClientLogger.file = "/tmp/testclient.log"
-
-    testCaseLogger = logger()
-    testCaseLogger.name = "TestCase"
-    testCaseLogger.file = "/tmp/testcase.log"
-
-    zs.logger.append(testClientLogger)
-    zs.logger.append(testCaseLogger)
-
-    return zs
-
-
-def generate_setup_config(config, file=None):
-    describe = config
-    if file is None:
-        return json.dumps(jsonHelper.jsonDump.dump(describe))
-    else:
-        fp = open(file, 'w')
-        json.dump(jsonHelper.jsonDump.dump(describe), fp, indent=4)
-        fp.close()
-
-
-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)
-
-if __name__ == "__main__":
-    parser = OptionParser()
-
-    parser.add_option("-i", "--input", action="store", default=None,
-                      dest="inputfile", help="input file")
-    parser.add_option("-a", "--advanced", action="store_true", default=False,
-                      dest="advanced", help="use advanced networking")
-    parser.add_option("-s", "--advancedsg", action="store_true", default=False,
-                      dest="advancedsg", help="use advanced networking \
-with security groups")
-    parser.add_option("-o", "--output", action="store",
-                      default="./datacenterCfg", dest="output",
-                      help="the path where the json config file generated, \
-by default is ./datacenterCfg")
-
-    (options, args) = parser.parse_args()
-
-    if options.inputfile:
-        config = getSetupConfig(options.inputfile)
-    if options.advanced:
-        config = describe_setup_in_advanced_mode()
-    elif options.advancedsg:
-        config = describe_setup_in_advancedsg_mode()
-    else:
-        config = describe_setup_in_basic_mode()
-
-    generate_setup_config(config, options.output)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/44b3edcf/tools/marvin/marvin/deployDataCenter.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/deployDataCenter.py b/tools/marvin/marvin/deployDataCenter.py
deleted file mode 100644
index 3f7eebb..0000000
--- a/tools/marvin/marvin/deployDataCenter.py
+++ /dev/null
@@ -1,623 +0,0 @@
-# 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.
-
-"""Deploy datacenters according to a json configuration file"""
-import configGenerator
-import cloudstackException
-import cloudstackTestClient
-import logging
-from cloudstackAPI import *
-from os import path
-from time import sleep
-from optparse import OptionParser
-
-
-class deployDataCenters(object):
-
-    def __init__(self, cfgFile):
-        if not path.exists(cfgFile) \
-           and not path.exists(path.abspath(cfgFile)):
-            raise IOError("config file %s not found. please \
-                           specify a valid config file" % cfgFile)
-        self.configFile = cfgFile
-        '''
-        parsed configuration information
-        '''
-        self.config = None
-
-    def addHosts(self, hosts, zoneId, podId, clusterId, hypervisor):
-        if hosts is None:
-            return
-        for host in hosts:
-            hostcmd = addHost.addHostCmd()
-            hostcmd.clusterid = clusterId
-            hostcmd.cpunumber = host.cpunumer
-            hostcmd.cpuspeed = host.cpuspeed
-            hostcmd.hostmac = host.hostmac
-            hostcmd.hosttags = host.hosttags
-            hostcmd.hypervisor = host.hypervisor
-            hostcmd.memory = host.memory
-            hostcmd.password = host.password
-            hostcmd.podid = podId
-            hostcmd.url = host.url
-            hostcmd.username = host.username
-            hostcmd.zoneid = zoneId
-            hostcmd.hypervisor = hypervisor
-            self.apiClient.addHost(hostcmd)
-
-    def addVmWareDataCenter(self, vmwareDc):
-        vdc = addVmwareDc.addVmwareDcCmd()
-        vdc.zoneid = vmwareDc.zoneid
-        vdc.name = vmwareDc.name
-        vdc.vcenter = vmwareDc.vcenter
-        vdc.username = vmwareDc.username
-        vdc.password = vmwareDc.password
-        self.apiClient.addVmwareDc(vdc)
-
-    def createClusters(self, clusters, zoneId, podId, vmwareDc=None):
-        if clusters is None:
-            return
-
-        if vmwareDc is not None:
-            vmwareDc.zoneid = zoneId
-            self.addVmWareDataCenter(vmwareDc)
-
-        for cluster in clusters:
-            clustercmd = addCluster.addClusterCmd()
-            clustercmd.clustername = cluster.clustername
-            clustercmd.clustertype = cluster.clustertype
-            clustercmd.hypervisor = cluster.hypervisor
-            clustercmd.password = cluster.password
-            clustercmd.podid = podId
-            clustercmd.url = cluster.url
-            clustercmd.username = cluster.username
-            clustercmd.zoneid = zoneId
-            clusterresponse = self.apiClient.addCluster(clustercmd)
-            clusterId = clusterresponse[0].id
-
-            if cluster.hypervisor.lower() != "vmware":
-                self.addHosts(cluster.hosts, zoneId, podId, clusterId,
-                              cluster.hypervisor)
-            self.waitForHost(zoneId, clusterId)
-            self.createPrimaryStorages(cluster.primaryStorages, zoneId, podId,
-                                       clusterId)
-
-    def waitForHost(self, zoneId, clusterId):
-        """
-        Wait for the hosts in the zoneid, clusterid to be up
-
-        2 retries with 30s delay
-        """
-        retry, timeout = 2, 30
-        cmd = listHosts.listHostsCmd()
-        cmd.clusterid, cmd.zoneid = clusterId, zoneId
-        hosts = self.apiClient.listHosts(cmd)
-        while retry != 0:
-            for host in hosts:
-                if host.state != 'Up':
-                    break
-            sleep(timeout)
-            retry = retry - 1
-
-    def createPrimaryStorages(self, primaryStorages, zoneId, podId, clusterId):
-        if primaryStorages is None:
-            return
-        for primary in primaryStorages:
-            primarycmd = createStoragePool.createStoragePoolCmd()
-            primarycmd.details = primary.details
-            primarycmd.name = primary.name
-            primarycmd.podid = podId
-            primarycmd.tags = primary.tags
-            primarycmd.url = primary.url
-            primarycmd.zoneid = zoneId
-            primarycmd.clusterid = clusterId
-            self.apiClient.createStoragePool(primarycmd)
-
-    def createPods(self, pods, zoneId, networkId=None):
-        if pods is None:
-            return
-        for pod in pods:
-            createpod = createPod.createPodCmd()
-            createpod.name = pod.name
-            createpod.gateway = pod.gateway
-            createpod.netmask = pod.netmask
-            createpod.startip = pod.startip
-            createpod.endip = pod.endip
-            createpod.zoneid = zoneId
-            createpodResponse = self.apiClient.createPod(createpod)
-            podId = createpodResponse.id
-
-            if pod.guestIpRanges is not None and networkId is not None:
-                self.createVlanIpRanges("Basic", pod.guestIpRanges, zoneId,
-                                        podId, networkId)
-
-            self.createClusters(pod.clusters, zoneId, podId,
-                                vmwareDc=pod.vmwaredc)
-
-    def createVlanIpRanges(self, mode, ipranges, zoneId, podId=None,
-                           networkId=None, forvirtualnetwork=None):
-        if ipranges is None:
-            return
-        for iprange in ipranges:
-            vlanipcmd = createVlanIpRange.createVlanIpRangeCmd()
-            vlanipcmd.account = iprange.account
-            vlanipcmd.domainid = iprange.domainid
-            vlanipcmd.endip = iprange.endip
-            vlanipcmd.gateway = iprange.gateway
-            vlanipcmd.netmask = iprange.netmask
-            vlanipcmd.networkid = networkId
-            vlanipcmd.podid = podId
-            vlanipcmd.startip = iprange.startip
-            vlanipcmd.zoneid = zoneId
-            vlanipcmd.vlan = iprange.vlan
-            if mode == "Basic":
-                if forvirtualnetwork:
-                    vlanipcmd.forvirtualnetwork = "true"
-                else:
-                    vlanipcmd.forvirtualnetwork = "false"
-            else:
-                vlanipcmd.forvirtualnetwork = "true"
-            self.apiClient.createVlanIpRange(vlanipcmd)
-
-    def createSecondaryStorages(self, secondaryStorages, zoneId):
-        if secondaryStorages is None:
-            return
-        for secondary in secondaryStorages:
-            secondarycmd = addImageStore.addImageStoreCmd()
-            secondarycmd.url = secondary.url
-            secondarycmd.provider = secondary.provider
-            secondarycmd.details = []
-
-            if secondarycmd.provider == 'S3' \
-                    or secondarycmd.provider == "Swift":
-                for key, value in vars(secondary.details).iteritems():
-                    secondarycmd.details.append({
-                                                'key': key,
-                                                'value': value
-                                                })
-            if secondarycmd.provider == "NFS":
-                secondarycmd.zoneid = zoneId
-            self.apiClient.addImageStore(secondarycmd)
-
-    def createCacheStorages(self, cacheStorages, zoneId):
-        if cacheStorages is None:
-            return
-        for cache in cacheStorages:
-            cachecmd = createSecondaryStagingStore.\
-                createSecondaryStagingStoreCmd()
-            cachecmd.url = cache.url
-            cachecmd.provider = cache.provider
-            cachecmd.zoneid = zoneId
-            cachecmd.details = []
-
-            if cache.details:
-                for key, value in vars(cache.details).iteritems():
-                    cachecmd.details.append({
-                                            'key': key,
-                                            'value': value
-                                            })
-            self.apiClient.createSecondaryStagingStore(cachecmd)
-
-    def createNetworks(self, networks, zoneId):
-        if networks is None:
-            return
-        for network in networks:
-            networkcmd = createNetwork.createNetworkCmd()
-            networkcmd.displaytext = network.displaytext
-            networkcmd.name = network.name
-            networkcmd.networkofferingid = network.networkofferingid
-            networkcmd.zoneid = zoneId
-
-            ipranges = network.ipranges
-            if ipranges:
-                iprange = ipranges.pop()
-                networkcmd.startip = iprange.startip
-                networkcmd.endip = iprange.endip
-                networkcmd.gateway = iprange.gateway
-                networkcmd.netmask = iprange.netmask
-
-            networkcmdresponse = self.apiClient.createNetwork(networkcmd)
-            networkId = networkcmdresponse.id
-            return networkId
-
-    def createPhysicalNetwork(self, net, zoneid):
-        phynet = createPhysicalNetwork.createPhysicalNetworkCmd()
-        phynet.zoneid = zoneid
-        phynet.name = net.name
-        phynet.isolationmethods = net.isolationmethods
-        phynetwrk = self.apiClient.createPhysicalNetwork(phynet)
-        self.addTrafficTypes(phynetwrk.id, net.traffictypes)
-        return phynetwrk
-
-    def updatePhysicalNetwork(self, networkid, state="Enabled", vlan=None):
-        upnet = updatePhysicalNetwork.updatePhysicalNetworkCmd()
-        upnet.id = networkid
-        upnet.state = state
-        if vlan:
-            upnet.vlan = vlan
-        return self.apiClient.updatePhysicalNetwork(upnet)
-
-    def enableProvider(self, provider_id):
-        upnetprov =\
-            updateNetworkServiceProvider.updateNetworkServiceProviderCmd()
-        upnetprov.id = provider_id
-        upnetprov.state = "Enabled"
-        self.apiClient.updateNetworkServiceProvider(upnetprov)
-
-    def configureProviders(self, phynetwrk, providers):
-        """
-        We will enable the virtualrouter elements for all zones. Other
-        providers like NetScalers, SRX, etc are explicitly added/configured
-        """
-
-        for provider in providers:
-            pnetprov = listNetworkServiceProviders.\
-                listNetworkServiceProvidersCmd()
-            pnetprov.physicalnetworkid = phynetwrk.id
-            pnetprov.state = "Disabled"
-            pnetprov.name = provider.name
-            pnetprovres = self.apiClient.listNetworkServiceProviders(pnetprov)
-
-            if pnetprovres and len(pnetprovres) > 0:
-                if provider.name == 'VirtualRouter'\
-                   or provider.name == 'VpcVirtualRouter':
-                    vrprov = listVirtualRouterElements.\
-                        listVirtualRouterElementsCmd()
-                    vrprov.nspid = pnetprovres[0].id
-                    vrprovresponse = self.apiClient.\
-                        listVirtualRouterElements(vrprov)
-                    vrprovid = vrprovresponse[0].id
-
-                    vrconfig = \
-                        configureVirtualRouterElement.\
-                        configureVirtualRouterElementCmd()
-                    vrconfig.enabled = "true"
-                    vrconfig.id = vrprovid
-                    self.apiClient.configureVirtualRouterElement(vrconfig)
-                    self.enableProvider(pnetprovres[0].id)
-                elif provider.name == 'InternalLbVm':
-                    internallbprov = listInternalLoadBalancerElements.\
-                        listInternalLoadBalancerElementsCmd()
-                    internallbprov.nspid = pnetprovres[0].id
-                    internallbresponse = self.apiClient.\
-                        listInternalLoadBalancerElements(internallbprov)
-                    internallbid = internallbresponse[0].id
-
-                    internallbconfig = \
-                        configureInternalLoadBalancerElement.\
-                        configureInternalLoadBalancerElementCmd()
-                    internallbconfig.enabled = "true"
-                    internallbconfig.id = internallbid
-                    self.apiClient.\
-                        configureInternalLoadBalancerElement(internallbconfig)
-                    self.enableProvider(pnetprovres[0].id)
-                elif provider.name == 'SecurityGroupProvider':
-                    self.enableProvider(pnetprovres[0].id)
-            elif provider.name in ['Netscaler', 'JuniperSRX', 'F5BigIp']:
-                netprov = addNetworkServiceProvider.\
-                    addNetworkServiceProviderCmd()
-                netprov.name = provider.name
-                netprov.physicalnetworkid = phynetwrk.id
-                result = self.apiClient.addNetworkServiceProvider(netprov)
-                for device in provider.devices:
-                    if provider.name == 'Netscaler':
-                        dev = addNetscalerLoadBalancer.\
-                            addNetscalerLoadBalancerCmd()
-                        dev.username = device.username
-                        dev.password = device.password
-                        dev.networkdevicetype = device.networkdevicetype
-                        dev.url = configGenerator.getDeviceUrl(device)
-                        dev.physicalnetworkid = phynetwrk.id
-                        self.apiClient.addNetscalerLoadBalancer(dev)
-                    elif provider.name == 'JuniperSRX':
-                        dev = addSrxFirewall.addSrxFirewallCmd()
-                        dev.username = device.username
-                        dev.password = device.password
-                        dev.networkdevicetype = device.networkdevicetype
-                        dev.url = configGenerator.getDeviceUrl(device)
-                        dev.physicalnetworkid = phynetwrk.id
-                        self.apiClient.addSrxFirewall(dev)
-                    elif provider.name == 'F5BigIp':
-                        dev = addF5LoadBalancer.addF5LoadBalancerCmd()
-                        dev.username = device.username
-                        dev.password = device.password
-                        dev.networkdevicetype = device.networkdevicetype
-                        dev.url = configGenerator.getDeviceUrl(device)
-                        dev.physicalnetworkid = phynetwrk.id
-                        self.apiClient.addF5LoadBalancer(dev)
-                    else:
-                        raise cloudstackException.\
-                            InvalidParameterException("Device %s doesn't match\
- any know provider type" % device)
-                self.enableProvider(result.id)
-
-    def addTrafficTypes(self, physical_network_id, traffictypes):
-        [self.addTrafficType(physical_network_id, traffic_type)
-            for traffic_type in traffictypes]
-
-    def addTrafficType(self, physical_network_id, traffictype):
-        traffic_type = addTrafficType.addTrafficTypeCmd()
-        traffic_type.physicalnetworkid = physical_network_id
-        traffic_type.traffictype = traffictype.typ
-        traffic_type.kvmnetworklabel = traffictype.kvm\
-            if traffictype.kvm is not None else None
-        traffic_type.xennetworklabel = traffictype.xen\
-            if traffictype.xen is not None else None
-        traffic_type.vmwarenetworklabel = traffictype.vmware\
-            if traffictype.vmware is not None else None
-        traffic_type.simulatorlabel = traffictype.simulator\
-            if traffictype.simulator is not None else None
-        return self.apiClient.addTrafficType(traffic_type)
-
-    def enableZone(self, zoneid, allocation_state="Enabled"):
-        zoneCmd = updateZone.updateZoneCmd()
-        zoneCmd.id = zoneid
-        zoneCmd.allocationstate = allocation_state
-        return self.apiClient.updateZone(zoneCmd)
-
-    def updateZoneDetails(self, zoneid, details):
-        zoneCmd = updateZone.updateZoneCmd()
-        zoneCmd.id = zoneid
-        zoneCmd.details = details
-        return self.apiClient.updateZone(zoneCmd)
-
-    def createZones(self, zones):
-        for zone in zones:
-            createzone = createZone.createZoneCmd()
-            createzone.dns1 = zone.dns1
-            createzone.dns2 = zone.dns2
-            createzone.internaldns1 = zone.internaldns1
-            createzone.internaldns2 = zone.internaldns2
-            createzone.name = zone.name
-            createzone.securitygroupenabled = zone.securitygroupenabled
-            createzone.localstorageenabled = zone.localstorageenabled
-            createzone.networktype = zone.networktype
-            if zone.securitygroupenabled != "true":
-                createzone.guestcidraddress = zone.guestcidraddress
-
-            zoneresponse = self.apiClient.createZone(createzone)
-            zoneId = zoneresponse.id
-
-            for pnet in zone.physical_networks:
-                phynetwrk = self.createPhysicalNetwork(pnet, zoneId)
-                self.configureProviders(phynetwrk, pnet.providers)
-                self.updatePhysicalNetwork(phynetwrk.id, "Enabled",
-                                           vlan=pnet.vlan)
-
-            if zone.networktype == "Basic":
-                listnetworkoffering =\
-                    listNetworkOfferings.listNetworkOfferingsCmd()
-                listnetworkoffering.name =\
-                    "DefaultSharedNetscalerEIPandELBNetworkOffering" \
-                    if len(filter(lambda x:
-                                  x.typ == 'Public',
-                                  zone.physical_networks[0].
-                                  traffictypes)) > 0 \
-                    else "DefaultSharedNetworkOfferingWithSGService"
-                if zone.networkofferingname is not None:
-                    listnetworkoffering.name = zone.networkofferingname
-
-                listnetworkofferingresponse = \
-                    self.apiClient.listNetworkOfferings(listnetworkoffering)
-
-                guestntwrk = configGenerator.network()
-                guestntwrk.displaytext = "guestNetworkForBasicZone"
-                guestntwrk.name = "guestNetworkForBasicZone"
-                guestntwrk.zoneid = zoneId
-                guestntwrk.networkofferingid = \
-                    listnetworkofferingresponse[0].id
-
-                networkid = self.createNetworks([guestntwrk], zoneId)
-                self.createPods(zone.pods, zoneId, networkid)
-                if self.isEipElbZone(zone):
-                    self.createVlanIpRanges(zone.networktype, zone.ipranges,
-                                            zoneId, forvirtualnetwork=True)
-
-            isPureAdvancedZone = (zone.networktype == "Advanced"
-                                  and zone.securitygroupenabled != "true")
-            if isPureAdvancedZone:
-                self.createPods(zone.pods, zoneId)
-                self.createVlanIpRanges(zone.networktype, zone.ipranges,
-                                        zoneId)
-            elif (zone.networktype == "Advanced"
-                  and zone.securitygroupenabled == "true"):
-                listnetworkoffering =\
-                    listNetworkOfferings.listNetworkOfferingsCmd()
-                listnetworkoffering.name =\
-                    "DefaultSharedNetworkOfferingWithSGService"
-                if zone.networkofferingname is not None:
-                    listnetworkoffering.name = zone.networkofferingname
-
-                listnetworkofferingresponse = \
-                    self.apiClient.listNetworkOfferings(listnetworkoffering)
-
-                networkcmd = createNetwork.createNetworkCmd()
-                networkcmd.displaytext = "Shared SG enabled network"
-                networkcmd.name = "Shared SG enabled network"
-                networkcmd.networkofferingid =\
-                    listnetworkofferingresponse[0].id
-                networkcmd.zoneid = zoneId
-
-                ipranges = zone.ipranges
-                if ipranges:
-                    iprange = ipranges.pop()
-                    networkcmd.startip = iprange.startip
-                    networkcmd.endip = iprange.endip
-                    networkcmd.gateway = iprange.gateway
-                    networkcmd.netmask = iprange.netmask
-                    networkcmd.vlan = iprange.vlan
-
-                networkcmdresponse = self.apiClient.createNetwork(networkcmd)
-                networkId = networkcmdresponse.id
-                self.createPods(zone.pods, zoneId, networkId)
-
-            '''Note: Swift needs cache storage first'''
-            self.createCacheStorages(zone.cacheStorages, zoneId)
-            self.createSecondaryStorages(zone.secondaryStorages, zoneId)
-
-            enabled = getattr(zone, 'enabled', 'True')
-            if enabled == 'True' or enabled is None:
-                self.enableZone(zoneId, "Enabled")
-            details = getattr(zone, 'details')
-            if details is not None:
-                det = [d.__dict__ for d in details]
-                self.updateZoneDetails(zoneId, det)
-
-        return
-
-    def isEipElbZone(self, zone):
-        if (zone.networktype == "Basic"
-            and len(filter(lambda x: x.typ == 'Public',
-                           zone.physical_networks[0].traffictypes)) > 0):
-            return True
-        return False
-
-    def registerApiKey(self):
-        listuser = listUsers.listUsersCmd()
-        listuser.account = "admin"
-        listuserRes = self.testClient.getApiClient().listUsers(listuser)
-        userId = listuserRes[0].id
-        apiKey = listuserRes[0].apikey
-        securityKey = listuserRes[0].secretkey
-        if apiKey is None:
-            registerUser = registerUserKeys.registerUserKeysCmd()
-            registerUser.id = userId
-            registerUserRes = \
-                self.testClient.getApiClient().registerUserKeys(registerUser)
-
-            apiKey = registerUserRes.apikey
-            securityKey = registerUserRes.secretkey
-
-        self.config.mgtSvr[0].port = 8080
-        self.config.mgtSvr[0].apiKey = apiKey
-        self.config.mgtSvr[0].securityKey = securityKey
-        return apiKey, securityKey
-
-    def getCfg(self):
-        if self.config is not None:
-            return self.config
-        return None
-
-    def loadCfg(self):
-        try:
-            self.config = configGenerator.getSetupConfig(self.configFile)
-        except:
-            raise cloudstackException.InvalidParameterException(
-                "Failed to load config %s" % self.configFile)
-
-        ''' Retrieving Management Server Connection Details '''
-        mgtDetails = self.config.mgtSvr[0]
-        ''' Retrieving Database Connection Details'''
-        dbSvrDetails = self.config.dbSvr
-        loggers = self.config.logger
-        testClientLogFile = None
-        self.testCaseLogFile = None
-        self.testResultLogFile = None
-        if loggers is not None and len(loggers) > 0:
-            for log in loggers:
-                if log.name == "TestClient":
-                    testClientLogFile = log.file
-                elif log.name == "TestCase":
-                    self.testCaseLogFile = log.file
-                elif log.name == "TestResult":
-                    self.testResultLogFile = log.file
-
-        testClientLogger = None
-        if testClientLogFile is not None:
-            testClientLogger = logging.getLogger("testclient.testengine.run")
-            fh = logging.FileHandler(testClientLogFile)
-            fh.setFormatter(logging.Formatter(
-                "%(asctime)s - %(levelname)s - %(name)s\ - %(message)s")
-            )
-            testClientLogger.addHandler(fh)
-            testClientLogger.setLevel(logging.INFO)
-        self.testClientLogger = testClientLogger
-
-        self.testClient = \
-            cloudstackTestClient.\
-            cloudstackTestClient(mgtDetails,
-                                 dbSvrDetails,
-                                 logging=self.testClientLogger)
-
-        if mgtDetails.apiKey is None:
-            mgtDetails.apiKey, mgtDetails.securityKey = self.registerApiKey()
-            mgtDetails.port = 8080
-            self.testClient = \
-                cloudstackTestClient.cloudstackTestClient(
-                    mgtDetails,
-                    dbSvrDetails,
-                    logging=
-                    self.testClientLogger)
-
-        self.apiClient = self.testClient.getApiClient()
-        """set hypervisor"""
-        if mgtDetails.hypervisor:
-            self.apiClient.hypervisor = mgtDetails.hypervisor
-        else:
-            self.apiClient.hypervisor = "XenServer"  # Defaults to Xenserver
-
-    def updateConfiguration(self, globalCfg):
-        if globalCfg is None:
-            return None
-
-        for config in globalCfg:
-            updateCfg = updateConfiguration.updateConfigurationCmd()
-            updateCfg.name = config.name
-            updateCfg.value = config.value
-            self.apiClient.updateConfiguration(updateCfg)
-
-    def copyAttributesToCommand(self, source, command):
-        map(lambda attr: setattr(command, attr, getattr(source, attr, None)),
-            filter(lambda attr: not attr.startswith("__") and attr not in
-                   ["required", "isAsync"], dir(command)))
-
-    def configureS3(self, s3):
-        if s3 is None:
-            return
-        command = addS3.addS3Cmd()
-        self.copyAttributesToCommand(s3, command)
-        self.apiClient.addS3(command)
-
-    def deploy(self):
-        self.loadCfg()
-        self.updateConfiguration(self.config.globalConfig)
-        self.createZones(self.config.zones)
-        self.configureS3(self.config.s3)
-
-if __name__ == "__main__":
-    parser = OptionParser()
-    parser.add_option("-i", "--input", action="store",
-                      default="./datacenterCfg", dest="input", help="the path \
-                      where the json config file generated, by default is \
-                      ./datacenterCfg")
-
-    (options, args) = parser.parse_args()
-    deploy = deployDataCenters(options.input)
-    deploy.deploy()
-
-    """
-    create = createStoragePool.createStoragePoolCmd()
-    create.clusterid = 1
-    create.podid = 2
-    create.name = "fdffdf"
-    create.url = "nfs://jfkdjf/fdkjfkd"
-    create.zoneid = 2
-
-    deploy = deployDataCenters("./datacenterCfg")
-    deploy.loadCfg()
-    deploy.apiClient.createStoragePool(create)
-    """

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/44b3edcf/tools/marvin/marvin/deployer/__init__.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/deployer/__init__.py b/tools/marvin/marvin/deployer/__init__.py
new file mode 100644
index 0000000..d216be4
--- /dev/null
+++ b/tools/marvin/marvin/deployer/__init__.py
@@ -0,0 +1,16 @@
+# 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.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/44b3edcf/tools/marvin/marvin/deployer/configGenerator.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/deployer/configGenerator.py b/tools/marvin/marvin/deployer/configGenerator.py
new file mode 100644
index 0000000..5e511d6
--- /dev/null
+++ b/tools/marvin/marvin/deployer/configGenerator.py
@@ -0,0 +1,873 @@
+# 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.
+
+import json
+import os
+from optparse import OptionParser
+import jsonHelper
+
+
+class managementServer(object):
+    def __init__(self):
+        self.mgtSvrIp = None
+        self.port = 8096
+        self.apiKey = None
+        self.securityKey = None
+        self.useHttps = None
+        self.certCAPath = None
+        self.certPath = None
+
+
+class dbServer(object):
+    def __init__(self):
+        self.dbSvr = None
+        self.port = 3306
+        self.user = "cloud"
+        self.passwd = "cloud"
+        self.db = "cloud"
+
+
+class configuration(object):
+    def __init__(self):
+        self.name = None
+        self.value = None
+
+
+class logger(object):
+    def __init__(self):
+        '''TestCase/TestClient'''
+        self.name = None
+        self.file = None
+
+
+class cloudstackConfiguration(object):
+    def __init__(self):
+        self.zones = []
+        self.mgtSvr = []
+        self.dbSvr = None
+        self.globalConfig = []
+        self.logger = []
+
+
+class zone(object):
+    def __init__(self):
+        self.dns1 = None
+        self.internaldns1 = None
+        self.name = None
+        '''Basic or Advanced'''
+        self.networktype = None
+        self.dns2 = None
+        self.internaldns2 = None
+        self.securitygroupenabled = None
+        self.localstorageenabled = None
+        '''default public network, in advanced mode'''
+        self.ipranges = []
+        self.physical_networks = []
+        self.pods = []
+        self.secondaryStorages = []
+        self.cacheStorages = []
+
+
+class traffictype(object):
+    def __init__(self, typ, labeldict=None):
+        self.typ = typ  # Guest/Management/Public
+        if labeldict:
+            self.xen = labeldict['xen'] if 'xen' in labeldict.keys() else None
+            self.kvm = labeldict['kvm'] if 'kvm' in labeldict.keys() else None
+            self.vmware = labeldict['vmware']\
+                if 'vmware' in labeldict.keys() else None
+            self.simulator = labeldict['simulator']\
+                if 'simulator' in labeldict.keys() else None
+        #{
+        #    'xen' : 'cloud-xen',
+        #    'kvm' : 'cloud-kvm',
+        #    'vmware' : 'cloud-vmware'
+        #}
+
+
+class pod(object):
+    def __init__(self):
+        self.gateway = None
+        self.name = None
+        self.netmask = None
+        self.startip = None
+        self.endip = None
+        self.zoneid = None
+        self.clusters = []
+        self.vmwaredc = []
+        '''Used in basic network mode'''
+        self.guestIpRanges = []
+
+
+class VmwareDc(object):
+    def __init__(self):
+        self.zoneid = None
+        self.name = None
+        self.vcenter = None
+        self.username = None
+        self.password = None
+
+
+class cluster(object):
+    def __init__(self):
+        self.clustername = None
+        self.clustertype = None
+        self.hypervisor = None
+        self.zoneid = None
+        self.podid = None
+        self.password = None
+        self.url = None
+        self.username = None
+        self.hosts = []
+        self.primaryStorages = []
+
+
+class host(object):
+    def __init__(self):
+        self.hypervisor = None
+        self.password = None
+        self.url = None
+        self.username = None
+        self.zoneid = None
+        self.podid = None
+        self.clusterid = None
+        self.clustername = None
+        self.cpunumber = None
+        self.cpuspeed = None
+        self.hostmac = None
+        self.hosttags = None
+        self.memory = None
+
+
+class physical_network(object):
+    def __init__(self):
+        self.name = None
+        self.tags = []
+        self.traffictypes = []
+        self.broadcastdomainrange = 'Zone'
+        self.vlan = None
+        self.isolationmethods = []
+        '''enable default virtual router provider'''
+        vrouter = provider()
+        vrouter.name = 'VirtualRouter'
+        self.providers = [vrouter]
+
+
+class provider(object):
+    def __init__(self, name=None):
+        self.name = name
+        self.state = None
+        self.broadcastdomainrange = 'ZONE'
+        self.zoneid = None
+        self.servicelist = []
+        self.devices = []
+
+
+class network(object):
+    def __init__(self):
+        self.displaytext = None
+        self.name = None
+        self.zoneid = None
+        self.acltype = None
+        self.domainid = None
+        self.networkdomain = None
+        self.networkofferingid = None
+        self.ipranges = []
+
+
+class iprange(object):
+    def __init__(self):
+        '''tagged/untagged'''
+        self.gateway = None
+        self.netmask = None
+        self.startip = None
+        self.endip = None
+        self.vlan = None
+        '''for account specific '''
+        self.account = None
+        self.domain = None
+
+
+class primaryStorage(object):
+    def __init__(self):
+        self.name = None
+        self.url = None
+
+
+class secondaryStorage(object):
+    def __init__(self):
+        self.url = None
+        self.provider = None
+        self.details = None
+
+
+class cacheStorage(object):
+    def __init__(self):
+        self.url = None
+        self.provider = None
+        self.details = None
+
+
+class s3(object):
+    def __init__(self):
+        self.accesskey = None
+        self.secretkey = None
+        self.bucket = None
+        self.endpoint = None
+        self.sockettimeout = None
+        self.connectiontimeout = None
+        self.maxerrorrety = None
+        self.usehttps = None
+
+
+class netscaler(object):
+    def __init__(self, hostname=None, username='nsroot', password='nsroot'):
+        self.hostname = hostname
+        self.username = username
+        self.password = password
+        self.networkdevicetype = 'NetscalerVPXLoadBalancer'
+        self.publicinterface = '1/1'
+        self.privateinterface = '1/1'
+        self.numretries = '2'
+        self.lbdevicecapacity = '50'
+        self.lbdevicededicated = 'false'
+
+    def getUrl(self):
+        return repr(self)
+
+    def __repr__(self):
+        req = zip(self.__dict__.keys(), self.__dict__.values())
+        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
+        self.password = password
+        self.networkdevicetype = 'JuniperSRXFirewall'
+        self.publicinterface = '1/1'
+        self.privateinterface = '1/1'
+        self.numretries = '2'
+        self.fwdevicededicated = 'false'
+        self.timeout = '300'
+        self.publicnetwork = 'untrusted'
+        self.privatenetwork = 'trusted'
+
+    def getUrl(self):
+        return repr(self)
+
+    def __repr__(self):
+        req = zip(self.__dict__.keys(), self.__dict__.values())
+        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
+        self.password = password
+        self.networkdevicetype = 'F5BigIpLoadBalancer'
+        self.publicinterface = '1/1'
+        self.privateinterface = '1/1'
+        self.numretries = '2'
+        self.lbdevicededicated = 'false'
+        self.lbdevicecapacity = '50'
+
+    def getUrl(self):
+        return repr(self)
+
+    def __repr__(self):
+        req = zip(self.__dict__.keys(), self.__dict__.values())
+        return self.hostname+"?" + "&".join(["=".join([r[0], r[1]])
+                                             for r in req])
+
+
+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])
+    else:
+        return None
+
+
+def describe_setup_in_basic_mode():
+    '''sample code to generate setup configuration file'''
+    zs = cloudstackConfiguration()
+
+    for l in range(1):
+        z = zone()
+        z.dns1 = "8.8.8.8"
+        z.dns2 = "8.8.4.4"
+        z.internaldns1 = "192.168.110.254"
+        z.internaldns2 = "192.168.110.253"
+        z.name = "test"+str(l)
+        z.networktype = 'Basic'
+        z.securitygroupenabled = 'True'
+
+        #If security groups are reqd
+        sgprovider = provider()
+        sgprovider.broadcastdomainrange = 'Pod'
+        sgprovider.name = 'SecurityGroupProvider'
+
+        pn = physical_network()
+        pn.name = "test-network"
+        pn.traffictypes = [traffictype("Guest"), traffictype("Management")]
+        pn.providers.append(sgprovider)
+
+        z.physical_networks.append(pn)
+
+        '''create 10 pods'''
+        for i in range(2):
+            p = pod()
+            p.name = "test" + str(l) + str(i)
+            p.gateway = "192.168.%d.1" % i
+            p.netmask = "255.255.255.0"
+            p.startip = "192.168.%d.150" % i
+            p.endip = "192.168.%d.220" % i
+
+            '''add two pod guest ip ranges'''
+            for j in range(2):
+                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)
+
+                p.guestIpRanges.append(ip)
+
+            '''add 10 clusters'''
+            for j in range(2):
+                c = cluster()
+                c.clustername = "test"+str(l)+str(i) + str(j)
+                c.clustertype = "CloudManaged"
+                c.hypervisor = "Simulator"
+
+                '''add 10 hosts'''
+                for k in range(2):
+                    h = host()
+                    h.username = "root"
+                    h.password = "password"
+                    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.url = "nfs://localhost/path%s" % (str(l) + str(i) +
+                                                              str(j) + str(m))
+                    c.primaryStorages.append(primary)
+
+                p.clusters.append(c)
+
+            z.pods.append(p)
+
+        '''add two secondary'''
+        for i in range(5):
+            secondary = secondaryStorage()
+            secondary.url = "nfs://localhost/path"+str(l) + str(i)
+            z.secondaryStorages.append(secondary)
+
+        zs.zones.append(z)
+
+    '''Add one mgt server'''
+    mgt = managementServer()
+    mgt.mgtSvrIp = "localhost"
+    zs.mgtSvr.append(mgt)
+
+    '''Add a database'''
+    db = dbServer()
+    db.dbSvr = "localhost"
+
+    zs.dbSvr = db
+
+    '''add global configuration'''
+    global_settings = {'expunge.delay': '60',
+                       'expunge.interval': '60',
+                       'expunge.workers': '3',
+                       }
+    for k, v in global_settings.iteritems():
+        cfg = configuration()
+        cfg.name = k
+        cfg.value = v
+        zs.globalConfig.append(cfg)
+
+    ''''add loggers'''
+    testClientLogger = logger()
+    testClientLogger.name = "TestClient"
+    testClientLogger.file = "/tmp/testclient.log"
+
+    testCaseLogger = logger()
+    testCaseLogger.name = "TestCase"
+    testCaseLogger.file = "/tmp/testcase.log"
+
+    zs.logger.append(testClientLogger)
+    zs.logger.append(testCaseLogger)
+
+    return zs
+
+
+def describe_setup_in_eip_mode():
+    """
+    Setting up an EIP/ELB enabled zone with netscaler provider
+    """
+    zs = cloudstackConfiguration()
+
+    for l in range(1):
+        z = zone()
+        z.dns1 = "8.8.8.8"
+        z.dns2 = "8.8.4.4"
+        z.internaldns1 = "192.168.110.254"
+        z.internaldns2 = "192.168.110.253"
+        z.name = "test"+str(l)
+        z.networktype = 'Basic'
+
+        ips = iprange()
+        ips.vlan = "49"
+        ips.startip = "10.147.49.200"
+        ips.endip = "10.147.49.250"
+        ips.gateway = "10.147.49.1"
+        ips.netmask = "255.255.255.0"
+        z.ipranges.append(ips)
+
+        #If security groups are reqd
+        sgprovider = provider()
+        sgprovider.broadcastdomainrange = 'Pod'
+        sgprovider.name = 'SecurityGroupProvider'
+
+        nsprovider = provider()
+        nsprovider.name = 'Netscaler'
+        ns = netscaler()
+        ns.hostname = '10.147.40.100'
+        nsprovider.devices.append(ns)
+
+        pn = physical_network()
+        pn.name = "test-network"
+        pn.traffictypes = [traffictype("Guest",
+                                       {"xen": "cloud-guest"}),
+                           traffictype("Management"),
+                           traffictype("Public", {"xen": "cloud-public"})]
+        pn.providers.extend([sgprovider, nsprovider])
+        z.physical_networks.append(pn)
+
+        '''create 10 pods'''
+        for i in range(2):
+            p = pod()
+            p.name = "test" + str(l) + str(i)
+            p.gateway = "192.168.%d.1" % i
+            p.netmask = "255.255.255.0"
+            p.startip = "192.168.%d.150" % i
+            p.endip = "192.168.%d.220" % i
+
+            '''add two pod guest ip ranges'''
+            for j in range(2):
+                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)
+
+                p.guestIpRanges.append(ip)
+
+            '''add 10 clusters'''
+            for j in range(2):
+                c = cluster()
+                c.clustername = "test"+str(l)+str(i) + str(j)
+                c.clustertype = "CloudManaged"
+                c.hypervisor = "Simulator"
+
+                '''add 10 hosts'''
+                for k in range(2):
+                    h = host()
+                    h.username = "root"
+                    h.password = "password"
+                    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" % (str(l) + str(i)
+                                                              + str(j)
+                                                              + str(m))
+                    c.primaryStorages.append(primary)
+
+                p.clusters.append(c)
+
+            z.pods.append(p)
+
+        '''add two secondary'''
+        for i in range(5):
+            secondary = secondaryStorage()
+            secondary.url = "nfs://localhost/path"+str(l) + str(i)
+            z.secondaryStorages.append(secondary)
+
+        zs.zones.append(z)
+
+    '''Add one mgt server'''
+    mgt = managementServer()
+    mgt.mgtSvrIp = "localhost"
+    zs.mgtSvr.append(mgt)
+
+    '''Add a database'''
+    db = dbServer()
+    db.dbSvr = "localhost"
+
+    zs.dbSvr = db
+
+    '''add global configuration'''
+    global_settings = {'expunge.delay': '60',
+                       'expunge.interval': '60',
+                       'expunge.workers': '3',
+                       }
+    for k, v in global_settings.iteritems():
+        cfg = configuration()
+        cfg.name = k
+        cfg.value = v
+        zs.globalConfig.append(cfg)
+
+    ''''add loggers'''
+    testClientLogger = logger()
+    testClientLogger.name = "TestClient"
+    testClientLogger.file = "/tmp/testclient.log"
+
+    testCaseLogger = logger()
+    testCaseLogger.name = "TestCase"
+    testCaseLogger.file = "/tmp/testcase.log"
+
+    zs.logger.append(testClientLogger)
+    zs.logger.append(testCaseLogger)
+
+    return zs
+
+
+def describe_setup_in_advanced_mode():
+    '''sample code to generate setup configuration file'''
+    zs = cloudstackConfiguration()
+
+    for l in range(1):
+        z = zone()
+        z.dns1 = "8.8.8.8"
+        z.dns2 = "8.8.4.4"
+        z.internaldns1 = "192.168.110.254"
+        z.internaldns2 = "192.168.110.253"
+        z.name = "test"+str(l)
+        z.networktype = 'Advanced'
+        z.guestcidraddress = "10.1.1.0/24"
+        z.vlan = "100-2000"
+
+        pn = physical_network()
+        pn.name = "test-network"
+        pn.traffictypes = [traffictype("Guest"), traffictype("Management"),
+                           traffictype("Public")]
+
+        vpcprovider = provider('VpcVirtualRouter')
+
+        nsprovider = provider('Netscaler')
+        nsprovider.devices.append(netscaler(hostname='10.147.40.100'))
+
+        srxprovider = provider('JuniperSRX')
+        srxprovider.devices.append(srx(hostname='10.147.40.3'))
+
+        f5provider = provider('F5BigIp')
+        f5provider.devices.append(bigip(hostname='10.147.40.3'))
+
+        pn.providers.extend([vpcprovider, nsprovider, srxprovider, f5provider])
+        z.physical_networks.append(pn)
+
+        '''create 10 pods'''
+        for i in range(2):
+            p = pod()
+            p.name = "test" + str(l) + str(i)
+            p.gateway = "192.168.%d.1" % i
+            p.netmask = "255.255.255.0"
+            p.startip = "192.168.%d.200" % i
+            p.endip = "192.168.%d.220" % i
+
+            '''add 10 clusters'''
+            for j in range(2):
+                c = cluster()
+                c.clustername = "test"+str(l)+str(i) + str(j)
+                c.clustertype = "CloudManaged"
+                c.hypervisor = "Simulator"
+
+                '''add 10 hosts'''
+                for k in range(2):
+                    h = host()
+                    h.username = "root"
+                    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" % (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" %
+                    #    (str(l) + str(i) + str(j) + str(m), size)
+                    primary.url = "nfs://localhost/path%s" % (str(l) + str(i)
+                                                              + str(j)
+                                                              + str(m))
+                    c.primaryStorages.append(primary)
+
+                p.clusters.append(c)
+
+            z.pods.append(p)
+
+        '''add two secondary'''
+        for i in range(5):
+            secondary = secondaryStorage()
+            secondary.url = "nfs://localhost/path"+str(l) + str(i)
+            z.secondaryStorages.append(secondary)
+
+        '''add default public network'''
+        ips = iprange()
+        ips.vlan = "26"
+        ips.startip = "172.16.26.2"
+        ips.endip = "172.16.26.100"
+        ips.gateway = "172.16.26.1"
+        ips.netmask = "255.255.255.0"
+        z.ipranges.append(ips)
+
+        zs.zones.append(z)
+
+    '''Add one mgt server'''
+    mgt = managementServer()
+    mgt.mgtSvrIp = "localhost"
+    zs.mgtSvr.append(mgt)
+
+    '''Add a database'''
+    db = dbServer()
+    db.dbSvr = "localhost"
+
+    zs.dbSvr = db
+
+    '''add global configuration'''
+    global_settings = {'expunge.delay': '60',
+                       'expunge.interval': '60',
+                       'expunge.workers': '3',
+                       }
+    for k, v in global_settings.iteritems():
+        cfg = configuration()
+        cfg.name = k
+        cfg.value = v
+        zs.globalConfig.append(cfg)
+
+    ''''add loggers'''
+    testClientLogger = logger()
+    testClientLogger.name = "TestClient"
+    testClientLogger.file = "/tmp/testclient.log"
+
+    testCaseLogger = logger()
+    testCaseLogger.name = "TestCase"
+    testCaseLogger.file = "/tmp/testcase.log"
+
+    zs.logger.append(testClientLogger)
+    zs.logger.append(testCaseLogger)
+
+    return zs
+
+'''sample code to generate setup configuration file'''
+
+
+def describe_setup_in_advancedsg_mode():
+    zs = cloudstackConfiguration()
+
+    for l in range(1):
+        z = zone()
+        z.dns1 = "8.8.8.8"
+        z.dns2 = "8.8.4.4"
+        z.internaldns1 = "192.168.110.254"
+        z.internaldns2 = "192.168.110.253"
+        z.name = "test"+str(l)
+        z.networktype = 'Advanced'
+        z.vlan = "100-2000"
+        z.securitygroupenabled = "true"
+
+        pn = physical_network()
+        pn.name = "test-network"
+        pn.traffictypes = [traffictype("Guest"), traffictype("Management")]
+
+        #If security groups are reqd
+        sgprovider = provider()
+        sgprovider.broadcastdomainrange = 'ZONE'
+        sgprovider.name = 'SecurityGroupProvider'
+
+        pn.providers.append(sgprovider)
+        z.physical_networks.append(pn)
+
+        '''create 10 pods'''
+        for i in range(2):
+            p = pod()
+            p.name = "test" + str(l) + str(i)
+            p.gateway = "192.168.%d.1" % i
+            p.netmask = "255.255.255.0"
+            p.startip = "192.168.%d.200" % i
+            p.endip = "192.168.%d.220" % i
+
+            '''add 10 clusters'''
+            for j in range(2):
+                c = cluster()
+                c.clustername = "test"+str(l)+str(i) + str(j)
+                c.clustertype = "CloudManaged"
+                c.hypervisor = "Simulator"
+
+                '''add 10 hosts'''
+                for k in range(2):
+                    h = host()
+                    h.username = "root"
+                    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" % (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" % \
+                        #(str(l) + str(i) + str(j) + str(m), size)
+                    primary.url = "nfs://localhost/path%s" % \
+                        (str(l) + str(i) + str(j) + str(m))
+                    c.primaryStorages.append(primary)
+
+                p.clusters.append(c)
+
+            z.pods.append(p)
+
+        '''add two secondary'''
+        for i in range(5):
+            secondary = secondaryStorage()
+            secondary.url = "nfs://localhost/path"+str(l) + str(i)
+            z.secondaryStorages.append(secondary)
+
+        '''add default guest network'''
+        ips = iprange()
+        ips.vlan = "26"
+        ips.startip = "172.16.26.2"
+        ips.endip = "172.16.26.100"
+        ips.gateway = "172.16.26.1"
+        ips.netmask = "255.255.255.0"
+        z.ipranges.append(ips)
+
+        zs.zones.append(z)
+
+    '''Add one mgt server'''
+    mgt = managementServer()
+    mgt.mgtSvrIp = "localhost"
+    zs.mgtSvr.append(mgt)
+
+    '''Add a database'''
+    db = dbServer()
+    db.dbSvr = "localhost"
+
+    zs.dbSvr = db
+
+    '''add global configuration'''
+    global_settings = {'expunge.delay': '60',
+                       'expunge.interval': '60',
+                       'expunge.workers': '3',
+                       }
+    for k, v in global_settings.iteritems():
+        cfg = configuration()
+        cfg.name = k
+        cfg.value = v
+        zs.globalConfig.append(cfg)
+
+    ''''add loggers'''
+    testClientLogger = logger()
+    testClientLogger.name = "TestClient"
+    testClientLogger.file = "/tmp/testclient.log"
+
+    testCaseLogger = logger()
+    testCaseLogger.name = "TestCase"
+    testCaseLogger.file = "/tmp/testcase.log"
+
+    zs.logger.append(testClientLogger)
+    zs.logger.append(testCaseLogger)
+
+    return zs
+
+
+def generate_setup_config(config, file=None):
+    describe = config
+    if file is None:
+        return json.dumps(jsonHelper.jsonDump.dump(describe))
+    else:
+        fp = open(file, 'w')
+        json.dump(jsonHelper.jsonDump.dump(describe), fp, indent=4)
+        fp.close()
+
+
+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)
+
+if __name__ == "__main__":
+    parser = OptionParser()
+
+    parser.add_option("-i", "--input", action="store", default=None,
+                      dest="inputfile", help="input file")
+    parser.add_option("-a", "--advanced", action="store_true", default=False,
+                      dest="advanced", help="use advanced networking")
+    parser.add_option("-s", "--advancedsg", action="store_true", default=False,
+                      dest="advancedsg", help="use advanced networking \
+with security groups")
+    parser.add_option("-o", "--output", action="store",
+                      default="./datacenterCfg", dest="output",
+                      help="the path where the json deployer file generated, \
+by default is ./datacenterCfg")
+
+    (options, args) = parser.parse_args()
+
+    if options.inputfile:
+        config = getSetupConfig(options.inputfile)
+    if options.advanced:
+        config = describe_setup_in_advanced_mode()
+    elif options.advancedsg:
+        config = describe_setup_in_advancedsg_mode()
+    else:
+        config = describe_setup_in_basic_mode()
+
+    generate_setup_config(config, options.output)


Mime
View raw message