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 14725d3499b..69a4a493ba3 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; diff --git a/client/tomcatconf/simulatorComponentContext.xml.in b/client/tomcatconf/simulatorComponentContext.xml.in index 92278a4da8e..1a43ba3c67f 100644 --- a/client/tomcatconf/simulatorComponentContext.xml.in +++ b/client/tomcatconf/simulatorComponentContext.xml.in @@ -30,6 +30,8 @@ + + @@ -89,6 +91,7 @@ + diff --git a/plugins/hypervisors/simulator/pom.xml b/plugins/hypervisors/simulator/pom.xml index e4ca9272853..e99d3559139 100644 --- a/plugins/hypervisors/simulator/pom.xml +++ b/plugins/hypervisors/simulator/pom.xml @@ -17,33 +17,52 @@ under the License. --> - 4.0.0 - + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + + org.apache.cloudstack + cloudstack-plugins + 4.2.0-SNAPSHOT + ../../pom.xml + org.apache.cloudstack - cloudstack-plugins - 4.2.0-SNAPSHOT - ../../pom.xml - - org.apache.cloudstack - cloud-plugin-hypervisor-simulator - Apache CloudStack Plugin - Hypervisor Simulator - Simulator Hypervisor for Cloudstack - - install - src - test - - - - org.apache.cloudstack - cloud-utils - ${project.version} - - - org.apache.cloudstack - cloud-secondary-storage - ${project.version} - - + cloud-plugin-hypervisor-simulator + Apache CloudStack Plugin - Hypervisor Simulator + Simulator Hypervisor for Cloudstack + + install + src + + + + org.apache.cloudstack + cloud-utils + ${project.version} + + + org.apache.cloudstack + cloud-secondary-storage + ${project.version} + + + org.apache.cloudstack + cloud-engine-storage + ${project.version} + + + org.apache.cloudstack + cloud-engine-storage-image + ${project.version} + + + org.apache.cloudstack + cloud-engine-storage-volume + ${project.version} + + + org.apache.cloudstack + cloud-engine-storage-snapshot + ${project.version} + + 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 fd611f83b9f..00000000000 --- 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 vmNames = new HashSet(); - private final Set newVMnames = new HashSet(); - private final Map metricsMap = new HashMap(); - - private final transient ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1, new NamedThreadFactory("Metrics")); - - private Set _currentVms; - - public MetricsCollector(Set currentVms) { - _currentVms = currentVms; - getAllVMNames(); - } - - public MetricsCollector() { - - } - - public synchronized void getAllVMNames() { - Set 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 getVMNames() { - return vmNames; - } - - public synchronized Map getMetricsMap() { - return metricsMap; - } -} 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 30b99e753a1..00000000000 --- 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 netTxKBps = new HashMap(); - - //the last calculated traffic speed (receive) per interface - private Map netRxKBps = new HashMap(); - - //the last calculated disk write speed per disk (Bytes Per Second) - private Map diskWriteKBytesPerSec = new HashMap(); - - //the last calculated disk read speed per disk (Bytes Per Second) - private Map diskReadKBytesPerSec = new HashMap(); - - //Total Bytes Transmitted on network interfaces - private Map netTxTotalBytes = new HashMap(); - - //Total Bytes Received on network interfaces - private Map netRxTotalBytes = new HashMap(); - - //Total Bytes read per disk - private Map diskReadTotalBytes = new HashMap(); - - //Total Bytes written per disk - private Map diskWriteTotalBytes = new HashMap(); - - //CPU time in seconds - private Double cpuSeconds = new Double(0.0); - - //CPU percentage - private Float cpuPercent = new Float(0.0); - - private Map diskMap = new HashMap(); - - private Map vifMap = new HashMap(); - - private Map diskStatTimestamp = new HashMap(); - private Map netStatTimestamp = new HashMap(); - - 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 entry : netRxTotalBytes.entrySet()) { - entry.setValue(entry.getValue() + getIncrementor()); - } - - for (Map.Entry entry : netTxTotalBytes.entrySet()) { - entry.setValue(entry.getValue() + getIncrementor()); - } - } - - public String getVmName() { - return vmName; - } - - public Map getNetTxKBps() { - return netTxKBps; - } - - public Map getNetRxKBps() { - return netRxKBps; - } - - public Map getDiskWriteBytesPerSec() { - return diskWriteKBytesPerSec; - } - - public Map getDiskReadBytesPerSec() { - return diskReadKBytesPerSec; - } - - public Map getNetTxTotalBytes() { - return netTxTotalBytes; - } - - public Map getNetRxTotalBytes() { - return netRxTotalBytes; - } - - public Map getDiskReadTotalBytes() { - return diskReadTotalBytes; - } - - public Map 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 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; - } -} 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 7d38baf0e68..00000000000 --- 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 listeners; - private DatagramSocket socket; - private byte[] recvBuffer; - - private Thread driver; - private volatile boolean stopRequested = false; - - public MultiCaster() { - listeners = new ArrayList(); - 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); - } - } - } -} 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 fe4761b4f98..00000000000 --- 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); -} 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 caed518dd78..00000000000 --- 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; - } -} 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 6a2190d696a..00000000000 --- 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(); - } -} 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 69efc83dbe1..9654b74ca1a --- 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 _resources = new ConcurrentHashMap(); 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; 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 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 00000000000..1cd67d448cb --- /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; + } +} diff --git a/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorSecondaryDiscoverer.java b/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorSecondaryDiscoverer.java index 735bf150224..30926e39d0b 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 params) throws ConfigurationException { @@ -62,27 +69,18 @@ public class SimulatorSecondaryDiscoverer extends SecondaryStorageDiscoverer imp @Override public Map> find(long dcId, Long podId, Long clusterId, URI uri, String username, String password, List 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> resources = new HashMap>(); + resources.put(this.resource, new HashMap()); + return resources; } @Override public void postDiscovery(List hosts, long msId) { - super.postDiscovery(hosts, msId); for (HostVO host: hosts) { if(s_logger.isDebugEnabled()) { s_logger.debug("Preinstalling simulator templates"); diff --git a/plugins/storage/image/simulator/src/org/apache/cloudstack/storage/datastore/driver/SimulatorImageStoreDriverImpl.java b/plugins/hypervisors/simulator/src/org/apache/cloudstack/storage/datastore/driver/SimulatorImageStoreDriverImpl.java similarity index 87% rename from plugins/storage/image/simulator/src/org/apache/cloudstack/storage/datastore/driver/SimulatorImageStoreDriverImpl.java rename to plugins/hypervisors/simulator/src/org/apache/cloudstack/storage/datastore/driver/SimulatorImageStoreDriverImpl.java index d5fe8a18a82..b230194bd65 100644 --- a/plugins/storage/image/simulator/src/org/apache/cloudstack/storage/datastore/driver/SimulatorImageStoreDriverImpl.java +++ b/plugins/hypervisors/simulator/src/org/apache/cloudstack/storage/datastore/driver/SimulatorImageStoreDriverImpl.java @@ -26,19 +26,28 @@ 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 { @@ -68,7 +77,7 @@ public class SimulatorImageStoreDriverImpl extends BaseImageStoreDriverImpl { } @Override - public void createAsync(DataStore store, DataObject data, AsyncCompletionCallback callback) { + public void createAsync(DataStore dataStore, DataObject data, AsyncCompletionCallback callback) { if (data.getType() == DataObjectType.TEMPLATE) { this.createTemplate(data, callback); } else if (data.getType() == DataObjectType.VOLUME) { diff --git a/plugins/storage/image/simulator/src/org/apache/cloudstack/storage/datastore/lifecycle/SimulatorImageStoreLifeCycleImpl.java b/plugins/hypervisors/simulator/src/org/apache/cloudstack/storage/datastore/lifecycle/SimulatorImageStoreLifeCycleImpl.java similarity index 100% rename from plugins/storage/image/simulator/src/org/apache/cloudstack/storage/datastore/lifecycle/SimulatorImageStoreLifeCycleImpl.java rename to plugins/hypervisors/simulator/src/org/apache/cloudstack/storage/datastore/lifecycle/SimulatorImageStoreLifeCycleImpl.java diff --git a/plugins/storage/image/simulator/src/org/apache/cloudstack/storage/datastore/provider/SimulatorImageStoreProviderImpl.java b/plugins/hypervisors/simulator/src/org/apache/cloudstack/storage/datastore/provider/SimulatorImageStoreProviderImpl.java similarity index 100% rename from plugins/storage/image/simulator/src/org/apache/cloudstack/storage/datastore/provider/SimulatorImageStoreProviderImpl.java rename to plugins/hypervisors/simulator/src/org/apache/cloudstack/storage/datastore/provider/SimulatorImageStoreProviderImpl.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 00000000000..05b3e6bc99b --- /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 volumeMap, Host srcHost, Host destHost) { + return true; + } + + @Override + public Void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback callback) { + CopyCommandResult result = new CopyCommandResult("something", null); + callback.complete(result); + return null; + } + + @Override + public Void copyAsync(Map volumeMap, VirtualMachineTO vmTo, Host srcHost, Host destHost, AsyncCompletionCallback callback) { + CopyCommandResult result = new CopyCommandResult("something", null); + callback.complete(result); + return null; + } +} 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 00000000000..dab2f932c75 --- /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 { + +} diff --git a/plugins/pom.xml b/plugins/pom.xml index 04eb55ca86d..5bc324dffbd 100755 --- a/plugins/pom.xml +++ b/plugins/pom.xml @@ -65,7 +65,6 @@ storage/image/swift storage/image/default storage/image/sample - storage/image/simulator storage/volume/solidfire storage/volume/default storage/volume/sample @@ -159,7 +158,6 @@ hypervisors/simulator - storage/image/simulator diff --git a/plugins/storage/image/simulator/pom.xml b/plugins/storage/image/simulator/pom.xml deleted file mode 100644 index d4b6838106c..00000000000 --- a/plugins/storage/image/simulator/pom.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - 4.0.0 - cloud-plugin-storage-image-simulator - Apache CloudStack Plugin - Storage Image Simulator provider - - org.apache.cloudstack - cloudstack-plugins - 4.2.0-SNAPSHOT - ../../../pom.xml - - - - org.apache.cloudstack - cloud-engine-storage - ${project.version} - - - org.apache.cloudstack - cloud-engine-storage-image - ${project.version} - - - org.apache.cloudstack - cloud-engine-storage-volume - ${project.version} - - - org.apache.cloudstack - cloud-engine-storage-snapshot - ${project.version} - - - mysql - mysql-connector-java - ${cs.mysql.version} - provided - - - - install - src - test - - - maven-surefire-plugin - - - integration-test - - test - - - - - - -