diff --git a/platform/api/src/org/apache/cloudstack/platform/cloud/entity/api/EdgeService.java b/platform/api/src/org/apache/cloudstack/platform/cloud/entity/api/EdgeService.java new file mode 100755 index 00000000000..8dceb746431 --- /dev/null +++ b/platform/api/src/org/apache/cloudstack/platform/cloud/entity/api/EdgeService.java @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.cloudstack.platform.cloud.entity.api; + +public interface EdgeService { + +} diff --git a/platform/api/src/org/apache/cloudstack/platform/datacenter/entity/api/ClusterEntity.java b/platform/api/src/org/apache/cloudstack/platform/datacenter/entity/api/ClusterEntity.java new file mode 100755 index 00000000000..83789098d24 --- /dev/null +++ b/platform/api/src/org/apache/cloudstack/platform/datacenter/entity/api/ClusterEntity.java @@ -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 { + +} diff --git a/platform/api/src/org/apache/cloudstack/platform/datacenter/entity/api/DataCenterResourceEntity.java b/platform/api/src/org/apache/cloudstack/platform/datacenter/entity/api/DataCenterResourceEntity.java new file mode 100755 index 00000000000..5ca27c54f69 --- /dev/null +++ b/platform/api/src/org/apache/cloudstack/platform/datacenter/entity/api/DataCenterResourceEntity.java @@ -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 { + + /** + * 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 s_fsm = new StateMachine2(); + 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(); + +} diff --git a/platform/api/src/org/apache/cloudstack/platform/datacenter/entity/api/OrganizationScope.java b/platform/api/src/org/apache/cloudstack/platform/datacenter/entity/api/OrganizationScope.java new file mode 100755 index 00000000000..0fa64976808 --- /dev/null +++ b/platform/api/src/org/apache/cloudstack/platform/datacenter/entity/api/OrganizationScope.java @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.cloudstack.platform.datacenter.entity.api; + +public interface OrganizationScope { + +} diff --git a/platform/api/src/org/apache/cloudstack/platform/datacenter/entity/api/PodEntity.java b/platform/api/src/org/apache/cloudstack/platform/datacenter/entity/api/PodEntity.java new file mode 100755 index 00000000000..e4743008f20 --- /dev/null +++ b/platform/api/src/org/apache/cloudstack/platform/datacenter/entity/api/PodEntity.java @@ -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 listClusters(); + +} diff --git a/platform/api/src/org/apache/cloudstack/platform/datacenter/entity/api/StorageEntity.java b/platform/api/src/org/apache/cloudstack/platform/datacenter/entity/api/StorageEntity.java new file mode 100755 index 00000000000..2d222324d2a --- /dev/null +++ b/platform/api/src/org/apache/cloudstack/platform/datacenter/entity/api/StorageEntity.java @@ -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 { +} diff --git a/platform/api/src/org/apache/cloudstack/platform/datacenter/entity/api/ZoneEntity.java b/platform/api/src/org/apache/cloudstack/platform/datacenter/entity/api/ZoneEntity.java new file mode 100755 index 00000000000..48940fae4e0 --- /dev/null +++ b/platform/api/src/org/apache/cloudstack/platform/datacenter/entity/api/ZoneEntity.java @@ -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 listPods(); +} diff --git a/platform/api/src/org/apache/cloudstack/platform/entity/api/CloudStackEntity.java b/platform/api/src/org/apache/cloudstack/platform/entity/api/CloudStackEntity.java new file mode 100755 index 00000000000..1aa70b6c124 --- /dev/null +++ b/platform/api/src/org/apache/cloudstack/platform/entity/api/CloudStackEntity.java @@ -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 getDetails(String source); + + /** + * @return a list of sources that have added to the details. + */ + List 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 getApplicableActions(); +} diff --git a/platform/api/src/org/apache/cloudstack/platform/service/api/ProvisioningService.java b/platform/api/src/org/apache/cloudstack/platform/service/api/ProvisioningService.java new file mode 100755 index 00000000000..0032a258786 --- /dev/null +++ b/platform/api/src/org/apache/cloudstack/platform/service/api/ProvisioningService.java @@ -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 tags, Map details); + ZoneEntity registerZone(String name, List tags, Map details); + String registerPod(String name, List tags, Map details); + String registerCluster(String name, List tags, Map details); + String registerHost(String name, List tags, Map details); + + + + void deregisterStorage(String uuid); + void deregisterZone(); + void deregisterPod(); + void deregisterCluster(); + void deregisterHost(); + + void changeState(String type, String entity, Status state); + + List listHosts(); + + List listPods(); + + List listZones(); + + + + List listStorage(); + +} diff --git a/utils/src/com/cloud/utils/fsm/ChangeEvent.java b/utils/src/com/cloud/utils/fsm/ChangeEvent.java new file mode 100755 index 00000000000..5b378060d60 --- /dev/null +++ b/utils/src/com/cloud/utils/fsm/ChangeEvent.java @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package com.cloud.utils.fsm; + +public class ChangeEvent { + +} diff --git a/utils/src/com/cloud/utils/fsm/FiniteState2.java b/utils/src/com/cloud/utils/fsm/FiniteState2.java new file mode 100755 index 00000000000..585521d4bf3 --- /dev/null +++ b/utils/src/com/cloud/utils/fsm/FiniteState2.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package com.cloud.utils.fsm; + +import java.util.Set; + +public interface FiniteState2 { + + StateMachine2 getStateMachine(); + + T getNextState(ChangeEvent e) throws NoTransitionException; + + T getFromStates(ChangeEvent e); + + Set getPossibleEvents(); + +}