mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Added engine
This commit is contained in:
parent
3dafea6eff
commit
a6df8a5b44
42
engine/api/pom.xml
Normal file
42
engine/api/pom.xml
Normal file
@ -0,0 +1,42 @@
|
||||
<!--
|
||||
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-engine-api</artifactId>
|
||||
<name>Apache CloudStack Cloud Engine API</name>
|
||||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine</artifactId>
|
||||
<version>4.1.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<defaultGoal>install</defaultGoal>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<testSourceDirectory>test</testSourceDirectory>
|
||||
</build>
|
||||
</project>
|
||||
85
engine/api/src/org/apache/cloudstack/platform/Rules.java
Executable file
85
engine/api/src/org/apache/cloudstack/platform/Rules.java
Executable file
@ -0,0 +1,85 @@
|
||||
/*
|
||||
* 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.platform;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.utils.StringUtils;
|
||||
|
||||
/**
|
||||
* Rules specifies all rules about developing and using CloudStack Orchestration
|
||||
* Platforms APIs. This class is not actually used in CloudStack Orchestration
|
||||
* Platform but must be read by all who wants to use and develop against
|
||||
* CloudStack Orchestration Platform.
|
||||
*
|
||||
* Make sure to make changes here when there are changes to how the APIs should
|
||||
* be used and developed.
|
||||
*
|
||||
* Changes to this class must be approved by the maintainer of this project.
|
||||
*
|
||||
*/
|
||||
public class Rules {
|
||||
public static List<String> whenUsing() {
|
||||
List<String> rules = new ArrayList<String>();
|
||||
rules.add("Always be prepared to handle RuntimeExceptions.");
|
||||
return rules;
|
||||
}
|
||||
|
||||
public static List<String> whenWritingNewApis() {
|
||||
List<String> rules = new ArrayList<String>();
|
||||
rules.add("You may think you're the greatest developer in the " +
|
||||
"world but every change to the API must be reviewed and approved. ");
|
||||
rules.add("Every API must have unit tests written against it. And not it's unit tests");
|
||||
rules.add("");
|
||||
|
||||
|
||||
return rules;
|
||||
}
|
||||
|
||||
private static void printRule(String rule) {
|
||||
System.out.print("API Rule: ");
|
||||
String skip = "";
|
||||
int brk = 0;
|
||||
while (true) {
|
||||
int stop = StringUtils.formatForOutput(rule, brk, 75 - skip.length(), ' ');
|
||||
if (stop < 0) {
|
||||
break;
|
||||
}
|
||||
System.out.print(skip);
|
||||
skip = " ";
|
||||
System.out.println(rule.substring(brk, stop).trim());
|
||||
brk = stop;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("When developing against the CloudStack Orchestration Platform, you must following the following rules:");
|
||||
for (String rule : whenUsing()) {
|
||||
printRule(rule);
|
||||
}
|
||||
System.out.println("");
|
||||
System.out.println("When writing APIs, you must follow these rules:");
|
||||
for (String rule : whenWritingNewApis()) {
|
||||
printRule(rule);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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.platform.cloud.entity.api;
|
||||
|
||||
import org.apache.cloudstack.platform.entity.api.CloudStackEntity;
|
||||
|
||||
/**
|
||||
* @author ahuang
|
||||
*
|
||||
*/
|
||||
public interface BackupEntity extends CloudStackEntity {
|
||||
|
||||
}
|
||||
@ -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.platform.cloud.entity.api;
|
||||
|
||||
public interface EdgeService {
|
||||
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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.platform.cloud.entity.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.platform.entity.api.CloudStackEntity;
|
||||
|
||||
import com.cloud.network.Network;
|
||||
|
||||
public interface NetworkEntity extends CloudStackEntity, Network {
|
||||
void routeTo(NetworkEntity network);
|
||||
|
||||
List<EdgeService> listEdgeServicesTo();
|
||||
|
||||
List<String> listVirtualMachineUuids();
|
||||
|
||||
List<VirtualMachineEntity> listVirtualMachines();
|
||||
|
||||
List<NicEntity> listNics();
|
||||
|
||||
void addIpRange();
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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.platform.cloud.entity.api;
|
||||
|
||||
import org.apache.cloudstack.platform.entity.api.CloudStackEntity;
|
||||
|
||||
/**
|
||||
* @author ahuang
|
||||
*
|
||||
*/
|
||||
public interface NicEntity extends CloudStackEntity {
|
||||
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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.platform.cloud.entity.api;
|
||||
|
||||
import org.apache.cloudstack.platform.entity.api.CloudStackEntity;
|
||||
|
||||
import com.cloud.storage.Snapshot;
|
||||
|
||||
public interface SnapshotEntity extends CloudStackEntity, Snapshot {
|
||||
/**
|
||||
* Make a reservation for backing up this snapshot
|
||||
* @param expiration time in seconds to expire the reservation
|
||||
* @return reservation token
|
||||
*/
|
||||
String reserveForBackup(int expiration);
|
||||
|
||||
/**
|
||||
* Perform the backup according to the reservation token
|
||||
* @param reservationToken token returned by reserveForBackup
|
||||
*/
|
||||
void backup(String reservationToken);
|
||||
|
||||
/**
|
||||
* restore this snapshot to this vm.
|
||||
* @param vm
|
||||
*/
|
||||
void restore(String vm);
|
||||
|
||||
/**
|
||||
* Destroy this snapshot.
|
||||
*/
|
||||
void destroy();
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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.platform.cloud.entity.api;
|
||||
|
||||
import org.apache.cloudstack.platform.entity.api.CloudStackEntity;
|
||||
|
||||
import com.cloud.template.VirtualMachineTemplate;
|
||||
|
||||
public interface TemplateEntity extends CloudStackEntity, VirtualMachineTemplate {
|
||||
|
||||
}
|
||||
@ -0,0 +1,148 @@
|
||||
/*
|
||||
* 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.platform.cloud.entity.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.platform.entity.api.CloudStackEntity;
|
||||
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.deploy.DeploymentPlanner.ExcludeList;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
/**
|
||||
* VirtualMachineEntity represents a Virtual Machine in Cloud Orchestration
|
||||
* Platform.
|
||||
*
|
||||
*/
|
||||
public interface VirtualMachineEntity extends VirtualMachine, CloudStackEntity {
|
||||
|
||||
/**
|
||||
* @return List of uuids for volumes attached to this virtual machine.
|
||||
*/
|
||||
List<String> listVolumeUuids();
|
||||
|
||||
/**
|
||||
* @return List of volumes attached to this virtual machine.
|
||||
*/
|
||||
List<VolumeEntity> listVolumes();
|
||||
|
||||
/**
|
||||
* @return List of uuids for nics attached to this virtual machine.
|
||||
*/
|
||||
List<String> listNicUuids();
|
||||
|
||||
/**
|
||||
* @return List of nics attached to this virtual machine.
|
||||
*/
|
||||
List<NicEntity> listNics();
|
||||
|
||||
/**
|
||||
* @return the template this virtual machine is based off.
|
||||
*/
|
||||
TemplateEntity getTemplate();
|
||||
|
||||
/**
|
||||
* @return the list of tags associated with the virtual machine
|
||||
*/
|
||||
List<String> listTags();
|
||||
|
||||
void addTag();
|
||||
|
||||
void delTag();
|
||||
|
||||
/**
|
||||
* Start the virtual machine with a given deploy destination
|
||||
* @param plannerToUse the Deployment Planner that should be used
|
||||
* @param dest destination to which to deploy the machine
|
||||
* @param exclude list of areas to exclude
|
||||
* @return a reservation id
|
||||
*/
|
||||
String reserve(String plannerToUse, DeployDestination dest, ExcludeList exclude);
|
||||
|
||||
/**
|
||||
* Migrate this VM to a certain destination.
|
||||
*
|
||||
* @param reservationId reservation id from reserve call.
|
||||
*/
|
||||
void migrateTo(String reservationId);
|
||||
|
||||
/**
|
||||
* Deploy this virtual machine according to the reservation from before.
|
||||
* @param reservationId reservation id from reserve call.
|
||||
*
|
||||
*/
|
||||
void deploy(String reservationId);
|
||||
|
||||
/**
|
||||
* Stop the virtual machine
|
||||
*
|
||||
*/
|
||||
void stop();
|
||||
|
||||
/**
|
||||
* Cleans up after any botched starts. CloudStack Orchestration Platform
|
||||
* will attempt a best effort to actually shutdown any resource but
|
||||
* even if it cannot, it releases the resource from its database.
|
||||
*/
|
||||
void cleanup();
|
||||
|
||||
/**
|
||||
* Destroys the VM.
|
||||
*/
|
||||
void destroy();
|
||||
|
||||
/**
|
||||
* Duplicate this VM in the database so that it will start new
|
||||
* @param externalId
|
||||
* @return a new VirtualMachineEntity
|
||||
*/
|
||||
VirtualMachineEntity duplicate(String externalId);
|
||||
|
||||
/**
|
||||
* Take a VM snapshot
|
||||
*/
|
||||
SnapshotEntity takeSnapshotOf();
|
||||
|
||||
/**
|
||||
* Attach volume to this VM
|
||||
* @param volume volume to attach
|
||||
* @param deviceId deviceId to use
|
||||
*/
|
||||
void attach(VolumeEntity volume, short deviceId);
|
||||
|
||||
/**
|
||||
* Detach the volume from this VM
|
||||
* @param volume volume to detach
|
||||
*/
|
||||
void detach(VolumeEntity volume);
|
||||
|
||||
/**
|
||||
* Connect the VM to a network
|
||||
* @param network network to attach
|
||||
* @param deviceId device id to use when a nic is created
|
||||
*/
|
||||
void connectTo(NetworkEntity network, short nicId);
|
||||
|
||||
/**
|
||||
* Disconnect the VM from this network
|
||||
* @param netowrk network to disconnect from
|
||||
*/
|
||||
void disconnectFrom(NetworkEntity netowrk, short nicId);
|
||||
}
|
||||
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* 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.platform.cloud.entity.api;
|
||||
|
||||
import org.apache.cloudstack.platform.entity.api.CloudStackEntity;
|
||||
|
||||
import com.cloud.storage.Volume;
|
||||
|
||||
public interface VolumeEntity extends CloudStackEntity, Volume {
|
||||
|
||||
/**
|
||||
* Take a snapshot of the volume
|
||||
*/
|
||||
SnapshotEntity takeSnapshotOf(boolean full);
|
||||
|
||||
/**
|
||||
* Make a reservation to do storage migration
|
||||
*
|
||||
* @param expirationTime time in seconds the reservation is cancelled
|
||||
* @return reservation token
|
||||
*/
|
||||
String reserveForMigration(long expirationTime);
|
||||
|
||||
/**
|
||||
* Migrate using a reservation.
|
||||
* @param reservationToken reservation token
|
||||
*/
|
||||
void migrate(String reservationToken);
|
||||
|
||||
/**
|
||||
* Setup for a copy of this volume.
|
||||
* @return destination to copy to
|
||||
*/
|
||||
VolumeEntity setupForCopy();
|
||||
|
||||
/**
|
||||
* Perform the copy
|
||||
* @param dest copy to this volume
|
||||
*/
|
||||
void copy(VolumeEntity dest);
|
||||
|
||||
/**
|
||||
* Attach to the vm
|
||||
* @param vm vm to attach to
|
||||
* @param deviceId device id to use
|
||||
*/
|
||||
void attachTo(String vm, long deviceId);
|
||||
|
||||
/**
|
||||
* Detach from the vm
|
||||
*/
|
||||
void detachFrom();
|
||||
|
||||
/**
|
||||
* Destroy the volume
|
||||
*/
|
||||
void destroy();
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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.platform.datacenter.entity.api;
|
||||
|
||||
import com.cloud.org.Cluster;
|
||||
|
||||
public interface ClusterEntity extends DataCenterResourceEntity, Cluster, OrganizationScope {
|
||||
|
||||
}
|
||||
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* 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.platform.datacenter.entity.api;
|
||||
|
||||
import org.apache.cloudstack.platform.entity.api.CloudStackEntity;
|
||||
|
||||
import com.cloud.utils.fsm.StateMachine2;
|
||||
import com.cloud.utils.fsm.StateObject;
|
||||
|
||||
/**
|
||||
* This interface specifies the states and operations all physical
|
||||
* and virtual resources in the data center must implement.
|
||||
*/
|
||||
public interface DataCenterResourceEntity extends CloudStackEntity, StateObject<DataCenterResourceEntity.State> {
|
||||
|
||||
/**
|
||||
* This is the state machine for how CloudStack should interact with
|
||||
*
|
||||
*/
|
||||
public enum State {
|
||||
Disabled("The resource is disabled so CloudStack should not use it. This is the initial state of all resources added to CloudStack."),
|
||||
Enabled("The resource is now enabled for CloudStack to use."),
|
||||
Deactivated("The resource is disactivated so CloudStack should not use it for new resource needs.");
|
||||
|
||||
String _description;
|
||||
|
||||
private State(String description) {
|
||||
_description = description;
|
||||
}
|
||||
|
||||
public enum Event {
|
||||
EnableRequest,
|
||||
DisableRequest,
|
||||
DeactivateRequest,
|
||||
ActivatedRequest
|
||||
}
|
||||
|
||||
protected static final StateMachine2<State, Event, DataCenterResourceEntity> s_fsm = new StateMachine2<State, Event, DataCenterResourceEntity>();
|
||||
static {
|
||||
s_fsm.addTransition(Disabled, Event.EnableRequest, Enabled);
|
||||
s_fsm.addTransition(Enabled, Event.DisableRequest, Disabled);
|
||||
s_fsm.addTransition(Enabled, Event.DeactivateRequest, Deactivated);
|
||||
s_fsm.addTransition(Deactivated, Event.ActivatedRequest, Enabled);
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Prepare the resource to take new on new demands.
|
||||
*/
|
||||
boolean enable();
|
||||
|
||||
/**
|
||||
* Disables the resource. Cleanup. Prepare for the resource to be removed.
|
||||
*/
|
||||
boolean disable();
|
||||
|
||||
/**
|
||||
* Do not use the resource for new demands.
|
||||
*/
|
||||
boolean deactivate();
|
||||
|
||||
/**
|
||||
* Reactivates a deactivated resource.
|
||||
*/
|
||||
boolean reactivate();
|
||||
|
||||
}
|
||||
@ -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.platform.datacenter.entity.api;
|
||||
|
||||
public interface OrganizationScope {
|
||||
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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.platform.datacenter.entity.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.dc.Pod;
|
||||
import com.cloud.org.Cluster;
|
||||
|
||||
public interface PodEntity extends DataCenterResourceEntity, Pod {
|
||||
|
||||
List<Cluster> listClusters();
|
||||
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* 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.platform.datacenter.entity.api;
|
||||
|
||||
import com.cloud.storage.StoragePool;
|
||||
|
||||
public interface StorageEntity extends DataCenterResourceEntity, StoragePool {
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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.platform.datacenter.entity.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.dc.DataCenter;
|
||||
|
||||
/**
|
||||
* Describes a zone and operations that can be done in a zone.
|
||||
*/
|
||||
public interface ZoneEntity extends DataCenterResourceEntity, DataCenter {
|
||||
List<PodEntity> listPods();
|
||||
}
|
||||
@ -0,0 +1,96 @@
|
||||
/*
|
||||
* 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.platform.entity.api;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* All entities returned by the Cloud Orchestration Platform must implement
|
||||
* this interface. CloudValueEntity is an immutable representation of
|
||||
* an entity exposed by Cloud Orchestration Platform. For each object, it
|
||||
* defines two ids: uuid, generated by CloudStack Orchestration Platform, and
|
||||
* an external id that is set by the caller when the entity is created. All
|
||||
* ids must be unique for that entity. CloudValueEntity also can be converted
|
||||
* to a CloudActionableEntity which contains actions the object can perform.
|
||||
*/
|
||||
public interface CloudStackEntity {
|
||||
/**
|
||||
* @return the uuid of the object.
|
||||
*/
|
||||
String getUuid();
|
||||
|
||||
/**
|
||||
* @return the id which is often the database id.
|
||||
*/
|
||||
long getId();
|
||||
|
||||
/**
|
||||
* @return external id set by the caller
|
||||
*/
|
||||
String getExternalId();
|
||||
|
||||
/**
|
||||
* @return current state for the entity
|
||||
*/
|
||||
String getCurrentState();
|
||||
|
||||
/**
|
||||
* @return desired state for the entity
|
||||
*/
|
||||
String getDesiredState();
|
||||
|
||||
/**
|
||||
* Get the time the entity was created
|
||||
*/
|
||||
Date getCreatedTime();
|
||||
|
||||
/**
|
||||
* Get the time the entity was last updated
|
||||
*/
|
||||
Date getLastUpdatedTime();
|
||||
|
||||
/**
|
||||
* @return reference to the owner of this entity
|
||||
*/
|
||||
String getOwner();
|
||||
|
||||
/**
|
||||
* @return details stored for this entity when created.
|
||||
*/
|
||||
Map<String, String> getDetails(String source);
|
||||
|
||||
/**
|
||||
* @return a list of sources that have added to the details.
|
||||
*/
|
||||
List<String> getDetailSources();
|
||||
|
||||
void addDetail(String source, String name, String value);
|
||||
|
||||
void delDetail(String source, String name, String value);
|
||||
|
||||
void updateDetail(String source, String name, String value);
|
||||
|
||||
/**
|
||||
* @return list of actions that can be performed on the object in its current state
|
||||
*/
|
||||
List<Method> getApplicableActions();
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* 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.platform.exception;
|
||||
|
||||
public class InsufficientCapacityException {
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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.platform.service.api;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.utils.component.PluggableService;
|
||||
|
||||
public interface DirectoryService {
|
||||
void registerService(String serviceName, URI endpoint);
|
||||
void unregisterService(String serviceName, URI endpoint);
|
||||
List<URI> getEndPoints(String serviceName);
|
||||
URI getLoadBalancedEndPoint(String serviceName);
|
||||
|
||||
List<PluggableService> listServices();
|
||||
|
||||
}
|
||||
45
engine/api/src/org/apache/cloudstack/platform/service/api/EntityService.java
Executable file
45
engine/api/src/org/apache/cloudstack/platform/service/api/EntityService.java
Executable file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.platform.service.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.storage.Volume;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
/**
|
||||
* Service to retrieve CloudStack entities
|
||||
* very likely to change
|
||||
*/
|
||||
public interface EntityService {
|
||||
List<String> listVirtualMachines();
|
||||
List<String> listVolumes();
|
||||
List<String> listNetworks();
|
||||
List<String> listNics();
|
||||
List<String> listSnapshots();
|
||||
List<String> listTemplates();
|
||||
List<String> listStoragePools();
|
||||
List<String> listHosts();
|
||||
|
||||
VirtualMachine getVirtualMachine(String vm);
|
||||
Volume getVolume(String volume);
|
||||
Network getNetwork(String network);
|
||||
|
||||
}
|
||||
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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.platform.service.api;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.alert.Alert;
|
||||
import com.cloud.async.AsyncJob;
|
||||
|
||||
public interface OperationsServices {
|
||||
List<AsyncJob> listJobs();
|
||||
|
||||
List<AsyncJob> listJobsInProgress();
|
||||
|
||||
List<AsyncJob> listJobsCompleted();
|
||||
|
||||
List<AsyncJob> listJobsCompleted(Long from);
|
||||
|
||||
List<AsyncJob> listJobsInWaiting();
|
||||
|
||||
void cancelJob(String job);
|
||||
|
||||
List<Alert> listAlerts();
|
||||
|
||||
Alert getAlert(String uuid);
|
||||
|
||||
void cancelAlert(String alert);
|
||||
|
||||
void registerForAlerts();
|
||||
|
||||
String registerForEventNotifications(String type, String topic, URL url);
|
||||
|
||||
boolean deregisterForEventNotifications(String notificationId);
|
||||
|
||||
/**
|
||||
* @return the list of event topics someone can register for
|
||||
*/
|
||||
List<String> listEventTopics();
|
||||
|
||||
}
|
||||
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* 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.platform.service.api;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.cloudstack.platform.cloud.entity.api.NetworkEntity;
|
||||
import org.apache.cloudstack.platform.cloud.entity.api.TemplateEntity;
|
||||
import org.apache.cloudstack.platform.cloud.entity.api.VirtualMachineEntity;
|
||||
import org.apache.cloudstack.platform.cloud.entity.api.VolumeEntity;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
|
||||
public interface OrchestrationService {
|
||||
/**
|
||||
* creates a new virtual machine
|
||||
*
|
||||
* @param uuid externally unique name to reference the virtual machine
|
||||
* @param template reference to the template
|
||||
* @param hostName name of the host
|
||||
* @param cpu # of cpu cores
|
||||
* @param speed speed of the cpu core
|
||||
* @param memory memory to allocate in bytes
|
||||
* @param networks networks that this VM belongs in
|
||||
* @param rootDiskTags tags for the root disk
|
||||
* @param computeTags tags for the compute
|
||||
* @param details extra details to store for the VM
|
||||
* @return VirtualMachine
|
||||
*/
|
||||
VirtualMachineEntity createVirtualMachine(String name,
|
||||
String template,
|
||||
String hostName,
|
||||
int cpu,
|
||||
int speed,
|
||||
long memory,
|
||||
List<String> networks,
|
||||
List<String> rootDiskTags,
|
||||
List<String> computeTags,
|
||||
Map<String, String> details,
|
||||
String owner);
|
||||
|
||||
VirtualMachineEntity createVirtualMachineFromScratch(String uuid,
|
||||
String iso,
|
||||
String os,
|
||||
String hypervisor,
|
||||
String hostName,
|
||||
int cpu,
|
||||
int speed,
|
||||
long memory,
|
||||
List<String> networks,
|
||||
List<String> computeTags,
|
||||
Map<String, String> details,
|
||||
String owner);
|
||||
|
||||
NetworkEntity createNetwork(String externaId, String name, String cidr, String gateway);
|
||||
|
||||
void destroyNetwork(String networkUuid);
|
||||
|
||||
VolumeEntity createVolume();
|
||||
|
||||
void destroyVolume(String volumeEntity);
|
||||
|
||||
TemplateEntity registerTemplate(String name, URL path, String os, Hypervisor hypervisor);
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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.platform.service.api;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.cloudstack.platform.datacenter.entity.api.ZoneEntity;
|
||||
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.Pod;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.storage.StoragePool;
|
||||
|
||||
|
||||
/**
|
||||
* ProvisioningService registers and deregisters physical and virtual
|
||||
* resources that the management server can use.
|
||||
*/
|
||||
public interface ProvisioningService {
|
||||
|
||||
String registerStorage(String name, List<String> tags, Map<String, String> details);
|
||||
ZoneEntity registerZone(String name, List<String> tags, Map<String, String> details);
|
||||
String registerPod(String name, List<String> tags, Map<String, String> details);
|
||||
String registerCluster(String name, List<String> tags, Map<String, String> details);
|
||||
String registerHost(String name, List<String> tags, Map<String, String> details);
|
||||
|
||||
|
||||
|
||||
void deregisterStorage(String uuid);
|
||||
void deregisterZone();
|
||||
void deregisterPod();
|
||||
void deregisterCluster();
|
||||
void deregisterHost();
|
||||
|
||||
void changeState(String type, String entity, Status state);
|
||||
|
||||
List<Host> listHosts();
|
||||
|
||||
List<Pod> listPods();
|
||||
|
||||
List<DataCenter> listZones();
|
||||
|
||||
|
||||
|
||||
List<StoragePool> listStorage();
|
||||
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.platform.subsystem.api.hypervisor;
|
||||
|
||||
|
||||
public interface ComputeSubsystem {
|
||||
|
||||
void start(String vm, String reservationId);
|
||||
|
||||
void cancel(String reservationId);
|
||||
|
||||
void stop(String vm, String reservationId);
|
||||
|
||||
void migrate(String vm, String reservationId);
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.platform.subsystem.api.network;
|
||||
|
||||
public interface NetworkServiceProvider {
|
||||
/**
|
||||
* Plug your network elements into this network
|
||||
* @param network
|
||||
* @param reservationId
|
||||
*/
|
||||
void plugInto(String network, String reservationId);
|
||||
|
||||
/**
|
||||
* Unplug your network elements from this network
|
||||
* @param network
|
||||
* @param reservationId
|
||||
*/
|
||||
void unplugFrom(String network, String reservationId);
|
||||
|
||||
/**
|
||||
* Cancel a previous work
|
||||
* @param reservationId
|
||||
*/
|
||||
void cancel(String reservationId);
|
||||
|
||||
void provideServiceTo(String vm, String network, String reservationId);
|
||||
|
||||
void removeServiceFrom(String vm, String network, String reservationId);
|
||||
|
||||
void cleanUp(String network, String reservationId);
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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.platform.subsystem.api.network;
|
||||
|
||||
public interface NetworkSubsystem {
|
||||
String create();
|
||||
|
||||
String start(String network, String reservationId);
|
||||
|
||||
void shutdown(String nework, String reservationId);
|
||||
|
||||
void prepare(String vm, String network, String reservationId);
|
||||
|
||||
void release(String vm, String network, String reservationId);
|
||||
|
||||
void cancel(String reservationId);
|
||||
|
||||
void destroy(String network, String reservationId);
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
package org.apache.cloudstack.platform.subsystem.api.storage;
|
||||
|
||||
public interface BackupStrategy {
|
||||
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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.platform.subsystem.api.storage;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import com.cloud.org.Grouping;
|
||||
|
||||
public interface DataMigrationSubSystem {
|
||||
|
||||
Class<? extends Grouping> getScopeCoverage();
|
||||
void migrate(URI source, URI dest, String reservationId);
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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.platform.subsystem.api.storage;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.platform.subsystem.api.storage.DataStore.DataStoreRef;
|
||||
|
||||
/*
|
||||
* Logic entity
|
||||
*/
|
||||
public interface DataObject {
|
||||
String getURI();
|
||||
String getUUID();
|
||||
DataStoreRef getStoreRef();
|
||||
long getSize();
|
||||
//volume/snapshot/template
|
||||
String getType();
|
||||
//db id
|
||||
Long getId();
|
||||
DataObject getParent();
|
||||
void setParent(DataObject obj);
|
||||
List<DataObject> getChidren();
|
||||
boolean lock();
|
||||
boolean unlock();
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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.platform.subsystem.api.storage;
|
||||
|
||||
import com.cloud.utils.fsm.StateMachine;
|
||||
|
||||
public enum DataObjectBackupStorageOperationState {
|
||||
Copying,
|
||||
Deleting,
|
||||
Ready,
|
||||
NonOperational;
|
||||
|
||||
public enum Event {
|
||||
Initial("Init state machine"),
|
||||
CopyingRequested("Copy operation is requested"),
|
||||
DeleteRequested("Delete operation is requested"),
|
||||
OperationSuccess("Operation successed"),
|
||||
OperationFailed("Operation failed");
|
||||
|
||||
private final String _msg;
|
||||
|
||||
private Event(String msg) {
|
||||
_msg = msg;
|
||||
}
|
||||
}
|
||||
|
||||
public DataObjectBackupStorageOperationState getNextState(Event a) {
|
||||
return s_fsm.getNextState(this, a);
|
||||
}
|
||||
|
||||
protected static final StateMachine<DataObjectBackupStorageOperationState, Event> s_fsm = new StateMachine<DataObjectBackupStorageOperationState, Event>();
|
||||
static {
|
||||
s_fsm.addTransition(null, Event.Initial, DataObjectBackupStorageOperationState.Ready);
|
||||
s_fsm.addTransition(DataObjectBackupStorageOperationState.Ready, Event.CopyingRequested, DataObjectBackupStorageOperationState.Copying);
|
||||
s_fsm.addTransition(DataObjectBackupStorageOperationState.Copying, Event.CopyingRequested, DataObjectBackupStorageOperationState.Copying);
|
||||
s_fsm.addTransition(DataObjectBackupStorageOperationState.Copying, Event.OperationFailed, DataObjectBackupStorageOperationState.Ready);
|
||||
s_fsm.addTransition(DataObjectBackupStorageOperationState.Copying, Event.OperationSuccess, DataObjectBackupStorageOperationState.Ready);
|
||||
s_fsm.addTransition(DataObjectBackupStorageOperationState.Ready, Event.DeleteRequested, DataObjectBackupStorageOperationState.Deleting);
|
||||
s_fsm.addTransition(DataObjectBackupStorageOperationState.Deleting, Event.OperationFailed, DataObjectBackupStorageOperationState.Ready);
|
||||
s_fsm.addTransition(DataObjectBackupStorageOperationState.Deleting, Event.OperationSuccess, DataObjectBackupStorageOperationState.NonOperational);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* 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.platform.subsystem.api.storage;
|
||||
|
||||
import com.cloud.agent.api.to.StorageFilerTO;
|
||||
import com.cloud.storage.Snapshot;
|
||||
import com.cloud.storage.Storage.StoragePoolType;
|
||||
import com.cloud.storage.Volume;
|
||||
import com.cloud.template.VirtualMachineTemplate;
|
||||
|
||||
public interface DataStore {
|
||||
public class DataStoreRef {
|
||||
|
||||
}
|
||||
|
||||
public class DataStoreDriverRef {
|
||||
|
||||
}
|
||||
|
||||
public enum StoreType {
|
||||
Primary,
|
||||
Image,
|
||||
Backup;
|
||||
}
|
||||
public class StoreScope {
|
||||
public long zoneId;
|
||||
private long clusterId;
|
||||
private long hostId;
|
||||
}
|
||||
|
||||
String getURI();
|
||||
String getUUID();
|
||||
long getCluterId();
|
||||
long getPodId();
|
||||
long getZoneId();
|
||||
String getPath();
|
||||
StoreType getType();
|
||||
StoragePoolType getPoolType();
|
||||
StoreScope getScope();
|
||||
boolean isSharedStorage();
|
||||
Long getId();
|
||||
DataStoreDriver getDataStoreDriver();
|
||||
StorageProvider getProvider();
|
||||
DataStoreEndPointSelector getEndPointSelector();
|
||||
FileSystem getFileSystem();
|
||||
VolumeStrategy getVolumeStrategy();
|
||||
SnapshotStrategy getSnapshotStrategy();
|
||||
BackupStrategy getBackupStrategy();
|
||||
TemplateStrategy getTemplateStrategy();
|
||||
DataStoreLifeCycle getLifeCycle();
|
||||
|
||||
VolumeProfile prepareVolume(Volume volume, DataStore destStore);
|
||||
SnapshotProfile prepareSnapshot(Snapshot snapshot, DataStore destStore);
|
||||
TemplateProfile prepareTemplate(long templateId, DataStore destStore);
|
||||
boolean contains(Volume volume);
|
||||
boolean contains(Snapshot snapshot);
|
||||
boolean contains(TemplateProfile template);
|
||||
TemplateProfile get(TemplateProfile template);
|
||||
StorageFilerTO getTO();
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package org.apache.cloudstack.platform.subsystem.api.storage;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.cloud.storage.StoragePool;
|
||||
|
||||
public interface DataStoreConfigurator {
|
||||
String getProtocol();
|
||||
StoragePool getStoragePool(Map<String, String> configs);
|
||||
List<String> getConfigNames();
|
||||
Map<String, String> getConfigs(URI uri, Map<String, String> extras);
|
||||
boolean validate(Map<String, String> configs);
|
||||
DataStore getDataStore(StoragePool pool);
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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.platform.subsystem.api.storage;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.Command;
|
||||
|
||||
public interface DataStoreDriver {
|
||||
String getDriverType();
|
||||
TemplateProfile install(TemplateProfile tp, DataStoreEndPoint ep);
|
||||
TemplateProfile register(TemplateProfile tp, DataStoreEndPoint ep);
|
||||
DataObject create(DataObject obj);
|
||||
DataObject copy(DataObject src, DataStore dest);
|
||||
DataObject copy(DataObject src, DataObject dest);
|
||||
DataObject move(DataObject src, DataObject dest);
|
||||
VolumeProfile createVolumeFromTemplate(VolumeProfile vol, TemplateProfile tp, DataStoreEndPoint dp);
|
||||
Answer sendMessage(DataStoreEndPoint dsep, Command cmd);
|
||||
boolean delete(DataObject obj);
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package org.apache.cloudstack.platform.subsystem.api.storage;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.Command;
|
||||
|
||||
public class DataStoreEndPoint {
|
||||
protected long hostId;
|
||||
protected String privIp;
|
||||
|
||||
public DataStoreEndPoint(long host, String ip) {
|
||||
hostId = host;
|
||||
privIp = ip;
|
||||
}
|
||||
|
||||
public long getHostId() {
|
||||
return hostId;
|
||||
}
|
||||
|
||||
public String getPrivateIp() {
|
||||
return privIp;
|
||||
}
|
||||
|
||||
public Answer sendCommand(Command cmd) {
|
||||
return new Answer(cmd);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
package org.apache.cloudstack.platform.subsystem.api.storage;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface DataStoreEndPointSelector {
|
||||
List<DataStoreEndPoint> getEndPoints(StorageEvent event);
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
package org.apache.cloudstack.platform.subsystem.api.storage;
|
||||
|
||||
public interface DataStoreExtendedAttribute {
|
||||
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
package org.apache.cloudstack.platform.subsystem.api.storage;
|
||||
|
||||
public interface DataStoreLifeCycle {
|
||||
public enum DataStoreEvent {
|
||||
HOSTUP,
|
||||
HOSTDOWN,
|
||||
}
|
||||
void add();
|
||||
void delete();
|
||||
void enable();
|
||||
void disable();
|
||||
void processEvent(DataStoreEvent event, Object... objs);
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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.platform.subsystem.api.storage;
|
||||
|
||||
public interface FileSystem {
|
||||
DataObject create(DataObject obj);
|
||||
DataObject copy(DataObject Obj, DataStore destStore);
|
||||
DataObject copy(DataObject obj, DataObject destObj);
|
||||
DataObject move(DataObject srcObj, DataObject destObj);
|
||||
boolean delete(DataObject obj);
|
||||
long getStats(DataObject obj);
|
||||
String getFileType();
|
||||
boolean isWritable(DataObject obj);
|
||||
boolean contains(DataObject obj);
|
||||
DataObject ioctl(DataObject obj, Object... objects);
|
||||
}
|
||||
@ -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.platform.subsystem.api.storage;
|
||||
|
||||
public interface Snapshot extends DataObject {
|
||||
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* 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.platform.subsystem.api.storage;
|
||||
|
||||
public class SnapshotProfile {
|
||||
private String _uri;
|
||||
public String getURI() {
|
||||
return _uri;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
package org.apache.cloudstack.platform.subsystem.api.storage;
|
||||
|
||||
public interface SnapshotStrategy {
|
||||
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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.platform.subsystem.api.storage;
|
||||
|
||||
public enum StorageEvent {
|
||||
DownloadTemplateToPrimary,
|
||||
RegisterTemplate,
|
||||
CreateVolumeFromTemplate;
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package org.apache.cloudstack.platform.subsystem.api.storage;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.cloudstack.platform.subsystem.api.storage.DataStore.StoreType;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.storage.StoragePool;
|
||||
import com.cloud.utils.component.Adapter;
|
||||
|
||||
public interface StorageProvider extends Adapter {
|
||||
List<HypervisorType> supportedHypervisors();
|
||||
String getProviderName();
|
||||
List<StoreType> supportedStoreTypes();
|
||||
void configure(Map<String, String> storeProviderInfo);
|
||||
DataStore addDataStore(StoragePool sp, String uri, Map<String, String> params);
|
||||
DataStore getDataStore(StoragePool pool);
|
||||
Map<HypervisorType, Map<String,DataStoreConfigurator>> getDataStoreConfigs();
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
package org.apache.cloudstack.platform.subsystem.api.storage;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import com.cloud.org.Grouping;
|
||||
|
||||
public interface StorageSubSystem {
|
||||
String getType();
|
||||
Class<? extends Grouping> getScope();
|
||||
|
||||
URI grantAccess(String vol, String reservationId);
|
||||
URI RemoveAccess(String vol, String reservationId);
|
||||
}
|
||||
@ -0,0 +1,287 @@
|
||||
// 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.platform.subsystem.api.storage;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.template.VirtualMachineTemplate;
|
||||
|
||||
public class TemplateProfile {
|
||||
Long userId;
|
||||
String name;
|
||||
String displayText;
|
||||
Integer bits;
|
||||
Boolean passwordEnabled;
|
||||
Boolean sshKeyEnbaled;
|
||||
Boolean requiresHvm;
|
||||
String url;
|
||||
Boolean isPublic;
|
||||
Boolean featured;
|
||||
Boolean isExtractable;
|
||||
ImageFormat format;
|
||||
Long guestOsId;
|
||||
Long zoneId;
|
||||
HypervisorType hypervisorType;
|
||||
String accountName;
|
||||
Long domainId;
|
||||
Long accountId;
|
||||
String chksum;
|
||||
Boolean bootable;
|
||||
Long templateId;
|
||||
VirtualMachineTemplate template;
|
||||
String templateTag;
|
||||
Map details;
|
||||
|
||||
public TemplateProfile(Long templateId, Long userId, String name, String displayText, Integer bits, Boolean passwordEnabled, Boolean requiresHvm,
|
||||
String url, Boolean isPublic, Boolean featured, Boolean isExtractable, ImageFormat format, Long guestOsId, Long zoneId,
|
||||
HypervisorType hypervisorType, String accountName, Long domainId, Long accountId, String chksum, Boolean bootable, Map details, Boolean sshKeyEnabled) {
|
||||
this.templateId = templateId;
|
||||
this.userId = userId;
|
||||
this.name = name;
|
||||
this.displayText = displayText;
|
||||
this.bits = bits;
|
||||
this.passwordEnabled = passwordEnabled;
|
||||
this.requiresHvm = requiresHvm;
|
||||
this.url = url;
|
||||
this.isPublic = isPublic;
|
||||
this.featured = featured;
|
||||
this.isExtractable = isExtractable;
|
||||
this.format = format;
|
||||
this.guestOsId = guestOsId;
|
||||
this.zoneId = zoneId;
|
||||
this.hypervisorType = hypervisorType;
|
||||
this.accountName = accountName;
|
||||
this.domainId = domainId;
|
||||
this.accountId = accountId;
|
||||
this.chksum = chksum;
|
||||
this.bootable = bootable;
|
||||
this.details = details;
|
||||
this.sshKeyEnbaled = sshKeyEnabled;
|
||||
}
|
||||
|
||||
public TemplateProfile(Long userId, VirtualMachineTemplate template, Long zoneId) {
|
||||
this.userId = userId;
|
||||
this.template = template;
|
||||
this.zoneId = zoneId;
|
||||
}
|
||||
|
||||
public TemplateProfile(Long templateId, Long userId, String name, String displayText, Integer bits, Boolean passwordEnabled, Boolean requiresHvm,
|
||||
String url, Boolean isPublic, Boolean featured, Boolean isExtractable, ImageFormat format, Long guestOsId, Long zoneId,
|
||||
HypervisorType hypervisorType, String accountName, Long domainId, Long accountId, String chksum, Boolean bootable, String templateTag, Map details, Boolean sshKeyEnabled) {
|
||||
this(templateId, userId, name, displayText, bits, passwordEnabled, requiresHvm, url, isPublic, featured, isExtractable, format, guestOsId, zoneId,
|
||||
hypervisorType, accountName, domainId, accountId, chksum, bootable, details, sshKeyEnabled);
|
||||
this.templateTag = templateTag;
|
||||
}
|
||||
|
||||
public Long getTemplateId() {
|
||||
return templateId;
|
||||
}
|
||||
public void setTemplateId(Long id) {
|
||||
this.templateId = id;
|
||||
}
|
||||
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDisplayText() {
|
||||
return displayText;
|
||||
}
|
||||
public void setDisplayText(String text) {
|
||||
this.displayText = text;
|
||||
}
|
||||
|
||||
public Integer getBits() {
|
||||
return bits;
|
||||
}
|
||||
public void setBits(Integer bits) {
|
||||
this.bits = bits;
|
||||
}
|
||||
|
||||
public Boolean getPasswordEnabled() {
|
||||
return passwordEnabled;
|
||||
}
|
||||
public void setPasswordEnabled(Boolean enabled) {
|
||||
this.passwordEnabled = enabled;
|
||||
}
|
||||
|
||||
public Boolean getRequiresHVM() {
|
||||
return requiresHvm;
|
||||
}
|
||||
public void setRequiresHVM(Boolean hvm) {
|
||||
this.requiresHvm = hvm;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public Boolean getIsPublic() {
|
||||
return isPublic;
|
||||
}
|
||||
public void setIsPublic(Boolean is) {
|
||||
this.isPublic = is;
|
||||
}
|
||||
|
||||
public Boolean getFeatured() {
|
||||
return featured;
|
||||
}
|
||||
public void setFeatured(Boolean featured) {
|
||||
this.featured = featured;
|
||||
}
|
||||
|
||||
public Boolean getIsExtractable() {
|
||||
return isExtractable;
|
||||
}
|
||||
public void setIsExtractable(Boolean is) {
|
||||
this.isExtractable = is;
|
||||
}
|
||||
|
||||
public ImageFormat getFormat() {
|
||||
return format;
|
||||
}
|
||||
public void setFormat(ImageFormat format) {
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
public Long getGuestOsId() {
|
||||
return guestOsId;
|
||||
}
|
||||
public void setGuestOsId(Long id) {
|
||||
this.guestOsId = id;
|
||||
}
|
||||
|
||||
public Long getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
public void setZoneId(Long id) {
|
||||
this.zoneId = id;
|
||||
}
|
||||
|
||||
public HypervisorType getHypervisorType() {
|
||||
return hypervisorType;
|
||||
}
|
||||
public void setHypervisorType(HypervisorType type) {
|
||||
this.hypervisorType = type;
|
||||
}
|
||||
|
||||
public Long getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
public void setDomainId(Long id) {
|
||||
this.domainId = id;
|
||||
}
|
||||
|
||||
public Long getAccountId() {
|
||||
return accountId;
|
||||
}
|
||||
public void setAccountId(Long id) {
|
||||
this.accountId = id;
|
||||
}
|
||||
|
||||
public String getCheckSum() {
|
||||
return chksum;
|
||||
}
|
||||
public void setCheckSum(String chksum) {
|
||||
this.chksum = chksum;
|
||||
}
|
||||
|
||||
public Boolean getBootable() {
|
||||
return this.bootable;
|
||||
}
|
||||
public void setBootable(Boolean bootable) {
|
||||
this.bootable = bootable;
|
||||
}
|
||||
|
||||
public VirtualMachineTemplate getTemplate() {
|
||||
return template;
|
||||
}
|
||||
public void setTemplate(VirtualMachineTemplate template) {
|
||||
this.template = template;
|
||||
}
|
||||
|
||||
public String getTemplateTag() {
|
||||
return templateTag;
|
||||
}
|
||||
|
||||
public void setTemplateTag(String templateTag) {
|
||||
this.templateTag = templateTag;
|
||||
}
|
||||
|
||||
public Map getDetails() {
|
||||
return this.details;
|
||||
}
|
||||
|
||||
public void setDetails(Map details) {
|
||||
this.details = details;
|
||||
}
|
||||
|
||||
public void setSshKeyEnabled(Boolean enabled) {
|
||||
this.sshKeyEnbaled = enabled;
|
||||
}
|
||||
|
||||
public Boolean getSshKeyEnabled() {
|
||||
return this.sshKeyEnbaled;
|
||||
}
|
||||
|
||||
public String getImageStorageUri() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setLocalPath(String path) {
|
||||
|
||||
}
|
||||
|
||||
public String getLocalPath() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getJobId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setTemplatePoolRefId(long id) {
|
||||
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long getTemplatePoolRefId() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long getSize() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
package org.apache.cloudstack.platform.subsystem.api.storage;
|
||||
|
||||
import com.cloud.agent.api.storage.DownloadCommand.Proxy;
|
||||
|
||||
public interface TemplateStrategy {
|
||||
TemplateProfile install(TemplateProfile tp);
|
||||
TemplateProfile get(long templateId);
|
||||
TemplateProfile register(TemplateProfile tp);
|
||||
boolean canRegister(long templateId);
|
||||
int getDownloadWait();
|
||||
long getMaxTemplateSizeInBytes();
|
||||
Proxy getHttpProxy();
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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.platform.subsystem.api.storage;
|
||||
|
||||
public class VolumeProfile {
|
||||
private String _uri;
|
||||
public String getURI() {
|
||||
return _uri;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public long getSize() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package org.apache.cloudstack.platform.subsystem.api.storage;
|
||||
|
||||
|
||||
import com.cloud.storage.Volume;
|
||||
|
||||
public interface VolumeStrategy {
|
||||
Volume createVolume(Volume vol);
|
||||
Volume createDataVolume(Volume vol);
|
||||
Volume copyVolumeFromBackup(VolumeProfile srcVol, Volume destVol);
|
||||
Volume createVolumeFromSnapshot(SnapshotProfile snapshot, Volume vol);
|
||||
Volume createVolumeFromTemplate(TemplateProfile template, Volume vol);
|
||||
Volume migrateVolume(Volume srcVol, Volume destVol, DataStore destStore);
|
||||
Volume createVolumeFromBaseTemplate(Volume destVol, TemplateProfile tp);
|
||||
boolean deleteVolume(Volume vol);
|
||||
VolumeProfile get(long volumeId);
|
||||
}
|
||||
47
engine/components-api/pom.xml
Normal file
47
engine/components-api/pom.xml
Normal file
@ -0,0 +1,47 @@
|
||||
<!--
|
||||
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-engine-components-api</artifactId>
|
||||
<name>Apache CloudStack Cloud Engine Internal Components API</name>
|
||||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine</artifactId>
|
||||
<version>4.1.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-framework-ipc</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<defaultGoal>install</defaultGoal>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<testSourceDirectory>test</testSourceDirectory>
|
||||
</build>
|
||||
</project>
|
||||
52
engine/compute/pom.xml
Normal file
52
engine/compute/pom.xml
Normal file
@ -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.
|
||||
-->
|
||||
<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-engine-compute</artifactId>
|
||||
<name>Apache CloudStack Cloud Engine Compute Component</name>
|
||||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine</artifactId>
|
||||
<version>4.1.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-framework-ipc</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine-components-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<defaultGoal>install</defaultGoal>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<testSourceDirectory>test</testSourceDirectory>
|
||||
</build>
|
||||
</project>
|
||||
37
engine/compute/src/org/apache/cloudstack/compute/ComputeOrchestrator.java
Executable file
37
engine/compute/src/org/apache/cloudstack/compute/ComputeOrchestrator.java
Executable file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.compute;
|
||||
|
||||
import java.util.logging.Handler;
|
||||
|
||||
public interface ComputeOrchestrator {
|
||||
/**
|
||||
* start the vm
|
||||
* @param vm vm
|
||||
* @param reservationId
|
||||
*/
|
||||
@Ipc(topic="cs.compute.start", response="cs.compute.start.response")
|
||||
void start(@IpcParam String vm, @IpcParam String reservationId, Handler handler);
|
||||
|
||||
@Ipc(topic="cs.compute.cancel")
|
||||
void cancel(@IpcParam String reservationId);
|
||||
|
||||
@Ipc(topic="cs.compute.stop")
|
||||
void stop(@IpcParam String vm, @IpcParam String reservationId);
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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.compute;
|
||||
|
||||
|
||||
public class ComputeOrchestratorImpl implements ComputeOrchestrator {
|
||||
|
||||
@Override
|
||||
public void start(String vm, String reservationId) {
|
||||
// Retrieve the VM
|
||||
// Locate the HypervisorGuru based on the VM type
|
||||
// Call HypervisorGuru to start the VM
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel(String reservationId) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop(String vm, String reservationId) {
|
||||
// Retrieve the VM
|
||||
// Locate the HypervisorGuru based on the VM type
|
||||
// Call HypervisorGuru to stop the VM
|
||||
}
|
||||
}
|
||||
52
engine/network/pom.xml
Normal file
52
engine/network/pom.xml
Normal file
@ -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.
|
||||
-->
|
||||
<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-engine-network</artifactId>
|
||||
<name>Apache CloudStack Cloud Engine API</name>
|
||||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine</artifactId>
|
||||
<version>4.1.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<depdency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine-components-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-framework-ipc</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<defaultGoal>install</defaultGoal>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<testSourceDirectory>test</testSourceDirectory>
|
||||
</build>
|
||||
</project>
|
||||
40
engine/network/src/org/apache/cloudstack/network/NetworkOrchestrator.java
Executable file
40
engine/network/src/org/apache/cloudstack/network/NetworkOrchestrator.java
Executable file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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.network;
|
||||
|
||||
public interface NetworkOrchestrator {
|
||||
|
||||
/**
|
||||
* Prepares for a VM to join a network
|
||||
* @param vm vm
|
||||
* @param reservationId reservation id
|
||||
*/
|
||||
void prepare(String vm, String reservationId);
|
||||
|
||||
/**
|
||||
* Release all reservation
|
||||
*/
|
||||
void release(String vm, String reservationId);
|
||||
|
||||
/**
|
||||
* Cancel a previous reservation
|
||||
* @param reservationId
|
||||
*/
|
||||
void cancel(String reservationId);
|
||||
}
|
||||
52
engine/orchestration/pom.xml
Executable file
52
engine/orchestration/pom.xml
Executable file
@ -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.
|
||||
-->
|
||||
<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-engine-orchestration</artifactId>
|
||||
<name>Apache CloudStack Cloud Engine Orchestration Component</name>
|
||||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine</artifactId>
|
||||
<version>4.1.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-framework-ipc</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine-components-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<defaultGoal>install</defaultGoal>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<testSourceDirectory>test</testSourceDirectory>
|
||||
</build>
|
||||
</project>
|
||||
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 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.platform.orchestration;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.cloudstack.platform.cloud.entity.api.VirtualMachineEntity;
|
||||
import org.apache.cloudstack.platform.cloud.entity.api.VolumeEntity;
|
||||
import org.apache.cloudstack.platform.service.api.OrchestrationService;
|
||||
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
|
||||
|
||||
public class CloudOrchestrator implements OrchestrationService {
|
||||
|
||||
public VirtualMachineEntity create(String name, String template, String hostName, int cpu, int speed, long memory, List<String> networks, List<String> rootDiskTags, List<String> computeTags,
|
||||
Map<String, String> details, String owner) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public VirtualMachineEntity createFromScratch(String uuid, String iso, String os, String hypervisor, String hostName, int cpu, int speed, long memory, List<String> networks, List<String> computeTags,
|
||||
Map<String, String> details, String owner) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public String reserve(String vm, String planner, Long until) throws InsufficientCapacityException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public String deploy(String reservationId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public void joinNetwork(String network1, String network2) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void createNetwork() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void destroyNetwork() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public VolumeEntity createVolume() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public void registerTemplate(String name, URL path, String os, Hypervisor hypervisor) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
36
engine/planning/src/org/apache/cloudstack/platform/planning/Concierge.java
Executable file
36
engine/planning/src/org/apache/cloudstack/platform/planning/Concierge.java
Executable file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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.platform.planning;
|
||||
|
||||
import org.apache.cloudstack.framework.ipc.Ipc;
|
||||
|
||||
public interface Concierge {
|
||||
@Ipc(topic="cs.concierge.reserve")
|
||||
String reserve(String vm, String planner, Long until);
|
||||
|
||||
@Ipc(topic="cs.concierge.cancel")
|
||||
String cancel(String reservationId);
|
||||
|
||||
@Ipc(topic="cs.concierge.claim")
|
||||
String claim(String reservationId);
|
||||
|
||||
@Ipc(topic="cs.concierge.reserveAnother")
|
||||
String reserveAnother(String reservationId);
|
||||
|
||||
}
|
||||
44
engine/pom.xml
Normal file
44
engine/pom.xml
Normal file
@ -0,0 +1,44 @@
|
||||
<!--
|
||||
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-engine</artifactId>
|
||||
<name>Apache CloudStack Cloud Engine</name>
|
||||
<packaging>pom</packaging>
|
||||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack</artifactId>
|
||||
<version>4.1.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<build>
|
||||
<defaultGoal>install</defaultGoal>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<testSourceDirectory>test</testSourceDirectory>
|
||||
</build>
|
||||
<modules>
|
||||
<module>api</module>
|
||||
<module>compute</module>
|
||||
<module>orchestration</module>
|
||||
<module>storage</module>
|
||||
<module>components-api</module>
|
||||
<module>schema</module>
|
||||
<module>network</module>
|
||||
</modules>
|
||||
</project>
|
||||
52
engine/schema/pom.xml
Normal file
52
engine/schema/pom.xml
Normal file
@ -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.
|
||||
-->
|
||||
<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-engine-schema</artifactId>
|
||||
<name>Apache CloudStack Cloud Engine Schema Component</name>
|
||||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine</artifactId>
|
||||
<version>4.1.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-framework-ipc</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine-components-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<defaultGoal>install</defaultGoal>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<testSourceDirectory>test</testSourceDirectory>
|
||||
</build>
|
||||
</project>
|
||||
85
engine/storage/pom.xml
Normal file
85
engine/storage/pom.xml
Normal file
@ -0,0 +1,85 @@
|
||||
<!-- 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-engine-storage</artifactId>
|
||||
<name>Apache CloudStack Engine Storage Component</name>
|
||||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine</artifactId>
|
||||
<version>4.1.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-server</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine-components-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.openjpa</groupId>
|
||||
<artifactId>openjpa</artifactId>
|
||||
<version>2.2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>${cs.mysql.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
<version>1.9.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.aspectj</groupId>
|
||||
<artifactId>aspectjrt</artifactId>
|
||||
<version>1.7.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.aspectj</groupId>
|
||||
<artifactId>aspectjweaver</artifactId>
|
||||
<version>1.7.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.inject</groupId>
|
||||
<artifactId>javax.inject</artifactId>
|
||||
<version>1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<defaultGoal>install</defaultGoal>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<testSourceDirectory>test</testSourceDirectory>
|
||||
</build>
|
||||
</project>
|
||||
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
public abstract class BaseType {
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
if (that instanceof String) {
|
||||
if (this.toString().equalsIgnoreCase((String)that)) {
|
||||
return true;
|
||||
}
|
||||
} else if (that instanceof BaseType) {
|
||||
BaseType th = (BaseType)that;
|
||||
if (this.toString().equalsIgnoreCase(th.toString())) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
package org.apache.cloudstack.storage;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.Command;
|
||||
|
||||
public interface EndPoint {
|
||||
public Answer sendMessage(Command cmd);
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.OperationTimedoutException;
|
||||
|
||||
public class HypervisorHostEndPoint implements EndPoint {
|
||||
private static final Logger s_logger = Logger.getLogger(HypervisorHostEndPoint.class);
|
||||
private long hostId;
|
||||
@Inject
|
||||
AgentManager agentMgr;
|
||||
public HypervisorHostEndPoint(long hostId) {
|
||||
this.hostId = hostId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer sendMessage(Command cmd) {
|
||||
Answer answer = null;
|
||||
try {
|
||||
answer = agentMgr.send(hostId, cmd);
|
||||
} catch (AgentUnavailableException e) {
|
||||
s_logger.debug("Unable to send command:" + cmd + ", due to: " + e.toString());
|
||||
} catch (OperationTimedoutException e) {
|
||||
s_logger.debug("Unable to send command:" + cmd + ", due to: " + e.toString());
|
||||
} catch (Exception e) {
|
||||
s_logger.debug("Unable to send command:" + cmd + ", due to: " + e.toString());
|
||||
}
|
||||
return answer;
|
||||
}
|
||||
|
||||
}
|
||||
59
engine/storage/src/org/apache/cloudstack/storage/StorageOrchestrator.java
Executable file
59
engine/storage/src/org/apache/cloudstack/storage/StorageOrchestrator.java
Executable file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.deploy.DeploymentPlan;
|
||||
|
||||
public interface StorageOrchestrator {
|
||||
|
||||
/**
|
||||
* Prepares all storage ready for a VM to start
|
||||
* @param vm
|
||||
* @param reservationId
|
||||
*/
|
||||
void prepare(long vmId, DeploymentPlan plan, String reservationId);
|
||||
|
||||
/**
|
||||
* Releases all storage that were used for a VM shutdown
|
||||
* @param vm
|
||||
* @param disks
|
||||
* @param reservationId
|
||||
*/
|
||||
void release(long vmId, String reservationId);
|
||||
|
||||
/**
|
||||
* Destroy all disks
|
||||
* @param disks
|
||||
* @param reservationId
|
||||
*/
|
||||
void destroy(List<Long> disks, String reservationId);
|
||||
|
||||
/**
|
||||
* Cancel a reservation
|
||||
* @param reservationId reservation to
|
||||
*/
|
||||
void cancel(String reservationId);
|
||||
|
||||
/**
|
||||
* If attaching a volume in allocated state to a running vm, need to create this volume
|
||||
*/
|
||||
void prepareAttachDiskToVM(long diskId, long vmId, String reservationId);
|
||||
}
|
||||
@ -0,0 +1,315 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.platform.subsystem.api.storage.DataObjectBackupStorageOperationState;
|
||||
import org.apache.cloudstack.platform.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.platform.subsystem.api.storage.StorageProvider;
|
||||
import org.apache.cloudstack.platform.subsystem.api.storage.TemplateProfile;
|
||||
import org.apache.cloudstack.platform.subsystem.api.storage.VolumeProfile;
|
||||
import org.apache.cloudstack.platform.subsystem.api.storage.VolumeStrategy;
|
||||
import org.apache.cloudstack.storage.image.ImageManager;
|
||||
import org.apache.cloudstack.storage.manager.BackupStorageManager;
|
||||
import org.apache.cloudstack.storage.manager.SecondaryStorageManager;
|
||||
import org.apache.cloudstack.storage.volume.VolumeManager;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.deploy.DeploymentPlan;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.offering.DiskOffering;
|
||||
import com.cloud.storage.DiskOfferingVO;
|
||||
import com.cloud.storage.StoragePool;
|
||||
import com.cloud.storage.Volume;
|
||||
import com.cloud.storage.VolumeVO;
|
||||
import com.cloud.storage.dao.DiskOfferingDao;
|
||||
import com.cloud.storage.dao.StoragePoolDao;
|
||||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
import com.cloud.storage.dao.VolumeDao;
|
||||
import com.cloud.storage.dao.VolumeHostDao;
|
||||
import com.cloud.template.VirtualMachineTemplate;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.fsm.NoTransitionException;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
|
||||
public class StorageOrchestratorImpl implements StorageOrchestrator {
|
||||
private static final Logger s_logger = Logger.getLogger(StorageOrchestratorImpl.class);
|
||||
@Inject
|
||||
StoragePoolDao _storagePoolDao;
|
||||
@Inject
|
||||
StorageProviderManager _spManager;
|
||||
@Inject
|
||||
VolumeDao _volumeDao;
|
||||
@Inject
|
||||
VMInstanceDao _vmDao;
|
||||
@Inject
|
||||
DiskOfferingDao _diskOfferingDao;
|
||||
@Inject
|
||||
VolumeHostDao _volumeHostDao;
|
||||
@Inject
|
||||
StorageProviderManager _storageProviderMgr;
|
||||
@Inject
|
||||
VolumeManager _volumeMgr;
|
||||
@Inject
|
||||
SecondaryStorageManager _secondaryStorageMgr;
|
||||
@Inject
|
||||
ImageManager _templateMgr;
|
||||
@Inject
|
||||
VMTemplateDao _templateDao;
|
||||
|
||||
@DB
|
||||
protected Volume copyVolumeFromBackupStorage(VolumeVO volume, DataStore destStore, String reservationId) throws NoTransitionException {
|
||||
DataStore ds = _secondaryStorageMgr.getStore(volume);
|
||||
if (!ds.contains(volume)) {
|
||||
throw new CloudRuntimeException("volume: " + volume + "doesn't exist on backup storage");
|
||||
}
|
||||
|
||||
VolumeProfile vp = ds.prepareVolume(volume, destStore);
|
||||
|
||||
VolumeStrategy vs = destStore.getVolumeStrategy();
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
volume.setReservationId(reservationId);
|
||||
_volumeMgr.processEvent(volume, Volume.Event.CopyRequested);
|
||||
VolumeVO destVolume = _volumeMgr.allocateDuplicateVolume(volume);
|
||||
destVolume = _volumeMgr.processEvent(destVolume, Volume.Event.CreateRequested);
|
||||
txn.commit();
|
||||
|
||||
vs.copyVolumeFromBackup(vp, destVolume);
|
||||
|
||||
txn.start();
|
||||
volume = _volumeMgr.processEvent(volume, Volume.Event.OperationSucceeded);
|
||||
destVolume = _volumeMgr.processEvent(destVolume, Volume.Event.OperationSucceeded);
|
||||
txn.commit();
|
||||
|
||||
return destVolume;
|
||||
}
|
||||
|
||||
@DB
|
||||
protected Volume migrateVolume(VolumeVO volume, DataStore srcStore, DataStore destStore, String reservationId) throws NoTransitionException {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
volume.setReservationId(reservationId);
|
||||
volume = _volumeMgr.processEvent(volume, Volume.Event.MigrationRequested);
|
||||
Volume destVolume = _volumeMgr.allocateDuplicateVolume(volume);
|
||||
destVolume = _volumeMgr.processEvent(destVolume, Volume.Event.CreateRequested);
|
||||
txn.commit();
|
||||
|
||||
VolumeStrategy vs = srcStore.getVolumeStrategy();
|
||||
vs.migrateVolume(volume, destVolume, destStore);
|
||||
|
||||
txn.start();
|
||||
volume = _volumeMgr.processEvent(volume, Volume.Event.OperationSucceeded);
|
||||
destVolume = _volumeMgr.processEvent(destVolume, Volume.Event.OperationSucceeded);
|
||||
txn.commit();
|
||||
|
||||
volume = _volumeMgr.processEvent(volume, Volume.Event.DestroyRequested);
|
||||
|
||||
vs.deleteVolume(volume);
|
||||
|
||||
_volumeMgr.processEvent(volume, Volume.Event.OperationSucceeded);
|
||||
return destVolume;
|
||||
}
|
||||
|
||||
@DB
|
||||
protected Volume recreateVolume(VolumeVO srcVolume, DataStore destStore, String reservationId) throws NoTransitionException {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
srcVolume.setReservationId(reservationId);
|
||||
srcVolume = _volumeMgr.processEvent(srcVolume, Volume.Event.CopyRequested);
|
||||
Volume destVolume = _volumeMgr.allocateDuplicateVolume(srcVolume);
|
||||
destVolume = _volumeMgr.processEvent(destVolume, Volume.Event.CreateRequested);
|
||||
txn.commit();
|
||||
|
||||
DataStore srcStore = _storageProviderMgr.getDataStore(srcVolume.getPoolId());
|
||||
VolumeStrategy vs = srcStore.getVolumeStrategy();
|
||||
|
||||
vs.migrateVolume(srcVolume, destVolume, destStore);
|
||||
|
||||
txn.start();
|
||||
srcVolume = _volumeMgr.processEvent(srcVolume, Volume.Event.OperationSucceeded);
|
||||
destVolume = _volumeMgr.processEvent(destVolume, Volume.Event.OperationSucceeded);
|
||||
txn.commit();
|
||||
|
||||
srcVolume = _volumeMgr.processEvent(srcVolume, Volume.Event.DestroyRequested);
|
||||
|
||||
vs.deleteVolume(srcVolume);
|
||||
|
||||
_volumeMgr.processEvent(srcVolume, Volume.Event.OperationSucceeded);
|
||||
|
||||
return destVolume;
|
||||
}
|
||||
|
||||
protected Volume createVolumeOnStorage(Volume volume, DataStore destStore, String reservationId) throws NoTransitionException {
|
||||
VolumeStrategy vs = destStore.getVolumeStrategy();
|
||||
volume.setReservationId(reservationId);
|
||||
volume = _volumeMgr.processEvent(volume, Volume.Event.CreateRequested);
|
||||
|
||||
if (volume.getTemplateId() != null) {
|
||||
DataStore ds = _secondaryStorageMgr.getImageStore(destStore);
|
||||
TemplateProfile tp = ds.prepareTemplate(volume.getTemplateId(), destStore);
|
||||
if (!destStore.contains(tp)) {
|
||||
tp = _templateMgr.AssociateTemplateStoragePool(tp, destStore);
|
||||
tp = destStore.getTemplateStrategy().install(tp);
|
||||
} else {
|
||||
tp = destStore.getTemplateStrategy().get(tp.getId());
|
||||
}
|
||||
volume = vs.createVolumeFromBaseTemplate(volume, tp);
|
||||
} else {
|
||||
volume = vs.createDataVolume(volume);
|
||||
}
|
||||
|
||||
volume = _volumeMgr.processEvent(volume, Volume.Event.OperationSucceeded);
|
||||
return volume;
|
||||
}
|
||||
|
||||
@DB
|
||||
protected void prepareVolumes(List<VolumeVO> vols, Long destPoolId, String reservationId) throws NoTransitionException {
|
||||
DataStore destStore = null;
|
||||
if (destPoolId != null) {
|
||||
destStore = _storageProviderMgr.getDataStore(destPoolId);
|
||||
}
|
||||
|
||||
for (VolumeVO volume : vols) {
|
||||
if (volume.getPoolId() == null && destStore == null) {
|
||||
throw new CloudRuntimeException("Volume has no pool associate and also no storage pool assigned in DeployDestination, Unable to create.");
|
||||
}
|
||||
if (destStore == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
DataStore srcStore = _storageProviderMgr.getDataStore(volume.getPoolId());
|
||||
boolean needToCreateVolume = false;
|
||||
boolean needToRecreateVolume = false;
|
||||
boolean needToMigrateVolume = false;
|
||||
boolean needToCopyFromSec = false;
|
||||
|
||||
Volume.State state = volume.getState();
|
||||
if (state == Volume.State.Allocated) {
|
||||
needToCreateVolume = true;
|
||||
} else if (state == Volume.State.UploadOp) {
|
||||
needToCopyFromSec = true;
|
||||
} else if (destStore.getId() != srcStore.getId()) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Mismatch in storage pool " + destStore.getId() + " assigned by deploymentPlanner and the one associated with volume " + volume);
|
||||
}
|
||||
|
||||
if (volume.isRecreatable()) {
|
||||
needToRecreateVolume = true;
|
||||
} else {
|
||||
if (Volume.Type.ROOT == volume.getVolumeType()) {
|
||||
needToMigrateVolume = true;
|
||||
} else {
|
||||
if (destStore.getCluterId() != srcStore.getCluterId()) {
|
||||
needToMigrateVolume = true;
|
||||
} else if (!srcStore.isSharedStorage() && srcStore.getId() != destStore.getId()) {
|
||||
needToMigrateVolume = true;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (needToCreateVolume) {
|
||||
createVolumeOnStorage(volume, destStore, reservationId);
|
||||
} else if (needToMigrateVolume) {
|
||||
migrateVolume(volume, srcStore, destStore, reservationId);
|
||||
} else if (needToCopyFromSec) {
|
||||
copyVolumeFromBackupStorage(volume, destStore, reservationId);
|
||||
} else if (needToRecreateVolume) {
|
||||
recreateVolume(volume, destStore, reservationId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void prepare(long vmId, DeploymentPlan plan, String reservationId) {
|
||||
VirtualMachine vm = _vmDao.findById(vmId);
|
||||
|
||||
|
||||
List<VolumeVO> vols = _volumeDao.findUsableVolumesForInstance(vm.getId());
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Prepare " + vols.size() + " volumes for " + vm.getInstanceName());
|
||||
}
|
||||
|
||||
try {
|
||||
prepareVolumes(vols, plan.getPoolId(), reservationId);
|
||||
} catch (NoTransitionException e) {
|
||||
s_logger.debug("Failed to prepare volume: " + e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void release(long vmId, String reservationId) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void destroy(List<Long> disks, String reservationId) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void cancel(String reservationId) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void prepareAttachDiskToVM(long diskId, long vmId, String reservationId) {
|
||||
VirtualMachine vm = _vmDao.findById(vmId);
|
||||
|
||||
if (vm == null || vm.getState() != VirtualMachine.State.Running) {
|
||||
return;
|
||||
}
|
||||
|
||||
VolumeVO volume = _volumeDao.findById(diskId);
|
||||
if (volume.getInstanceId() != null) {
|
||||
if (volume.getInstanceId() != vmId) {
|
||||
throw new InvalidParameterValueException("Volume " + volume + "already attached to " + volume.getInstanceId());
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
List<VolumeVO> vols = new ArrayList<VolumeVO>();
|
||||
vols.add(volume);
|
||||
|
||||
List<VolumeVO> rootDisks = _volumeDao.findByInstanceAndType(vmId, Volume.Type.ROOT);
|
||||
VolumeVO rootDisk = rootDisks.get(0);
|
||||
try {
|
||||
prepareVolumes(vols, rootDisk.getPoolId(), reservationId);
|
||||
} catch (NoTransitionException e) {
|
||||
s_logger.debug("Failed to prepare volume: " + volume + ", due to" + e.toString());
|
||||
throw new CloudRuntimeException(e.toString());
|
||||
}
|
||||
|
||||
volume = _volumeDao.findById(diskId);
|
||||
volume.setInstanceId(vmId);
|
||||
_volumeDao.update(volume.getId(), volume);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package org.apache.cloudstack.storage;
|
||||
|
||||
import org.apache.cloudstack.platform.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.platform.subsystem.api.storage.StorageProvider;
|
||||
|
||||
public interface StorageProviderManager {
|
||||
StorageProvider getProvider(String uuid);
|
||||
StorageProvider getProvider(long poolId);
|
||||
StorageProvider getBackupStorageProvider(long zoneId);
|
||||
DataStore getDataStore(long poolId);
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
package org.apache.cloudstack.storage;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.cloudstack.platform.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.platform.subsystem.api.storage.StorageProvider;
|
||||
|
||||
import com.cloud.utils.component.Manager;
|
||||
|
||||
public class StorageProviderManagerImpl implements StorageProviderManager, Manager {
|
||||
|
||||
public StorageProvider getProvider(String uuid) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean configure(String name, Map<String, Object> params)
|
||||
throws ConfigurationException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean start() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean stop() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public StorageProvider getProvider(long poolId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public StorageProvider getBackupStorageProvider(long zoneId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public DataStore getDataStore(long poolId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.cloudstack.platform.subsystem.api.storage.DataObjectBackupStorageOperationState;
|
||||
|
||||
import com.cloud.storage.Storage;
|
||||
import com.cloud.storage.VMTemplateStorageResourceAssoc;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
||||
|
||||
public interface VolumeBackupRef {
|
||||
public DataObjectBackupStorageOperationState getOperationState();
|
||||
|
||||
public String getInstallPath();
|
||||
|
||||
public long getHostId();
|
||||
|
||||
public long getVolumeId();
|
||||
|
||||
public long getZoneId();
|
||||
|
||||
public int getDownloadPercent();
|
||||
|
||||
public long getVolumeSize();
|
||||
|
||||
public Storage.ImageFormat getFormat();
|
||||
|
||||
public String getDownloadUrl();
|
||||
|
||||
public boolean getDestroyed();
|
||||
|
||||
public long getPhysicalSize();
|
||||
|
||||
public long getSize();
|
||||
|
||||
public String getLocalDownloadPath();
|
||||
|
||||
public String getChecksum();
|
||||
|
||||
public Status getDownloadState();
|
||||
|
||||
public Date getLastUpdated();
|
||||
|
||||
public Date getCreated();
|
||||
|
||||
public long getId();
|
||||
}
|
||||
@ -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.backup;
|
||||
|
||||
public interface BackupMotionService {
|
||||
boolean copySnapshot(String snapshotUri, String destSnapshotUri);
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* 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.backup;
|
||||
|
||||
public interface BackupService {
|
||||
String grantAccessSnapshot(long snapshotId, long endpointId);
|
||||
boolean revokeAccessSnapshot(long snapshotId, long endpointId);
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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.command;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
|
||||
public class CreateVolumeAnswer extends Answer {
|
||||
private String volumeUuid;
|
||||
protected CreateVolumeAnswer() {
|
||||
super();
|
||||
}
|
||||
|
||||
public CreateVolumeAnswer(String volumeUuid) {
|
||||
this.volumeUuid = volumeUuid;
|
||||
}
|
||||
|
||||
public String getVolumeUuid() {
|
||||
return this.volumeUuid;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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.command;
|
||||
|
||||
import org.apache.cloudstack.storage.volume.VolumeInfo;
|
||||
|
||||
import com.cloud.agent.api.Command;
|
||||
|
||||
public class CreateVolumeCommand extends Command {
|
||||
protected VolumeInfo volumeInfo;
|
||||
public CreateVolumeCommand(VolumeInfo volumeInfo) {
|
||||
super();
|
||||
this.volumeInfo = volumeInfo;
|
||||
}
|
||||
|
||||
protected CreateVolumeCommand() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean executeInSequence() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
public enum DataStoreStatus {
|
||||
Creating,
|
||||
Up,
|
||||
PrepareForMaintenance,
|
||||
ErrorInMaintenance,
|
||||
CancelMaintenance,
|
||||
Maintenance,
|
||||
Removed;
|
||||
}
|
||||
@ -0,0 +1,229 @@
|
||||
package org.apache.cloudstack.storage.datastore;
|
||||
|
||||
import org.apache.cloudstack.platform.subsystem.api.storage.BackupStrategy;
|
||||
import org.apache.cloudstack.platform.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.platform.subsystem.api.storage.DataStoreDriver;
|
||||
import org.apache.cloudstack.platform.subsystem.api.storage.DataStoreEndPointSelector;
|
||||
import org.apache.cloudstack.platform.subsystem.api.storage.DataStoreLifeCycle;
|
||||
import org.apache.cloudstack.platform.subsystem.api.storage.FileSystem;
|
||||
import org.apache.cloudstack.platform.subsystem.api.storage.SnapshotProfile;
|
||||
import org.apache.cloudstack.platform.subsystem.api.storage.SnapshotStrategy;
|
||||
import org.apache.cloudstack.platform.subsystem.api.storage.StorageProvider;
|
||||
import org.apache.cloudstack.platform.subsystem.api.storage.TemplateProfile;
|
||||
import org.apache.cloudstack.platform.subsystem.api.storage.TemplateStrategy;
|
||||
import org.apache.cloudstack.platform.subsystem.api.storage.VolumeProfile;
|
||||
import org.apache.cloudstack.platform.subsystem.api.storage.VolumeStrategy;
|
||||
|
||||
import com.cloud.agent.api.to.StorageFilerTO;
|
||||
import com.cloud.storage.Snapshot;
|
||||
import com.cloud.storage.Storage.StoragePoolType;
|
||||
import com.cloud.storage.Volume;
|
||||
|
||||
public class DefaultDataStore implements DataStore {
|
||||
protected VolumeStrategy _volumeStrategy;
|
||||
protected SnapshotStrategy _snapshotStrategy;
|
||||
protected BackupStrategy _backupStrategy;
|
||||
protected TemplateStrategy _templateStrategy;
|
||||
protected String _uri;
|
||||
protected String _uuid;
|
||||
protected StoreType _type;
|
||||
protected StoreScope _scope;
|
||||
protected long _poolId;
|
||||
protected DataStoreDriver _driverRef;
|
||||
protected DataStoreEndPointSelector _selector;
|
||||
protected FileSystem _fs;
|
||||
protected VolumeStrategy _volumeSt;
|
||||
protected SnapshotStrategy _snapshotSt;
|
||||
protected BackupStrategy _backupSt;
|
||||
protected long _id;
|
||||
protected DataStoreLifeCycle _dslf;
|
||||
|
||||
public DefaultDataStore(
|
||||
) {
|
||||
}
|
||||
|
||||
public String getURI() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setURI(String uri) {
|
||||
this._uri = uri;
|
||||
}
|
||||
|
||||
public String getUUID() {
|
||||
return this._uuid;
|
||||
}
|
||||
|
||||
public void setUUID(String uuid) {
|
||||
this._uuid = uuid;
|
||||
}
|
||||
|
||||
public StoreType getType() {
|
||||
return this._type;
|
||||
}
|
||||
|
||||
public void setType(StoreType type) {
|
||||
this._type = type;
|
||||
}
|
||||
|
||||
public StoreScope getScope() {
|
||||
return this._scope;
|
||||
}
|
||||
|
||||
public void setScope(StoreScope scope) {
|
||||
this._scope = scope;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return this._id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this._id = id;
|
||||
}
|
||||
|
||||
public DataStoreDriver getDataStoreDriver() {
|
||||
return this._driverRef;
|
||||
}
|
||||
|
||||
public void setDataStoreDriver(DataStoreDriver drv) {
|
||||
this._driverRef = drv;
|
||||
}
|
||||
|
||||
public void setEndPointSelector(DataStoreEndPointSelector selector) {
|
||||
this._selector = selector;
|
||||
}
|
||||
|
||||
public DataStoreEndPointSelector getSelector() {
|
||||
return this._selector;
|
||||
}
|
||||
|
||||
public FileSystem getFileSystem() {
|
||||
return this._fs;
|
||||
}
|
||||
|
||||
public void setFileSystem(FileSystem fs) {
|
||||
this._fs = fs;
|
||||
}
|
||||
|
||||
public VolumeStrategy getVolumeStrategy() {
|
||||
return this._volumeSt;
|
||||
}
|
||||
|
||||
public void setVolumeStrategy(VolumeStrategy vs) {
|
||||
this._volumeSt = vs;
|
||||
}
|
||||
|
||||
public SnapshotStrategy getSnapshotStrategy() {
|
||||
return this._snapshotSt;
|
||||
}
|
||||
|
||||
public void setSnapshotStrategy(SnapshotStrategy ss) {
|
||||
this._snapshotSt = ss;
|
||||
}
|
||||
|
||||
public BackupStrategy getBackupStrategy() {
|
||||
return this._backupSt;
|
||||
}
|
||||
|
||||
public void setBackupStrategy(BackupStrategy bs) {
|
||||
this._backupSt = bs;
|
||||
}
|
||||
|
||||
public TemplateStrategy getTemplateStrategy() {
|
||||
return this._templateStrategy;
|
||||
}
|
||||
|
||||
public void setTemplateStrategy(TemplateStrategy ts) {
|
||||
this._templateStrategy = ts;
|
||||
}
|
||||
|
||||
public DataStoreLifeCycle getLifeCycle() {
|
||||
return this._dslf;
|
||||
}
|
||||
|
||||
public void setLifeCycle(DataStoreLifeCycle lf) {
|
||||
this._dslf = lf;
|
||||
}
|
||||
|
||||
public long getCluterId() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long getPodId() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long getZoneId() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public StoragePoolType getPoolType() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isSharedStorage() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
public StorageProvider getProvider() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public DataStoreEndPointSelector getEndPointSelector() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public VolumeProfile prepareVolume(Volume volume, DataStore destStore) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public SnapshotProfile prepareSnapshot(Snapshot snapshot, DataStore destStore) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public TemplateProfile prepareTemplate(long templateId, DataStore destStore) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean contains(Volume volume) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean contains(Snapshot snapshot) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean contains(TemplateProfile template) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
public TemplateProfile get(TemplateProfile template) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public StorageFilerTO getTO() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,118 @@
|
||||
package org.apache.cloudstack.storage.datastore;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.storage.EndPoint;
|
||||
import org.apache.cloudstack.storage.HypervisorHostEndPoint;
|
||||
import org.apache.cloudstack.storage.datastore.db.DataStoreVO;
|
||||
import org.apache.cloudstack.storage.datastore.driver.PrimaryDataStoreDriver;
|
||||
import org.apache.cloudstack.storage.volume.Volume;
|
||||
import org.apache.cloudstack.storage.volume.VolumeEvent;
|
||||
import org.apache.cloudstack.storage.volume.db.VolumeDao;
|
||||
import org.apache.cloudstack.storage.volume.db.VolumeVO;
|
||||
import org.apache.cloudstack.storage.volume.disktype.VolumeDiskType;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.utils.component.ComponentInject;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
import edu.emory.mathcs.backport.java.util.Collections;
|
||||
|
||||
public class DefaultPrimaryDataStoreImpl implements PrimaryDataStore {
|
||||
private static final Logger s_logger = Logger.getLogger(DefaultPrimaryDataStoreImpl.class);
|
||||
protected PrimaryDataStoreDriver driver;
|
||||
protected DataStoreVO pdsv;
|
||||
protected PrimaryDataStoreInfo pdsInfo;
|
||||
@Inject
|
||||
private VolumeDao volumeDao;
|
||||
@Inject
|
||||
private HostDao hostDao;
|
||||
public DefaultPrimaryDataStoreImpl(PrimaryDataStoreDriver driver, DataStoreVO pdsv, PrimaryDataStoreInfo pdsInfo) {
|
||||
this.driver = driver;
|
||||
this.pdsv = pdsv;
|
||||
this.pdsInfo = pdsInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Volume getVolume(long id) {
|
||||
VolumeVO volumeVO = volumeDao.findById(id);
|
||||
Volume vol = new Volume(this, volumeVO);
|
||||
return vol;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Volume> getVolumes() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteVolume(long id) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Volume createVolume(long id, VolumeDiskType diskType) {
|
||||
Volume vol = this.getVolume(id);
|
||||
if (vol == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!pdsInfo.isVolumeDiskTypeSupported(diskType)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
boolean result = vol.stateTransit(VolumeEvent.CreateRequested);
|
||||
if (!result) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
vol.setVolumeDiskType(diskType);
|
||||
result = this.driver.createVolume(vol);
|
||||
vol.update();
|
||||
return vol;
|
||||
} catch (Exception e) {
|
||||
result = false;
|
||||
s_logger.debug("Failed to create volume: " + e.toString());
|
||||
throw new CloudRuntimeException(e.toString());
|
||||
} finally {
|
||||
if (result == true) {
|
||||
vol.stateTransit(VolumeEvent.OperationSucceeded);
|
||||
} else {
|
||||
vol.stateTransit(VolumeEvent.OperationFailed);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EndPoint> getEndPoints() {
|
||||
Long clusterId = pdsv.getClusterId();
|
||||
if (clusterId == null) {
|
||||
return null;
|
||||
}
|
||||
List<EndPoint> endpoints = new ArrayList<EndPoint>();
|
||||
List<HostVO> hosts = hostDao.findHypervisorHostInCluster(clusterId);
|
||||
for (HostVO host : hosts) {
|
||||
HypervisorHostEndPoint ep = new HypervisorHostEndPoint(host.getId());
|
||||
ComponentInject.inject(ep);
|
||||
endpoints.add(ep);
|
||||
}
|
||||
Collections.shuffle(endpoints);
|
||||
return endpoints;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrimaryDataStoreInfo getDataStoreInfo() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.storage.EndPoint;
|
||||
import org.apache.cloudstack.storage.volume.Volume;
|
||||
import org.apache.cloudstack.storage.volume.disktype.VolumeDiskType;
|
||||
|
||||
public interface PrimaryDataStore {
|
||||
Volume getVolume(long id);
|
||||
List<Volume> getVolumes();
|
||||
boolean deleteVolume(long id);
|
||||
Volume createVolume(long id, VolumeDiskType diskType);
|
||||
List<EndPoint> getEndPoints();
|
||||
PrimaryDataStoreInfo getDataStoreInfo();
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import org.apache.cloudstack.storage.volume.disktype.VolumeDiskType;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
|
||||
public interface PrimaryDataStoreInfo {
|
||||
public boolean isHypervisorSupported(HypervisorType hypervisor);
|
||||
public boolean isLocalStorageSupported();
|
||||
public boolean isVolumeDiskTypeSupported(VolumeDiskType diskType);
|
||||
public long getCapacity();
|
||||
public long getAvailableCapacity();
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.storage.datastore.db.DataStoreVO;
|
||||
import org.apache.cloudstack.storage.volume.disktype.VolumeDiskType;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
|
||||
public class PrimaryDataStoreInfoImpl implements PrimaryDataStoreInfo {
|
||||
protected List<HypervisorType> supportedHypervs;
|
||||
protected List<VolumeDiskType> supportedDiskTypes;
|
||||
protected long caapcity;
|
||||
protected long avail;
|
||||
protected boolean localStorage;
|
||||
|
||||
public PrimaryDataStoreInfoImpl(List<HypervisorType> hypers, List<VolumeDiskType> diskTypes,
|
||||
long capacity, long avail, boolean localStorage) {
|
||||
this.avail = avail;
|
||||
this.caapcity = capacity;
|
||||
this.localStorage = localStorage;
|
||||
this.supportedDiskTypes = diskTypes;
|
||||
this.supportedHypervs = hypers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHypervisorSupported(HypervisorType hypervisor) {
|
||||
return this.supportedHypervs.contains(hypervisor) ? true : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLocalStorageSupported() {
|
||||
return this.localStorage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVolumeDiskTypeSupported(VolumeDiskType diskType) {
|
||||
return this.supportedDiskTypes.contains(diskType) ? true : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCapacity() {
|
||||
return this.caapcity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAvailableCapacity() {
|
||||
return this.avail;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,258 @@
|
||||
/*
|
||||
* 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.db;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.TableGenerator;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import org.apache.cloudstack.storage.datastore.DataStoreStatus;
|
||||
|
||||
import com.cloud.api.Identity;
|
||||
import com.cloud.storage.Storage.StoragePoolType;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
@Entity
|
||||
@Table(name="storage_pool")
|
||||
public class DataStoreVO implements Identity {
|
||||
@Id
|
||||
@TableGenerator(name="storage_pool_sq", table="sequence", pkColumnName="name", valueColumnName="value", pkColumnValue="storage_pool_seq", allocationSize=1)
|
||||
@Column(name="id", updatable=false, nullable = false)
|
||||
private long id;
|
||||
|
||||
@Column(name="name", updatable=false, nullable=false, length=255)
|
||||
private String name = null;
|
||||
|
||||
@Column(name="uuid", length=255)
|
||||
private String uuid = null;
|
||||
|
||||
@Column(name="pool_type", updatable=false, nullable=false, length=32)
|
||||
private String protocol;
|
||||
|
||||
@Column(name=GenericDao.CREATED_COLUMN)
|
||||
Date created;
|
||||
|
||||
@Column(name=GenericDao.REMOVED_COLUMN)
|
||||
private Date removed;
|
||||
|
||||
@Column(name="update_time", updatable=true)
|
||||
@Temporal(value=TemporalType.TIMESTAMP)
|
||||
private Date updateTime;
|
||||
|
||||
@Column(name="data_center_id", updatable=true, nullable=false)
|
||||
private long dataCenterId;
|
||||
|
||||
@Column(name="pod_id", updatable=true)
|
||||
private Long podId;
|
||||
|
||||
@Column(name="available_bytes", updatable=true, nullable=true)
|
||||
private long availableBytes;
|
||||
|
||||
@Column(name="capacity_bytes", updatable=true, nullable=true)
|
||||
private long capacityBytes;
|
||||
|
||||
@Column(name="status", updatable=true, nullable=false)
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
private DataStoreStatus status;
|
||||
|
||||
@Column(name="storage_provider", updatable=true, nullable=false)
|
||||
private Long storageProvider;
|
||||
|
||||
@Column(name="storage_type", nullable=false)
|
||||
private String storageType;
|
||||
|
||||
@Column(name="host_address")
|
||||
private String hostAddress;
|
||||
|
||||
@Column(name="path")
|
||||
private String path;
|
||||
|
||||
@Column(name="port")
|
||||
private int port;
|
||||
|
||||
@Column(name="user_info")
|
||||
private String userInfo;
|
||||
|
||||
@Column(name="cluster_id")
|
||||
private Long clusterId;
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public DataStoreStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public DataStoreVO() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
|
||||
public String getPoolType() {
|
||||
return protocol;
|
||||
}
|
||||
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public Date getRemoved() {
|
||||
return removed;
|
||||
}
|
||||
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public long getDataCenterId() {
|
||||
return dataCenterId;
|
||||
}
|
||||
|
||||
public long getAvailableBytes() {
|
||||
return availableBytes;
|
||||
}
|
||||
|
||||
public Long getStorageProviderId() {
|
||||
return storageProvider;
|
||||
}
|
||||
|
||||
public void setStorageProviderId(Long provider) {
|
||||
storageProvider = provider;
|
||||
}
|
||||
|
||||
public String getStorageType() {
|
||||
return storageType;
|
||||
}
|
||||
|
||||
public void setStorageType(String type) {
|
||||
storageType = type;
|
||||
}
|
||||
|
||||
public long getCapacityBytes() {
|
||||
return capacityBytes;
|
||||
}
|
||||
|
||||
public void setAvailableBytes(long available) {
|
||||
availableBytes = available;
|
||||
}
|
||||
|
||||
public void setCapacityBytes(long capacity) {
|
||||
capacityBytes = capacity;
|
||||
}
|
||||
|
||||
|
||||
public Long getClusterId() {
|
||||
return clusterId;
|
||||
}
|
||||
|
||||
public void setClusterId(Long clusterId) {
|
||||
this.clusterId = clusterId;
|
||||
}
|
||||
|
||||
public String getHostAddress() {
|
||||
return hostAddress;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public String getUserInfo() {
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
public void setStatus(DataStoreStatus status)
|
||||
{
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setDataCenterId(long dcId) {
|
||||
this.dataCenterId = dcId;
|
||||
}
|
||||
|
||||
public void setPodId(Long podId) {
|
||||
this.podId = podId;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public void setUserInfo(String userInfo) {
|
||||
this.userInfo = userInfo;
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public Long getPodId() {
|
||||
return podId;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof DataStoreVO) || obj == null) {
|
||||
return false;
|
||||
}
|
||||
DataStoreVO that = (DataStoreVO)obj;
|
||||
return this.id == that.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return new Long(id).hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new StringBuilder("Pool[").append(id).append("|").append(protocol).append("]").toString();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,106 @@
|
||||
/*
|
||||
* 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.db;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.cloudstack.storage.datastore.DataStoreStatus;
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
|
||||
public interface PrimaryDataStoreDao extends GenericDao<DataStoreVO, Long> {
|
||||
|
||||
/**
|
||||
* @param datacenterId -- the id of the datacenter (availability zone)
|
||||
*/
|
||||
List<DataStoreVO> listByDataCenterId(long datacenterId);
|
||||
|
||||
/**
|
||||
* @param datacenterId -- the id of the datacenter (availability zone)
|
||||
*/
|
||||
List<DataStoreVO> listBy(long datacenterId, long podId, Long clusterId);
|
||||
|
||||
/**
|
||||
* Set capacity of storage pool in bytes
|
||||
* @param id pool id.
|
||||
* @param capacity capacity in bytes
|
||||
*/
|
||||
void updateCapacity(long id, long capacity);
|
||||
|
||||
/**
|
||||
* Set available bytes of storage pool in bytes
|
||||
* @param id pool id.
|
||||
* @param available available capacity in bytes
|
||||
*/
|
||||
void updateAvailable(long id, long available);
|
||||
|
||||
|
||||
DataStoreVO persist(DataStoreVO pool, Map<String, String> details);
|
||||
|
||||
/**
|
||||
* Find pool by name.
|
||||
*
|
||||
* @param name name of pool.
|
||||
* @return the single StoragePoolVO
|
||||
*/
|
||||
List<DataStoreVO> findPoolByName(String name);
|
||||
|
||||
/**
|
||||
* Find pools by the pod that matches the details.
|
||||
*
|
||||
* @param podId pod id to find the pools in.
|
||||
* @param details details to match. All must match for the pool to be returned.
|
||||
* @return List of StoragePoolVO
|
||||
*/
|
||||
List<DataStoreVO> findPoolsByDetails(long dcId, long podId, Long clusterId, Map<String, String> details);
|
||||
|
||||
List<DataStoreVO> findPoolsByTags(long dcId, long podId, Long clusterId, String[] tags, Boolean shared);
|
||||
|
||||
/**
|
||||
* Find pool by UUID.
|
||||
*
|
||||
* @param uuid uuid of pool.
|
||||
* @return the single StoragePoolVO
|
||||
*/
|
||||
DataStoreVO findPoolByUUID(String uuid);
|
||||
|
||||
List<DataStoreVO> listByStorageHost(String hostFqdnOrIp);
|
||||
|
||||
DataStoreVO findPoolByHostPath(long dcId, Long podId, String host, String path, String uuid);
|
||||
|
||||
List<DataStoreVO> listPoolByHostPath(String host, String path);
|
||||
|
||||
void updateDetails(long poolId, Map<String, String> details);
|
||||
|
||||
Map<String, String> getDetails(long poolId);
|
||||
|
||||
List<String> searchForStoragePoolDetails(long poolId, String value);
|
||||
|
||||
List<DataStoreVO> findIfDuplicatePoolsExistByUUID(String uuid);
|
||||
|
||||
List<DataStoreVO> listByStatus(DataStoreStatus status);
|
||||
|
||||
long countPoolsByStatus(DataStoreStatus... statuses);
|
||||
|
||||
List<DataStoreVO> listByStatusInZone(long dcId, DataStoreStatus status);
|
||||
|
||||
List<DataStoreVO> listPoolsByCluster(long clusterId);
|
||||
}
|
||||
@ -0,0 +1,377 @@
|
||||
/*
|
||||
* 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.db;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.cloudstack.storage.datastore.DataStoreStatus;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.storage.StoragePoolDetailVO;
|
||||
import com.cloud.storage.dao.StoragePoolDetailsDao;
|
||||
import com.cloud.storage.dao.StoragePoolDetailsDaoImpl;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.GenericSearchBuilder;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.SearchCriteria.Func;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
@Component
|
||||
public class PrimaryDataStoreDaoImpl extends GenericDaoBase<DataStoreVO, Long> implements PrimaryDataStoreDao {
|
||||
protected final SearchBuilder<DataStoreVO> AllFieldSearch;
|
||||
protected final SearchBuilder<DataStoreVO> DcPodSearch;
|
||||
protected final SearchBuilder<DataStoreVO> DcPodAnyClusterSearch;
|
||||
protected final SearchBuilder<DataStoreVO> DeleteLvmSearch;
|
||||
protected final GenericSearchBuilder<DataStoreVO, Long> StatusCountSearch;
|
||||
|
||||
|
||||
|
||||
protected final StoragePoolDetailsDao _detailsDao;
|
||||
|
||||
private final String DetailsSqlPrefix = "SELECT storage_pool.* from storage_pool LEFT JOIN storage_pool_details ON storage_pool.id = storage_pool_details.pool_id WHERE storage_pool.removed is null and storage_pool.data_center_id = ? and (storage_pool.pod_id = ? or storage_pool.pod_id is null) and (";
|
||||
private final String DetailsSqlSuffix = ") GROUP BY storage_pool_details.pool_id HAVING COUNT(storage_pool_details.name) >= ?";
|
||||
private final String FindPoolTagDetails = "SELECT storage_pool_details.name FROM storage_pool_details WHERE pool_id = ? and value = ?";
|
||||
|
||||
protected PrimaryDataStoreDaoImpl() {
|
||||
AllFieldSearch = createSearchBuilder();
|
||||
AllFieldSearch.and("name", AllFieldSearch.entity().getName(), SearchCriteria.Op.EQ);
|
||||
AllFieldSearch.and("uuid", AllFieldSearch.entity().getUuid(), SearchCriteria.Op.EQ);
|
||||
AllFieldSearch.and("datacenterId", AllFieldSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||
AllFieldSearch.and("hostAddress", AllFieldSearch.entity().getHostAddress(), SearchCriteria.Op.EQ);
|
||||
AllFieldSearch.and("status",AllFieldSearch.entity().getStatus(),SearchCriteria.Op.EQ);
|
||||
AllFieldSearch.and("path", AllFieldSearch.entity().getPath(), SearchCriteria.Op.EQ);
|
||||
AllFieldSearch.and("podId", AllFieldSearch.entity().getPodId(), Op.EQ);
|
||||
AllFieldSearch.and("clusterId", AllFieldSearch.entity().getClusterId(), Op.EQ);
|
||||
AllFieldSearch.done();
|
||||
|
||||
DcPodSearch = createSearchBuilder();
|
||||
DcPodSearch.and("datacenterId", DcPodSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||
DcPodSearch.and().op("nullpod", DcPodSearch.entity().getPodId(), SearchCriteria.Op.NULL);
|
||||
DcPodSearch.or("podId", DcPodSearch.entity().getPodId(), SearchCriteria.Op.EQ);
|
||||
DcPodSearch.cp();
|
||||
DcPodSearch.and().op("nullcluster", DcPodSearch.entity().getClusterId(), SearchCriteria.Op.NULL);
|
||||
DcPodSearch.or("cluster", DcPodSearch.entity().getClusterId(), SearchCriteria.Op.EQ);
|
||||
DcPodSearch.cp();
|
||||
DcPodSearch.done();
|
||||
|
||||
DcPodAnyClusterSearch = createSearchBuilder();
|
||||
DcPodAnyClusterSearch.and("datacenterId", DcPodAnyClusterSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||
DcPodAnyClusterSearch.and().op("nullpod", DcPodAnyClusterSearch.entity().getPodId(), SearchCriteria.Op.NULL);
|
||||
DcPodAnyClusterSearch.or("podId", DcPodAnyClusterSearch.entity().getPodId(), SearchCriteria.Op.EQ);
|
||||
DcPodAnyClusterSearch.cp();
|
||||
DcPodAnyClusterSearch.done();
|
||||
|
||||
DeleteLvmSearch = createSearchBuilder();
|
||||
DeleteLvmSearch.and("ids", DeleteLvmSearch.entity().getId(), SearchCriteria.Op.IN);
|
||||
DeleteLvmSearch.and().op("LVM", DeleteLvmSearch.entity().getPoolType(), SearchCriteria.Op.EQ);
|
||||
DeleteLvmSearch.or("Filesystem", DeleteLvmSearch.entity().getPoolType(), SearchCriteria.Op.EQ);
|
||||
DeleteLvmSearch.cp();
|
||||
DeleteLvmSearch.done();
|
||||
|
||||
|
||||
|
||||
StatusCountSearch = createSearchBuilder(Long.class);
|
||||
StatusCountSearch.and("status", StatusCountSearch.entity().getStatus(), SearchCriteria.Op.IN);
|
||||
StatusCountSearch.select(null, Func.COUNT, null);
|
||||
StatusCountSearch.done();
|
||||
|
||||
_detailsDao = ComponentLocator.inject(StoragePoolDetailsDaoImpl.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataStoreVO> findPoolByName(String name) {
|
||||
SearchCriteria<DataStoreVO> sc = AllFieldSearch.create();
|
||||
sc.setParameters("name", name);
|
||||
return listIncludingRemovedBy(sc);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public DataStoreVO findPoolByUUID(String uuid) {
|
||||
SearchCriteria<DataStoreVO> sc = AllFieldSearch.create();
|
||||
sc.setParameters("uuid", uuid);
|
||||
return findOneIncludingRemovedBy(sc);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<DataStoreVO> findIfDuplicatePoolsExistByUUID(String uuid) {
|
||||
SearchCriteria<DataStoreVO> sc = AllFieldSearch.create();
|
||||
sc.setParameters("uuid", uuid);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<DataStoreVO> listByDataCenterId(long datacenterId) {
|
||||
SearchCriteria<DataStoreVO> sc = AllFieldSearch.create();
|
||||
sc.setParameters("datacenterId", datacenterId);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateAvailable(long id, long available) {
|
||||
DataStoreVO pool = createForUpdate(id);
|
||||
pool.setAvailableBytes(available);
|
||||
update(id, pool);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateCapacity(long id, long capacity) {
|
||||
DataStoreVO pool = createForUpdate(id);
|
||||
pool.setCapacityBytes(capacity);
|
||||
update(id, pool);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataStoreVO> listByStorageHost(String hostFqdnOrIp) {
|
||||
SearchCriteria<DataStoreVO> sc = AllFieldSearch.create();
|
||||
sc.setParameters("hostAddress", hostFqdnOrIp);
|
||||
return listIncludingRemovedBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataStoreVO> listByStatus(DataStoreStatus status){
|
||||
SearchCriteria<DataStoreVO> sc = AllFieldSearch.create();
|
||||
sc.setParameters("status", status);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataStoreVO> listByStatusInZone(long dcId, DataStoreStatus status){
|
||||
SearchCriteria<DataStoreVO> sc = AllFieldSearch.create();
|
||||
sc.setParameters("status", status);
|
||||
sc.setParameters("datacenterId", dcId);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataStoreVO findPoolByHostPath(long datacenterId, Long podId, String host, String path, String uuid) {
|
||||
SearchCriteria<DataStoreVO> sc = AllFieldSearch.create();
|
||||
sc.setParameters("hostAddress", host);
|
||||
sc.setParameters("path", path);
|
||||
sc.setParameters("datacenterId", datacenterId);
|
||||
sc.setParameters("podId", podId);
|
||||
sc.setParameters("uuid", uuid);
|
||||
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataStoreVO> listBy(long datacenterId, long podId, Long clusterId) {
|
||||
if (clusterId != null) {
|
||||
SearchCriteria<DataStoreVO> sc = DcPodSearch.create();
|
||||
sc.setParameters("datacenterId", datacenterId);
|
||||
sc.setParameters("podId", podId);
|
||||
|
||||
sc.setParameters("cluster", clusterId);
|
||||
return listBy(sc);
|
||||
} else {
|
||||
SearchCriteria<DataStoreVO> sc = DcPodAnyClusterSearch.create();
|
||||
sc.setParameters("datacenterId", datacenterId);
|
||||
sc.setParameters("podId", podId);
|
||||
return listBy(sc);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataStoreVO> listPoolByHostPath(String host, String path) {
|
||||
SearchCriteria<DataStoreVO> sc = AllFieldSearch.create();
|
||||
sc.setParameters("hostAddress", host);
|
||||
sc.setParameters("path", path);
|
||||
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
public DataStoreVO listById(Integer id)
|
||||
{
|
||||
SearchCriteria<DataStoreVO> sc = AllFieldSearch.create();
|
||||
sc.setParameters("id", id);
|
||||
|
||||
return findOneIncludingRemovedBy(sc);
|
||||
}
|
||||
|
||||
@Override @DB
|
||||
public DataStoreVO persist(DataStoreVO pool, Map<String, String> details) {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
pool = super.persist(pool);
|
||||
if (details != null) {
|
||||
for (Map.Entry<String, String> detail : details.entrySet()) {
|
||||
StoragePoolDetailVO vo = new StoragePoolDetailVO(pool.getId(), detail.getKey(), detail.getValue());
|
||||
_detailsDao.persist(vo);
|
||||
}
|
||||
}
|
||||
txn.commit();
|
||||
return pool;
|
||||
}
|
||||
|
||||
@DB
|
||||
@Override
|
||||
public List<DataStoreVO> findPoolsByDetails(long dcId, long podId, Long clusterId, Map<String, String> details) {
|
||||
StringBuilder sql = new StringBuilder(DetailsSqlPrefix);
|
||||
if (clusterId != null) {
|
||||
sql.append("storage_pool.cluster_id = ? OR storage_pool.cluster_id IS NULL) AND (");
|
||||
}
|
||||
for (Map.Entry<String, String> detail : details.entrySet()) {
|
||||
sql.append("((storage_pool_details.name='").append(detail.getKey()).append("') AND (storage_pool_details.value='").append(detail.getValue()).append("')) OR ");
|
||||
}
|
||||
sql.delete(sql.length() - 4, sql.length());
|
||||
sql.append(DetailsSqlSuffix);
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
PreparedStatement pstmt = null;
|
||||
try {
|
||||
pstmt = txn.prepareAutoCloseStatement(sql.toString());
|
||||
int i = 1;
|
||||
pstmt.setLong(i++, dcId);
|
||||
pstmt.setLong(i++, podId);
|
||||
if (clusterId != null) {
|
||||
pstmt.setLong(i++, clusterId);
|
||||
}
|
||||
pstmt.setInt(i++, details.size());
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
List<DataStoreVO> pools = new ArrayList<DataStoreVO>();
|
||||
while (rs.next()) {
|
||||
pools.add(toEntityBean(rs, false));
|
||||
}
|
||||
return pools;
|
||||
} catch (SQLException e) {
|
||||
throw new CloudRuntimeException("Unable to execute " + pstmt, e);
|
||||
}
|
||||
}
|
||||
|
||||
protected Map<String, String> tagsToDetails(String[] tags) {
|
||||
Map<String, String> details = new HashMap<String, String>(tags.length);
|
||||
for (String tag: tags) {
|
||||
details.put(tag, "true");
|
||||
}
|
||||
return details;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataStoreVO> findPoolsByTags(long dcId, long podId, Long clusterId, String[] tags, Boolean shared) {
|
||||
List<DataStoreVO> storagePools = null;
|
||||
if (tags == null || tags.length == 0) {
|
||||
storagePools = listBy(dcId, podId, clusterId);
|
||||
} else {
|
||||
Map<String, String> details = tagsToDetails(tags);
|
||||
storagePools = findPoolsByDetails(dcId, podId, clusterId, details);
|
||||
}
|
||||
|
||||
if (shared == null) {
|
||||
return storagePools;
|
||||
} else {
|
||||
List<DataStoreVO> filteredStoragePools = new ArrayList<DataStoreVO>(storagePools);
|
||||
for (DataStoreVO pool : storagePools) {
|
||||
/*
|
||||
if (shared != pool.isShared()) {
|
||||
filteredStoragePools.remove(pool);
|
||||
}*/
|
||||
}
|
||||
|
||||
return filteredStoragePools;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public List<String> searchForStoragePoolDetails(long poolId, String value){
|
||||
|
||||
StringBuilder sql = new StringBuilder(FindPoolTagDetails);
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
PreparedStatement pstmt = null;
|
||||
try {
|
||||
pstmt = txn.prepareAutoCloseStatement(sql.toString());
|
||||
pstmt.setLong(1, poolId);
|
||||
pstmt.setString(2, value);
|
||||
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
List<String> tags = new ArrayList<String>();
|
||||
|
||||
while (rs.next()) {
|
||||
tags.add(rs.getString("name"));
|
||||
}
|
||||
return tags;
|
||||
} catch (SQLException e) {
|
||||
throw new CloudRuntimeException("Unable to execute " + pstmt.toString(), e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDetails(long poolId, Map<String, String> details) {
|
||||
if (details != null) {
|
||||
_detailsDao.update(poolId, details);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getDetails(long poolId) {
|
||||
return _detailsDao.getDetails(poolId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
super.configure(name, params);
|
||||
_detailsDao.configure("DetailsDao", params);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public long countPoolsByStatus( DataStoreStatus... statuses) {
|
||||
SearchCriteria<Long> sc = StatusCountSearch.create();
|
||||
|
||||
sc.setParameters("status", (Object[])statuses);
|
||||
|
||||
List<Long> rs = customSearchIncludingRemoved(sc, null);
|
||||
if (rs.size() == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return rs.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataStoreVO> listPoolsByCluster(long clusterId) {
|
||||
SearchCriteria<DataStoreVO> sc = AllFieldSearch.create();
|
||||
sc.setParameters("clusterId", clusterId);
|
||||
|
||||
return listBy(sc);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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.db;
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface PrimaryDataStoreProviderDao extends GenericDao<PrimaryDataStoreProviderVO, Long> {
|
||||
|
||||
}
|
||||
@ -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 org.apache.cloudstack.storage.datastore.db;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
|
||||
@Component
|
||||
class PrimaryDataStoreProviderDaoImpl extends GenericDaoBase<PrimaryDataStoreProviderVO, Long> implements PrimaryDataStoreProviderDao {
|
||||
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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.db;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.TableGenerator;
|
||||
|
||||
@Entity
|
||||
@Table(name="data_store_provider")
|
||||
public class PrimaryDataStoreProviderVO {
|
||||
@Id
|
||||
@TableGenerator(name="data_store_provider_sq", table="sequence", pkColumnName="name", valueColumnName="value", pkColumnValue="data_store_provider_seq", allocationSize=1)
|
||||
@Column(name="id", updatable=false, nullable = false)
|
||||
private long id;
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,65 @@
|
||||
package org.apache.cloudstack.storage.datastore.driver;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.storage.EndPoint;
|
||||
import org.apache.cloudstack.storage.command.CreateVolumeAnswer;
|
||||
import org.apache.cloudstack.storage.command.CreateVolumeCommand;
|
||||
import org.apache.cloudstack.storage.volume.Volume;
|
||||
import org.apache.cloudstack.storage.volume.VolumeInfo;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
|
||||
@Component
|
||||
public class DefaultPrimaryDataStoreDriverImpl implements
|
||||
PrimaryDataStoreDriver {
|
||||
private static final Logger s_logger = Logger.getLogger(DefaultPrimaryDataStoreDriverImpl.class);
|
||||
@Override
|
||||
public boolean createVolume(Volume vol) {
|
||||
//The default driver will send createvolume command to one of hosts which can access its datastore
|
||||
List<EndPoint> endPoints = vol.getDataStore().getEndPoints();
|
||||
int retries = 3;
|
||||
VolumeInfo volInfo = new VolumeInfo(vol);
|
||||
CreateVolumeCommand createCmd = new CreateVolumeCommand(volInfo);
|
||||
Answer answer = null;
|
||||
int i = 0;
|
||||
boolean result = false;
|
||||
|
||||
for (EndPoint ep : endPoints) {
|
||||
answer = ep.sendMessage(createCmd);
|
||||
if (answer == null) {
|
||||
if (i < retries) {
|
||||
s_logger.debug("create volume failed, retrying: " + i);
|
||||
}
|
||||
i++;
|
||||
} else {
|
||||
CreateVolumeAnswer volAnswer = (CreateVolumeAnswer)answer;
|
||||
vol.setUuid(volAnswer.getVolumeUuid());
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteVolume(Volume vo) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String grantAccess(Volume vol, EndPoint ep) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean revokeAccess(Volume vol, EndPoint ep) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package org.apache.cloudstack.storage.datastore.driver;
|
||||
|
||||
import org.apache.cloudstack.storage.EndPoint;
|
||||
import org.apache.cloudstack.storage.volume.Volume;
|
||||
|
||||
public interface PrimaryDataStoreDriver {
|
||||
boolean createVolume(Volume vol);
|
||||
boolean deleteVolume(Volume vo);
|
||||
String grantAccess(Volume vol, EndPoint ep);
|
||||
boolean revokeAccess(Volume vol, EndPoint ep);
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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 java.util.Map;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class DefaultPrimaryDataStoreLifeCycleImpl implements PrimaryDataStoreLifeCycle {
|
||||
|
||||
@Override
|
||||
public boolean registerDataStore(Map<String, String> dsInfos) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean attach(long scope) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dettach(long dataStoreId) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean unmanaged(long dataStoreId) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean maintain(long dataStoreId) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cancelMaintain(long dataStoreId) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteDataStore(long dataStoreId) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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 java.util.Map;
|
||||
|
||||
public interface PrimaryDataStoreLifeCycle {
|
||||
public boolean registerDataStore(Map<String, String> dsInfos);
|
||||
public boolean attach(long scope);
|
||||
public boolean dettach(long dataStoreId);
|
||||
public boolean unmanaged(long dataStoreId);
|
||||
public boolean maintain(long dataStoreId);
|
||||
public boolean cancelMaintain(long dataStoreId);
|
||||
public boolean deleteDataStore(long dataStoreId);
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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.manager;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
|
||||
import org.apache.cloudstack.storage.datastore.db.DataStoreVO;
|
||||
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreProviderDao;
|
||||
import org.apache.cloudstack.storage.datastore.lifecycle.PrimaryDataStoreLifeCycle;
|
||||
import org.apache.cloudstack.storage.datastore.provider.PrimaryDataStoreProvider;
|
||||
import org.apache.cloudstack.storage.datastore.provider.PrimaryDataStoreProviderManager;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class DefaultPrimaryDataStoreManagerImpl implements PrimaryDataStoreManager {
|
||||
@Inject
|
||||
PrimaryDataStoreProviderDao dataStoreProviderDao;
|
||||
@Inject
|
||||
PrimaryDataStoreProviderManager providerManager;
|
||||
@Inject
|
||||
PrimaryDataStoreDao dataStoreDao;
|
||||
@Override
|
||||
public PrimaryDataStore getPrimaryDataStore(long dataStoreId) {
|
||||
DataStoreVO dataStoreVO = dataStoreDao.findById(dataStoreId);
|
||||
Long providerId = dataStoreVO.getStorageProviderId();
|
||||
PrimaryDataStoreProvider provider = providerManager.getDataStoreProvider(providerId);
|
||||
PrimaryDataStore dataStore = provider.getDataStore(dataStoreId);
|
||||
return dataStore;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrimaryDataStoreLifeCycle getPrimaryDataStoreLifeCycle(long dataStoreId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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.manager;
|
||||
|
||||
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
|
||||
import org.apache.cloudstack.storage.datastore.lifecycle.PrimaryDataStoreLifeCycle;
|
||||
|
||||
public interface PrimaryDataStoreManager {
|
||||
public PrimaryDataStore getPrimaryDataStore(long dataStoreId);
|
||||
public PrimaryDataStoreLifeCycle getPrimaryDataStoreLifeCycle(long dataStoreId);
|
||||
}
|
||||
@ -0,0 +1,44 @@
|
||||
package org.apache.cloudstack.storage.datastore.provider;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.storage.datastore.DefaultPrimaryDataStoreImpl;
|
||||
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
|
||||
import org.apache.cloudstack.storage.datastore.PrimaryDataStoreInfo;
|
||||
import org.apache.cloudstack.storage.datastore.db.DataStoreVO;
|
||||
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
||||
import org.apache.cloudstack.storage.datastore.driver.DefaultPrimaryDataStoreDriverImpl;
|
||||
import org.apache.cloudstack.storage.datastore.driver.PrimaryDataStoreDriver;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.utils.component.ComponentInject;
|
||||
|
||||
@Component
|
||||
public class DefaultPrimaryDatastoreProviderImpl implements
|
||||
PrimaryDataStoreProvider {
|
||||
protected PrimaryDataStoreDriver driver;
|
||||
@Inject
|
||||
public PrimaryDataStoreDao dataStoreDao;
|
||||
|
||||
public DefaultPrimaryDatastoreProviderImpl() {
|
||||
this.driver = new DefaultPrimaryDataStoreDriverImpl();
|
||||
}
|
||||
@Override
|
||||
public PrimaryDataStore getDataStore(long dataStoreId) {
|
||||
DataStoreVO dsv = dataStoreDao.findById(dataStoreId);
|
||||
if (dsv == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
PrimaryDataStore pds = new DefaultPrimaryDataStoreImpl(driver, dsv, null);
|
||||
pds = ComponentInject.inject(pds);
|
||||
return pds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrimaryDataStoreInfo getDataStoreInfo(long dataStoreId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
package org.apache.cloudstack.storage.datastore.provider;
|
||||
|
||||
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
|
||||
import org.apache.cloudstack.storage.datastore.PrimaryDataStoreInfo;
|
||||
|
||||
public interface PrimaryDataStoreProvider {
|
||||
public PrimaryDataStore getDataStore(long dataStoreId);
|
||||
public PrimaryDataStoreInfo getDataStoreInfo(long dataStoreId);
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
package org.apache.cloudstack.storage.datastore.provider;
|
||||
|
||||
public interface PrimaryDataStoreProviderManager {
|
||||
public PrimaryDataStoreProvider getDataStoreProvider(Long providerId);
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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 org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class PrimaryDataStoreProviderManagerImpl implements PrimaryDataStoreProviderManager {
|
||||
|
||||
@Override
|
||||
public PrimaryDataStoreProvider getDataStoreProvider(Long providerId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@ -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.datastore.type;
|
||||
|
||||
public interface DataStoreType {
|
||||
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.type;
|
||||
|
||||
import org.apache.cloudstack.storage.BaseType;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class ISCSI extends BaseType implements DataStoreType {
|
||||
private final String type = "iscsi";
|
||||
@Override
|
||||
public String toString() {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.type;
|
||||
|
||||
import org.apache.cloudstack.storage.BaseType;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class NetworkFileSystem extends BaseType implements DataStoreType {
|
||||
private final String type = "nfs";
|
||||
@Override
|
||||
public String toString() {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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.type;
|
||||
|
||||
import org.apache.cloudstack.storage.BaseType;
|
||||
|
||||
public class SharedMount extends BaseType implements DataStoreType {
|
||||
private final String type = "SharedMountPoint";
|
||||
@Override
|
||||
public String toString() {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* 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.driver;
|
||||
|
||||
import org.apache.cloudstack.platform.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.platform.subsystem.api.storage.DataStoreDriver;
|
||||
import org.apache.cloudstack.platform.subsystem.api.storage.DataStoreEndPoint;
|
||||
import org.apache.cloudstack.platform.subsystem.api.storage.TemplateProfile;
|
||||
|
||||
import org.apache.cloudstack.platform.subsystem.api.storage.TemplateStrategy;
|
||||
import com.cloud.agent.api.storage.DownloadProgressCommand;
|
||||
import com.cloud.agent.api.storage.DownloadProgressCommand.RequestType;
|
||||
import com.cloud.agent.api.storage.DownloadCommand;
|
||||
import com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer;
|
||||
import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand;
|
||||
|
||||
public abstract class AbstractStorageDriver implements DataStoreDriver {
|
||||
protected DataStore _ds;
|
||||
protected TemplateStrategy _ts;
|
||||
|
||||
public AbstractStorageDriver(DataStore ds) {
|
||||
_ds = ds;
|
||||
_ts = ds.getTemplateStrategy();
|
||||
}
|
||||
|
||||
public TemplateProfile install(TemplateProfile tp, DataStoreEndPoint ep) {
|
||||
PrimaryStorageDownloadCommand dcmd = new PrimaryStorageDownloadCommand(tp.getName(), tp.getUrl(), tp.getFormat(),
|
||||
0, _ds.getId(), _ds.getUUID(), _ts.getDownloadWait());
|
||||
dcmd.setSecondaryStorageUrl(tp.getImageStorageUri());
|
||||
dcmd.setPrimaryStorageUrl(_ds.getURI());
|
||||
PrimaryStorageDownloadAnswer asw = (PrimaryStorageDownloadAnswer)ep.sendCommand(dcmd);
|
||||
|
||||
tp.setLocalPath(asw.getInstallPath());
|
||||
return tp;
|
||||
}
|
||||
|
||||
public TemplateProfile register(TemplateProfile tp, DataStoreEndPoint ep, boolean freshDownload) {
|
||||
|
||||
DownloadCommand dcmd =
|
||||
new DownloadCommand(_ds.getURI(), tp.getTemplate(), _ts.getMaxTemplateSizeInBytes());
|
||||
dcmd.setProxy(_ts.getHttpProxy());
|
||||
if (!freshDownload) {
|
||||
dcmd = new DownloadProgressCommand(dcmd, tp.getJobId(), RequestType.GET_OR_RESTART);
|
||||
}
|
||||
|
||||
ep.sendCommand(dcmd);
|
||||
return tp;
|
||||
}
|
||||
/*
|
||||
public VolumeProfile createVolumeFromTemplate(VolumeProfile volProfile, TemplateProfile tp, DataStoreEndPoint ep) {
|
||||
CreateCommand cmd = new CreateCommand(volProfile, tp.getLocalPath(), _ds.getTO());
|
||||
CreateAnswer ans = (CreateAnswer)ep.sendCommand(cmd);
|
||||
VolumeTO created = ans.getVolume();
|
||||
DiskProfile diskProfile = new VolumeProfile(volProfile);
|
||||
diskProfile.setPath(created.getPath());
|
||||
diskProfile.setSize(created.getSize());
|
||||
return diskProfile;
|
||||
return null;
|
||||
}*/
|
||||
}
|
||||
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* 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.driver;
|
||||
|
||||
import org.apache.cloudstack.platform.subsystem.api.storage.DataObject;
|
||||
import org.apache.cloudstack.platform.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.platform.subsystem.api.storage.DataStoreEndPoint;
|
||||
import org.apache.cloudstack.platform.subsystem.api.storage.VolumeProfile;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.storage.TemplateProfile;
|
||||
|
||||
public class DefaultNfsSecondaryDriver extends AbstractStorageDriver {
|
||||
|
||||
/**
|
||||
* @param ds
|
||||
*/
|
||||
public DefaultNfsSecondaryDriver(DataStore ds) {
|
||||
super(ds);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public String getDriverType() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public TemplateProfile register(TemplateProfile tp, DataStoreEndPoint ep) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public DataObject create(DataObject obj) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public DataObject copy(DataObject src, DataStore dest) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public DataObject copy(DataObject src, DataObject dest) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public DataObject move(DataObject src, DataObject dest) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public Answer sendMessage(DataStoreEndPoint dsep, Command cmd) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean delete(DataObject obj) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
public org.apache.cloudstack.platform.subsystem.api.storage.TemplateProfile register(org.apache.cloudstack.platform.subsystem.api.storage.TemplateProfile tp, DataStoreEndPoint ep) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public VolumeProfile createVolumeFromTemplate(VolumeProfile vol, org.apache.cloudstack.platform.subsystem.api.storage.TemplateProfile tp, DataStoreEndPoint dp) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user