You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by hu...@apache.org on 2013/01/14 17:15:57 UTC

[44/50] git commit: devcloud-kvm: marvin deployment config generator for devcloud-kvm

devcloud-kvm: marvin deployment config generator for devcloud-kvm

The devcloud-kvm.py script will take the kvm.properties file to generate
an advanced zone configuration with two physical networks with traffic
labels for 'guest' and 'public' traffic going on 'eth0' and 'eth1'
respectively.

To generate config:
$ python devcloud-kvm.py -i kvm.properties -o devcloud-kvm-advanced.cfg

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


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

Branch: refs/heads/cloud-agent-with-openvswitch
Commit: 5442df2b5eba253f2dc80e08ff97e3f22047bbae
Parents: 8d3cbc8
Author: Prasanna Santhanam <ts...@apache.org>
Authored: Sun Jan 13 14:22:56 2013 +0530
Committer: Prasanna Santhanam <ts...@apache.org>
Committed: Sun Jan 13 14:22:56 2013 +0530

----------------------------------------------------------------------
 tools/devcloud-kvm/devcloud-kvm-advanced.cfg |  183 +++++++++++++++++++++
 tools/devcloud-kvm/devcloud-kvm.py           |  157 ++++++++++++++++++
 tools/devcloud-kvm/kvm.properties            |   62 +++++++
 3 files changed, 402 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5442df2b/tools/devcloud-kvm/devcloud-kvm-advanced.cfg
----------------------------------------------------------------------
diff --git a/tools/devcloud-kvm/devcloud-kvm-advanced.cfg b/tools/devcloud-kvm/devcloud-kvm-advanced.cfg
new file mode 100644
index 0000000..b96805e
--- /dev/null
+++ b/tools/devcloud-kvm/devcloud-kvm-advanced.cfg
@@ -0,0 +1,183 @@
+{
+    "zones": [
+        {
+            "localstorageenabled": "true", 
+            "name": "Devcloud-KVM", 
+            "guestcidraddress": "10.1.1.0/24", 
+            "dns1": "8.8.8.8", 
+            "physical_networks": [
+                {
+                    "name": "eth0", 
+                    "providers": [
+                        {
+                            "broadcastdomainrange": "ZONE", 
+                            "name": "VirtualRouter"
+                        }, 
+                        {
+                            "broadcastdomainrange": "ZONE", 
+                            "name": "VpcVirtualRouter"
+                        }
+                    ], 
+                    "broadcastdomainrange": "Zone", 
+                    "vlan": "3900-3919", 
+                    "traffictypes": [
+                        {
+                            "kvm": "kvm-guest", 
+                            "typ": "Guest"
+                        }, 
+                        {
+                            "typ": "Management"
+                        }
+                    ], 
+                    "tags": [
+                        "devcloud-guest"
+                    ]
+                }, 
+                {
+                    "name": "eth1", 
+                    "providers": [
+                        {
+                            "broadcastdomainrange": "ZONE", 
+                            "name": "VirtualRouter"
+                        }, 
+                        {
+                            "broadcastdomainrange": "ZONE", 
+                            "name": "VpcVirtualRouter"
+                        }
+                    ], 
+                    "broadcastdomainrange": "Zone", 
+                    "vlan": "3920-3939", 
+                    "traffictypes": [
+                        {
+                            "kvm": "kvm-public", 
+                            "typ": "Public"
+                        }
+                    ], 
+                    "tags": [
+                        "devcloud-public"
+                    ]
+                }
+            ], 
+            "ipranges": [
+                {
+                    "startip": "10.0.3.100", 
+                    "endip": "10.0.3.199", 
+                    "netmask": "255.255.255.0", 
+                    "vlan": "31", 
+                    "gateway": "10.0.3.2"
+                }
+            ], 
+            "networktype": "Advanced", 
+            "pods": [
+                {
+                    "endip": "192.168.56.249", 
+                    "name": "POD0", 
+                    "startip": "192.168.56.200", 
+                    "netmask": "255.255.255.0", 
+                    "clusters": [
+                        {
+                            "clustername": "C0", 
+                            "hypervisor": "KVM", 
+                            "hosts": [
+                                {
+                                    "username": "root", 
+                                    "url": "http://192.168.56.10", 
+                                    "password": "password"
+                                }
+                            ], 
+                            "clustertype": "CloudManaged", 
+                            "primaryStorages": [
+                                {
+                                    "url": "nfs://192.168.56.10/opt/storage/primary", 
+                                    "name": "PS0"
+                                }
+                            ]
+                        }
+                    ], 
+                    "gateway": "192.168.56.1"
+                }
+            ], 
+            "internaldns1": "8.8.8.8", 
+            "secondaryStorages": [
+                {
+                    "url": "nfs://192.168.56.10/opt/storage/secondary"
+                }
+            ]
+        }
+    ], 
+    "dbSvr": {
+        "dbSvr": "127.0.0.1", 
+        "passwd": "cloud", 
+        "db": "cloud", 
+        "port": 3306, 
+        "user": "cloud"
+    }, 
+    "logger": [
+        {
+            "name": "TestClient", 
+            "file": "testclient.log"
+        }, 
+        {
+            "name": "TestCase", 
+            "file": "testcase.log"
+        }
+    ], 
+    "globalConfig": [
+        {
+            "name": "storage.cleanup.interval", 
+            "value": "300"
+        }, 
+        {
+            "name": "instance.name", 
+            "value": "vm"
+        }, 
+        {
+            "name": "workers", 
+            "value": "10"
+        }, 
+        {
+            "name": "vm.op.wait.interval", 
+            "value": "5"
+        }, 
+        {
+            "name": "account.cleanup.interval", 
+            "value": "600"
+        }, 
+        {
+            "name": "guest.domain.suffix", 
+            "value": "devcloud.kvm"
+        }, 
+        {
+            "name": "expunge.delay", 
+            "value": "60"
+        }, 
+        {
+            "name": "vm.allocation.algorithm", 
+            "value": "random"
+        }, 
+        {
+            "name": "expunge.interval", 
+            "value": "60"
+        }, 
+        {
+            "name": "expunge.workers", 
+            "value": "3"
+        }, 
+        {
+            "name": "secstorage.allowed.internal.sites", 
+            "value": "10.147.28.0/24"
+        }, 
+        {
+            "name": "check.pod.cidrs", 
+            "value": "true"
+        }
+    ], 
+    "mgtSvr": [
+        {
+            "mgtSvrIp": "127.0.0.1", 
+            "passwd": "password", 
+            "user": "root", 
+            "port": 8096
+        }
+    ]
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5442df2b/tools/devcloud-kvm/devcloud-kvm.py
----------------------------------------------------------------------
diff --git a/tools/devcloud-kvm/devcloud-kvm.py b/tools/devcloud-kvm/devcloud-kvm.py
new file mode 100644
index 0000000..dd551b5
--- /dev/null
+++ b/tools/devcloud-kvm/devcloud-kvm.py
@@ -0,0 +1,157 @@
+#!/usr/bin/env python
+# 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.
+'''
+############################################################
+# Experimental state of scripts 
+#    * Need to be reviewed
+#    * Only a sandbox
+############################################################
+'''
+import random
+import marvin
+from ConfigParser import SafeConfigParser
+from optparse import OptionParser
+from marvin.configGenerator import *
+
+
+def getGlobalSettings(config):
+   for k, v in dict(config.items('globals')).iteritems():
+        cfg = configuration()
+        cfg.name = k
+        cfg.value = v
+        yield cfg
+
+
+def describeDevcloudKvmResources(config):
+    zs = cloudstackConfiguration()
+
+    z = zone()
+    z.dns1 = config.get('environment', 'dns')
+    z.internaldns1 = config.get('environment', 'dns')
+    z.name = 'Devcloud-%s'%(config.get('cloudstack', 'hypervisor'))
+    z.networktype = 'Advanced'
+    z.guestcidraddress = '10.1.1.0/24'
+    z.localstorageenabled = 'true'
+    
+    vpcprovider = provider()
+    vpcprovider.name = 'VpcVirtualRouter'
+    
+    pn = physical_network()
+    pn.name = "eth0"
+    pn.vlan = config.get('cloudstack', 'pnet.vlan')
+    pn.tags = ["devcloud-guest"]
+    pn.traffictypes = [traffictype("Guest", {"kvm" :"kvm-guest" }), traffictype("Management")]
+    pn.providers.append(vpcprovider)
+
+    pn2 = physical_network()
+    pn2.name = "eth1"
+    pn2.vlan = config.get('cloudstack', 'pnet2.vlan')
+    pn2.tags = ["devcloud-public"]
+    pn2.traffictypes = [traffictype("Public", {"kvm" : "kvm-public"})]
+    pn2.providers.append(vpcprovider)
+    
+    z.physical_networks.append(pn)
+    z.physical_networks.append(pn2)
+
+    p = pod()
+    p.name = 'POD0'
+    p.gateway = config.get('cloudstack', 'private.gateway')
+    p.startip =  config.get('cloudstack', 'private.pod.startip')
+    p.endip =  config.get('cloudstack', 'private.pod.endip')
+    p.netmask = config.get('cloudstack', 'private.netmask')
+
+    v = iprange()
+    v.gateway = config.get('cloudstack', 'public.gateway')
+    v.startip = config.get('cloudstack', 'public.vlan.startip')
+    v.endip = config.get('cloudstack', 'public.vlan.endip') 
+    v.netmask = config.get('cloudstack', 'public.netmask')
+    v.vlan = config.get('cloudstack', 'public.vlan')
+    z.ipranges.append(v)
+
+    c = cluster()
+    c.clustername = 'C0'
+    c.hypervisor = config.get('cloudstack', 'hypervisor')
+    c.clustertype = 'CloudManaged'
+
+    h = host()
+    h.username = 'root'
+    h.password = config.get('cloudstack', 'host.password')
+    h.url = 'http://%s'%(config.get('cloudstack', 'host'))
+    c.hosts.append(h)
+
+    ps = primaryStorage()
+    ps.name = 'PS0'
+    ps.url = config.get('cloudstack', 'primary.pool')
+    c.primaryStorages.append(ps)
+
+    p.clusters.append(c)
+    z.pods.append(p)
+
+    secondary = secondaryStorage()
+    secondary.url = config.get('cloudstack', 'secondary.pool')
+    z.secondaryStorages.append(secondary)
+
+    '''Add zone'''
+    zs.zones.append(z)
+
+    '''Add mgt server'''
+    mgt = managementServer()
+    mgt.mgtSvrIp = config.get('environment', 'mshost')
+    mgt.user = config.get('environment', 'mshost.user')
+    mgt.passwd = config.get('environment', 'mshost.passwd')
+    zs.mgtSvr.append(mgt)
+
+    '''Add a database'''
+    db = dbServer()
+    db.dbSvr = config.get('environment', 'mysql.host')
+    db.user = config.get('environment', 'mysql.cloud.user')
+    db.passwd = config.get('environment', 'mysql.cloud.passwd')
+    zs.dbSvr = db
+
+    '''Add some configuration'''
+    [zs.globalConfig.append(cfg) for cfg in getGlobalSettings(config)]
+
+    ''''add loggers'''
+    testClientLogger = logger()
+    testClientLogger.name = 'TestClient'
+    testClientLogger.file = 'testclient.log'
+
+    testCaseLogger = logger()
+    testCaseLogger.name = 'TestCase'
+    testCaseLogger.file = 'testcase.log'
+
+    zs.logger.append(testClientLogger)
+    zs.logger.append(testCaseLogger)
+    return zs
+
+
+if __name__ == '__main__':
+    parser = OptionParser()
+    parser.add_option('-i', '--input', action='store', default='setup.properties', \
+                      dest='input', help='file containing environment setup information')
+    parser.add_option('-o', '--output', action='store', default='./devcloud-kvm-advanced.cfg', \
+                      dest='output', help='path where environment json will be generated')
+
+
+    (opts, args) = parser.parse_args()
+
+    cfg_parser = SafeConfigParser()
+    cfg_parser.read(opts.input)
+
+    cfg = describeDevcloudKvmResources(cfg_parser)
+    generate_setup_config(cfg, opts.output)

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5442df2b/tools/devcloud-kvm/kvm.properties
----------------------------------------------------------------------
diff --git a/tools/devcloud-kvm/kvm.properties b/tools/devcloud-kvm/kvm.properties
new file mode 100644
index 0000000..79afcd4
--- /dev/null
+++ b/tools/devcloud-kvm/kvm.properties
@@ -0,0 +1,62 @@
+# 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.
+
+
+[globals]
+#global settings in cloudstack
+expunge.delay=60
+expunge.interval=60
+storage.cleanup.interval=300
+account.cleanup.interval=600
+expunge.workers=3
+workers=10
+vm.allocation.algorithm=random
+vm.op.wait.interval=5
+guest.domain.suffix=devcloud.kvm
+instance.name=vm
+check.pod.cidrs=true
+secstorage.allowed.internal.sites=10.147.28.0/24
+[environment]
+dns=8.8.8.8
+mshost=127.0.0.1
+mshost.user=root
+mshost.passwd=password
+mysql.host=127.0.0.1
+mysql.cloud.user=cloud
+mysql.cloud.passwd=cloud
+[cloudstack]
+#guest VLAN
+pnet.vlan=3900-3919
+pnet2.vlan=3920-3939
+#management network
+private.gateway=192.168.56.1
+private.pod.startip=192.168.56.200
+private.pod.endip=192.168.56.249
+private.netmask=255.255.255.0
+#public network
+public.gateway=10.0.3.2
+public.vlan=31
+public.vlan.startip=10.0.3.100
+public.vlan.endip=10.0.3.199
+public.netmask=255.255.255.0
+#hypervisor host information
+hypervisor=KVM
+host=192.168.56.10
+host.password=password
+#storage pools
+primary.pool=nfs://192.168.56.10/opt/storage/primary
+secondary.pool=nfs://192.168.56.10/opt/storage/secondary