You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ed...@apache.org on 2013/07/09 03:43:56 UTC
[2/2] git commit: updated refs/heads/4.2 to 9a9720c
fix simulator
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/ba4192dc
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/ba4192dc
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/ba4192dc
Branch: refs/heads/4.2
Commit: ba4192dc5ef9c8891bfc3c637710ca3174f5232e
Parents: 40cac19
Author: Edison Su <su...@gmail.com>
Authored: Wed Jul 3 18:06:39 2013 -0700
Committer: Edison Su <su...@gmail.com>
Committed: Mon Jul 8 18:43:20 2013 -0700
----------------------------------------------------------------------
.../admin/host/AddSecondaryStorageCmd.java | 4 +-
.../tomcatconf/simulatorComponentContext.xml.in | 3 +
plugins/hypervisors/simulator/pom.xml | 75 ++++---
.../src/com/cloud/agent/MetricsCollector.java | 107 ----------
.../src/com/cloud/agent/MockVmMetrics.java | 204 -------------------
.../src/com/cloud/agent/MultiCaster.java | 152 --------------
.../com/cloud/agent/MultiCasterListener.java | 22 --
.../src/com/cloud/agent/SimulatorCmd.java | 37 ----
.../com/cloud/agent/SimulatorMigrateVmCmd.java | 83 --------
.../agent/manager/MockAgentManagerImpl.java | 18 +-
.../cloud/agent/manager/SimulatorManager.java | 0
.../commands/SimulatorAddSecondaryAgent.java | 28 +++
.../resource/SimulatorSecondaryDiscoverer.java | 24 +--
.../driver/SimulatorImageStoreDriverImpl.java | 115 +++++++++++
.../SimulatorImageStoreLifeCycleImpl.java | 132 ++++++++++++
.../SimulatorImageStoreProviderImpl.java | 98 +++++++++
.../motion/SimulatorDataMotionStrategy.java | 52 +++++
.../SimulatorSecondaryStorageResource.java | 23 +++
plugins/pom.xml | 2 -
plugins/storage/image/simulator/pom.xml | 68 -------
.../driver/SimulatorImageStoreDriverImpl.java | 106 ----------
.../SimulatorImageStoreLifeCycleImpl.java | 132 ------------
.../SimulatorImageStoreProviderImpl.java | 98 ---------
23 files changed, 525 insertions(+), 1058 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ba4192dc/api/src/org/apache/cloudstack/api/command/admin/host/AddSecondaryStorageCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/host/AddSecondaryStorageCmd.java b/api/src/org/apache/cloudstack/api/command/admin/host/AddSecondaryStorageCmd.java
index 14725d3..69a4a49 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/host/AddSecondaryStorageCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/host/AddSecondaryStorageCmd.java
@@ -41,11 +41,11 @@ public class AddSecondaryStorageCmd extends BaseCmd {
/////////////////////////////////////////////////////
@Parameter(name=ApiConstants.URL, type=CommandType.STRING, required=true, description="the URL for the secondary storage")
- private String url;
+ protected String url;
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType=ZoneResponse.class,
description="the Zone ID for the secondary storage")
- private Long zoneId;
+ protected Long zoneId;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ba4192dc/client/tomcatconf/simulatorComponentContext.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/simulatorComponentContext.xml.in b/client/tomcatconf/simulatorComponentContext.xml.in
index 92278a4..1a43ba3 100644
--- a/client/tomcatconf/simulatorComponentContext.xml.in
+++ b/client/tomcatconf/simulatorComponentContext.xml.in
@@ -30,6 +30,8 @@
<bean id="SimulatorDiscoverer" class="com.cloud.resource.SimulatorDiscoverer">
<property name="name" value="Simulator Agent"/>
</bean>
+ <bean id="SimulatorSecondaryDiscoverer" class="com.cloud.resource.SimulatorSecondaryDiscoverer">
+ </bean>
<bean id="SimulatorGuru" class="com.cloud.simulator.SimulatorGuru">
<property name="name" value="Simulator Guru"/>
</bean>
@@ -89,6 +91,7 @@
<property name="Adapters">
<list>
<ref bean="SimulatorDiscoverer"/>
+ <ref bean="SimulatorSecondaryDiscoverer"/>
<ref bean="XcpServerDiscoverer"/>
<ref bean="SecondaryStorageDiscoverer"/>
<ref bean="KvmServerDiscoverer"/>
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ba4192dc/plugins/hypervisors/simulator/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/pom.xml b/plugins/hypervisors/simulator/pom.xml
index e4ca927..e99d355 100644
--- a/plugins/hypervisors/simulator/pom.xml
+++ b/plugins/hypervisors/simulator/pom.xml
@@ -17,33 +17,52 @@
under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.cloudstack</groupId>
+ <artifactId>cloudstack-plugins</artifactId>
+ <version>4.2.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
<groupId>org.apache.cloudstack</groupId>
- <artifactId>cloudstack-plugins</artifactId>
- <version>4.2.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
- <groupId>org.apache.cloudstack</groupId>
- <artifactId>cloud-plugin-hypervisor-simulator</artifactId>
- <name>Apache CloudStack Plugin - Hypervisor Simulator</name>
- <description>Simulator Hypervisor for Cloudstack</description>
- <build>
- <defaultGoal>install</defaultGoal>
- <sourceDirectory>src</sourceDirectory>
- <testSourceDirectory>test</testSourceDirectory>
- </build>
- <dependencies>
- <dependency>
- <groupId>org.apache.cloudstack</groupId>
- <artifactId>cloud-utils</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cloudstack</groupId>
- <artifactId>cloud-secondary-storage</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
+ <artifactId>cloud-plugin-hypervisor-simulator</artifactId>
+ <name>Apache CloudStack Plugin - Hypervisor Simulator</name>
+ <description>Simulator Hypervisor for Cloudstack</description>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <sourceDirectory>src</sourceDirectory>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.cloudstack</groupId>
+ <artifactId>cloud-utils</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cloudstack</groupId>
+ <artifactId>cloud-secondary-storage</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cloudstack</groupId>
+ <artifactId>cloud-engine-storage</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cloudstack</groupId>
+ <artifactId>cloud-engine-storage-image</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cloudstack</groupId>
+ <artifactId>cloud-engine-storage-volume</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cloudstack</groupId>
+ <artifactId>cloud-engine-storage-snapshot</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
</project>
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ba4192dc/plugins/hypervisors/simulator/src/com/cloud/agent/MetricsCollector.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/agent/MetricsCollector.java b/plugins/hypervisors/simulator/src/com/cloud/agent/MetricsCollector.java
deleted file mode 100644
index fd611f8..0000000
--- a/plugins/hypervisors/simulator/src/com/cloud/agent/MetricsCollector.java
+++ /dev/null
@@ -1,107 +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.
-package com.cloud.agent;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.ScheduledThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.utils.concurrency.NamedThreadFactory;
-
-public class MetricsCollector {
- private static final Logger s_logger = Logger.getLogger(MetricsCollector.class);
-
- private final Set<String> vmNames = new HashSet<String>();
- private final Set<String> newVMnames = new HashSet<String>();
- private final Map<String, MockVmMetrics> metricsMap = new HashMap<String, MockVmMetrics>();
-
- private final transient ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1, new NamedThreadFactory("Metrics"));
-
- private Set<String> _currentVms;
-
- public MetricsCollector(Set<String> currentVms) {
- _currentVms = currentVms;
- getAllVMNames();
- }
-
- public MetricsCollector() {
-
- }
-
- public synchronized void getAllVMNames() {
- Set<String> currentVMs = _currentVms;
-
- newVMnames.clear();
- newVMnames.addAll(currentVMs);
- newVMnames.removeAll(vmNames); //leave only new vms
-
- vmNames.removeAll(currentVMs); //old vms - current vms --> leave non-running vms;
- for (String vm: vmNames) {
- removeVM(vm);
- }
-
- vmNames.clear();
- vmNames.addAll(currentVMs);
- }
-
- public synchronized void submitMetricsJobs() {
- s_logger.debug("Submit Metric Jobs called");
-
- for (String vm : newVMnames) {
- MockVmMetrics task = new MockVmMetrics(vm);
- if (!metricsMap.containsKey(vm)) {
- metricsMap.put(vm, task);
- ScheduledFuture<?> sf = executor.scheduleWithFixedDelay(task, 2, 600, TimeUnit.SECONDS);
- task.setFuture(sf);
- }
- }
- newVMnames.clear();
- }
-
- public synchronized void addVM(String vmName) {
- newVMnames.add(vmName);
- s_logger.debug("Added vm name= " + vmName);
- }
-
- public synchronized void removeVM(String vmName) {
- newVMnames.remove(vmName);
- vmNames.remove(vmName);
- MockVmMetrics task = metricsMap.get(vmName);
- if (task != null) {
- task.stop();
- boolean r1= task.getFuture().cancel(false);
- metricsMap.remove(vmName);
- s_logger.debug("removeVM: cancel returned " + r1 + " for VM " + vmName);
- } else {
- s_logger.warn("removeVM called for nonexistent VM " + vmName);
- }
- }
-
- public synchronized Set<String> getVMNames() {
- return vmNames;
- }
-
- public synchronized Map<String, MockVmMetrics> getMetricsMap() {
- return metricsMap;
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ba4192dc/plugins/hypervisors/simulator/src/com/cloud/agent/MockVmMetrics.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/agent/MockVmMetrics.java b/plugins/hypervisors/simulator/src/com/cloud/agent/MockVmMetrics.java
deleted file mode 100644
index 30b99e7..0000000
--- a/plugins/hypervisors/simulator/src/com/cloud/agent/MockVmMetrics.java
+++ /dev/null
@@ -1,204 +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.
-package com.cloud.agent;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Random;
-import java.util.concurrent.ScheduledFuture;
-
-import org.apache.log4j.Logger;
-
-public class MockVmMetrics implements Runnable {
- private static final Logger s_logger = Logger.getLogger(MockVmMetrics.class);
-
- private String vmName;
-
- public final int MAX_INTERFACES=1;
-
- public final int MAX_DISKS=8;
-
- //the last calculated traffic speed (transmit) per interface
- private Map<String, Double> netTxKBps = new HashMap<String, Double>();
-
- //the last calculated traffic speed (receive) per interface
- private Map<String, Double> netRxKBps = new HashMap<String, Double>();
-
- //the last calculated disk write speed per disk (Bytes Per Second)
- private Map<String, Double> diskWriteKBytesPerSec = new HashMap<String, Double>();
-
- //the last calculated disk read speed per disk (Bytes Per Second)
- private Map<String, Double> diskReadKBytesPerSec = new HashMap<String, Double>();
-
- //Total Bytes Transmitted on network interfaces
- private Map<String, Long> netTxTotalBytes = new HashMap<String, Long>();
-
- //Total Bytes Received on network interfaces
- private Map<String, Long> netRxTotalBytes = new HashMap<String, Long>();
-
- //Total Bytes read per disk
- private Map<String, Long> diskReadTotalBytes = new HashMap<String, Long>();
-
- //Total Bytes written per disk
- private Map<String, Long> diskWriteTotalBytes = new HashMap<String, Long>();
-
- //CPU time in seconds
- private Double cpuSeconds = new Double(0.0);
-
- //CPU percentage
- private Float cpuPercent = new Float(0.0);
-
- private Map<String, String> diskMap = new HashMap<String, String>();
-
- private Map<String, String> vifMap = new HashMap<String, String>();
-
- private Map<String, Long> diskStatTimestamp = new HashMap<String, Long>();
- private Map<String, Long> netStatTimestamp = new HashMap<String, Long>();
-
- private long cpuStatTimestamp = 0L;
-
- private ScheduledFuture<?> future;
- private boolean stopped = false;
- private Random randSeed = new Random();
-
- public MockVmMetrics(String vmName) {
- this.vmName = vmName;
- vifMap.put("eth0", "eth0");
- vifMap.put("eth1", "eth1");
- vifMap.put("eth2", "eth2");
-
- Long networkStart = 0L;
- netTxTotalBytes.put("eth0", networkStart);
- netRxTotalBytes.put("eth0", networkStart);
-
- netTxTotalBytes.put("eth1", networkStart);
- netRxTotalBytes.put("eth1", networkStart);
-
- netTxTotalBytes.put("eth2", networkStart);
- netRxTotalBytes.put("eth2", networkStart);
- }
-
- private int getIncrementor() {
- return randSeed.nextInt(100);
- }
-
- @Override
- public void run() {
- if(s_logger.isDebugEnabled()) {
- s_logger.debug("Generating MockVM metrics");
- }
- for (Map.Entry<String, Long> entry : netRxTotalBytes.entrySet()) {
- entry.setValue(entry.getValue() + getIncrementor());
- }
-
- for (Map.Entry<String, Long> entry : netTxTotalBytes.entrySet()) {
- entry.setValue(entry.getValue() + getIncrementor());
- }
- }
-
- public String getVmName() {
- return vmName;
- }
-
- public Map<String, Double> getNetTxKBps() {
- return netTxKBps;
- }
-
- public Map<String, Double> getNetRxKBps() {
- return netRxKBps;
- }
-
- public Map<String, Double> getDiskWriteBytesPerSec() {
- return diskWriteKBytesPerSec;
- }
-
- public Map<String, Double> getDiskReadBytesPerSec() {
- return diskReadKBytesPerSec;
- }
-
- public Map<String, Long> getNetTxTotalBytes() {
- return netTxTotalBytes;
- }
-
- public Map<String, Long> getNetRxTotalBytes() {
- return netRxTotalBytes;
- }
-
- public Map<String, Long> getDiskReadTotalBytes() {
- return diskReadTotalBytes;
- }
-
- public Map<String, Long> getDiskWriteTotalBytes() {
- return diskWriteTotalBytes;
- }
-
- public Double getNetTxKBps(String intf) {
- return netTxKBps.get(intf);
- }
-
- public Double getNetRxKBps(String intf) {
- return netRxKBps.get(intf);
- }
-
- public Double getDiskWriteKBytesPerSec(String disk) {
- return diskWriteKBytesPerSec.get(disk);
- }
-
- public Double getDiskReadKBytesPerSec(String disk) {
- return diskReadKBytesPerSec.get(disk);
- }
-
- public Long getNetTxTotalBytes(String intf) {
- return netTxTotalBytes.get(intf);
- }
-
- public Long getNetRxTotalBytes(String intf) {
- return netRxTotalBytes.get(intf);
- }
-
- public Long getDiskReadTotalBytes(String disk) {
- return diskReadTotalBytes.get(disk);
- }
-
- public Long getDiskWriteTotalBytes(String disk) {
- return diskWriteTotalBytes.get(disk);
- }
-
- public Double getCpuSeconds() {
- return cpuSeconds;
- }
-
- public Map<String, String> getDiskMap() {
- return diskMap;
- }
-
- public Float getCpuPercent() {
- return cpuPercent;
- }
-
- public void setFuture(ScheduledFuture<?> sf) {
- this.future = sf;
- }
-
- public ScheduledFuture<?> getFuture() {
- return future;
- }
-
- public void stop() {
- this.stopped = true;
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ba4192dc/plugins/hypervisors/simulator/src/com/cloud/agent/MultiCaster.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/agent/MultiCaster.java b/plugins/hypervisors/simulator/src/com/cloud/agent/MultiCaster.java
deleted file mode 100644
index 7d38baf..0000000
--- a/plugins/hypervisors/simulator/src/com/cloud/agent/MultiCaster.java
+++ /dev/null
@@ -1,152 +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.
-package com.cloud.agent;
-
-import java.io.IOException;
-import java.net.DatagramPacket;
-import java.net.DatagramSocket;
-import java.net.InetAddress;
-import java.net.MulticastSocket;
-import java.net.NetworkInterface;
-import java.net.SocketException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-public class MultiCaster implements Runnable {
- private static final Logger s_logger = Logger.getLogger(MultiCaster.class);
-
- public final int MAX_PACKET_SIZE = 8096;
-
- private List<MultiCasterListener> listeners;
- private DatagramSocket socket;
- private byte[] recvBuffer;
-
- private Thread driver;
- private volatile boolean stopRequested = false;
-
- public MultiCaster() {
- listeners = new ArrayList<MultiCasterListener>();
- recvBuffer = new byte[MAX_PACKET_SIZE];
- }
-
- public void addListener(MultiCasterListener listener) {
- synchronized(listeners) {
- listeners.add(listener);
- }
- }
-
- public void removeListener(MultiCasterListener listener) {
- synchronized(listeners) {
- listeners.remove(listener);
- }
- }
-
- public void cast(byte[] buf, int off, int len,
- InetAddress toAddress, int nToPort) throws IOException {
-
- if(socket == null)
- throw new IOException("multi caster is not started");
-
- if(len >= MAX_PACKET_SIZE)
- throw new IOException("packet size exceeds limit of " + MAX_PACKET_SIZE);
-
- DatagramPacket packet = new DatagramPacket(buf, off,
- len, toAddress, nToPort);
-
- socket.send(packet);
- }
-
- public void start(String strOutboundAddress,
- String strClusterAddress, int nPort) throws SocketException {
- assert(socket == null);
-
- InetAddress addr = null;
- try {
- addr = InetAddress.getByName(strClusterAddress);
- } catch(IOException e) {
- s_logger.error("Unexpected exception " , e);
- }
-
- if(addr != null && addr.isMulticastAddress()) {
- try {
- socket = new MulticastSocket(nPort);
- socket.setReuseAddress(true);
-
- if(s_logger.isInfoEnabled())
- s_logger.info("Join multicast group : " + addr);
-
- ((MulticastSocket)socket).joinGroup(addr);
- ((MulticastSocket)socket).setTimeToLive(1);
-
- if(strOutboundAddress != null) {
- if(s_logger.isInfoEnabled())
- s_logger.info("set outgoing interface to : " + strOutboundAddress);
-
- InetAddress ia = InetAddress.getByName(strOutboundAddress);
- NetworkInterface ni = NetworkInterface.getByInetAddress(ia);
- ((MulticastSocket)socket).setNetworkInterface(ni);
- }
- } catch(IOException e) {
- s_logger.error("Unexpected exception " , e);
- }
- } else {
- socket = new DatagramSocket(nPort);
- socket.setReuseAddress(true);
- }
-
- driver = new Thread(this, "Multi-caster");
- driver.setDaemon(true);
- driver.start();
- }
-
- public void stop() {
- if(socket != null) {
- stopRequested = true;
-
- socket.close();
- if(driver != null) {
- try {
- driver.join();
- } catch(InterruptedException e) {
- }
- driver = null;
- }
- }
-
- socket = null;
- stopRequested = false;
- }
-
- public void run() {
- while(!stopRequested) {
- try {
- DatagramPacket packet = new DatagramPacket(recvBuffer, recvBuffer.length);
- socket.receive(packet);
-
- for(Object listener : listeners.toArray()) {
- ((MultiCasterListener)listener).onMultiCasting(packet.getData(),
- packet.getOffset(), packet.getLength(), packet.getAddress());
- }
- } catch(IOException e) {
- } catch(Throwable e) {
- s_logger.error("Unhandled exception : ", e);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ba4192dc/plugins/hypervisors/simulator/src/com/cloud/agent/MultiCasterListener.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/agent/MultiCasterListener.java b/plugins/hypervisors/simulator/src/com/cloud/agent/MultiCasterListener.java
deleted file mode 100644
index fe4761b..0000000
--- a/plugins/hypervisors/simulator/src/com/cloud/agent/MultiCasterListener.java
+++ /dev/null
@@ -1,22 +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.
-package com.cloud.agent;
-import java.net.InetAddress;
-
-public interface MultiCasterListener {
- public void onMultiCasting(byte[] data, int off, int len, InetAddress addrFrom);
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ba4192dc/plugins/hypervisors/simulator/src/com/cloud/agent/SimulatorCmd.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/agent/SimulatorCmd.java b/plugins/hypervisors/simulator/src/com/cloud/agent/SimulatorCmd.java
deleted file mode 100644
index caed518..0000000
--- a/plugins/hypervisors/simulator/src/com/cloud/agent/SimulatorCmd.java
+++ /dev/null
@@ -1,37 +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.
-package com.cloud.agent;
-
-import java.io.Serializable;
-
-public class SimulatorCmd implements Serializable {
- private static final long serialVersionUID = 1L;
-
- private String testCase = "DEFAULT";
-
- public SimulatorCmd(String testCase) {
- this.testCase = testCase;
- }
-
- public String getTestCase() {
- return testCase;
- }
-
- public void setTestCase(String testCase) {
- this.testCase = testCase;
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ba4192dc/plugins/hypervisors/simulator/src/com/cloud/agent/SimulatorMigrateVmCmd.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/agent/SimulatorMigrateVmCmd.java b/plugins/hypervisors/simulator/src/com/cloud/agent/SimulatorMigrateVmCmd.java
deleted file mode 100644
index 6a2190d..0000000
--- a/plugins/hypervisors/simulator/src/com/cloud/agent/SimulatorMigrateVmCmd.java
+++ /dev/null
@@ -1,83 +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.
-package com.cloud.agent;
-
-public class SimulatorMigrateVmCmd extends SimulatorCmd {
-
- private static final long serialVersionUID = 1L;
-
- private String destIp;
-
- private String vmName;
- private long ramSize;
- private int cpuCount;
- private int utilization;
-
- public SimulatorMigrateVmCmd(String testCase) {
- super(testCase);
- }
-
- public String getDestIp() {
- return destIp;
- }
-
- public void setDestIp(String destIp) {
- this.destIp = destIp;
- }
-
- public String getVmName() {
- return vmName;
- }
-
- public void setVmName(String vmName) {
- this.vmName = vmName;
- }
-
- public long getRamSize() {
- return ramSize;
- }
-
- public void setRamSize(long ramSize) {
- this.ramSize = ramSize;
- }
-
- public int getCpuCount() {
- return cpuCount;
- }
-
- public void setCpuCount(int cpuCount) {
- this.cpuCount = cpuCount;
- }
-
- public int getUtilization() {
- return utilization;
- }
-
- public void setUtilization(int utilization) {
- this.utilization = utilization;
- }
-
- public String toString() {
- StringBuffer sb = new StringBuffer();
- sb.append("SimulatorMigrateVmCmd {").append("vm: ").append(getVmName());
- sb.append(", destIp: ").append(getDestIp()).append(", ramSize: ").append(getRamSize());
- sb.append(", cpuCount: ").append(getCpuCount()).append(", utilization: ").append(getUtilization());
- sb.append("}");
-
- return sb.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ba4192dc/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockAgentManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockAgentManagerImpl.java b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockAgentManagerImpl.java
old mode 100755
new mode 100644
index 69efc83..9654b74
--- a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockAgentManagerImpl.java
+++ b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockAgentManagerImpl.java
@@ -26,11 +26,10 @@ import com.cloud.agent.api.GetHostStatsCommand;
import com.cloud.agent.api.HostStatsEntry;
import com.cloud.agent.api.MaintainAnswer;
import com.cloud.agent.api.PingTestCommand;
+import com.cloud.api.commands.SimulatorAddSecondaryAgent;
import com.cloud.dc.dao.HostPodDao;
-import com.cloud.resource.AgentResourceBase;
-import com.cloud.resource.AgentRoutingResource;
-import com.cloud.resource.AgentStorageResource;
-import com.cloud.resource.ResourceManager;
+import com.cloud.exception.DiscoveryException;
+import com.cloud.resource.*;
import com.cloud.simulator.MockHost;
import com.cloud.simulator.MockHostVO;
import com.cloud.simulator.MockVMVO;
@@ -43,6 +42,7 @@ import com.cloud.utils.db.DB;
import com.cloud.utils.db.Transaction;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.net.NetUtils;
+import org.apache.cloudstack.api.command.admin.host.AddSecondaryStorageCmd;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
@@ -79,6 +79,8 @@ public class MockAgentManagerImpl extends ManagerBase implements MockAgentManage
MockStorageManager _storageMgr = null;
@Inject
ResourceManager _resourceMgr;
+ @Inject
+ SimulatorSecondaryDiscoverer discoverer;
private SecureRandom random;
private final Map<String, AgentResourceBase> _resources = new ConcurrentHashMap<String, AgentResourceBase>();
private ThreadPoolExecutor _executor;
@@ -325,6 +327,14 @@ public class MockAgentManagerImpl extends ManagerBase implements MockAgentManage
storageResource.configure("secondaryStorage", params);
storageResource.start();
_resources.put(this.guid, storageResource);
+ discoverer.setResource(storageResource);
+ SimulatorAddSecondaryAgent cmd = new SimulatorAddSecondaryAgent("sim://" + this.guid, this.dcId);
+ try {
+ _resourceMgr.discoverHosts(cmd);
+ } catch (DiscoveryException e) {
+ s_logger.debug("Failed to discover host: " + e.toString());
+ return;
+ }
} catch (ConfigurationException e) {
s_logger.debug("Failed to load secondary storage resource: " + e.toString());
return;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ba4192dc/plugins/hypervisors/simulator/src/com/cloud/agent/manager/SimulatorManager.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/SimulatorManager.java b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/SimulatorManager.java
old mode 100755
new mode 100644
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ba4192dc/plugins/hypervisors/simulator/src/com/cloud/api/commands/SimulatorAddSecondaryAgent.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/api/commands/SimulatorAddSecondaryAgent.java b/plugins/hypervisors/simulator/src/com/cloud/api/commands/SimulatorAddSecondaryAgent.java
new file mode 100644
index 0000000..1cd67d4
--- /dev/null
+++ b/plugins/hypervisors/simulator/src/com/cloud/api/commands/SimulatorAddSecondaryAgent.java
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+package com.cloud.api.commands;
+
+import org.apache.cloudstack.api.command.admin.host.AddSecondaryStorageCmd;
+
+public class SimulatorAddSecondaryAgent extends AddSecondaryStorageCmd {
+ public SimulatorAddSecondaryAgent(String url, Long zoneId) {
+ this.url = url;
+ this.zoneId = zoneId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ba4192dc/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorSecondaryDiscoverer.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorSecondaryDiscoverer.java b/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorSecondaryDiscoverer.java
index 735bf15..30926e3 100644
--- a/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorSecondaryDiscoverer.java
+++ b/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorSecondaryDiscoverer.java
@@ -17,6 +17,7 @@
package com.cloud.resource;
import java.net.URI;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -25,6 +26,7 @@ import javax.inject.Inject;
import javax.naming.ConfigurationException;
import org.apache.cloudstack.storage.resource.SecondaryStorageDiscoverer;
+import org.apache.cloudstack.storage.resource.SecondaryStorageResource;
import org.apache.log4j.Logger;
import com.cloud.agent.AgentManager;
@@ -52,6 +54,11 @@ public class SimulatorSecondaryDiscoverer extends SecondaryStorageDiscoverer imp
@Inject AgentManager _agentMgr;
@Inject ResourceManager _resourceMgr;
@Inject SnapshotDao _snapshotDao;
+ protected SecondaryStorageResource resource;
+
+ public void setResource(SecondaryStorageResource resource) {
+ this.resource = resource;
+ }
@Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
@@ -62,27 +69,18 @@ public class SimulatorSecondaryDiscoverer extends SecondaryStorageDiscoverer imp
@Override
public Map<? extends ServerResource, Map<String, String>> find(long dcId, Long podId, Long clusterId, URI uri, String username, String password, List<String> hostTags) {
- if (!uri.getScheme().equalsIgnoreCase("nfs") && !uri.getScheme().equalsIgnoreCase("file")
- && !uri.getScheme().equalsIgnoreCase("iso") && !uri.getScheme().equalsIgnoreCase("dummy")) {
+ if (!uri.getScheme().equalsIgnoreCase("sim")) {
s_logger.debug("It's not NFS or file or ISO, so not a secondary storage server: " + uri.toString());
return null;
}
-
- if (uri.getScheme().equalsIgnoreCase("nfs") || uri.getScheme().equalsIgnoreCase("iso")) {
- return createNfsSecondaryStorageResource(dcId, podId, uri);
- } else if (uri.getScheme().equalsIgnoreCase("file")) {
- return createLocalSecondaryStorageResource(dcId, podId, uri);
- } else if (uri.getScheme().equalsIgnoreCase("dummy")) {
- return createDummySecondaryStorageResource(dcId, podId, uri);
- } else {
- return null;
- }
+ Map<SecondaryStorageResource, Map<String, String>> resources = new HashMap<SecondaryStorageResource, Map<String, String>>();
+ resources.put(this.resource, new HashMap<String, String>());
+ return resources;
}
@Override
public void postDiscovery(List<HostVO> hosts, long msId) {
- super.postDiscovery(hosts, msId);
for (HostVO host: hosts) {
if(s_logger.isDebugEnabled()) {
s_logger.debug("Preinstalling simulator templates");
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ba4192dc/plugins/hypervisors/simulator/src/org/apache/cloudstack/storage/datastore/driver/SimulatorImageStoreDriverImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/org/apache/cloudstack/storage/datastore/driver/SimulatorImageStoreDriverImpl.java b/plugins/hypervisors/simulator/src/org/apache/cloudstack/storage/datastore/driver/SimulatorImageStoreDriverImpl.java
new file mode 100644
index 0000000..b230194
--- /dev/null
+++ b/plugins/hypervisors/simulator/src/org/apache/cloudstack/storage/datastore/driver/SimulatorImageStoreDriverImpl.java
@@ -0,0 +1,115 @@
+/*
+ * 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.
+ */
+
+package org.apache.cloudstack.storage.datastore.driver;
+
+
+import com.cloud.agent.api.storage.DownloadAnswer;
+import com.cloud.agent.api.to.DataObjectType;
+import com.cloud.agent.api.to.DataStoreTO;
+import com.cloud.agent.api.to.NfsTO;
+import com.cloud.storage.Storage;
+import com.cloud.storage.VMTemplateStorageResourceAssoc;
+import com.cloud.storage.VMTemplateVO;
+import com.cloud.storage.VolumeVO;
+import com.cloud.storage.dao.VMTemplateDao;
+import com.cloud.storage.dao.VolumeDao;
+import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
+import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
+import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
+import org.apache.cloudstack.framework.async.AsyncRpcContext;
+import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
+import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
+import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreDao;
+import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO;
+import org.apache.cloudstack.storage.image.BaseImageStoreDriverImpl;
+import org.apache.cloudstack.storage.image.store.ImageStoreImpl;
+import org.apache.cloudstack.storage.to.TemplateObjectTO;
+import org.apache.cloudstack.storage.to.VolumeObjectTO;
+
+import javax.inject.Inject;
+import java.util.Date;
+import java.util.UUID;
+
+public class SimulatorImageStoreDriverImpl extends BaseImageStoreDriverImpl {
+
+ @Inject
+ TemplateDataStoreDao _templateStoreDao;
+ @Inject
+ VMTemplateDao _templateDao;
+ @Inject
+ VolumeDao _volumeDao;
+ @Inject
+ VolumeDataStoreDao _volumeStoreDao;
+
+ @Override
+ public DataStoreTO getStoreTO(DataStore store) {
+ ImageStoreImpl nfsStore = (ImageStoreImpl) store;
+ NfsTO nfsTO = new NfsTO();
+ nfsTO.setRole(store.getRole());
+ nfsTO.setUrl(nfsStore.getUri());
+ return nfsTO;
+ }
+
+
+
+ public String createEntityExtractUrl(DataStore store, String installPath, Storage.ImageFormat format) {
+ return null;
+ }
+
+ @Override
+ public void createAsync(DataStore dataStore, DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) {
+ if (data.getType() == DataObjectType.TEMPLATE) {
+ this.createTemplate(data, callback);
+ } else if (data.getType() == DataObjectType.VOLUME) {
+ this.createVolume(data, callback);
+ }
+ }
+
+ protected void createTemplate(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) {
+ CreateContext<CreateCmdResult> context = new CreateContext<CreateCmdResult>(callback, data);
+ AsyncCallbackDispatcher<SimulatorImageStoreDriverImpl, DownloadAnswer> caller = AsyncCallbackDispatcher
+ .create(this);
+ caller.setContext(context);
+ caller.setCallback(caller.getTarget().createTemplateAsyncCallback(null, null));
+ String path = UUID.randomUUID().toString();
+ Long size = new Long(5 * 1024L * 1024L);
+ DownloadAnswer answer = new DownloadAnswer(null, 100, null, VMTemplateStorageResourceAssoc.Status.DOWNLOADED,
+ path, path, size, size, null);
+ caller.complete(answer);
+ return;
+ }
+
+ protected void createVolume(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) {
+ CreateContext<CreateCmdResult> context = new CreateContext<CreateCmdResult>(callback, data);
+ AsyncCallbackDispatcher<SimulatorImageStoreDriverImpl, DownloadAnswer> caller = AsyncCallbackDispatcher
+ .create(this);
+ caller.setContext(context);
+ caller.setCallback(caller.getTarget().createVolumeAsyncCallback(null, null));
+ String path = UUID.randomUUID().toString();
+ Long size = new Long(5 * 1024L * 1024L);
+ DownloadAnswer answer = new DownloadAnswer(null, 100, null, VMTemplateStorageResourceAssoc.Status.DOWNLOADED,
+ path, path, size, size, null);
+ caller.complete(answer);
+ return;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ba4192dc/plugins/hypervisors/simulator/src/org/apache/cloudstack/storage/datastore/lifecycle/SimulatorImageStoreLifeCycleImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/org/apache/cloudstack/storage/datastore/lifecycle/SimulatorImageStoreLifeCycleImpl.java b/plugins/hypervisors/simulator/src/org/apache/cloudstack/storage/datastore/lifecycle/SimulatorImageStoreLifeCycleImpl.java
new file mode 100644
index 0000000..beaa7a5
--- /dev/null
+++ b/plugins/hypervisors/simulator/src/org/apache/cloudstack/storage/datastore/lifecycle/SimulatorImageStoreLifeCycleImpl.java
@@ -0,0 +1,132 @@
+/*
+ * 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.
+ */
+
+package org.apache.cloudstack.storage.datastore.lifecycle;
+
+
+import com.cloud.agent.api.StoragePoolInfo;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.hypervisor.Hypervisor;
+import com.cloud.storage.DataStoreRole;
+import com.cloud.storage.ScopeType;
+import com.cloud.utils.UriUtils;
+import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.HostScope;
+import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
+import org.apache.cloudstack.storage.datastore.db.ImageStoreVO;
+import org.apache.cloudstack.storage.image.datastore.ImageStoreHelper;
+import org.apache.cloudstack.storage.image.datastore.ImageStoreProviderManager;
+import org.apache.cloudstack.storage.image.store.lifecycle.ImageStoreLifeCycle;
+import org.apache.log4j.Logger;
+
+import javax.inject.Inject;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.HashMap;
+import java.util.Map;
+
+public class SimulatorImageStoreLifeCycleImpl implements ImageStoreLifeCycle {
+ private static final Logger s_logger = Logger.getLogger(SimulatorImageStoreLifeCycleImpl.class);
+
+ @Inject
+ ImageStoreHelper imageStoreHelper;
+
+ @Inject
+ ImageStoreProviderManager imageStoreMgr;
+
+
+ @Override
+ public DataStore initialize(Map<String, Object> dsInfos) {
+ Long dcId = (Long) dsInfos.get("zoneId");
+ String url = (String) dsInfos.get("url");
+ String name = (String) dsInfos.get("name");
+ if (name == null) {
+ name = url;
+ }
+ String providerName = (String) dsInfos.get("providerName");
+ DataStoreRole role = (DataStoreRole) dsInfos.get("role");
+ Map<String, String> details = (Map<String, String>) dsInfos.get("details");
+
+ s_logger.info("Trying to add a new data store at " + url + " to data center " + dcId);
+
+ URI uri;
+ try {
+ uri = new URI(UriUtils.encodeURIComponent(url));
+ if (uri.getScheme() == null) {
+ throw new InvalidParameterValueException("uri.scheme is null " + url + ", add nfs:// as a prefix");
+ } else if (uri.getScheme().equalsIgnoreCase("nfs")) {
+ if (uri.getHost() == null || uri.getHost().equalsIgnoreCase("") || uri.getPath() == null
+ || uri.getPath().equalsIgnoreCase("")) {
+ throw new InvalidParameterValueException(
+ "Your host and/or path is wrong. Make sure it is of the format nfs://hostname/path");
+ }
+ }
+ } catch (URISyntaxException e) {
+ throw new InvalidParameterValueException(url + " is not a valid uri");
+ }
+
+ if (dcId == null) {
+ throw new InvalidParameterValueException(
+ "DataCenter id is null, and simulator image store has to be associated with a data center");
+ }
+
+ Map<String, Object> imageStoreParameters = new HashMap<String, Object>();
+ imageStoreParameters.put("name", name);
+ imageStoreParameters.put("zoneId", dcId);
+ imageStoreParameters.put("url", url);
+ imageStoreParameters.put("protocol", uri.getScheme().toLowerCase());
+ imageStoreParameters.put("scope", ScopeType.ZONE);
+ imageStoreParameters.put("providerName", providerName);
+ imageStoreParameters.put("role", role);
+
+ ImageStoreVO ids = imageStoreHelper.createImageStore(imageStoreParameters, details);
+ return imageStoreMgr.getImageStore(ids.getId());
+ }
+
+ @Override
+ public boolean attachCluster(DataStore store, ClusterScope scope) {
+ return false;
+ }
+
+ @Override
+ public boolean attachHost(DataStore store, HostScope scope, StoragePoolInfo existingInfo) {
+ return false;
+ }
+
+ @Override
+ public boolean attachZone(DataStore dataStore, ZoneScope scope, Hypervisor.HypervisorType hypervisorType) {
+ return false;
+ }
+
+ @Override
+ public boolean maintain(DataStore store) {
+ return false;
+ }
+
+ @Override
+ public boolean cancelMaintain(DataStore store) {
+ return false;
+ }
+
+ @Override
+ public boolean deleteDataStore(DataStore store) {
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ba4192dc/plugins/hypervisors/simulator/src/org/apache/cloudstack/storage/datastore/provider/SimulatorImageStoreProviderImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/org/apache/cloudstack/storage/datastore/provider/SimulatorImageStoreProviderImpl.java b/plugins/hypervisors/simulator/src/org/apache/cloudstack/storage/datastore/provider/SimulatorImageStoreProviderImpl.java
new file mode 100644
index 0000000..775d743
--- /dev/null
+++ b/plugins/hypervisors/simulator/src/org/apache/cloudstack/storage/datastore/provider/SimulatorImageStoreProviderImpl.java
@@ -0,0 +1,98 @@
+/*
+ * 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.
+ */
+
+package org.apache.cloudstack.storage.datastore.provider;
+
+import com.cloud.storage.ScopeType;
+import com.cloud.utils.component.ComponentContext;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
+import org.apache.cloudstack.engine.subsystem.api.storage.HypervisorHostListener;
+import org.apache.cloudstack.engine.subsystem.api.storage.ImageStoreProvider;
+import org.apache.cloudstack.storage.datastore.driver.SimulatorImageStoreDriverImpl;
+import org.apache.cloudstack.storage.datastore.lifecycle.SimulatorImageStoreLifeCycleImpl;
+import org.apache.cloudstack.storage.image.ImageStoreDriver;
+import org.apache.cloudstack.storage.image.datastore.ImageStoreHelper;
+import org.apache.cloudstack.storage.image.datastore.ImageStoreProviderManager;
+import org.apache.cloudstack.storage.image.store.lifecycle.ImageStoreLifeCycle;
+import org.springframework.stereotype.Component;
+
+import javax.inject.Inject;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+@Component
+public class SimulatorImageStoreProviderImpl implements ImageStoreProvider {
+
+ private final String _providerName = DataStoreProvider.NFS_IMAGE;
+ protected ImageStoreLifeCycle lifeCycle;
+ protected ImageStoreDriver driver;
+
+ @Inject
+ ImageStoreProviderManager storeMgr;
+ @Inject
+ ImageStoreHelper helper;
+
+ @Override
+ public boolean isScopeSupported(ScopeType scope) {
+ return true;
+ }
+
+ @Override
+ public boolean needDownloadSysTemplate() {
+ return false;
+ }
+
+ @Override
+ public DataStoreLifeCycle getDataStoreLifeCycle() {
+ return this.lifeCycle;
+ }
+
+ @Override
+ public DataStoreDriver getDataStoreDriver() {
+ return this.driver;
+ }
+
+ @Override
+ public HypervisorHostListener getHostListener() {
+ return null;
+ }
+
+ @Override
+ public String getName() {
+ return this._providerName;
+ }
+
+ @Override
+ public boolean configure(Map<String, Object> params) {
+ lifeCycle = ComponentContext.inject(SimulatorImageStoreLifeCycleImpl.class);
+ driver = ComponentContext.inject(SimulatorImageStoreDriverImpl.class);
+ storeMgr.registerDriver(this.getName(), driver);
+ return true;
+ }
+
+ @Override
+ public Set<DataStoreProviderType> getTypes() {
+ Set<DataStoreProviderType> types = new HashSet<DataStoreProviderType>();
+ types.add(DataStoreProviderType.IMAGE);
+ return types;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ba4192dc/plugins/hypervisors/simulator/src/org/apache/cloudstack/storage/motion/SimulatorDataMotionStrategy.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/org/apache/cloudstack/storage/motion/SimulatorDataMotionStrategy.java b/plugins/hypervisors/simulator/src/org/apache/cloudstack/storage/motion/SimulatorDataMotionStrategy.java
new file mode 100644
index 0000000..05b3e6b
--- /dev/null
+++ b/plugins/hypervisors/simulator/src/org/apache/cloudstack/storage/motion/SimulatorDataMotionStrategy.java
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+package org.apache.cloudstack.storage.motion;
+
+import com.cloud.agent.api.to.VirtualMachineTO;
+import com.cloud.host.Host;
+import org.apache.cloudstack.engine.subsystem.api.storage.*;
+import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
+
+import java.util.Map;
+
+public class SimulatorDataMotionStrategy implements DataMotionStrategy {
+ @Override
+ public boolean canHandle(DataObject srcData, DataObject destData) {
+ return true;
+ }
+
+ @Override
+ public boolean canHandle(Map<VolumeInfo, DataStore> volumeMap, Host srcHost, Host destHost) {
+ return true;
+ }
+
+ @Override
+ public Void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback) {
+ CopyCommandResult result = new CopyCommandResult("something", null);
+ callback.complete(result);
+ return null;
+ }
+
+ @Override
+ public Void copyAsync(Map<VolumeInfo, DataStore> volumeMap, VirtualMachineTO vmTo, Host srcHost, Host destHost, AsyncCompletionCallback<CopyCommandResult> callback) {
+ CopyCommandResult result = new CopyCommandResult("something", null);
+ callback.complete(result);
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ba4192dc/plugins/hypervisors/simulator/src/org/apache/cloudstack/storage/resource/SimulatorSecondaryStorageResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/org/apache/cloudstack/storage/resource/SimulatorSecondaryStorageResource.java b/plugins/hypervisors/simulator/src/org/apache/cloudstack/storage/resource/SimulatorSecondaryStorageResource.java
new file mode 100644
index 0000000..dab2f93
--- /dev/null
+++ b/plugins/hypervisors/simulator/src/org/apache/cloudstack/storage/resource/SimulatorSecondaryStorageResource.java
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+package org.apache.cloudstack.storage.resource;
+
+public class SimulatorSecondaryStorageResource extends NfsSecondaryStorageResource {
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ba4192dc/plugins/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/pom.xml b/plugins/pom.xml
index 04eb55c..5bc324d 100755
--- a/plugins/pom.xml
+++ b/plugins/pom.xml
@@ -65,7 +65,6 @@
<module>storage/image/swift</module>
<module>storage/image/default</module>
<module>storage/image/sample</module>
- <module>storage/image/simulator</module>
<module>storage/volume/solidfire</module>
<module>storage/volume/default</module>
<module>storage/volume/sample</module>
@@ -159,7 +158,6 @@
</activation>
<modules>
<module>hypervisors/simulator</module>
- <module>storage/image/simulator</module>
</modules>
</profile>
</profiles>
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ba4192dc/plugins/storage/image/simulator/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/storage/image/simulator/pom.xml b/plugins/storage/image/simulator/pom.xml
deleted file mode 100644
index d4b6838..0000000
--- a/plugins/storage/image/simulator/pom.xml
+++ /dev/null
@@ -1,68 +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. -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <artifactId>cloud-plugin-storage-image-simulator</artifactId>
- <name>Apache CloudStack Plugin - Storage Image Simulator provider</name>
- <parent>
- <groupId>org.apache.cloudstack</groupId>
- <artifactId>cloudstack-plugins</artifactId>
- <version>4.2.0-SNAPSHOT</version>
- <relativePath>../../../pom.xml</relativePath>
- </parent>
- <dependencies>
- <dependency>
- <groupId>org.apache.cloudstack</groupId>
- <artifactId>cloud-engine-storage</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cloudstack</groupId>
- <artifactId>cloud-engine-storage-image</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cloudstack</groupId>
- <artifactId>cloud-engine-storage-volume</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cloudstack</groupId>
- <artifactId>cloud-engine-storage-snapshot</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- <version>${cs.mysql.version}</version>
- <scope>provided</scope>
- </dependency>
- </dependencies>
- <build>
- <defaultGoal>install</defaultGoal>
- <sourceDirectory>src</sourceDirectory>
- <testSourceDirectory>test</testSourceDirectory>
- <plugins>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <executions>
- <execution>
- <phase>integration-test</phase>
- <goals>
- <goal>test</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ba4192dc/plugins/storage/image/simulator/src/org/apache/cloudstack/storage/datastore/driver/SimulatorImageStoreDriverImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/image/simulator/src/org/apache/cloudstack/storage/datastore/driver/SimulatorImageStoreDriverImpl.java b/plugins/storage/image/simulator/src/org/apache/cloudstack/storage/datastore/driver/SimulatorImageStoreDriverImpl.java
deleted file mode 100644
index d5fe8a1..0000000
--- a/plugins/storage/image/simulator/src/org/apache/cloudstack/storage/datastore/driver/SimulatorImageStoreDriverImpl.java
+++ /dev/null
@@ -1,106 +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.
- */
-
-package org.apache.cloudstack.storage.datastore.driver;
-
-
-import com.cloud.agent.api.storage.DownloadAnswer;
-import com.cloud.agent.api.to.DataObjectType;
-import com.cloud.agent.api.to.DataStoreTO;
-import com.cloud.agent.api.to.NfsTO;
-import com.cloud.storage.Storage;
-import com.cloud.storage.VMTemplateStorageResourceAssoc;
-import com.cloud.storage.dao.VMTemplateDao;
-import com.cloud.storage.dao.VolumeDao;
-import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
-import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
-import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
-import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
-import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreDao;
-import org.apache.cloudstack.storage.image.BaseImageStoreDriverImpl;
-import org.apache.cloudstack.storage.image.store.ImageStoreImpl;
-
-import javax.inject.Inject;
-import java.util.UUID;
-
-public class SimulatorImageStoreDriverImpl extends BaseImageStoreDriverImpl {
-
- @Inject
- TemplateDataStoreDao _templateStoreDao;
- @Inject
- VMTemplateDao _templateDao;
- @Inject
- VolumeDao _volumeDao;
- @Inject
- VolumeDataStoreDao _volumeStoreDao;
-
- @Override
- public DataStoreTO getStoreTO(DataStore store) {
- ImageStoreImpl nfsStore = (ImageStoreImpl) store;
- NfsTO nfsTO = new NfsTO();
- nfsTO.setRole(store.getRole());
- nfsTO.setUrl(nfsStore.getUri());
- return nfsTO;
- }
-
-
-
- public String createEntityExtractUrl(DataStore store, String installPath, Storage.ImageFormat format) {
- return null;
- }
-
- @Override
- public void createAsync(DataStore store, DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) {
- if (data.getType() == DataObjectType.TEMPLATE) {
- this.createTemplate(data, callback);
- } else if (data.getType() == DataObjectType.VOLUME) {
- this.createVolume(data, callback);
- }
- }
-
- protected void createTemplate(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) {
- CreateContext<CreateCmdResult> context = new CreateContext<CreateCmdResult>(callback, data);
- AsyncCallbackDispatcher<SimulatorImageStoreDriverImpl, DownloadAnswer> caller = AsyncCallbackDispatcher
- .create(this);
- caller.setContext(context);
- caller.setCallback(caller.getTarget().createTemplateAsyncCallback(null, null));
- String path = UUID.randomUUID().toString();
- Long size = new Long(5 * 1024L * 1024L);
- DownloadAnswer answer = new DownloadAnswer(null, 100, null, VMTemplateStorageResourceAssoc.Status.DOWNLOADED,
- path, path, size, size, null);
- caller.complete(answer);
- return;
- }
-
- protected void createVolume(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) {
- CreateContext<CreateCmdResult> context = new CreateContext<CreateCmdResult>(callback, data);
- AsyncCallbackDispatcher<SimulatorImageStoreDriverImpl, DownloadAnswer> caller = AsyncCallbackDispatcher
- .create(this);
- caller.setContext(context);
- caller.setCallback(caller.getTarget().createVolumeAsyncCallback(null, null));
- String path = UUID.randomUUID().toString();
- Long size = new Long(5 * 1024L * 1024L);
- DownloadAnswer answer = new DownloadAnswer(null, 100, null, VMTemplateStorageResourceAssoc.Status.DOWNLOADED,
- path, path, size, size, null);
- caller.complete(answer);
- return;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ba4192dc/plugins/storage/image/simulator/src/org/apache/cloudstack/storage/datastore/lifecycle/SimulatorImageStoreLifeCycleImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/image/simulator/src/org/apache/cloudstack/storage/datastore/lifecycle/SimulatorImageStoreLifeCycleImpl.java b/plugins/storage/image/simulator/src/org/apache/cloudstack/storage/datastore/lifecycle/SimulatorImageStoreLifeCycleImpl.java
deleted file mode 100644
index beaa7a5..0000000
--- a/plugins/storage/image/simulator/src/org/apache/cloudstack/storage/datastore/lifecycle/SimulatorImageStoreLifeCycleImpl.java
+++ /dev/null
@@ -1,132 +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.
- */
-
-package org.apache.cloudstack.storage.datastore.lifecycle;
-
-
-import com.cloud.agent.api.StoragePoolInfo;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.hypervisor.Hypervisor;
-import com.cloud.storage.DataStoreRole;
-import com.cloud.storage.ScopeType;
-import com.cloud.utils.UriUtils;
-import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
-import org.apache.cloudstack.engine.subsystem.api.storage.HostScope;
-import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
-import org.apache.cloudstack.storage.datastore.db.ImageStoreVO;
-import org.apache.cloudstack.storage.image.datastore.ImageStoreHelper;
-import org.apache.cloudstack.storage.image.datastore.ImageStoreProviderManager;
-import org.apache.cloudstack.storage.image.store.lifecycle.ImageStoreLifeCycle;
-import org.apache.log4j.Logger;
-
-import javax.inject.Inject;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.HashMap;
-import java.util.Map;
-
-public class SimulatorImageStoreLifeCycleImpl implements ImageStoreLifeCycle {
- private static final Logger s_logger = Logger.getLogger(SimulatorImageStoreLifeCycleImpl.class);
-
- @Inject
- ImageStoreHelper imageStoreHelper;
-
- @Inject
- ImageStoreProviderManager imageStoreMgr;
-
-
- @Override
- public DataStore initialize(Map<String, Object> dsInfos) {
- Long dcId = (Long) dsInfos.get("zoneId");
- String url = (String) dsInfos.get("url");
- String name = (String) dsInfos.get("name");
- if (name == null) {
- name = url;
- }
- String providerName = (String) dsInfos.get("providerName");
- DataStoreRole role = (DataStoreRole) dsInfos.get("role");
- Map<String, String> details = (Map<String, String>) dsInfos.get("details");
-
- s_logger.info("Trying to add a new data store at " + url + " to data center " + dcId);
-
- URI uri;
- try {
- uri = new URI(UriUtils.encodeURIComponent(url));
- if (uri.getScheme() == null) {
- throw new InvalidParameterValueException("uri.scheme is null " + url + ", add nfs:// as a prefix");
- } else if (uri.getScheme().equalsIgnoreCase("nfs")) {
- if (uri.getHost() == null || uri.getHost().equalsIgnoreCase("") || uri.getPath() == null
- || uri.getPath().equalsIgnoreCase("")) {
- throw new InvalidParameterValueException(
- "Your host and/or path is wrong. Make sure it is of the format nfs://hostname/path");
- }
- }
- } catch (URISyntaxException e) {
- throw new InvalidParameterValueException(url + " is not a valid uri");
- }
-
- if (dcId == null) {
- throw new InvalidParameterValueException(
- "DataCenter id is null, and simulator image store has to be associated with a data center");
- }
-
- Map<String, Object> imageStoreParameters = new HashMap<String, Object>();
- imageStoreParameters.put("name", name);
- imageStoreParameters.put("zoneId", dcId);
- imageStoreParameters.put("url", url);
- imageStoreParameters.put("protocol", uri.getScheme().toLowerCase());
- imageStoreParameters.put("scope", ScopeType.ZONE);
- imageStoreParameters.put("providerName", providerName);
- imageStoreParameters.put("role", role);
-
- ImageStoreVO ids = imageStoreHelper.createImageStore(imageStoreParameters, details);
- return imageStoreMgr.getImageStore(ids.getId());
- }
-
- @Override
- public boolean attachCluster(DataStore store, ClusterScope scope) {
- return false;
- }
-
- @Override
- public boolean attachHost(DataStore store, HostScope scope, StoragePoolInfo existingInfo) {
- return false;
- }
-
- @Override
- public boolean attachZone(DataStore dataStore, ZoneScope scope, Hypervisor.HypervisorType hypervisorType) {
- return false;
- }
-
- @Override
- public boolean maintain(DataStore store) {
- return false;
- }
-
- @Override
- public boolean cancelMaintain(DataStore store) {
- return false;
- }
-
- @Override
- public boolean deleteDataStore(DataStore store) {
- return false;
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ba4192dc/plugins/storage/image/simulator/src/org/apache/cloudstack/storage/datastore/provider/SimulatorImageStoreProviderImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/image/simulator/src/org/apache/cloudstack/storage/datastore/provider/SimulatorImageStoreProviderImpl.java b/plugins/storage/image/simulator/src/org/apache/cloudstack/storage/datastore/provider/SimulatorImageStoreProviderImpl.java
deleted file mode 100644
index 775d743..0000000
--- a/plugins/storage/image/simulator/src/org/apache/cloudstack/storage/datastore/provider/SimulatorImageStoreProviderImpl.java
+++ /dev/null
@@ -1,98 +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.
- */
-
-package org.apache.cloudstack.storage.datastore.provider;
-
-import com.cloud.storage.ScopeType;
-import com.cloud.utils.component.ComponentContext;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
-import org.apache.cloudstack.engine.subsystem.api.storage.HypervisorHostListener;
-import org.apache.cloudstack.engine.subsystem.api.storage.ImageStoreProvider;
-import org.apache.cloudstack.storage.datastore.driver.SimulatorImageStoreDriverImpl;
-import org.apache.cloudstack.storage.datastore.lifecycle.SimulatorImageStoreLifeCycleImpl;
-import org.apache.cloudstack.storage.image.ImageStoreDriver;
-import org.apache.cloudstack.storage.image.datastore.ImageStoreHelper;
-import org.apache.cloudstack.storage.image.datastore.ImageStoreProviderManager;
-import org.apache.cloudstack.storage.image.store.lifecycle.ImageStoreLifeCycle;
-import org.springframework.stereotype.Component;
-
-import javax.inject.Inject;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-@Component
-public class SimulatorImageStoreProviderImpl implements ImageStoreProvider {
-
- private final String _providerName = DataStoreProvider.NFS_IMAGE;
- protected ImageStoreLifeCycle lifeCycle;
- protected ImageStoreDriver driver;
-
- @Inject
- ImageStoreProviderManager storeMgr;
- @Inject
- ImageStoreHelper helper;
-
- @Override
- public boolean isScopeSupported(ScopeType scope) {
- return true;
- }
-
- @Override
- public boolean needDownloadSysTemplate() {
- return false;
- }
-
- @Override
- public DataStoreLifeCycle getDataStoreLifeCycle() {
- return this.lifeCycle;
- }
-
- @Override
- public DataStoreDriver getDataStoreDriver() {
- return this.driver;
- }
-
- @Override
- public HypervisorHostListener getHostListener() {
- return null;
- }
-
- @Override
- public String getName() {
- return this._providerName;
- }
-
- @Override
- public boolean configure(Map<String, Object> params) {
- lifeCycle = ComponentContext.inject(SimulatorImageStoreLifeCycleImpl.class);
- driver = ComponentContext.inject(SimulatorImageStoreDriverImpl.class);
- storeMgr.registerDriver(this.getName(), driver);
- return true;
- }
-
- @Override
- public Set<DataStoreProviderType> getTypes() {
- Set<DataStoreProviderType> types = new HashSet<DataStoreProviderType>();
- types.add(DataStoreProviderType.IMAGE);
- return types;
- }
-}