From 292e77b96b0a518765a5065320cec45bf87ef1ec Mon Sep 17 00:00:00 2001 From: Min Chen Date: Thu, 9 May 2013 16:19:06 -0700 Subject: [PATCH] Fix marvin test to add S3 image store and cache storage. --- client/tomcatconf/commands.properties.in | 1 + .../LocalNfsSecondaryStorageResource.java | 4 + .../cloudstack/storage/LocalHostEndpoint.java | 2 +- .../cloud/server/ManagementServerImpl.java | 1 + setup/db/db/schema-410to420.sql | 3 +- tools/devcloud/devcloud.cfg | 2 +- tools/devcloud/devcloud_s3.cfg | 141 ++++++++++++++++++ tools/marvin/marvin/configGenerator.py | 7 + tools/marvin/marvin/deployDataCenter.py | 21 ++- 9 files changed, 177 insertions(+), 5 deletions(-) create mode 100644 tools/devcloud/devcloud_s3.cfg diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in index 002da875cae..c93512262b2 100644 --- a/client/tomcatconf/commands.properties.in +++ b/client/tomcatconf/commands.properties.in @@ -245,6 +245,7 @@ listS3s=1 addImageStore=1 listImageStores=1 deleteImageStore=1 +createCacheStore=1 #### host commands addHost=3 diff --git a/core/src/com/cloud/storage/resource/LocalNfsSecondaryStorageResource.java b/core/src/com/cloud/storage/resource/LocalNfsSecondaryStorageResource.java index a2cf757b432..4c708af91d5 100644 --- a/core/src/com/cloud/storage/resource/LocalNfsSecondaryStorageResource.java +++ b/core/src/com/cloud/storage/resource/LocalNfsSecondaryStorageResource.java @@ -32,6 +32,10 @@ import com.cloud.utils.exception.CloudRuntimeException; public class LocalNfsSecondaryStorageResource extends NfsSecondaryStorageResource { + public LocalNfsSecondaryStorageResource(){ + this._dlMgr = new DownloadManagerImpl(); + } + @Override public Answer executeRequest(Command cmd) { if (cmd instanceof DownloadSystemTemplateCommand){ diff --git a/engine/storage/src/org/apache/cloudstack/storage/LocalHostEndpoint.java b/engine/storage/src/org/apache/cloudstack/storage/LocalHostEndpoint.java index 1ae13b630d0..d689f36dfe6 100644 --- a/engine/storage/src/org/apache/cloudstack/storage/LocalHostEndpoint.java +++ b/engine/storage/src/org/apache/cloudstack/storage/LocalHostEndpoint.java @@ -23,7 +23,7 @@ public class LocalHostEndpoint implements EndPoint { private ScheduledExecutorService executor; ServerResource resource; public LocalHostEndpoint() { - resource = ComponentContext.inject(LocalNfsSecondaryStorageResource.class); + resource = new LocalNfsSecondaryStorageResource(); executor = Executors.newScheduledThreadPool(10); } @Override diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index 92d8c7bc606..b0f0fcb9709 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -2153,6 +2153,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe cmdList.add(AddImageStoreCmd.class); cmdList.add(ListImageStoresCmd.class); cmdList.add(DeleteImageStoreCmd.class); + cmdList.add(CreateCacheStoreCmd.class); return cmdList; } diff --git a/setup/db/db/schema-410to420.sql b/setup/db/db/schema-410to420.sql index 6ce0d2defee..75d29f65e8d 100644 --- a/setup/db/db/schema-410to420.sql +++ b/setup/db/db/schema-410to420.sql @@ -115,7 +115,8 @@ CREATE VIEW `cloud`.`image_store_view` AS left join `cloud`.`data_center` ON image_store.data_center_id = data_center.id left join - `cloud`.`image_store_details` ON image_store_details.store_id = image_store.id; + `cloud`.`image_store_details` ON image_store_details.store_id = image_store.id + where image_store.role = 'Image'; -- here we have to allow null for store_id to accomodate baremetal case to search for ready templates since template state is only stored in this table -- FK also commented out due to this diff --git a/tools/devcloud/devcloud.cfg b/tools/devcloud/devcloud.cfg index 0be6026a822..a2a9fd82791 100644 --- a/tools/devcloud/devcloud.cfg +++ b/tools/devcloud/devcloud.cfg @@ -84,7 +84,7 @@ "secondaryStorages": [ { "url": "nfs://192.168.56.10/opt/storage/secondary", - "providerName": "CloudStack ImageStore Provider", + "providerName": "NFS", "details": { } } diff --git a/tools/devcloud/devcloud_s3.cfg b/tools/devcloud/devcloud_s3.cfg new file mode 100644 index 00000000000..885f54aa110 --- /dev/null +++ b/tools/devcloud/devcloud_s3.cfg @@ -0,0 +1,141 @@ +# 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. +# + +{ + "zones": [ + { + "name": "DevCloud0", + "physical_networks": [ + { + "broadcastdomainrange": "Zone", + "name": "test-network", + "traffictypes": [ + { + "typ": "Guest" + }, + { + "typ": "Management" + } + ], + "providers": [ + { + "broadcastdomainrange": "ZONE", + "name": "VirtualRouter" + }, + { + "broadcastdomainrange": "Pod", + "name": "SecurityGroupProvider" + } + ] + } + ], + "dns2": "4.4.4.4", + "dns1": "8.8.8.8", + "securitygroupenabled": "true", + "localstorageenabled": "true", + "networktype": "Basic", + "pods": [ + { + "endip": "192.168.56.220", + "name": "test00", + "startip": "192.168.56.200", + "guestIpRanges": [ + { + "startip": "192.168.56.100", + "endip": "192.168.56.199", + "netmask": "255.255.255.0", + "gateway": "192.168.56.1" + } + ], + "netmask": "255.255.255.0", + "clusters": [ + { + "clustername": "test000", + "hypervisor": "XenServer", + "hosts": [ + { + "username": "root", + "url": "http://192.168.56.10/", + "password": "password" + } + ], + "clustertype": "CloudManaged" + } + ], + "gateway": "192.168.56.1" + } + ], + "internaldns1": "192.168.56.1", + "secondaryStorages": [ + { + "providerName": "S3", + "details": [ + { + "key" : "accesskey", + "value" :"OYAZXCAFUC1DAFOXNJWI" + }, + { + "key" : "secretkey", + "value" : "OYAZXCAFUC1DAFOXNJWI" + }, + { + "key" : "endpoint", + "value" : "10.223.89.7:8080" + }, + { + "key" : "bucket", + "value" : "cloudstack" + } + ] + } + ], + "cacheStorages": [ + { + "url": "nfs://192.168.56.10/opt/storage/cache", + "providerName": "NFS", + "details": [ + ] + } + ] + } + ], + "logger": [ + { + "name": "TestClient", + "file": "/tmp/testclient.log" + }, + { + "name": "TestCase", + "file": "/tmp/testcase.log" + } + ], + "mgtSvr": [ + { + "mgtSvrIp": "127.0.0.1", + "port": 8096 + } + ], + "dbSvr": + { + "dbSvr": "127.0.0.1", + "port": 3306, + "user": "cloud", + "passwd": "cloud", + "db": "cloud" + } +} diff --git a/tools/marvin/marvin/configGenerator.py b/tools/marvin/marvin/configGenerator.py index 8235b095ca1..adb8f541391 100644 --- a/tools/marvin/marvin/configGenerator.py +++ b/tools/marvin/marvin/configGenerator.py @@ -70,6 +70,7 @@ class zone(): self.physical_networks = [] self.pods = [] self.secondaryStorages = [] + self.cacheStorages = [] class traffictype(): @@ -182,6 +183,12 @@ class secondaryStorage(): self.providerName = None self.details = None +class cacheStorage(): + def __init__(self): + self.url = None + self.providerName = None + self.details = None + class s3(): def __init__(self): self.accesskey = None diff --git a/tools/marvin/marvin/deployDataCenter.py b/tools/marvin/marvin/deployDataCenter.py index aaf05011dc1..164af74adc0 100644 --- a/tools/marvin/marvin/deployDataCenter.py +++ b/tools/marvin/marvin/deployDataCenter.py @@ -141,10 +141,26 @@ class deployDataCenters(): secondarycmd = addImageStore.addImageStoreCmd() secondarycmd.url = secondary.url secondarycmd.provider = secondary.providerName - """if secondary.provider == "CloudStack ImageStore Provider":""" - secondarycmd.zoneid = zoneId + secondarycmd.details = [] + for item in secondary.details: + secondarycmd.details.append(item.__dict__) + 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 = createCacheStore.createCacheStoreCmd() + cachecmd.url = cache.url + cachecmd.provider = cache.providerName + cachecmd.zoneid = zoneId + cachecmd.details = [] + for item in cache.details: + cachecmd.details.append(item.__dict__) + self.apiClient.createCacheStore(cachecmd) + def createnetworks(self, networks, zoneId): if networks is None: return @@ -322,6 +338,7 @@ class deployDataCenters(): zoneId) self.createSecondaryStorages(zone.secondaryStorages, zoneId) + self.createCacheStorages(zone.cacheStorages, zoneId) self.enableZone(zoneId, "Enabled") return