mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Merge from master and fix conflicts
This commit is contained in:
commit
fbfc5c6894
112
LICENSE
112
LICENSE
@ -180,7 +180,6 @@ Copyright (c) 2013 The Apache Software Foundation
|
||||
|
||||
|
||||
This distribution contains third party resources.
|
||||
|
||||
Within the . directory
|
||||
licensed under the BSD (3-clause) http://www.opensource.org/licenses/BSD-3-Clause (as follows)
|
||||
|
||||
@ -213,7 +212,6 @@ Within the . directory
|
||||
from Thomas Nagy http://code.google.com/p/waf/
|
||||
waf
|
||||
|
||||
|
||||
Within the awsapi directory
|
||||
licensed under the BSD (3-clause) http://www.opensource.org/licenses/BSD-3-Clause (as follows)
|
||||
|
||||
@ -246,7 +244,6 @@ Within the awsapi directory
|
||||
from Thomas Nagy http://code.google.com/p/waf/
|
||||
waf
|
||||
|
||||
|
||||
Within the console-proxy/js directory
|
||||
licensed under the MIT License http://www.opensource.org/licenses/mit-license.php (as follows)
|
||||
|
||||
@ -274,7 +271,6 @@ Within the console-proxy/js directory
|
||||
from John Resig
|
||||
jquery.js
|
||||
|
||||
|
||||
Within the deps directory
|
||||
licensed under the BSD (2-clause) for XenServerJava http://www.opensource.org/licenses/BSD-2-Clause (as follows)
|
||||
|
||||
@ -306,16 +302,16 @@ Within the deps directory
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
from Citrix Systems, Inc http://www.citrix.com/
|
||||
XenServerJava http://community.citrix.com/cdn/xs/sdks/
|
||||
|
||||
XenServerJava from http://community.citrix.com/cdn/xs/sdks/
|
||||
|
||||
Within the patches/systemvm/debian/config/etc directory
|
||||
placed in the public domain
|
||||
by Adiscon GmbH http://www.adiscon.com/
|
||||
rsyslog.conf
|
||||
by Simon Kelley
|
||||
dnsmasq.conf
|
||||
vpcdnsmasq.conf
|
||||
|
||||
|
||||
Within the patches/systemvm/debian/config/etc/apache2 directory
|
||||
licensed under the Apache License, Version 2 http://www.apache.org/licenses/LICENSE-2.0.txt (as above)
|
||||
Copyright (c) 2012 The Apache Software Foundation
|
||||
@ -326,7 +322,6 @@ Within the patches/systemvm/debian/config/etc/apache2 directory
|
||||
sites-available/default-ssl
|
||||
vhostexample.conf
|
||||
|
||||
|
||||
Within the patches/systemvm/debian/config/etc/ssh/ directory
|
||||
licensed under the BSD (2-clause) http://www.opensource.org/licenses/BSD-2-Clause (as follows)
|
||||
|
||||
@ -358,36 +353,91 @@ Within the patches/systemvm/debian/config/etc/ssh/ directory
|
||||
from OpenSSH Project http://www.openssh.org/
|
||||
sshd_config
|
||||
|
||||
|
||||
Within the patches/systemvm/debian/config/root/redundant_router directory
|
||||
placed in the public domain
|
||||
by The netfilter.org project http://www.netfilter.org/
|
||||
conntrackd.conf.templ
|
||||
|
||||
|
||||
Within the scripts/storage/secondary directory
|
||||
licensed under the Apache License, Version 2 http://www.apache.org/licenses/LICENSE-2.0.txt (as above)
|
||||
Copyright (c) 2010-2011 OpenStack, LLC.
|
||||
from OpenStack, LLC http://www.openstack.org
|
||||
swift
|
||||
|
||||
|
||||
Within the scripts/vm/hypervisor/xenserver directory
|
||||
licensed under the Apache License, Version 2 http://www.apache.org/licenses/LICENSE-2.0.txt (as above)
|
||||
Copyright (c) 2010-2011 OpenStack, LLC.
|
||||
from OpenStack, LLC http://www.openstack.org
|
||||
swift
|
||||
|
||||
Within the tools/appliance/definitions/systemvmtemplate directory
|
||||
licensed under the MIT License http://www.opensource.org/licenses/mit-license.php (as follows)
|
||||
|
||||
Copyright (c) 2010-2012 Patrick Debois
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
from Patrick Debois http://www.jedi.be/blog/
|
||||
base.sh from https://github.com/jedi4ever/veewee
|
||||
cleanup.sh from https://github.com/jedi4ever/veewee
|
||||
definition.rb from https://github.com/jedi4ever/veewee
|
||||
preseed.cfg from https://github.com/jedi4ever/veewee
|
||||
zerodisk.sh from https://github.com/jedi4ever/veewee
|
||||
|
||||
Within the tools/devcloud/src/deps/boxes/basebox-build directory
|
||||
licensed under the MIT License http://www.opensource.org/licenses/mit-license.php (as follows)
|
||||
|
||||
Copyright (c) 2010-2012 Patrick Debois
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
from Patrick Debois http://www.jedi.be/blog/
|
||||
definition.rb from https://github.com/jedi4ever/veewee
|
||||
preseed.cfg from https://github.com/jedi4ever/veewee
|
||||
|
||||
Within the ui/lib directory
|
||||
placed in the public domain
|
||||
by Eric Meyer http://meyerweb.com/eric/
|
||||
reset.css
|
||||
reset.css from http://meyerweb.com/eric/tools/css/reset/
|
||||
|
||||
licensed under the Apache License, Version 2 http://www.apache.org/licenses/LICENSE-2.0.txt (as above)
|
||||
Copyright (c) 2006 Google Inc.
|
||||
from Google Inc. http://google.com
|
||||
excanvas.js http://code.google.com/p/explorercanvas/
|
||||
excanvas.js from http://code.google.com/p/explorercanvas/
|
||||
|
||||
licensed under the BSD (2-clause) http://www.opensource.org/licenses/BSD-2-Clause (as follows)
|
||||
|
||||
@ -421,6 +471,31 @@ Within the ui/lib directory
|
||||
from George McGinley Smith
|
||||
jquery.easing.js
|
||||
|
||||
licensed under the MIT License http://www.opensource.org/licenses/mit-license.php (as follows)
|
||||
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
from The Dojo Foundation http://dojofoundation.org/
|
||||
require.js from http://github.com/jrburke/requirejs
|
||||
|
||||
licensed under the MIT License http://www.opensource.org/licenses/mit-license.php (as follows)
|
||||
|
||||
Copyright (c) 2011, John Resig
|
||||
@ -525,7 +600,6 @@ Within the ui/lib directory
|
||||
from Klaus Hartl http://stilbuero.de
|
||||
jquery.cookies.js
|
||||
|
||||
|
||||
Within the ui/lib/flot directory
|
||||
licensed under the MIT License http://www.opensource.org/licenses/mit-license.php (as follows)
|
||||
|
||||
@ -614,7 +688,6 @@ Within the ui/lib/flot directory
|
||||
from Ole Laursen
|
||||
jquery.colorhelpers.js
|
||||
|
||||
|
||||
Within the ui/lib/jquery-ui directory
|
||||
licensed under the MIT License http://www.opensource.org/licenses/mit-license.php (as follows)
|
||||
|
||||
@ -643,7 +716,6 @@ Within the ui/lib/jquery-ui directory
|
||||
index.html
|
||||
js/jquery-ui.js
|
||||
|
||||
|
||||
Within the ui/lib/qunit directory
|
||||
licensed under the MIT License http://www.opensource.org/licenses/mit-license.php (as follows)
|
||||
|
||||
@ -669,12 +741,12 @@ Within the ui/lib/qunit directory
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
from Jorn Zaefferer
|
||||
qunit.css http://docs.jquery.com/QUnit
|
||||
qunit.js http://docs.jquery.com/QUnit
|
||||
|
||||
qunit.css from http://docs.jquery.com/QUnit
|
||||
qunit.js from http://docs.jquery.com/QUnit
|
||||
|
||||
Within the utils/src/com/cloud/utils/db directory
|
||||
licensed under the Apache License, Version 2 http://www.apache.org/licenses/LICENSE-2.0.txt (as above)
|
||||
Copyright (c) 2004 Clinton Begin
|
||||
from Clinton Begin http://code.google.com/p/mybatis/
|
||||
ScriptRunner.java http://code.google.com/p/mybatis/
|
||||
ScriptRunner.java from http://code.google.com/p/mybatis/
|
||||
|
||||
|
||||
47
NOTICE
47
NOTICE
@ -6,30 +6,7 @@
|
||||
|
||||
|
||||
|
||||
Source code distribution if this software contains third party resources requiring
|
||||
the following notices:
|
||||
|
||||
|
||||
For
|
||||
jquery.md5.js
|
||||
|
||||
|
||||
jQuery MD5 Plugin 1.2.1
|
||||
https://github.com/blueimp/jQuery-MD5
|
||||
|
||||
Copyright 2010, Sebastian Tschan
|
||||
https://blueimp.net
|
||||
|
||||
Licensed under the MIT license:
|
||||
http://creativecommons.org/licenses/MIT/
|
||||
|
||||
Based on
|
||||
A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
|
||||
Digest Algorithm, as defined in RFC 1321.
|
||||
Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
|
||||
Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
|
||||
Distributed under the BSD License
|
||||
See http://pajhome.org.uk/crypt/md5 for more info.
|
||||
This distribution contains third party resources requiring the following notices:
|
||||
|
||||
|
||||
For
|
||||
@ -66,6 +43,28 @@
|
||||
Date: Thu May 12 15:04:36 2011 -0400
|
||||
|
||||
|
||||
For
|
||||
jquery.md5.js
|
||||
|
||||
|
||||
jQuery MD5 Plugin 1.2.1
|
||||
https://github.com/blueimp/jQuery-MD5
|
||||
|
||||
Copyright 2010, Sebastian Tschan
|
||||
https://blueimp.net
|
||||
|
||||
Licensed under the MIT license:
|
||||
http://creativecommons.org/licenses/MIT/
|
||||
|
||||
Based on
|
||||
A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
|
||||
Digest Algorithm, as defined in RFC 1321.
|
||||
Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
|
||||
Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
|
||||
Distributed under the BSD License
|
||||
See http://pajhome.org.uk/crypt/md5 for more info.
|
||||
|
||||
|
||||
For
|
||||
jquery.colorhelpers.js
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack</artifactId>
|
||||
<version>4.1.0-SNAPSHOT</version>
|
||||
<version>4.2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack</artifactId>
|
||||
<version>4.1.0-SNAPSHOT</version>
|
||||
<version>4.2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
||||
62
api/src/com/cloud/agent/api/CreateVMSnapshotAnswer.java
Normal file
62
api/src/com/cloud/agent/api/CreateVMSnapshotAnswer.java
Normal file
@ -0,0 +1,62 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package com.cloud.agent.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.agent.api.to.VolumeTO;
|
||||
|
||||
public class CreateVMSnapshotAnswer extends Answer {
|
||||
|
||||
private List<VolumeTO> volumeTOs;
|
||||
private VMSnapshotTO vmSnapshotTo;
|
||||
|
||||
|
||||
public List<VolumeTO> getVolumeTOs() {
|
||||
return volumeTOs;
|
||||
}
|
||||
|
||||
public void setVolumeTOs(List<VolumeTO> volumeTOs) {
|
||||
this.volumeTOs = volumeTOs;
|
||||
}
|
||||
|
||||
public VMSnapshotTO getVmSnapshotTo() {
|
||||
return vmSnapshotTo;
|
||||
}
|
||||
|
||||
public void setVmSnapshotTo(VMSnapshotTO vmSnapshotTo) {
|
||||
this.vmSnapshotTo = vmSnapshotTo;
|
||||
}
|
||||
|
||||
public CreateVMSnapshotAnswer() {
|
||||
|
||||
}
|
||||
|
||||
public CreateVMSnapshotAnswer(CreateVMSnapshotCommand cmd, boolean success,
|
||||
String result) {
|
||||
super(cmd, success, result);
|
||||
}
|
||||
|
||||
public CreateVMSnapshotAnswer(CreateVMSnapshotCommand cmd,
|
||||
VMSnapshotTO vmSnapshotTo, List<VolumeTO> volumeTOs) {
|
||||
super(cmd, true, "");
|
||||
this.vmSnapshotTo = vmSnapshotTo;
|
||||
this.volumeTOs = volumeTOs;
|
||||
}
|
||||
|
||||
}
|
||||
@ -14,33 +14,29 @@
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.vm;
|
||||
package com.cloud.agent.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* be an information carrier within one thread only.
|
||||
*
|
||||
*/
|
||||
public class VirtualEnvironment {
|
||||
/**
|
||||
* The actual machine
|
||||
*/
|
||||
public VirtualMachine machine;
|
||||
import com.cloud.agent.api.to.VolumeTO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
/**
|
||||
* Disks to assign to the machine in order.
|
||||
*/
|
||||
public List<VirtualDisk> disks;
|
||||
public class CreateVMSnapshotCommand extends VMSnapshotBaseCommand {
|
||||
|
||||
/**
|
||||
* Networks to assign to the machine.
|
||||
*/
|
||||
public List<VirtualNetwork> networks;
|
||||
public CreateVMSnapshotCommand(String vmName, VMSnapshotTO snapshot, List<VolumeTO> volumeTOs, String guestOSType, VirtualMachine.State vmState) {
|
||||
super(vmName, snapshot, volumeTOs, guestOSType);
|
||||
this.vmState = vmState;
|
||||
}
|
||||
|
||||
private VirtualMachine.State vmState;
|
||||
|
||||
|
||||
public VirtualMachine.State getVmState() {
|
||||
return vmState;
|
||||
}
|
||||
|
||||
public void setVmState(VirtualMachine.State vmState) {
|
||||
this.vmState = vmState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Boot options to assign to the machine.
|
||||
*/
|
||||
public String bootOptions;
|
||||
}
|
||||
@ -18,6 +18,7 @@ package com.cloud.agent.api;
|
||||
|
||||
import com.cloud.storage.StoragePool;
|
||||
|
||||
|
||||
/**
|
||||
* This currently assumes that both primary and secondary storage are mounted on the XenServer.
|
||||
*/
|
||||
|
||||
@ -0,0 +1,54 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package com.cloud.agent.api;
|
||||
|
||||
import com.cloud.agent.api.to.VolumeTO;
|
||||
|
||||
public class CreateVolumeFromVMSnapshotAnswer extends Answer {
|
||||
private String path;
|
||||
private VolumeTO volumeTo;
|
||||
|
||||
public VolumeTO getVolumeTo() {
|
||||
return volumeTo;
|
||||
}
|
||||
|
||||
public CreateVolumeFromVMSnapshotAnswer(
|
||||
CreateVolumeFromVMSnapshotCommand cmd, VolumeTO volumeTo) {
|
||||
super(cmd, true, "");
|
||||
this.volumeTo = volumeTo;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
protected CreateVolumeFromVMSnapshotAnswer() {
|
||||
|
||||
}
|
||||
|
||||
public CreateVolumeFromVMSnapshotAnswer(
|
||||
CreateVolumeFromVMSnapshotCommand cmd, String path) {
|
||||
super(cmd, true, "");
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public CreateVolumeFromVMSnapshotAnswer(
|
||||
CreateVolumeFromVMSnapshotCommand cmd, boolean result, String string) {
|
||||
super(cmd, result, string);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,88 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.agent.api;
|
||||
|
||||
import com.cloud.agent.api.to.StorageFilerTO;
|
||||
import com.cloud.vm.DiskProfile;
|
||||
|
||||
public class CreateVolumeFromVMSnapshotCommand extends Command {
|
||||
|
||||
protected String path;
|
||||
protected String name;
|
||||
protected Boolean fullClone;
|
||||
protected String storagePoolUuid;
|
||||
private StorageFilerTO pool;
|
||||
private DiskProfile diskProfile;
|
||||
private Long volumeId;
|
||||
|
||||
public DiskProfile getDskch() {
|
||||
return diskProfile;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public Long getVolumeId() {
|
||||
return volumeId;
|
||||
}
|
||||
|
||||
protected CreateVolumeFromVMSnapshotCommand() {
|
||||
|
||||
}
|
||||
|
||||
public CreateVolumeFromVMSnapshotCommand(String path, String name,
|
||||
Boolean fullClone, String storagePoolUuid) {
|
||||
this.path = path;
|
||||
this.name = name;
|
||||
this.fullClone = fullClone;
|
||||
this.storagePoolUuid = storagePoolUuid;
|
||||
}
|
||||
|
||||
public CreateVolumeFromVMSnapshotCommand(String path, String name,
|
||||
Boolean fullClone, String storagePoolUuid, StorageFilerTO pool,
|
||||
DiskProfile diskProfile, Long volumeId) {
|
||||
this.path = path;
|
||||
this.name = name;
|
||||
this.fullClone = fullClone;
|
||||
this.storagePoolUuid = storagePoolUuid;
|
||||
this.pool = pool;
|
||||
this.diskProfile = diskProfile;
|
||||
this.volumeId = volumeId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean executeInSequence() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Boolean getFullClone() {
|
||||
return fullClone;
|
||||
}
|
||||
|
||||
public String getStoragePoolUuid() {
|
||||
return storagePoolUuid;
|
||||
}
|
||||
|
||||
public StorageFilerTO getPool() {
|
||||
return pool;
|
||||
}
|
||||
}
|
||||
@ -14,22 +14,36 @@
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.baremetal;
|
||||
package com.cloud.agent.api;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import java.util.List;
|
||||
|
||||
public class DhcpServerResponse extends BaseResponse {
|
||||
@SerializedName(ApiConstants.ID) @Param(description="the ID of the Dhcp server")
|
||||
private String id;
|
||||
import com.cloud.agent.api.to.VolumeTO;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
public class DeleteVMSnapshotAnswer extends Answer {
|
||||
private List<VolumeTO> volumeTOs;
|
||||
|
||||
public DeleteVMSnapshotAnswer() {
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
public DeleteVMSnapshotAnswer(DeleteVMSnapshotCommand cmd, boolean result,
|
||||
String message) {
|
||||
super(cmd, result, message);
|
||||
}
|
||||
|
||||
public DeleteVMSnapshotAnswer(DeleteVMSnapshotCommand cmd,
|
||||
List<VolumeTO> volumeTOs) {
|
||||
super(cmd, true, "");
|
||||
this.volumeTOs = volumeTOs;
|
||||
}
|
||||
|
||||
public List<VolumeTO> getVolumeTOs() {
|
||||
return volumeTOs;
|
||||
}
|
||||
|
||||
public void setVolumeTOs(List<VolumeTO> volumeTOs) {
|
||||
this.volumeTOs = volumeTOs;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
28
api/src/com/cloud/agent/api/DeleteVMSnapshotCommand.java
Normal file
28
api/src/com/cloud/agent/api/DeleteVMSnapshotCommand.java
Normal file
@ -0,0 +1,28 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License
|
||||
package com.cloud.agent.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.agent.api.to.VolumeTO;
|
||||
|
||||
|
||||
public class DeleteVMSnapshotCommand extends VMSnapshotBaseCommand {
|
||||
public DeleteVMSnapshotCommand(String vmName, VMSnapshotTO snapshot, List<VolumeTO> volumeTOs, String guestOSType) {
|
||||
super( vmName, snapshot, volumeTOs, guestOSType);
|
||||
}
|
||||
}
|
||||
63
api/src/com/cloud/agent/api/RevertToVMSnapshotAnswer.java
Normal file
63
api/src/com/cloud/agent/api/RevertToVMSnapshotAnswer.java
Normal file
@ -0,0 +1,63 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package com.cloud.agent.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.agent.api.to.VolumeTO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
public class RevertToVMSnapshotAnswer extends Answer {
|
||||
|
||||
private List<VolumeTO> volumeTOs;
|
||||
private VirtualMachine.State vmState;
|
||||
|
||||
public RevertToVMSnapshotAnswer(RevertToVMSnapshotCommand cmd, boolean result,
|
||||
String message) {
|
||||
super(cmd, result, message);
|
||||
}
|
||||
|
||||
public RevertToVMSnapshotAnswer() {
|
||||
super();
|
||||
}
|
||||
|
||||
public RevertToVMSnapshotAnswer(RevertToVMSnapshotCommand cmd,
|
||||
List<VolumeTO> volumeTOs,
|
||||
VirtualMachine.State vmState) {
|
||||
super(cmd, true, "");
|
||||
this.volumeTOs = volumeTOs;
|
||||
this.vmState = vmState;
|
||||
}
|
||||
|
||||
public VirtualMachine.State getVmState() {
|
||||
return vmState;
|
||||
}
|
||||
|
||||
public List<VolumeTO> getVolumeTOs() {
|
||||
return volumeTOs;
|
||||
}
|
||||
|
||||
public void setVolumeTOs(List<VolumeTO> volumeTOs) {
|
||||
this.volumeTOs = volumeTOs;
|
||||
}
|
||||
|
||||
public void setVmState(VirtualMachine.State vmState) {
|
||||
this.vmState = vmState;
|
||||
}
|
||||
|
||||
}
|
||||
29
api/src/com/cloud/agent/api/RevertToVMSnapshotCommand.java
Normal file
29
api/src/com/cloud/agent/api/RevertToVMSnapshotCommand.java
Normal file
@ -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 com.cloud.agent.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.agent.api.to.VolumeTO;
|
||||
|
||||
public class RevertToVMSnapshotCommand extends VMSnapshotBaseCommand {
|
||||
|
||||
public RevertToVMSnapshotCommand(String vmName, VMSnapshotTO snapshot, List<VolumeTO> volumeTOs, String guestOSType) {
|
||||
super(vmName, snapshot, volumeTOs, guestOSType);
|
||||
}
|
||||
|
||||
}
|
||||
74
api/src/com/cloud/agent/api/VMSnapshotBaseCommand.java
Normal file
74
api/src/com/cloud/agent/api/VMSnapshotBaseCommand.java
Normal file
@ -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 com.cloud.agent.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.agent.api.to.VolumeTO;
|
||||
|
||||
public class VMSnapshotBaseCommand extends Command{
|
||||
protected List<VolumeTO> volumeTOs;
|
||||
protected VMSnapshotTO target;
|
||||
protected String vmName;
|
||||
protected String guestOSType;
|
||||
|
||||
|
||||
public VMSnapshotBaseCommand(String vmName, VMSnapshotTO snapshot, List<VolumeTO> volumeTOs, String guestOSType) {
|
||||
this.vmName = vmName;
|
||||
this.target = snapshot;
|
||||
this.volumeTOs = volumeTOs;
|
||||
this.guestOSType = guestOSType;
|
||||
}
|
||||
|
||||
public List<VolumeTO> getVolumeTOs() {
|
||||
return volumeTOs;
|
||||
}
|
||||
|
||||
public void setVolumeTOs(List<VolumeTO> volumeTOs) {
|
||||
this.volumeTOs = volumeTOs;
|
||||
}
|
||||
|
||||
public VMSnapshotTO getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
public void setTarget(VMSnapshotTO target) {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public String getVmName() {
|
||||
return vmName;
|
||||
}
|
||||
|
||||
public void setVmName(String vmName) {
|
||||
this.vmName = vmName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean executeInSequence() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getGuestOSType() {
|
||||
return guestOSType;
|
||||
}
|
||||
|
||||
public void setGuestOSType(String guestOSType) {
|
||||
this.guestOSType = guestOSType;
|
||||
}
|
||||
}
|
||||
90
api/src/com/cloud/agent/api/VMSnapshotTO.java
Normal file
90
api/src/com/cloud/agent/api/VMSnapshotTO.java
Normal file
@ -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 com.cloud.agent.api;
|
||||
|
||||
import com.cloud.vm.snapshot.VMSnapshot;
|
||||
|
||||
public class VMSnapshotTO {
|
||||
private Long id;
|
||||
private String snapshotName;
|
||||
private VMSnapshot.Type type;
|
||||
private Long createTime;
|
||||
private Boolean current;
|
||||
private String description;
|
||||
private VMSnapshotTO parent;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
public VMSnapshotTO(Long id, String snapshotName,
|
||||
VMSnapshot.Type type, Long createTime,
|
||||
String description, Boolean current, VMSnapshotTO parent) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.snapshotName = snapshotName;
|
||||
this.type = type;
|
||||
this.createTime = createTime;
|
||||
this.current = current;
|
||||
this.description = description;
|
||||
this.parent = parent;
|
||||
}
|
||||
public VMSnapshotTO() {
|
||||
|
||||
}
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
public Boolean getCurrent() {
|
||||
return current;
|
||||
}
|
||||
public void setCurrent(Boolean current) {
|
||||
this.current = current;
|
||||
}
|
||||
public Long getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
public void setCreateTime(Long createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public VMSnapshot.Type getType() {
|
||||
return type;
|
||||
}
|
||||
public void setType(VMSnapshot.Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getSnapshotName() {
|
||||
return snapshotName;
|
||||
}
|
||||
public void setSnapshotName(String snapshotName) {
|
||||
this.snapshotName = snapshotName;
|
||||
}
|
||||
public VMSnapshotTO getParent() {
|
||||
return parent;
|
||||
}
|
||||
public void setParent(VMSnapshotTO parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
}
|
||||
@ -28,7 +28,8 @@ public class VirtualMachineTO {
|
||||
private BootloaderType bootloader;
|
||||
Type type;
|
||||
int cpus;
|
||||
Integer speed;
|
||||
Integer minSpeed;
|
||||
Integer maxSpeed;
|
||||
long minRam;
|
||||
long maxRam;
|
||||
String hostName;
|
||||
@ -47,12 +48,13 @@ public class VirtualMachineTO {
|
||||
VolumeTO[] disks;
|
||||
NicTO[] nics;
|
||||
|
||||
public VirtualMachineTO(long id, String instanceName, VirtualMachine.Type type, int cpus, Integer speed, long minRam, long maxRam, BootloaderType bootloader, String os, boolean enableHA, boolean limitCpuUse, String vncPassword) {
|
||||
public VirtualMachineTO(long id, String instanceName, VirtualMachine.Type type, int cpus, Integer minSpeed, Integer maxSpeed, long minRam, long maxRam, BootloaderType bootloader, String os, boolean enableHA, boolean limitCpuUse, String vncPassword) {
|
||||
this.id = id;
|
||||
this.name = instanceName;
|
||||
this.type = type;
|
||||
this.cpus = cpus;
|
||||
this.speed = speed;
|
||||
this.minSpeed = minSpeed;
|
||||
this.maxSpeed = maxSpeed;
|
||||
this.minRam = minRam;
|
||||
this.maxRam = maxRam;
|
||||
this.bootloader = bootloader;
|
||||
@ -101,10 +103,13 @@ public class VirtualMachineTO {
|
||||
this.cpus = cpus;
|
||||
}
|
||||
|
||||
public Integer getSpeed() {
|
||||
return speed;
|
||||
public Integer getMinSpeed() {
|
||||
return minSpeed;
|
||||
}
|
||||
|
||||
public Integer getMaxSpeed() {
|
||||
return maxSpeed;
|
||||
}
|
||||
public boolean getLimitCpuUse() {
|
||||
return limitCpuUse;
|
||||
}
|
||||
|
||||
@ -125,6 +125,10 @@ public class VolumeTO implements InternalIdentity {
|
||||
return guestOsType;
|
||||
}
|
||||
|
||||
public void setPath(String path){
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new StringBuilder("Vol[").append(id).append("|").append(type).append("|").append(path).append("|").append(size).append("]").toString();
|
||||
|
||||
@ -264,6 +264,8 @@ public interface ConfigurationService {
|
||||
|
||||
boolean removeLDAP(LDAPRemoveCmd cmd);
|
||||
|
||||
LDAPConfigCmd listLDAPConfig(LDAPConfigCmd cmd);
|
||||
|
||||
/**
|
||||
* @param offering
|
||||
* @return
|
||||
|
||||
@ -28,7 +28,9 @@ public interface Resource {
|
||||
template("template", 4, ResourceOwnerType.Account, ResourceOwnerType.Domain),
|
||||
project("project", 5, ResourceOwnerType.Account, ResourceOwnerType.Domain),
|
||||
network("network", 6, ResourceOwnerType.Account, ResourceOwnerType.Domain),
|
||||
vpc("vpc", 7, ResourceOwnerType.Account, ResourceOwnerType.Domain);
|
||||
vpc("vpc", 7, ResourceOwnerType.Account, ResourceOwnerType.Domain),
|
||||
cpu("cpu", 8, ResourceOwnerType.Account, ResourceOwnerType.Domain),
|
||||
memory("memory", 9, ResourceOwnerType.Account, ResourceOwnerType.Domain);
|
||||
|
||||
private String name;
|
||||
private ResourceOwnerType[] supportedOwners;
|
||||
|
||||
@ -332,6 +332,11 @@ public class EventTypes {
|
||||
public static final String EVENT_TAGS_CREATE = "CREATE_TAGS";
|
||||
public static final String EVENT_TAGS_DELETE = "DELETE_TAGS";
|
||||
|
||||
// vm snapshot events
|
||||
public static final String EVENT_VM_SNAPSHOT_CREATE = "VMSNAPSHOT.CREATE";
|
||||
public static final String EVENT_VM_SNAPSHOT_DELETE = "VMSNAPSHOT.DELETE";
|
||||
public static final String EVENT_VM_SNAPSHOT_REVERT = "VMSNAPSHOT.REVERTTO";
|
||||
|
||||
// external network device events
|
||||
public static final String EVENT_EXTERNAL_NVP_CONTROLLER_ADD = "PHYSICAL.NVPCONTROLLER.ADD";
|
||||
public static final String EVENT_EXTERNAL_NVP_CONTROLLER_DELETE = "PHYSICAL.NVPCONTROLLER.DELETE";
|
||||
|
||||
@ -21,7 +21,6 @@ import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
/**
|
||||
* Exception thrown if number of requests is over api rate limit set.
|
||||
* @author minc
|
||||
*
|
||||
*/
|
||||
public class RequestLimitException extends CloudRuntimeException {
|
||||
|
||||
@ -46,4 +46,10 @@ public interface HypervisorCapabilities extends Identity, InternalIdentity{
|
||||
* @return the max. data volumes per VM supported by hypervisor
|
||||
*/
|
||||
Integer getMaxDataVolumesLimit();
|
||||
|
||||
/**
|
||||
* @return the max. hosts per cluster supported by hypervisor
|
||||
*/
|
||||
Integer getMaxHostsPerCluster();
|
||||
|
||||
}
|
||||
|
||||
@ -138,6 +138,7 @@ public interface Network extends ControlledEntity, StateObject<Network.State>, I
|
||||
// NiciraNvp is not an "External" provider, otherwise we get in trouble with NetworkServiceImpl.providersConfiguredForExternalNetworking
|
||||
public static final Provider NiciraNvp = new Provider("NiciraNvp", false);
|
||||
public static final Provider MidokuraMidonet = new Provider("MidokuraMidonet", true);
|
||||
public static final Provider VPCNetscaler = new Provider("VPCNetscaler", true);
|
||||
|
||||
private String name;
|
||||
private boolean isExternal;
|
||||
@ -283,8 +284,17 @@ public interface Network extends ControlledEntity, StateObject<Network.State>, I
|
||||
|
||||
String getGateway();
|
||||
|
||||
// "cidr" is the Cloudstack managed address space, all CloudStack managed vms get IP address from "cidr",
|
||||
// In general "cidr" also serves as the network CIDR
|
||||
// But in case IP reservation is configured for a Guest network, "networkcidr" is the Effective network CIDR for that network,
|
||||
// "cidr" will still continue to be the effective address space for CloudStack managed vms in that Guest network
|
||||
String getCidr();
|
||||
|
||||
// "networkcidr" is the network CIDR of the guest network which uses IP reservation.
|
||||
// It is the summation of "cidr" and the reservedIPrange(the address space used for non CloudStack purposes).
|
||||
// For networks not configured with IP reservation, "networkcidr" is always null
|
||||
String getNetworkCidr();
|
||||
|
||||
String getIp6Gateway();
|
||||
|
||||
String getIp6Cidr();
|
||||
|
||||
@ -255,4 +255,6 @@ public interface NetworkModel {
|
||||
boolean isIP6AddressAvailableInVlan(long vlanId);
|
||||
|
||||
void checkIp6Parameters(String startIPv6, String endIPv6, String ip6Gateway, String ip6Cidr) throws InvalidParameterValueException;
|
||||
|
||||
void checkRequestedIpAddresses(long networkId, String ip4, String ip6) throws InvalidParameterValueException;
|
||||
}
|
||||
@ -38,6 +38,7 @@ public class NetworkProfile implements Network {
|
||||
private TrafficType trafficType;
|
||||
private String gateway;
|
||||
private String cidr;
|
||||
private String networkCidr;
|
||||
private String ip6Gateway;
|
||||
private String ip6Cidr;
|
||||
private long networkOfferingId;
|
||||
@ -65,6 +66,7 @@ public class NetworkProfile implements Network {
|
||||
this.trafficType = network.getTrafficType();
|
||||
this.gateway = network.getGateway();
|
||||
this.cidr = network.getCidr();
|
||||
this.networkCidr = network.getNetworkCidr();
|
||||
this.ip6Gateway = network.getIp6Gateway();
|
||||
this.ip6Cidr = network.getIp6Cidr();
|
||||
this.networkOfferingId = network.getNetworkOfferingId();
|
||||
@ -162,6 +164,11 @@ public class NetworkProfile implements Network {
|
||||
return cidr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNetworkCidr() {
|
||||
return networkCidr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getNetworkOfferingId() {
|
||||
return networkOfferingId;
|
||||
|
||||
@ -66,10 +66,8 @@ public interface NetworkService {
|
||||
|
||||
IpAddress getIp(long id);
|
||||
|
||||
|
||||
Network updateGuestNetwork(long networkId, String name, String displayText, Account callerAccount, User callerUser,
|
||||
String domainSuffix, Long networkOfferingId, Boolean changeCidr);
|
||||
|
||||
String domainSuffix, Long networkOfferingId, Boolean changeCidr, String guestVmCidr);
|
||||
|
||||
PhysicalNetwork createPhysicalNetwork(Long zoneId, String vnetRange, String networkSpeed,
|
||||
List<String> isolationMethods, String broadcastDomainRange, Long domainId, List<String> tags, String name);
|
||||
|
||||
@ -41,7 +41,7 @@ public interface VpcService {
|
||||
|
||||
public VpcOffering getVpcOffering(long vpcOfferingId);
|
||||
|
||||
public VpcOffering createVpcOffering(String name, String displayText, List<String> supportedServices);
|
||||
public VpcOffering createVpcOffering(String name, String displayText, List<String> supportedServices, Map<String, List<String>> serviceProviders);
|
||||
|
||||
public Vpc getVpc(long vpcId);
|
||||
|
||||
@ -246,5 +246,5 @@ public interface VpcService {
|
||||
InsufficientAddressCapacityException, ConcurrentOperationException;
|
||||
|
||||
public Network updateVpcGuestNetwork(long networkId, String name, String displayText, Account callerAccount,
|
||||
User callerUser, String domainSuffix, Long ntwkOffId, Boolean changeCidr);
|
||||
User callerUser, String domainSuffix, Long ntwkOffId, Boolean changeCidr, String guestVmCidr);
|
||||
}
|
||||
|
||||
@ -77,6 +77,11 @@ public interface ServiceOffering extends InfrastructureEntity, InternalIdentity,
|
||||
*/
|
||||
boolean getLimitCpuUse();
|
||||
|
||||
/**
|
||||
* @return Does this service plan support Volatile VM that is, discard VM's root disk and create a new one on reboot?
|
||||
*/
|
||||
boolean getVolatileVm();
|
||||
|
||||
/**
|
||||
* @return the rate in megabits per sec to which a VM's network interface is throttled to
|
||||
*/
|
||||
|
||||
@ -71,7 +71,7 @@ public interface ResourceService {
|
||||
|
||||
boolean deleteCluster(DeleteClusterCmd cmd);
|
||||
|
||||
Cluster updateCluster(Cluster cluster, String clusterType, String hypervisor, String allocationState, String managedstate);
|
||||
Cluster updateCluster(Cluster cluster, String clusterType, String hypervisor, String allocationState, String managedstate,Float memoryOvercommitRatio, Float cpuOvercommitRatio);
|
||||
|
||||
List<? extends Host> discoverHosts(AddHostCmd cmd) throws IllegalArgumentException, DiscoveryException, InvalidParameterValueException;
|
||||
|
||||
|
||||
@ -37,7 +37,8 @@ public interface ResourceTag extends ControlledEntity, Identity, InternalIdentit
|
||||
Project,
|
||||
Vpc,
|
||||
NetworkACL,
|
||||
StaticRoute
|
||||
StaticRoute,
|
||||
VMSnapshot
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -19,7 +19,6 @@ package com.cloud.storage;
|
||||
import java.util.Date;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.utils.fsm.StateMachine2;
|
||||
import com.cloud.utils.fsm.StateObject;
|
||||
import org.apache.cloudstack.acl.ControlledEntity;
|
||||
import org.apache.cloudstack.api.Identity;
|
||||
@ -55,28 +54,13 @@ public interface Snapshot extends ControlledEntity, Identity, InternalIdentity,
|
||||
}
|
||||
|
||||
public enum State {
|
||||
Allocated,
|
||||
Creating,
|
||||
CreatedOnPrimary,
|
||||
BackingUp,
|
||||
BackedUp,
|
||||
Error;
|
||||
|
||||
private final static StateMachine2<State, Event, Snapshot> s_fsm = new StateMachine2<State, Event, Snapshot>();
|
||||
|
||||
public static StateMachine2<State, Event, Snapshot> getStateMachine() {
|
||||
return s_fsm;
|
||||
}
|
||||
|
||||
static {
|
||||
s_fsm.addTransition(null, Event.CreateRequested, Creating);
|
||||
s_fsm.addTransition(Creating, Event.OperationSucceeded, CreatedOnPrimary);
|
||||
s_fsm.addTransition(Creating, Event.OperationNotPerformed, BackedUp);
|
||||
s_fsm.addTransition(Creating, Event.OperationFailed, Error);
|
||||
s_fsm.addTransition(CreatedOnPrimary, Event.BackupToSecondary, BackingUp);
|
||||
s_fsm.addTransition(BackingUp, Event.OperationSucceeded, BackedUp);
|
||||
s_fsm.addTransition(BackingUp, Event.OperationFailed, Error);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return this.name();
|
||||
}
|
||||
@ -107,7 +91,7 @@ public interface Snapshot extends ControlledEntity, Identity, InternalIdentity,
|
||||
|
||||
Date getCreated();
|
||||
|
||||
Type getType();
|
||||
Type getRecurringType();
|
||||
|
||||
State getState();
|
||||
|
||||
|
||||
@ -99,10 +99,7 @@ public interface StoragePool extends Identity, InternalIdentity {
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
String getStorageProvider();
|
||||
Long getStorageProviderId();
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
String getStorageType();
|
||||
boolean isInMaintenance();
|
||||
}
|
||||
|
||||
@ -17,11 +17,6 @@
|
||||
package com.cloud.storage;
|
||||
|
||||
public enum StoragePoolStatus {
|
||||
Creating,
|
||||
Up,
|
||||
PrepareForMaintenance,
|
||||
ErrorInMaintenance,
|
||||
CancelMaintenance,
|
||||
Maintenance,
|
||||
Removed;
|
||||
Initial, Initialized, Creating, Attaching, Up, PrepareForMaintenance,
|
||||
ErrorInMaintenance, CancelMaintenance, Maintenance, Removed;
|
||||
}
|
||||
|
||||
@ -22,17 +22,10 @@ import org.apache.cloudstack.api.command.admin.storage.CancelPrimaryStorageMaint
|
||||
import org.apache.cloudstack.api.command.admin.storage.CreateStoragePoolCmd;
|
||||
import org.apache.cloudstack.api.command.admin.storage.DeletePoolCmd;
|
||||
import org.apache.cloudstack.api.command.admin.storage.UpdateStoragePoolCmd;
|
||||
import org.apache.cloudstack.api.command.user.volume.CreateVolumeCmd;
|
||||
import org.apache.cloudstack.api.command.user.volume.ResizeVolumeCmd;
|
||||
import org.apache.cloudstack.api.command.user.volume.UploadVolumeCmd;
|
||||
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceInUseException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
public interface StorageService{
|
||||
/**
|
||||
@ -51,37 +44,6 @@ public interface StorageService{
|
||||
StoragePool createPool(CreateStoragePoolCmd cmd) throws ResourceInUseException, IllegalArgumentException,
|
||||
UnknownHostException, ResourceUnavailableException;
|
||||
|
||||
/**
|
||||
* Creates the database object for a volume based on the given criteria
|
||||
*
|
||||
* @param cmd
|
||||
* the API command wrapping the criteria (account/domainId [admin only], zone, diskOffering, snapshot,
|
||||
* name)
|
||||
* @return the volume object
|
||||
* @throws PermissionDeniedException
|
||||
*/
|
||||
Volume allocVolume(CreateVolumeCmd cmd) throws ResourceAllocationException;
|
||||
|
||||
/**
|
||||
* Creates the volume based on the given criteria
|
||||
*
|
||||
* @param cmd
|
||||
* the API command wrapping the criteria (account/domainId [admin only], zone, diskOffering, snapshot,
|
||||
* name)
|
||||
* @return the volume object
|
||||
*/
|
||||
Volume createVolume(CreateVolumeCmd cmd);
|
||||
|
||||
|
||||
/**
|
||||
* Resizes the volume based on the given criteria
|
||||
*
|
||||
* @param cmd
|
||||
* the API command wrapping the criteria
|
||||
* @return the volume object
|
||||
*/
|
||||
Volume resizeVolume(ResizeVolumeCmd cmd);
|
||||
|
||||
/**
|
||||
* Delete the storage pool
|
||||
*
|
||||
@ -120,19 +82,4 @@ public interface StorageService{
|
||||
public StoragePool updateStoragePool(UpdateStoragePoolCmd cmd) throws IllegalArgumentException;
|
||||
|
||||
public StoragePool getStoragePool(long id);
|
||||
|
||||
Volume migrateVolume(Long volumeId, Long storagePoolId) throws ConcurrentOperationException;
|
||||
|
||||
|
||||
/**
|
||||
* Uploads the volume to secondary storage
|
||||
*
|
||||
* @param UploadVolumeCmd cmd
|
||||
*
|
||||
* @return Volume object
|
||||
*/
|
||||
Volume uploadVolume(UploadVolumeCmd cmd) throws ResourceAllocationException;
|
||||
|
||||
boolean deleteVolume(long volumeId, Account caller) throws ConcurrentOperationException;
|
||||
|
||||
}
|
||||
|
||||
@ -39,9 +39,12 @@ public interface Volume extends ControlledEntity, Identity, InternalIdentity, Ba
|
||||
Snapshotting("There is a snapshot created on this volume, not backed up to secondary storage yet"),
|
||||
Resizing("The volume is being resized"),
|
||||
Expunging("The volume is being expunging"),
|
||||
Expunged("The volume is being expunging"),
|
||||
Destroy("The volume is destroyed, and can't be recovered."),
|
||||
Destroying("The volume is destroying, and can't be recovered."),
|
||||
UploadOp ("The volume upload operation is in progress or in short the volume is on secondary storage");
|
||||
UploadOp ("The volume upload operation is in progress or in short the volume is on secondary storage"),
|
||||
Uploading("volume is uploading"),
|
||||
Uploaded("volume is uploaded");
|
||||
|
||||
String _description;
|
||||
|
||||
@ -70,12 +73,15 @@ public interface Volume extends ControlledEntity, Identity, InternalIdentity, Ba
|
||||
s_fsm.addTransition(Resizing, Event.OperationSucceeded, Ready);
|
||||
s_fsm.addTransition(Resizing, Event.OperationFailed, Ready);
|
||||
s_fsm.addTransition(Allocated, Event.UploadRequested, UploadOp);
|
||||
s_fsm.addTransition(UploadOp, Event.CopyRequested, Creating);// CopyRequested for volume from sec to primary storage
|
||||
s_fsm.addTransition(Uploaded, Event.CopyRequested, Creating);// CopyRequested for volume from sec to primary storage
|
||||
s_fsm.addTransition(Creating, Event.CopySucceeded, Ready);
|
||||
s_fsm.addTransition(Creating, Event.CopyFailed, UploadOp);// Copying volume from sec to primary failed.
|
||||
s_fsm.addTransition(Creating, Event.CopyFailed, Uploaded);// Copying volume from sec to primary failed.
|
||||
s_fsm.addTransition(UploadOp, Event.DestroyRequested, Destroy);
|
||||
s_fsm.addTransition(Ready, Event.DestroyRequested, Destroy);
|
||||
s_fsm.addTransition(Destroy, Event.ExpungingRequested, Expunging);
|
||||
s_fsm.addTransition(Expunging, Event.ExpungingRequested, Expunging);
|
||||
s_fsm.addTransition(Expunging, Event.OperationSucceeded, Expunged);
|
||||
s_fsm.addTransition(Expunging, Event.OperationFailed, Expunging);
|
||||
s_fsm.addTransition(Ready, Event.SnapshotRequested, Snapshotting);
|
||||
s_fsm.addTransition(Snapshotting, Event.OperationSucceeded, Ready);
|
||||
s_fsm.addTransition(Snapshotting, Event.OperationFailed, Ready);
|
||||
@ -83,6 +89,9 @@ public interface Volume extends ControlledEntity, Identity, InternalIdentity, Ba
|
||||
s_fsm.addTransition(Migrating, Event.OperationSucceeded, Ready);
|
||||
s_fsm.addTransition(Migrating, Event.OperationFailed, Ready);
|
||||
s_fsm.addTransition(Destroy, Event.OperationSucceeded, Destroy);
|
||||
s_fsm.addTransition(UploadOp, Event.OperationSucceeded, Uploaded);
|
||||
s_fsm.addTransition(UploadOp, Event.OperationFailed, Allocated);
|
||||
s_fsm.addTransition(Uploaded, Event.DestroyRequested, Destroy);
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,7 +119,7 @@ public interface Volume extends ControlledEntity, Identity, InternalIdentity, Ba
|
||||
/**
|
||||
* @return total size of the partition
|
||||
*/
|
||||
long getSize();
|
||||
Long getSize();
|
||||
|
||||
/**
|
||||
* @return the vm instance id
|
||||
|
||||
81
api/src/com/cloud/storage/VolumeApiService.java
Normal file
81
api/src/com/cloud/storage/VolumeApiService.java
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* 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.storage;
|
||||
|
||||
import org.apache.cloudstack.api.command.user.volume.AttachVolumeCmd;
|
||||
import org.apache.cloudstack.api.command.user.volume.CreateVolumeCmd;
|
||||
import org.apache.cloudstack.api.command.user.volume.DetachVolumeCmd;
|
||||
import org.apache.cloudstack.api.command.user.volume.MigrateVolumeCmd;
|
||||
import org.apache.cloudstack.api.command.user.volume.ResizeVolumeCmd;
|
||||
import org.apache.cloudstack.api.command.user.volume.UploadVolumeCmd;
|
||||
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
public interface VolumeApiService {
|
||||
/**
|
||||
* Creates the database object for a volume based on the given criteria
|
||||
*
|
||||
* @param cmd
|
||||
* the API command wrapping the criteria (account/domainId [admin only], zone, diskOffering, snapshot,
|
||||
* name)
|
||||
* @return the volume object
|
||||
* @throws PermissionDeniedException
|
||||
*/
|
||||
Volume allocVolume(CreateVolumeCmd cmd) throws ResourceAllocationException;
|
||||
|
||||
/**
|
||||
* Creates the volume based on the given criteria
|
||||
*
|
||||
* @param cmd
|
||||
* the API command wrapping the criteria (account/domainId [admin only], zone, diskOffering, snapshot,
|
||||
* name)
|
||||
* @return the volume object
|
||||
*/
|
||||
Volume createVolume(CreateVolumeCmd cmd);
|
||||
|
||||
|
||||
/**
|
||||
* Resizes the volume based on the given criteria
|
||||
*
|
||||
* @param cmd
|
||||
* the API command wrapping the criteria
|
||||
* @return the volume object
|
||||
*/
|
||||
Volume resizeVolume(ResizeVolumeCmd cmd);
|
||||
|
||||
Volume migrateVolume(MigrateVolumeCmd cmd) throws ConcurrentOperationException;
|
||||
|
||||
/**
|
||||
* Uploads the volume to secondary storage
|
||||
*
|
||||
* @param UploadVolumeCmd cmd
|
||||
*
|
||||
* @return Volume object
|
||||
*/
|
||||
Volume uploadVolume(UploadVolumeCmd cmd) throws ResourceAllocationException;
|
||||
|
||||
boolean deleteVolume(long volumeId, Account caller) throws ConcurrentOperationException;
|
||||
|
||||
Volume attachVolumeToVM(AttachVolumeCmd command);
|
||||
|
||||
Volume detachVolumeFromVM(DetachVolumeCmd cmmd);
|
||||
}
|
||||
@ -25,6 +25,7 @@ import org.apache.cloudstack.api.command.user.iso.DeleteIsoCmd;
|
||||
import org.apache.cloudstack.api.command.user.iso.ExtractIsoCmd;
|
||||
import org.apache.cloudstack.api.command.user.iso.RegisterIsoCmd;
|
||||
import org.apache.cloudstack.api.command.user.template.CopyTemplateCmd;
|
||||
import org.apache.cloudstack.api.command.user.template.CreateTemplateCmd;
|
||||
import org.apache.cloudstack.api.command.user.template.DeleteTemplateCmd;
|
||||
import org.apache.cloudstack.api.command.user.template.ExtractTemplateCmd;
|
||||
import org.apache.cloudstack.api.command.user.template.RegisterTemplateCmd;
|
||||
@ -32,6 +33,8 @@ import org.apache.cloudstack.api.command.user.template.RegisterTemplateCmd;
|
||||
import com.cloud.exception.InternalErrorException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.StorageUnavailableException;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
public interface TemplateService {
|
||||
|
||||
@ -87,4 +90,11 @@ public interface TemplateService {
|
||||
List<String> listTemplatePermissions(BaseListTemplateOrIsoPermissionsCmd cmd);
|
||||
|
||||
boolean updateTemplateOrIsoPermissions(BaseUpdateTemplateOrIsoPermissionsCmd cmd);
|
||||
|
||||
VirtualMachineTemplate createPrivateTemplateRecord(CreateTemplateCmd cmd,
|
||||
Account templateOwner) throws ResourceAllocationException;
|
||||
|
||||
VirtualMachineTemplate createPrivateTemplate(CreateTemplateCmd command)
|
||||
throws CloudRuntimeException;
|
||||
|
||||
}
|
||||
|
||||
@ -23,7 +23,6 @@ import javax.naming.InsufficientResourcesException;
|
||||
|
||||
import org.apache.cloudstack.api.command.admin.vm.AssignVMCmd;
|
||||
import org.apache.cloudstack.api.command.admin.vm.RecoverVMCmd;
|
||||
import org.apache.cloudstack.api.command.user.template.CreateTemplateCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.AddNicToVMCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.DeployVMCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.DestroyVMCmd;
|
||||
@ -103,24 +102,6 @@ public interface UserVmService {
|
||||
*/
|
||||
UserVm resetVMSSHKey(ResetVMSSHKeyCmd cmd) throws ResourceUnavailableException, InsufficientCapacityException;
|
||||
|
||||
/**
|
||||
* Attaches the specified volume to the specified VM
|
||||
*
|
||||
* @param cmd
|
||||
* - the command specifying volumeId and vmId
|
||||
* @return the Volume object if attach worked successfully.
|
||||
*/
|
||||
Volume attachVolumeToVM(AttachVolumeCmd cmd);
|
||||
|
||||
/**
|
||||
* Detaches the specified volume from the VM it is currently attached to.
|
||||
*
|
||||
* @param cmd
|
||||
* - the command specifying volumeId
|
||||
* @return the Volume object if detach worked successfully.
|
||||
*/
|
||||
Volume detachVolumeFromVM(DetachVolumeCmd cmmd);
|
||||
|
||||
UserVm startVirtualMachine(StartVMCmd cmd) throws StorageUnavailableException, ExecutionException, ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException,
|
||||
ResourceAllocationException;
|
||||
|
||||
@ -151,28 +132,6 @@ public interface UserVmService {
|
||||
|
||||
UserVm recoverVirtualMachine(RecoverVMCmd cmd) throws ResourceAllocationException;
|
||||
|
||||
/**
|
||||
* Create a template database record in preparation for creating a private template.
|
||||
*
|
||||
* @param cmd
|
||||
* the command object that defines the name, display text, snapshot/volume, bits, public/private, etc.
|
||||
* for the
|
||||
* private template
|
||||
* @param templateOwner
|
||||
* TODO
|
||||
* @return the vm template object if successful, null otherwise
|
||||
* @throws ResourceAllocationException
|
||||
*/
|
||||
VirtualMachineTemplate createPrivateTemplateRecord(CreateTemplateCmd cmd, Account templateOwner) throws ResourceAllocationException;
|
||||
|
||||
/**
|
||||
* Creates a private template from a snapshot of a VM
|
||||
*
|
||||
* @param cmd
|
||||
* - the command specifying snapshotId, name, description
|
||||
* @return a template if successfully created, null otherwise
|
||||
*/
|
||||
VirtualMachineTemplate createPrivateTemplate(CreateTemplateCmd cmd);
|
||||
|
||||
/**
|
||||
* Creates a Basic Zone User VM in the database and returns the VM to the caller.
|
||||
|
||||
@ -174,7 +174,9 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, Identity, I
|
||||
OperationFailedToError,
|
||||
OperationRetry,
|
||||
AgentReportShutdowned,
|
||||
AgentReportMigrated
|
||||
AgentReportMigrated,
|
||||
RevertRequested,
|
||||
SnapshotRequested
|
||||
};
|
||||
|
||||
public enum Type {
|
||||
|
||||
@ -136,4 +136,10 @@ public interface VirtualMachineProfile<T extends VirtualMachine> {
|
||||
BootloaderType getBootLoaderType();
|
||||
|
||||
Map<Param, Object> getParameters();
|
||||
|
||||
Float getCpuOvercommitRatio();
|
||||
|
||||
Float getMemoryOvercommitRatio();
|
||||
|
||||
|
||||
}
|
||||
|
||||
110
api/src/com/cloud/vm/snapshot/VMSnapshot.java
Normal file
110
api/src/com/cloud/vm/snapshot/VMSnapshot.java
Normal file
@ -0,0 +1,110 @@
|
||||
// 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.vm.snapshot;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.cloudstack.api.Identity;
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
|
||||
import org.apache.cloudstack.acl.ControlledEntity;
|
||||
import com.cloud.utils.fsm.StateMachine2;
|
||||
import com.cloud.utils.fsm.StateObject;
|
||||
|
||||
public interface VMSnapshot extends ControlledEntity, Identity, InternalIdentity,StateObject<VMSnapshot.State> {
|
||||
|
||||
enum State {
|
||||
Allocated("The VM snapshot is allocated but has not been created yet."),
|
||||
Creating("The VM snapshot is being created."),
|
||||
Ready("The VM snapshot is ready to be used."),
|
||||
Reverting("The VM snapshot is being used to revert"),
|
||||
Expunging("The volume is being expunging"),
|
||||
Removed("The volume is destroyed, and can't be recovered."),
|
||||
Error ("The volume is in error state, and can't be recovered");
|
||||
|
||||
String _description;
|
||||
|
||||
private State(String description) {
|
||||
_description = description;
|
||||
}
|
||||
|
||||
public static StateMachine2<State, Event, VMSnapshot> getStateMachine() {
|
||||
return s_fsm;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return _description;
|
||||
}
|
||||
|
||||
private final static StateMachine2<State, Event, VMSnapshot> s_fsm = new StateMachine2<State, Event, VMSnapshot>();
|
||||
static {
|
||||
s_fsm.addTransition(Allocated, Event.CreateRequested, Creating);
|
||||
s_fsm.addTransition(Creating, Event.OperationSucceeded, Ready);
|
||||
s_fsm.addTransition(Creating, Event.OperationFailed, Error);
|
||||
s_fsm.addTransition(Ready, Event.RevertRequested, Reverting);
|
||||
s_fsm.addTransition(Reverting, Event.OperationSucceeded, Ready);
|
||||
s_fsm.addTransition(Reverting, Event.OperationFailed, Ready);
|
||||
s_fsm.addTransition(Ready, Event.ExpungeRequested, Expunging);
|
||||
s_fsm.addTransition(Error, Event.ExpungeRequested, Expunging);
|
||||
s_fsm.addTransition(Expunging, Event.ExpungeRequested, Expunging);
|
||||
s_fsm.addTransition(Expunging, Event.OperationSucceeded, Removed);
|
||||
}
|
||||
}
|
||||
|
||||
enum Type{
|
||||
Disk, DiskAndMemory
|
||||
}
|
||||
|
||||
enum Event {
|
||||
CreateRequested,
|
||||
OperationFailed,
|
||||
OperationSucceeded,
|
||||
RevertRequested,
|
||||
ExpungeRequested,
|
||||
}
|
||||
|
||||
long getId();
|
||||
|
||||
public String getName();
|
||||
|
||||
public Long getVmId();
|
||||
|
||||
public State getState();
|
||||
|
||||
public Date getCreated();
|
||||
|
||||
public String getDescription();
|
||||
|
||||
public String getDisplayName();
|
||||
|
||||
public Long getParent();
|
||||
|
||||
public Boolean getCurrent();
|
||||
|
||||
public Type getType();
|
||||
|
||||
public long getUpdatedCount();
|
||||
|
||||
public void incrUpdatedCount();
|
||||
|
||||
public Date getUpdated();
|
||||
|
||||
public Date getRemoved();
|
||||
|
||||
public long getAccountId();
|
||||
}
|
||||
48
api/src/com/cloud/vm/snapshot/VMSnapshotService.java
Normal file
48
api/src/com/cloud/vm/snapshot/VMSnapshotService.java
Normal file
@ -0,0 +1,48 @@
|
||||
// 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.vm.snapshot;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.api.command.user.vmsnapshot.ListVMSnapshotCmd;
|
||||
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InsufficientServerCapacityException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
public interface VMSnapshotService {
|
||||
|
||||
List<? extends VMSnapshot> listVMSnapshots(ListVMSnapshotCmd cmd);
|
||||
|
||||
VMSnapshot getVMSnapshotById(Long id);
|
||||
|
||||
VMSnapshot creatVMSnapshot(Long vmId, Long vmSnapshotId);
|
||||
|
||||
VMSnapshot allocVMSnapshot(Long vmId, String vsDisplayName, String vsDescription, Boolean snapshotMemory)
|
||||
throws ResourceAllocationException;
|
||||
|
||||
boolean deleteVMSnapshot(Long vmSnapshotId);
|
||||
|
||||
UserVm revertToSnapshot(Long vmSnapshotId) throws InsufficientServerCapacityException, InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException;
|
||||
|
||||
VirtualMachine getVMBySnapshotId(Long id);
|
||||
}
|
||||
@ -46,6 +46,7 @@ public class ApiConstants {
|
||||
public static final String COMPONENT = "component";
|
||||
public static final String CPU_NUMBER = "cpunumber";
|
||||
public static final String CPU_SPEED = "cpuspeed";
|
||||
public static final String CPU_OVERCOMMIT_RATIO="cpuovercommitratio";
|
||||
public static final String CREATED = "created";
|
||||
public static final String CUSTOMIZED = "customized";
|
||||
public static final String DESCRIPTION = "description";
|
||||
@ -119,6 +120,7 @@ public class ApiConstants {
|
||||
public static final String MAX = "max";
|
||||
public static final String MAX_SNAPS = "maxsnaps";
|
||||
public static final String MEMORY = "memory";
|
||||
public static final String MEMORY_OVERCOMMIT_RATIO="memoryovercommitratio";
|
||||
public static final String MODE = "mode";
|
||||
public static final String NAME = "name";
|
||||
public static final String METHOD_NAME = "methodname";
|
||||
@ -218,6 +220,7 @@ public class ApiConstants {
|
||||
public static final String VM_LIMIT = "vmlimit";
|
||||
public static final String VM_TOTAL = "vmtotal";
|
||||
public static final String VNET = "vnet";
|
||||
public static final String IS_VOLATILE = "isvolatile";
|
||||
public static final String VOLUME_ID = "volumeid";
|
||||
public static final String ZONE_ID = "zoneid";
|
||||
public static final String ZONE_NAME = "zonename";
|
||||
@ -438,6 +441,15 @@ public class ApiConstants {
|
||||
public static final String AUTOSCALE_USER_ID = "autoscaleuserid";
|
||||
public static final String BAREMETAL_DISCOVER_NAME = "baremetaldiscovername";
|
||||
public static final String UCS_DN = "ucsdn";
|
||||
public static final String VM_SNAPSHOT_DESCRIPTION = "description";
|
||||
public static final String VM_SNAPSHOT_DISPLAYNAME = "name";
|
||||
public static final String VM_SNAPSHOT_ID = "vmsnapshotid";
|
||||
public static final String VM_SNAPSHOT_DISK_IDS = "vmsnapshotdiskids";
|
||||
public static final String VM_SNAPSHOT_MEMORY = "snapshotmemory";
|
||||
public static final String IMAGE_STORE_UUID = "imagestoreuuid";
|
||||
public static final String GUEST_VM_CIDR = "guestvmcidr";
|
||||
public static final String NETWORK_CIDR = "networkcidr";
|
||||
public static final String RESERVED_IP_RANGE = "reservediprange";
|
||||
|
||||
public enum HostDetails {
|
||||
all, capacity, events, stats, min;
|
||||
|
||||
468
api/src/org/apache/cloudstack/api/ApiConstants.java.orig
Normal file
468
api/src/org/apache/cloudstack/api/ApiConstants.java.orig
Normal file
@ -0,0 +1,468 @@
|
||||
// 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.api;
|
||||
|
||||
|
||||
public class ApiConstants {
|
||||
public static final String ACCOUNT = "account";
|
||||
public static final String ACCOUNTS = "accounts";
|
||||
public static final String ACCOUNT_TYPE = "accounttype";
|
||||
public static final String ACCOUNT_ID = "accountid";
|
||||
public static final String ALGORITHM = "algorithm";
|
||||
public static final String ALLOCATED_ONLY = "allocatedonly";
|
||||
public static final String API_KEY = "userapikey";
|
||||
public static final String APPLIED = "applied";
|
||||
public static final String AVAILABLE = "available";
|
||||
public static final String BITS = "bits";
|
||||
public static final String BOOTABLE = "bootable";
|
||||
public static final String BIND_DN = "binddn";
|
||||
public static final String BIND_PASSWORD = "bindpass";
|
||||
public static final String CATEGORY = "category";
|
||||
public static final String CERTIFICATE = "certificate";
|
||||
public static final String PRIVATE_KEY = "privatekey";
|
||||
public static final String DOMAIN_SUFFIX = "domainsuffix";
|
||||
public static final String DNS_SEARCH_ORDER = "dnssearchorder";
|
||||
public static final String CIDR = "cidr";
|
||||
public static final String IP6_CIDR = "ip6cidr";
|
||||
public static final String CIDR_LIST = "cidrlist";
|
||||
public static final String CLEANUP = "cleanup";
|
||||
public static final String CLUSTER_ID = "clusterid";
|
||||
public static final String CLUSTER_NAME = "clustername";
|
||||
public static final String CLUSTER_TYPE = "clustertype";
|
||||
public static final String COMPONENT = "component";
|
||||
public static final String CPU_NUMBER = "cpunumber";
|
||||
public static final String CPU_SPEED = "cpuspeed";
|
||||
public static final String CREATED = "created";
|
||||
public static final String CUSTOMIZED = "customized";
|
||||
public static final String DESCRIPTION = "description";
|
||||
public static final String DESTINATION_ZONE_ID = "destzoneid";
|
||||
public static final String DETAILS = "details";
|
||||
public static final String DEVICE_ID = "deviceid";
|
||||
public static final String DISK_OFFERING_ID = "diskofferingid";
|
||||
public static final String DISK_SIZE = "disksize";
|
||||
public static final String DISPLAY_NAME = "displayname";
|
||||
public static final String DISPLAY_TEXT = "displaytext";
|
||||
public static final String DNS1 = "dns1";
|
||||
public static final String DNS2 = "dns2";
|
||||
public static final String DOMAIN = "domain";
|
||||
public static final String DOMAIN_ID = "domainid";
|
||||
public static final String DURATION = "duration";
|
||||
public static final String EMAIL = "email";
|
||||
public static final String END_DATE = "enddate";
|
||||
public static final String END_IP = "endip";
|
||||
public static final String END_IPV6 = "endipv6";
|
||||
public static final String END_PORT = "endport";
|
||||
public static final String ENTRY_TIME = "entrytime";
|
||||
public static final String FETCH_LATEST = "fetchlatest";
|
||||
public static final String FIRSTNAME = "firstname";
|
||||
public static final String FORCED = "forced";
|
||||
public static final String FORCED_DESTROY_LOCAL_STORAGE = "forcedestroylocalstorage";
|
||||
public static final String FORMAT = "format";
|
||||
public static final String FOR_VIRTUAL_NETWORK = "forvirtualnetwork";
|
||||
public static final String GATEWAY = "gateway";
|
||||
public static final String IP6_GATEWAY = "ip6gateway";
|
||||
public static final String GROUP = "group";
|
||||
public static final String GROUP_ID = "groupid";
|
||||
public static final String GUEST_CIDR_ADDRESS = "guestcidraddress";
|
||||
public static final String HA_ENABLE = "haenable";
|
||||
public static final String HOST_ID = "hostid";
|
||||
public static final String HOST_NAME = "hostname";
|
||||
public static final String HYPERVISOR = "hypervisor";
|
||||
public static final String INLINE = "inline";
|
||||
public static final String INSTANCE = "instance";
|
||||
public static final String ICMP_CODE = "icmpcode";
|
||||
public static final String ICMP_TYPE = "icmptype";
|
||||
public static final String ID = "id";
|
||||
public static final String IDS = "ids";
|
||||
public static final String INTERNAL_DNS1 = "internaldns1";
|
||||
public static final String INTERNAL_DNS2 = "internaldns2";
|
||||
public static final String INTERVAL_TYPE = "intervaltype";
|
||||
public static final String IP_ADDRESS = "ipaddress";
|
||||
public static final String IP6_ADDRESS = "ip6address";
|
||||
public static final String IP_ADDRESS_ID = "ipaddressid";
|
||||
public static final String IS_ASYNC = "isasync";
|
||||
public static final String IP_AVAILABLE = "ipavailable";
|
||||
public static final String IP_LIMIT = "iplimit";
|
||||
public static final String IP_TOTAL = "iptotal";
|
||||
public static final String IS_CLEANUP_REQUIRED = "iscleanuprequired";
|
||||
public static final String IS_EXTRACTABLE = "isextractable";
|
||||
public static final String IS_FEATURED = "isfeatured";
|
||||
public static final String IS_PUBLIC = "ispublic";
|
||||
public static final String IS_PERSISTENT = "ispersistent";
|
||||
public static final String IS_READY = "isready";
|
||||
public static final String IS_RECURSIVE = "isrecursive";
|
||||
public static final String ISO_FILTER = "isofilter";
|
||||
public static final String ISO_GUEST_OS_NONE = "None";
|
||||
public static final String JOB_ID = "jobid";
|
||||
public static final String JOB_STATUS = "jobstatus";
|
||||
public static final String LASTNAME = "lastname";
|
||||
public static final String LEVEL = "level";
|
||||
public static final String LENGTH = "length";
|
||||
public static final String LIMIT_CPU_USE = "limitcpuuse";
|
||||
public static final String LOCK = "lock";
|
||||
public static final String LUN = "lun";
|
||||
public static final String LBID = "lbruleid";
|
||||
public static final String MAX = "max";
|
||||
public static final String MAX_SNAPS = "maxsnaps";
|
||||
public static final String MEMORY = "memory";
|
||||
public static final String MODE = "mode";
|
||||
public static final String NAME = "name";
|
||||
public static final String METHOD_NAME = "methodname";
|
||||
public static final String NETWORK_DOMAIN = "networkdomain";
|
||||
public static final String NETMASK = "netmask";
|
||||
public static final String NEW_NAME = "newname";
|
||||
public static final String NUM_RETRIES = "numretries";
|
||||
public static final String OFFER_HA = "offerha";
|
||||
public static final String IS_SYSTEM_OFFERING = "issystem";
|
||||
public static final String IS_DEFAULT_USE = "defaultuse";
|
||||
public static final String OP = "op";
|
||||
public static final String OS_CATEGORY_ID = "oscategoryid";
|
||||
public static final String OS_TYPE_ID = "ostypeid";
|
||||
public static final String PARAMS = "params";
|
||||
public static final String PARENT_DOMAIN_ID = "parentdomainid";
|
||||
public static final String PASSWORD = "password";
|
||||
public static final String NEW_PASSWORD = "new_password";
|
||||
public static final String PASSWORD_ENABLED = "passwordenabled";
|
||||
public static final String SSHKEY_ENABLED = "sshkeyenabled";
|
||||
public static final String PATH = "path";
|
||||
public static final String POD_ID = "podid";
|
||||
public static final String POD_IDS = "podids";
|
||||
public static final String POLICY_ID = "policyid";
|
||||
public static final String PORT = "port";
|
||||
public static final String PORTAL = "portal";
|
||||
public static final String PORT_FORWARDING_SERVICE_ID = "portforwardingserviceid";
|
||||
public static final String PRIVATE_INTERFACE = "privateinterface";
|
||||
public static final String PRIVATE_IP = "privateip";
|
||||
public static final String PRIVATE_PORT = "privateport";
|
||||
public static final String PRIVATE_START_PORT = "privateport";
|
||||
public static final String PRIVATE_END_PORT = "privateendport";
|
||||
public static final String PRIVATE_ZONE = "privatezone";
|
||||
public static final String PROTOCOL = "protocol";
|
||||
public static final String PUBLIC_INTERFACE = "publicinterface";
|
||||
public static final String PUBLIC_IP_ID = "publicipid";
|
||||
public static final String PUBLIC_IP = "publicip";
|
||||
public static final String PUBLIC_PORT = "publicport";
|
||||
public static final String PUBLIC_START_PORT = "publicport";
|
||||
public static final String PUBLIC_END_PORT = "publicendport";
|
||||
public static final String PUBLIC_ZONE = "publiczone";
|
||||
public static final String RECEIVED_BYTES = "receivedbytes";
|
||||
public static final String REQUIRES_HVM = "requireshvm";
|
||||
public static final String RESOURCE_TYPE = "resourcetype";
|
||||
public static final String RESPONSE = "response";
|
||||
public static final String QUERY_FILTER = "queryfilter";
|
||||
public static final String SCHEDULE = "schedule";
|
||||
public static final String SCOPE = "scope";
|
||||
public static final String SECRET_KEY = "usersecretkey";
|
||||
public static final String SINCE = "since";
|
||||
public static final String KEY = "key";
|
||||
public static final String SEARCH_BASE = "searchbase";
|
||||
public static final String SECURITY_GROUP_IDS = "securitygroupids";
|
||||
public static final String SECURITY_GROUP_NAMES = "securitygroupnames";
|
||||
public static final String SECURITY_GROUP_NAME = "securitygroupname";
|
||||
public static final String SECURITY_GROUP_ID = "securitygroupid";
|
||||
public static final String SENT = "sent";
|
||||
public static final String SENT_BYTES = "sentbytes";
|
||||
public static final String SERVICE_OFFERING_ID = "serviceofferingid";
|
||||
public static final String SHOW_CAPACITIES = "showcapacities";
|
||||
public static final String SIZE = "size";
|
||||
public static final String SNAPSHOT_ID = "snapshotid";
|
||||
public static final String SNAPSHOT_POLICY_ID = "snapshotpolicyid";
|
||||
public static final String SNAPSHOT_TYPE = "snapshottype";
|
||||
public static final String SOURCE_ZONE_ID = "sourcezoneid";
|
||||
public static final String START_DATE = "startdate";
|
||||
public static final String START_IP = "startip";
|
||||
public static final String START_IPV6 = "startipv6";
|
||||
public static final String START_PORT = "startport";
|
||||
public static final String STATE = "state";
|
||||
public static final String STATUS = "status";
|
||||
public static final String STORAGE_TYPE = "storagetype";
|
||||
public static final String SYSTEM_VM_TYPE = "systemvmtype";
|
||||
public static final String TAGS = "tags";
|
||||
public static final String TARGET_IQN = "targetiqn";
|
||||
public static final String TEMPLATE_FILTER = "templatefilter";
|
||||
public static final String TEMPLATE_ID = "templateid";
|
||||
public static final String ISO_ID = "isoid";
|
||||
public static final String TIMEOUT = "timeout";
|
||||
public static final String TIMEZONE = "timezone";
|
||||
public static final String TYPE = "type";
|
||||
public static final String TRUST_STORE = "truststore";
|
||||
public static final String TRUST_STORE_PASSWORD = "truststorepass";
|
||||
public static final String URL = "url";
|
||||
public static final String USAGE_INTERFACE = "usageinterface";
|
||||
public static final String USER_DATA = "userdata";
|
||||
public static final String USER_ID = "userid";
|
||||
public static final String USE_SSL = "ssl";
|
||||
public static final String USERNAME = "username";
|
||||
public static final String USER_SECURITY_GROUP_LIST = "usersecuritygrouplist";
|
||||
public static final String USE_VIRTUAL_NETWORK = "usevirtualnetwork";
|
||||
public static final String VALUE = "value";
|
||||
public static final String VIRTUAL_MACHINE_ID = "virtualmachineid";
|
||||
public static final String VIRTUAL_MACHINE_IDS = "virtualmachineids";
|
||||
public static final String VLAN = "vlan";
|
||||
public static final String VLAN_ID = "vlanid";
|
||||
public static final String VM_AVAILABLE = "vmavailable";
|
||||
public static final String VM_LIMIT = "vmlimit";
|
||||
public static final String VM_TOTAL = "vmtotal";
|
||||
public static final String VNET = "vnet";
|
||||
public static final String VOLUME_ID = "volumeid";
|
||||
public static final String ZONE_ID = "zoneid";
|
||||
public static final String ZONE_NAME = "zonename";
|
||||
public static final String NETWORK_TYPE = "networktype";
|
||||
public static final String PAGE = "page";
|
||||
public static final String PAGE_SIZE = "pagesize";
|
||||
public static final String COUNT = "count";
|
||||
public static final String TRAFFIC_TYPE = "traffictype";
|
||||
public static final String NETWORK_OFFERING_ID = "networkofferingid";
|
||||
public static final String NETWORK_IDS = "networkids";
|
||||
public static final String NETWORK_ID = "networkid";
|
||||
public static final String NIC_ID = "nicid";
|
||||
public static final String SPECIFY_VLAN = "specifyvlan";
|
||||
public static final String IS_DEFAULT = "isdefault";
|
||||
public static final String IS_SYSTEM = "issystem";
|
||||
public static final String AVAILABILITY = "availability";
|
||||
public static final String NETWORKRATE = "networkrate";
|
||||
public static final String HOST_TAGS = "hosttags";
|
||||
public static final String SSH_KEYPAIR = "keypair";
|
||||
public static final String HOST_CPU_CAPACITY = "hostcpucapacity";
|
||||
public static final String HOST_CPU_NUM = "hostcpunum";
|
||||
public static final String HOST_MEM_CAPACITY = "hostmemcapacity";
|
||||
public static final String HOST_MAC = "hostmac";
|
||||
public static final String HOST_TAG = "hosttag";
|
||||
public static final String PXE_SERVER_TYPE = "pxeservertype";
|
||||
public static final String LINMIN_USERNAME = "linminusername";
|
||||
public static final String LINMIN_PASSWORD = "linminpassword";
|
||||
public static final String LINMIN_APID = "linminapid";
|
||||
public static final String DHCP_SERVER_TYPE = "dhcpservertype";
|
||||
public static final String LINK_LOCAL_IP = "linklocalip";
|
||||
public static final String LINK_LOCAL_MAC_ADDRESS = "linklocalmacaddress";
|
||||
public static final String LINK_LOCAL_MAC_NETMASK = "linklocalnetmask";
|
||||
public static final String LINK_LOCAL_NETWORK_ID = "linklocalnetworkid";
|
||||
public static final String PRIVATE_MAC_ADDRESS = "privatemacaddress";
|
||||
public static final String PRIVATE_NETMASK = "privatenetmask";
|
||||
public static final String PRIVATE_NETWORK_ID = "privatenetworkid";
|
||||
public static final String ALLOCATION_STATE = "allocationstate";
|
||||
public static final String MANAGED_STATE = "managedstate";
|
||||
public static final String STORAGE_ID = "storageid";
|
||||
public static final String PING_STORAGE_SERVER_IP = "pingstorageserverip";
|
||||
public static final String PING_DIR = "pingdir";
|
||||
public static final String TFTP_DIR = "tftpdir";
|
||||
public static final String PING_CIFS_USERNAME = "pingcifsusername";
|
||||
public static final String PING_CIFS_PASSWORD = "pingcifspassword";
|
||||
public static final String CHECKSUM = "checksum";
|
||||
public static final String NETWORK_DEVICE_TYPE = "networkdevicetype";
|
||||
public static final String NETWORK_DEVICE_PARAMETER_LIST = "networkdeviceparameterlist";
|
||||
public static final String ZONE_TOKEN = "zonetoken";
|
||||
public static final String DHCP_PROVIDER = "dhcpprovider";
|
||||
public static final String RESULT = "success";
|
||||
public static final String LUN_ID = "lunId";
|
||||
public static final String IQN = "iqn";
|
||||
public static final String AGGREGATE_NAME = "aggregatename";
|
||||
public static final String POOL_NAME = "poolname";
|
||||
public static final String VOLUME_NAME = "volumename";
|
||||
public static final String SNAPSHOT_POLICY = "snapshotpolicy";
|
||||
public static final String SNAPSHOT_RESERVATION = "snapshotreservation";
|
||||
public static final String IP_NETWORK_LIST = "iptonetworklist";
|
||||
public static final String PARAM_LIST = "param";
|
||||
public static final String FOR_LOAD_BALANCING = "forloadbalancing";
|
||||
public static final String KEYBOARD = "keyboard";
|
||||
public static final String OPEN_FIREWALL = "openfirewall";
|
||||
public static final String TEMPLATE_TAG = "templatetag";
|
||||
public static final String HYPERVISOR_VERSION = "hypervisorversion";
|
||||
public static final String MAX_GUESTS_LIMIT = "maxguestslimit";
|
||||
public static final String PROJECT_ID = "projectid";
|
||||
public static final String PROJECT_IDS = "projectids";
|
||||
public static final String PROJECT = "project";
|
||||
public static final String ROLE = "role";
|
||||
public static final String USER = "user";
|
||||
public static final String ACTIVE_ONLY = "activeonly";
|
||||
public static final String TOKEN = "token";
|
||||
public static final String ACCEPT = "accept";
|
||||
public static final String SORT_KEY = "sortkey";
|
||||
public static final String ACCOUNT_DETAILS = "accountdetails";
|
||||
public static final String SERVICE_PROVIDER_LIST = "serviceproviderlist";
|
||||
public static final String SERVICE_CAPABILITY_LIST = "servicecapabilitylist";
|
||||
public static final String CAN_CHOOSE_SERVICE_CAPABILITY = "canchooseservicecapability";
|
||||
public static final String PROVIDER = "provider";
|
||||
public static final String NETWORK_SPEED = "networkspeed";
|
||||
public static final String BROADCAST_DOMAIN_RANGE = "broadcastdomainrange";
|
||||
public static final String ISOLATION_METHODS = "isolationmethods";
|
||||
public static final String PHYSICAL_NETWORK_ID = "physicalnetworkid";
|
||||
public static final String DEST_PHYSICAL_NETWORK_ID = "destinationphysicalnetworkid";
|
||||
public static final String ENABLED = "enabled";
|
||||
public static final String SERVICE_NAME = "servicename";
|
||||
public static final String DHCP_RANGE = "dhcprange";
|
||||
public static final String UUID = "uuid";
|
||||
public static final String SECURITY_GROUP_EANBLED = "securitygroupenabled";
|
||||
public static final String LOCAL_STORAGE_ENABLED = "localstorageenabled";
|
||||
public static final String GUEST_IP_TYPE = "guestiptype";
|
||||
public static final String XEN_NETWORK_LABEL = "xennetworklabel";
|
||||
public static final String KVM_NETWORK_LABEL = "kvmnetworklabel";
|
||||
public static final String VMWARE_NETWORK_LABEL = "vmwarenetworklabel";
|
||||
public static final String NETWORK_SERVICE_PROVIDER_ID = "nspid";
|
||||
public static final String SERVICE_LIST = "servicelist";
|
||||
public static final String CAN_ENABLE_INDIVIDUAL_SERVICE = "canenableindividualservice";
|
||||
public static final String SUPPORTED_SERVICES = "supportedservices";
|
||||
public static final String NSP_ID = "nspid";
|
||||
public static final String ACL_TYPE = "acltype";
|
||||
public static final String SUBDOMAIN_ACCESS = "subdomainaccess";
|
||||
public static final String LOAD_BALANCER_DEVICE_ID = "lbdeviceid";
|
||||
public static final String LOAD_BALANCER_DEVICE_NAME = "lbdevicename";
|
||||
public static final String LOAD_BALANCER_DEVICE_STATE = "lbdevicestate";
|
||||
public static final String LOAD_BALANCER_DEVICE_CAPACITY = "lbdevicecapacity";
|
||||
public static final String LOAD_BALANCER_DEVICE_DEDICATED = "lbdevicededicated";
|
||||
public static final String FIREWALL_DEVICE_ID = "fwdeviceid";
|
||||
public static final String FIREWALL_DEVICE_NAME = "fwdevicename";
|
||||
public static final String FIREWALL_DEVICE_STATE = "fwdevicestate";
|
||||
public static final String FIREWALL_DEVICE_CAPACITY = "fwdevicecapacity";
|
||||
public static final String FIREWALL_DEVICE_DEDICATED = "fwdevicededicated";
|
||||
public static final String SERVICE = "service";
|
||||
public static final String ASSOCIATED_NETWORK_ID = "associatednetworkid";
|
||||
public static final String ASSOCIATED_NETWORK_NAME = "associatednetworkname";
|
||||
public static final String SOURCE_NAT_SUPPORTED = "sourcenatsupported";
|
||||
public static final String RESOURCE_STATE = "resourcestate";
|
||||
public static final String PROJECT_INVITE_REQUIRED = "projectinviterequired";
|
||||
public static final String REQUIRED = "required";
|
||||
public static final String RESTART_REQUIRED = "restartrequired";
|
||||
public static final String ALLOW_USER_CREATE_PROJECTS = "allowusercreateprojects";
|
||||
public static final String CONSERVE_MODE = "conservemode";
|
||||
public static final String TRAFFIC_TYPE_IMPLEMENTOR = "traffictypeimplementor";
|
||||
public static final String KEYWORD = "keyword";
|
||||
public static final String LIST_ALL = "listall";
|
||||
public static final String SPECIFY_IP_RANGES = "specifyipranges";
|
||||
public static final String IS_SOURCE_NAT = "issourcenat";
|
||||
public static final String IS_STATIC_NAT = "isstaticnat";
|
||||
public static final String SORT_BY = "sortby";
|
||||
public static final String CHANGE_CIDR = "changecidr";
|
||||
public static final String PURPOSE = "purpose";
|
||||
public static final String IS_TAGGED = "istagged";
|
||||
public static final String INSTANCE_NAME = "instancename";
|
||||
public static final String START_VM = "startvm";
|
||||
public static final String HA_HOST = "hahost";
|
||||
public static final String CUSTOM_DISK_OFF_MAX_SIZE = "customdiskofferingmaxsize";
|
||||
public static final String DEFAULT_ZONE_ID = "defaultzoneid";
|
||||
public static final String GUID = "guid";
|
||||
|
||||
public static final String EXTERNAL_SWITCH_MGMT_DEVICE_ID = "vsmdeviceid";
|
||||
public static final String EXTERNAL_SWITCH_MGMT_DEVICE_NAME = "vsmdevicename";
|
||||
public static final String EXTERNAL_SWITCH_MGMT_DEVICE_STATE = "vsmdevicestate";
|
||||
// Would we need to have a capacity field for Cisco N1KV VSM? Max hosts managed by it perhaps? May remove this later.
|
||||
public static final String EXTERNAL_SWITCH_MGMT_DEVICE_CAPACITY = "vsmdevicecapacity";
|
||||
public static final String CISCO_NEXUS_VSM_NAME = "vsmname";
|
||||
public static final String VSM_USERNAME = "vsmusername";
|
||||
public static final String VSM_PASSWORD = "vsmpassword";
|
||||
public static final String VSM_IPADDRESS = "vsmipaddress";
|
||||
public static final String VSM_MGMT_VLAN_ID = "vsmmgmtvlanid";
|
||||
public static final String VSM_PKT_VLAN_ID = "vsmpktvlanid";
|
||||
public static final String VSM_CTRL_VLAN_ID = "vsmctrlvlanid";
|
||||
public static final String VSM_STORAGE_VLAN_ID = "vsmstoragevlanid";
|
||||
public static final String VSM_DOMAIN_ID = "vsmdomainid";
|
||||
public static final String VSM_CONFIG_MODE = "vsmconfigmode";
|
||||
public static final String VSM_CONFIG_STATE = "vsmconfigstate";
|
||||
public static final String VSM_DEVICE_STATE = "vsmdevicestate";
|
||||
public static final String ADD_VSM_FLAG = "addvsmflag";
|
||||
public static final String END_POINT = "endpoint";
|
||||
public static final String REGION_ID = "regionid";
|
||||
public static final String IS_PROPAGATE = "ispropagate";
|
||||
public static final String VPC_OFF_ID = "vpcofferingid";
|
||||
public static final String NETWORK = "network";
|
||||
public static final String VPC_ID = "vpcid";
|
||||
public static final String GATEWAY_ID = "gatewayid";
|
||||
public static final String CAN_USE_FOR_DEPLOY = "canusefordeploy";
|
||||
public static final String RESOURCE_IDS = "resourceids";
|
||||
public static final String RESOURCE_ID = "resourceid";
|
||||
public static final String CUSTOMER = "customer";
|
||||
public static final String S2S_VPN_GATEWAY_ID = "s2svpngatewayid";
|
||||
public static final String S2S_CUSTOMER_GATEWAY_ID = "s2scustomergatewayid";
|
||||
public static final String IPSEC_PSK = "ipsecpsk";
|
||||
public static final String GUEST_IP = "guestip";
|
||||
public static final String REMOVED = "removed";
|
||||
public static final String IKE_POLICY = "ikepolicy";
|
||||
public static final String ESP_POLICY = "esppolicy";
|
||||
public static final String IKE_LIFETIME = "ikelifetime";
|
||||
public static final String ESP_LIFETIME = "esplifetime";
|
||||
public static final String DPD = "dpd";
|
||||
public static final String FOR_VPC = "forvpc";
|
||||
public static final String SHRINK_OK = "shrinkok";
|
||||
public static final String NICIRA_NVP_DEVICE_ID = "nvpdeviceid";
|
||||
public static final String NICIRA_NVP_TRANSPORT_ZONE_UUID = "transportzoneuuid";
|
||||
public static final String NICIRA_NVP_DEVICE_NAME = "niciradevicename";
|
||||
public static final String NICIRA_NVP_GATEWAYSERVICE_UUID = "l3gatewayserviceuuid";
|
||||
public static final String S3_ACCESS_KEY = "accesskey";
|
||||
public static final String S3_SECRET_KEY = "secretkey";
|
||||
public static final String S3_END_POINT = "endpoint";
|
||||
public static final String S3_BUCKET_NAME = "bucket";
|
||||
public static final String S3_HTTPS_FLAG = "usehttps";
|
||||
public static final String S3_CONNECTION_TIMEOUT = "connectiontimeout";
|
||||
public static final String S3_MAX_ERROR_RETRY = "maxerrorretry";
|
||||
public static final String S3_SOCKET_TIMEOUT = "sockettimeout";
|
||||
public static final String INCL_ZONES = "includezones";
|
||||
public static final String EXCL_ZONES = "excludezones";
|
||||
public static final String SOURCE = "source";
|
||||
public static final String COUNTER_ID = "counterid";
|
||||
public static final String AGGR_OPERATOR = "aggroperator";
|
||||
public static final String AGGR_FUNCTION = "aggrfunction";
|
||||
public static final String AGGR_VALUE = "aggrvalue";
|
||||
public static final String THRESHOLD = "threshold";
|
||||
public static final String RELATIONAL_OPERATOR = "relationaloperator";
|
||||
public static final String OTHER_DEPLOY_PARAMS = "otherdeployparams";
|
||||
public static final String MIN_MEMBERS = "minmembers";
|
||||
public static final String MAX_MEMBERS = "maxmembers";
|
||||
public static final String AUTOSCALE_VM_DESTROY_TIME = "destroyvmgraceperiod";
|
||||
public static final String VMPROFILE_ID = "vmprofileid";
|
||||
public static final String VMGROUP_ID = "vmgroupid";
|
||||
public static final String CS_URL = "csurl";
|
||||
public static final String SCALEUP_POLICY_IDS = "scaleuppolicyids";
|
||||
public static final String SCALEDOWN_POLICY_IDS = "scaledownpolicyids";
|
||||
public static final String SCALEUP_POLICIES = "scaleuppolicies";
|
||||
public static final String SCALEDOWN_POLICIES = "scaledownpolicies";
|
||||
public static final String INTERVAL = "interval";
|
||||
public static final String QUIETTIME = "quiettime";
|
||||
public static final String ACTION = "action";
|
||||
public static final String CONDITION_ID = "conditionid";
|
||||
public static final String CONDITION_IDS = "conditionids";
|
||||
public static final String COUNTERPARAM_LIST = "counterparam";
|
||||
public static final String AUTOSCALE_USER_ID = "autoscaleuserid";
|
||||
public static final String BAREMETAL_DISCOVER_NAME = "baremetaldiscovername";
|
||||
<<<<<<< HEAD
|
||||
public static final String UCS_DN = "ucsdn";
|
||||
=======
|
||||
public static final String VM_SNAPSHOT_DESCRIPTION = "description";
|
||||
public static final String VM_SNAPSHOT_DISPLAYNAME = "name";
|
||||
public static final String VM_SNAPSHOT_ID = "vmsnapshotid";
|
||||
public static final String VM_SNAPSHOT_DISK_IDS = "vmsnapshotdiskids";
|
||||
public static final String VM_SNAPSHOT_MEMORY = "snapshotmemory";
|
||||
>>>>>>> CLOUDSTACK-684 Support VM Snapshot
|
||||
|
||||
public enum HostDetails {
|
||||
all, capacity, events, stats, min;
|
||||
}
|
||||
|
||||
public enum VMDetails {
|
||||
all, group, nics, stats, secgrp, tmpl, servoff, iso, volume, min;
|
||||
}
|
||||
|
||||
public enum LDAPParams {
|
||||
hostname, port, usessl, queryfilter, searchbase, dn, passwd, truststore, truststorepass;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ldap." + name();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -18,7 +18,6 @@ package org.apache.cloudstack.api;
|
||||
|
||||
/**
|
||||
* Enum class for various API error code used in CloudStack
|
||||
* @author minc
|
||||
*
|
||||
*/
|
||||
public enum ApiErrorCode {
|
||||
|
||||
@ -62,6 +62,7 @@ import com.cloud.resource.ResourceService;
|
||||
import com.cloud.server.ManagementService;
|
||||
import com.cloud.server.TaggedResourceService;
|
||||
import com.cloud.storage.StorageService;
|
||||
import com.cloud.storage.VolumeApiService;
|
||||
import com.cloud.storage.snapshot.SnapshotService;
|
||||
import com.cloud.template.TemplateService;
|
||||
import com.cloud.user.Account;
|
||||
@ -69,8 +70,8 @@ import com.cloud.user.AccountService;
|
||||
import com.cloud.user.DomainService;
|
||||
import com.cloud.user.ResourceLimitService;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.vm.BareMetalVmService;
|
||||
import com.cloud.vm.UserVmService;
|
||||
import com.cloud.vm.snapshot.VMSnapshotService;
|
||||
|
||||
public abstract class BaseCmd {
|
||||
private static final Logger s_logger = Logger.getLogger(BaseCmd.class.getName());
|
||||
@ -101,6 +102,7 @@ public abstract class BaseCmd {
|
||||
@Inject public UserVmService _userVmService;
|
||||
@Inject public ManagementService _mgr;
|
||||
@Inject public StorageService _storageService;
|
||||
@Inject public VolumeApiService _volumeService;
|
||||
@Inject public ResourceService _resourceService;
|
||||
@Inject public NetworkService _networkService;
|
||||
@Inject public TemplateService _templateService;
|
||||
@ -128,6 +130,7 @@ public abstract class BaseCmd {
|
||||
@Inject public QueryService _queryService;
|
||||
@Inject public UsageService _usageService;
|
||||
@Inject public NetworkUsageService _networkUsageService;
|
||||
@Inject public VMSnapshotService _vmSnapshotService;
|
||||
|
||||
public abstract void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException;
|
||||
|
||||
|
||||
@ -88,6 +88,7 @@ import org.apache.cloudstack.api.response.TrafficTypeResponse;
|
||||
import org.apache.cloudstack.api.response.UsageRecordResponse;
|
||||
import org.apache.cloudstack.api.response.UserResponse;
|
||||
import org.apache.cloudstack.api.response.UserVmResponse;
|
||||
import org.apache.cloudstack.api.response.VMSnapshotResponse;
|
||||
import org.apache.cloudstack.api.response.VirtualRouterProviderResponse;
|
||||
import org.apache.cloudstack.api.response.VlanIpRangeResponse;
|
||||
import org.apache.cloudstack.api.response.VolumeResponse;
|
||||
@ -163,6 +164,7 @@ import com.cloud.user.UserAccount;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.vm.InstanceGroup;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.snapshot.VMSnapshot;
|
||||
|
||||
public interface ResponseGenerator {
|
||||
UserResponse createUserResponse(UserAccount user);
|
||||
@ -382,4 +384,5 @@ public interface ResponseGenerator {
|
||||
UsageRecordResponse createUsageResponse(Usage usageRecord);
|
||||
|
||||
TrafficMonitorResponse createTrafficMonitorResponse(Host trafficMonitor);
|
||||
VMSnapshotResponse createVMSnapshotResponse(VMSnapshot vmSnapshot);
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ public class ServerApiException extends CloudRuntimeException {
|
||||
super(description, cause);
|
||||
_errorCode = errorCode;
|
||||
_description = description;
|
||||
if (cause instanceof CloudRuntimeException || cause instanceof CloudException ) {
|
||||
if (cause instanceof CloudRuntimeException) {
|
||||
CloudRuntimeException rt = (CloudRuntimeException) cause;
|
||||
ArrayList<String> idList = rt.getIdProxyList();
|
||||
if (idList != null) {
|
||||
@ -52,6 +52,15 @@ public class ServerApiException extends CloudRuntimeException {
|
||||
}
|
||||
}
|
||||
setCSErrorCode(rt.getCSErrorCode());
|
||||
} else if (cause instanceof CloudException) {
|
||||
CloudException rt = (CloudException) cause;
|
||||
ArrayList<String> idList = rt.getIdProxyList();
|
||||
if (idList != null) {
|
||||
for (int i = 0; i < idList.size(); i++) {
|
||||
addProxyObject(idList.get(i));
|
||||
}
|
||||
}
|
||||
setCSErrorCode(rt.getCSErrorCode());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -20,6 +20,10 @@ package org.apache.cloudstack.api.command.admin.cluster;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import org.apache.cloudstack.api.*;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
@ -81,6 +85,12 @@ public class AddClusterCmd extends BaseCmd {
|
||||
@Parameter(name = ApiConstants.VSM_IPADDRESS, type = CommandType.STRING, required = false, description = "the ipaddress of the VSM associated with this cluster")
|
||||
private String vsmipaddress;
|
||||
|
||||
@Parameter (name=ApiConstants.CPU_OVERCOMMIT_RATIO, type = CommandType.STRING, required = false , description = "value of the cpu overcommit ratio, defaults to 1")
|
||||
private String cpuovercommitRatio;
|
||||
|
||||
@Parameter(name = ApiConstants.MEMORY_OVERCOMMIT_RATIO, type = CommandType.STRING, required = false ,description = "value of the default ram overcommit ratio, defaults to 1")
|
||||
private String memoryovercommitratio;
|
||||
|
||||
public String getVSMIpaddress() {
|
||||
return vsmipaddress;
|
||||
}
|
||||
@ -147,9 +157,26 @@ public class AddClusterCmd extends BaseCmd {
|
||||
this.allocationState = allocationState;
|
||||
}
|
||||
|
||||
public Float getCpuOvercommitRatio (){
|
||||
if(cpuovercommitRatio != null){
|
||||
return Float.parseFloat(cpuovercommitRatio);
|
||||
}
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
public Float getMemoryOvercommitRaito (){
|
||||
if (memoryovercommitratio != null){
|
||||
return Float.parseFloat(memoryovercommitratio);
|
||||
}
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
try {
|
||||
if ((getMemoryOvercommitRaito().compareTo(1f) < 0) | (getCpuOvercommitRatio().compareTo(1f) < 0)) {
|
||||
throw new InvalidParameterValueException("Cpu and ram overcommit ratios should not be less than 1");
|
||||
}
|
||||
List<? extends Cluster> result = _resourceService.discoverCluster(this);
|
||||
ListResponse<ClusterResponse> response = new ListResponse<ClusterResponse>();
|
||||
List<ClusterResponse> clusterResponses = new ArrayList<ClusterResponse>();
|
||||
|
||||
@ -54,6 +54,13 @@ public class UpdateClusterCmd extends BaseCmd {
|
||||
@Parameter(name=ApiConstants.MANAGED_STATE, type=CommandType.STRING, description="whether this cluster is managed by cloudstack")
|
||||
private String managedState;
|
||||
|
||||
@Parameter(name=ApiConstants.CPU_OVERCOMMIT_RATIO, type = CommandType.STRING, description = "Value of cpu overcommit ratio")
|
||||
private String cpuovercommitratio;
|
||||
|
||||
@Parameter(name=ApiConstants.MEMORY_OVERCOMMIT_RATIO, type = CommandType.STRING, description = "Value of ram overcommit ratio")
|
||||
private String memoryovercommitratio;
|
||||
|
||||
|
||||
public String getClusterName() {
|
||||
return clusterName;
|
||||
}
|
||||
@ -100,6 +107,20 @@ public class UpdateClusterCmd extends BaseCmd {
|
||||
this.managedState = managedstate;
|
||||
}
|
||||
|
||||
public Float getCpuOvercommitRatio (){
|
||||
if(cpuovercommitratio != null){
|
||||
return Float.parseFloat(cpuovercommitratio);
|
||||
}
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
public Float getMemoryOvercommitRaito (){
|
||||
if (memoryovercommitratio != null){
|
||||
return Float.parseFloat(memoryovercommitratio);
|
||||
}
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
Cluster cluster = _resourceService.getCluster(getId());
|
||||
@ -107,7 +128,11 @@ public class UpdateClusterCmd extends BaseCmd {
|
||||
throw new InvalidParameterValueException("Unable to find the cluster by id=" + getId());
|
||||
}
|
||||
|
||||
Cluster result = _resourceService.updateCluster(cluster, getClusterType(), getHypervisor(), getAllocationState(), getManagedstate());
|
||||
if ((getMemoryOvercommitRaito().compareTo(1f) < 0) | (getCpuOvercommitRatio().compareTo(1f) < 0)) {
|
||||
throw new InvalidParameterValueException("Cpu and ram overcommit ratios should be greater than one");
|
||||
}
|
||||
|
||||
Cluster result = _resourceService.updateCluster(cluster, getClusterType(), getHypervisor(), getAllocationState(), getManagedstate(), getMemoryOvercommitRaito(), getCpuOvercommitRatio());
|
||||
if (result != null) {
|
||||
ClusterResponse clusterResponse = _responseGenerator.createClusterResponse(cluster, false);
|
||||
clusterResponse.setResponseName(getCommandName());
|
||||
|
||||
@ -31,6 +31,7 @@ import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
@APICommand(name = "ldapConfig", description="Configure the LDAP context for this site.", responseObject=LDAPConfigResponse.class, since="3.0.0")
|
||||
@ -43,7 +44,10 @@ public class LDAPConfigCmd extends BaseCmd {
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.HOST_NAME, type=CommandType.STRING, required=true, description="Hostname or ip address of the ldap server eg: my.ldap.com")
|
||||
@Parameter(name=ApiConstants.LIST_ALL, type=CommandType.STRING, description="Hostname or ip address of the ldap server eg: my.ldap.com")
|
||||
private String listall;
|
||||
|
||||
@Parameter(name=ApiConstants.HOST_NAME, type=CommandType.STRING, description="Hostname or ip address of the ldap server eg: my.ldap.com")
|
||||
private String hostname;
|
||||
|
||||
@Parameter(name=ApiConstants.PORT, type=CommandType.INTEGER, description="Specify the LDAP port if required, default is 389.")
|
||||
@ -52,10 +56,10 @@ public class LDAPConfigCmd extends BaseCmd {
|
||||
@Parameter(name=ApiConstants.USE_SSL, type=CommandType.BOOLEAN, description="Check Use SSL if the external LDAP server is configured for LDAP over SSL.")
|
||||
private Boolean useSSL;
|
||||
|
||||
@Parameter(name=ApiConstants.SEARCH_BASE, type=CommandType.STRING, required=true, description="The search base defines the starting point for the search in the directory tree Example: dc=cloud,dc=com.")
|
||||
@Parameter(name=ApiConstants.SEARCH_BASE, type=CommandType.STRING, description="The search base defines the starting point for the search in the directory tree Example: dc=cloud,dc=com.")
|
||||
private String searchBase;
|
||||
|
||||
@Parameter(name=ApiConstants.QUERY_FILTER, type=CommandType.STRING, required=true, description="You specify a query filter here, which narrows down the users, who can be part of this domain.")
|
||||
@Parameter(name=ApiConstants.QUERY_FILTER, type=CommandType.STRING, description="You specify a query filter here, which narrows down the users, who can be part of this domain.")
|
||||
private String queryFilter;
|
||||
|
||||
@Parameter(name=ApiConstants.BIND_DN, type=CommandType.STRING, description="Specify the distinguished name of a user with the search permission on the directory.")
|
||||
@ -74,6 +78,10 @@ public class LDAPConfigCmd extends BaseCmd {
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public String getListAll() {
|
||||
return listall == null ? "false" : listall;
|
||||
}
|
||||
|
||||
public String getBindPassword() {
|
||||
return bindPassword;
|
||||
}
|
||||
@ -82,30 +90,56 @@ public class LDAPConfigCmd extends BaseCmd {
|
||||
return bindDN;
|
||||
}
|
||||
|
||||
public void setBindDN(String bdn) {
|
||||
this.bindDN=bdn;
|
||||
}
|
||||
|
||||
public String getQueryFilter() {
|
||||
return queryFilter;
|
||||
}
|
||||
|
||||
public void setQueryFilter(String queryFilter) {
|
||||
this.queryFilter=queryFilter;
|
||||
}
|
||||
public String getSearchBase() {
|
||||
return searchBase;
|
||||
}
|
||||
|
||||
public void setSearchBase(String searchBase) {
|
||||
this.searchBase=searchBase;
|
||||
}
|
||||
|
||||
public Boolean getUseSSL() {
|
||||
return useSSL == null ? Boolean.FALSE : Boolean.TRUE;
|
||||
return useSSL == null ? Boolean.FALSE : useSSL;
|
||||
}
|
||||
|
||||
public void setUseSSL(Boolean useSSL) {
|
||||
this.useSSL=useSSL;
|
||||
}
|
||||
|
||||
public String getHostname() {
|
||||
return hostname;
|
||||
}
|
||||
|
||||
public void setHostname(String hostname) {
|
||||
this.hostname=hostname;
|
||||
}
|
||||
|
||||
public Integer getPort() {
|
||||
return port <= 0 ? 389 : port;
|
||||
}
|
||||
|
||||
public void setPort(Integer port) {
|
||||
this.port=port;
|
||||
}
|
||||
|
||||
public String getTrustStore() {
|
||||
return trustStore;
|
||||
}
|
||||
|
||||
public void setTrustStore(String trustStore) {
|
||||
this.trustStore=trustStore;
|
||||
}
|
||||
|
||||
public String getTrustStorePassword() {
|
||||
return trustStorePassword;
|
||||
@ -122,6 +156,18 @@ public class LDAPConfigCmd extends BaseCmd {
|
||||
InsufficientCapacityException, ServerApiException,
|
||||
ConcurrentOperationException, ResourceAllocationException {
|
||||
try {
|
||||
if ("true".equalsIgnoreCase(getListAll())){
|
||||
// return the existing conf
|
||||
LDAPConfigCmd cmd = _configService.listLDAPConfig(this);
|
||||
LDAPConfigResponse lr = _responseGenerator.createLDAPConfigResponse(cmd.getHostname(), cmd.getPort(), cmd.getUseSSL(),
|
||||
cmd.getQueryFilter(), cmd.getSearchBase(), cmd.getBindDN());
|
||||
lr.setResponseName(getCommandName());
|
||||
this.setResponseObject(lr);
|
||||
}
|
||||
else if (getHostname()==null || getSearchBase() == null || getQueryFilter() == null) {
|
||||
throw new InvalidParameterValueException("You need to provide hostname, serachbase and queryfilter to configure your LDAP server");
|
||||
}
|
||||
else {
|
||||
boolean result = _configService.updateLDAP(this);
|
||||
if (result){
|
||||
LDAPConfigResponse lr = _responseGenerator.createLDAPConfigResponse(getHostname(), getPort(), getUseSSL(), getQueryFilter(), getSearchBase(), getBindDN());
|
||||
@ -129,6 +175,7 @@ public class LDAPConfigCmd extends BaseCmd {
|
||||
this.setResponseObject(lr);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (NamingException ne){
|
||||
ne.printStackTrace();
|
||||
}
|
||||
|
||||
@ -59,6 +59,9 @@ public class CreateServiceOfferingCmd extends BaseCmd {
|
||||
@Parameter(name=ApiConstants.LIMIT_CPU_USE, type=CommandType.BOOLEAN, description="restrict the CPU usage to committed service offering")
|
||||
private Boolean limitCpuUse;
|
||||
|
||||
@Parameter(name=ApiConstants.IS_VOLATILE, type=CommandType.BOOLEAN, description="true if the virtual machine needs to be volatile so that on every reboot of VM, original root disk is dettached then destroyed and a fresh root disk is created and attached to VM")
|
||||
private Boolean isVolatile;
|
||||
|
||||
@Parameter(name=ApiConstants.STORAGE_TYPE, type=CommandType.STRING, description="the storage type of the service offering. Values are local and shared.")
|
||||
private String storageType;
|
||||
|
||||
@ -106,11 +109,15 @@ public class CreateServiceOfferingCmd extends BaseCmd {
|
||||
}
|
||||
|
||||
public Boolean getOfferHa() {
|
||||
return offerHa;
|
||||
return offerHa == null ? false : offerHa;
|
||||
}
|
||||
|
||||
public Boolean GetLimitCpuUse() {
|
||||
return limitCpuUse;
|
||||
return limitCpuUse == null ? false : limitCpuUse;
|
||||
}
|
||||
|
||||
public Boolean getVolatileVm() {
|
||||
return isVolatile == null ? false : isVolatile;
|
||||
}
|
||||
|
||||
public String getStorageType() {
|
||||
|
||||
@ -22,8 +22,8 @@ import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.DiskOfferingResponse;
|
||||
import org.apache.cloudstack.api.response.DomainRouterResponse;
|
||||
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.network.router.VirtualRouter;
|
||||
@ -42,7 +42,7 @@ public class UpgradeRouterCmd extends BaseCmd {
|
||||
required=true, description="The ID of the router")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name=ApiConstants.SERVICE_OFFERING_ID, type=CommandType.UUID, entityType = DiskOfferingResponse.class,
|
||||
@Parameter(name=ApiConstants.SERVICE_OFFERING_ID, type=CommandType.UUID, entityType = ServiceOfferingResponse.class,
|
||||
required=true, description="the service offering ID to apply to the domain router")
|
||||
private Long serviceOfferingId;
|
||||
|
||||
|
||||
@ -36,6 +36,7 @@ import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.storage.StoragePool;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@APICommand(name = "createStoragePool", description="Creates a storage pool.", responseObject=StoragePoolResponse.class)
|
||||
public class CreateStoragePoolCmd extends BaseCmd {
|
||||
@ -71,6 +72,14 @@ public class CreateStoragePoolCmd extends BaseCmd {
|
||||
required=true, description="the Zone ID for the storage pool")
|
||||
private Long zoneId;
|
||||
|
||||
@Parameter(name=ApiConstants.PROVIDER, type=CommandType.STRING,
|
||||
required=false, description="the storage provider uuid")
|
||||
private String storageProviderUuid;
|
||||
|
||||
@Parameter(name=ApiConstants.SCOPE, type=CommandType.STRING,
|
||||
required=false, description="the scope of the storage: cluster or zone")
|
||||
private String scope;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@ -103,6 +112,14 @@ public class CreateStoragePoolCmd extends BaseCmd {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
public String getStorageProviderUuid() {
|
||||
return this.storageProviderUuid;
|
||||
}
|
||||
|
||||
public String getScope() {
|
||||
return this.scope;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@ -23,7 +23,7 @@ import org.apache.cloudstack.api.BaseCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.command.user.vm.UpgradeVMCmd;
|
||||
import org.apache.cloudstack.api.response.DiskOfferingResponse;
|
||||
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
|
||||
import org.apache.cloudstack.api.response.SystemVmResponse;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
@ -48,7 +48,7 @@ public class UpgradeSystemVMCmd extends BaseCmd {
|
||||
required=true, description="The ID of the system vm")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name=ApiConstants.SERVICE_OFFERING_ID, type=CommandType.UUID, entityType=DiskOfferingResponse.class,
|
||||
@Parameter(name=ApiConstants.SERVICE_OFFERING_ID, type=CommandType.UUID, entityType=ServiceOfferingResponse.class,
|
||||
required=true, description="the service offering ID to apply to the system vm")
|
||||
private Long serviceOfferingId;
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.command.admin.vpc;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
@ -52,6 +52,10 @@ public class CreateVPCOfferingCmd extends BaseAsyncCreateCmd{
|
||||
description="services supported by the vpc offering")
|
||||
private List<String> supportedServices;
|
||||
|
||||
@Parameter(name = ApiConstants.SERVICE_PROVIDER_LIST, type = CommandType.MAP, description = "provider to service mapping. " +
|
||||
"If not specified, the provider for the service will be mapped to the default provider on the physical network")
|
||||
private Map<String, String> serviceProviderList;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@ -68,10 +72,33 @@ public class CreateVPCOfferingCmd extends BaseAsyncCreateCmd{
|
||||
return supportedServices;
|
||||
}
|
||||
|
||||
public Map<String, List<String>> getServiceProviders() {
|
||||
Map<String, List<String>> serviceProviderMap = null;
|
||||
if (serviceProviderList != null && !serviceProviderList.isEmpty()) {
|
||||
serviceProviderMap = new HashMap<String, List<String>>();
|
||||
Collection servicesCollection = serviceProviderList.values();
|
||||
Iterator iter = servicesCollection.iterator();
|
||||
while (iter.hasNext()) {
|
||||
HashMap<String, String> services = (HashMap<String, String>) iter.next();
|
||||
String service = services.get("service");
|
||||
String provider = services.get("provider");
|
||||
List<String> providerList = null;
|
||||
if (serviceProviderMap.containsKey(service)) {
|
||||
providerList = serviceProviderMap.get(service);
|
||||
} else {
|
||||
providerList = new ArrayList<String>();
|
||||
}
|
||||
providerList.add(provider);
|
||||
serviceProviderMap.put(service, providerList);
|
||||
}
|
||||
}
|
||||
|
||||
return serviceProviderMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create() throws ResourceAllocationException {
|
||||
VpcOffering vpcOff = _vpcService.createVpcOffering(getVpcOfferingName(), getDisplayText(), getSupportedServices());
|
||||
VpcOffering vpcOff = _vpcService.createVpcOffering(getVpcOfferingName(), getDisplayText(), getSupportedServices(), getServiceProviders());
|
||||
if (vpcOff != null) {
|
||||
this.setEntityId(vpcOff.getId());
|
||||
this.setEntityUuid(vpcOff.getUuid());
|
||||
|
||||
@ -26,7 +26,7 @@ import org.apache.cloudstack.api.BaseAsyncCreateCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.AutoScaleVmProfileResponse;
|
||||
import org.apache.cloudstack.api.response.DiskOfferingResponse;
|
||||
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
|
||||
import org.apache.cloudstack.api.response.TemplateResponse;
|
||||
import org.apache.cloudstack.api.response.UserResponse;
|
||||
import org.apache.cloudstack.api.response.ZoneResponse;
|
||||
@ -56,7 +56,7 @@ public class CreateAutoScaleVmProfileCmd extends BaseAsyncCreateCmd {
|
||||
required = true, description = "availability zone for the auto deployed virtual machine")
|
||||
private Long zoneId;
|
||||
|
||||
@Parameter(name = ApiConstants.SERVICE_OFFERING_ID, type = CommandType.UUID, entityType = DiskOfferingResponse.class,
|
||||
@Parameter(name = ApiConstants.SERVICE_OFFERING_ID, type = CommandType.UUID, entityType = ServiceOfferingResponse.class,
|
||||
required = true, description = "the service offering of the auto deployed virtual machine")
|
||||
private Long serviceOfferingId;
|
||||
|
||||
|
||||
@ -89,6 +89,10 @@ public class RegisterIsoCmd extends BaseCmd {
|
||||
description="Register iso for the project")
|
||||
private Long projectId;
|
||||
|
||||
@Parameter(name=ApiConstants.IMAGE_STORE_UUID, type=CommandType.STRING,
|
||||
description="Image store uuid")
|
||||
private String imageStoreUuid;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@ -141,6 +145,10 @@ public class RegisterIsoCmd extends BaseCmd {
|
||||
return checksum;
|
||||
}
|
||||
|
||||
public String getImageStoreUuid() {
|
||||
return this.imageStoreUuid;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@ -268,10 +268,6 @@ public class CreateNetworkCmd extends BaseCmd {
|
||||
@Override
|
||||
// an exception thrown by createNetwork() will be caught by the dispatcher.
|
||||
public void execute() throws InsufficientCapacityException, ConcurrentOperationException, ResourceAllocationException{
|
||||
if (getStartIpv6() != null && getStartIp() != null) {
|
||||
throw new InvalidParameterValueException("Cannot support dualstack at this moment!");
|
||||
}
|
||||
|
||||
Network result = _networkService.createGuestNetwork(this);
|
||||
if (result != null) {
|
||||
NetworkResponse response = _responseGenerator.createNetworkResponse(result);
|
||||
|
||||
@ -64,6 +64,9 @@ public class UpdateNetworkCmd extends BaseAsyncCmd {
|
||||
description="network offering ID")
|
||||
private Long networkOfferingId;
|
||||
|
||||
@Parameter(name=ApiConstants.GUEST_VM_CIDR, type=CommandType.STRING, description="CIDR for Guest VMs,Cloudstack allocates IPs to Guest VMs only from this CIDR")
|
||||
private String guestVmCidr;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@ -94,6 +97,10 @@ public class UpdateNetworkCmd extends BaseAsyncCmd {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private String getGuestVmCidr() {
|
||||
return guestVmCidr;
|
||||
}
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@ -125,10 +132,10 @@ public class UpdateNetworkCmd extends BaseAsyncCmd {
|
||||
Network result = null;
|
||||
if (network.getVpcId() != null) {
|
||||
result = _vpcService.updateVpcGuestNetwork(getId(), getNetworkName(), getDisplayText(), callerAccount,
|
||||
callerUser, getNetworkDomain(), getNetworkOfferingId(), getChangeCidr());
|
||||
callerUser, getNetworkDomain(), getNetworkOfferingId(), getChangeCidr(), getGuestVmCidr());
|
||||
} else {
|
||||
result = _networkService.updateGuestNetwork(getId(), getNetworkName(), getDisplayText(), callerAccount,
|
||||
callerUser, getNetworkDomain(), getNetworkOfferingId(), getChangeCidr());
|
||||
callerUser, getNetworkDomain(), getNetworkOfferingId(), getChangeCidr(), getGuestVmCidr());
|
||||
}
|
||||
|
||||
if (result != null) {
|
||||
|
||||
@ -53,12 +53,17 @@ public class UpdateResourceCountCmd extends BaseCmd {
|
||||
required=true, description="If account parameter specified then updates resource counts for a specified account in this domain else update resource counts for all accounts & child domains in specified domain.")
|
||||
private Long domainId;
|
||||
|
||||
@Parameter(name=ApiConstants.RESOURCE_TYPE, type=CommandType.INTEGER, description= "Type of resource to update. If specifies valid values are 0, 1, 2, 3, and 4. If not specified will update all resource counts" +
|
||||
@Parameter(name=ApiConstants.RESOURCE_TYPE, type=CommandType.INTEGER, description= "Type of resource to update. If specifies valid values are 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9. If not specified will update all resource counts" +
|
||||
"0 - Instance. Number of instances a user can create. " +
|
||||
"1 - IP. Number of public IP addresses a user can own. " +
|
||||
"2 - Volume. Number of disk volumes a user can create." +
|
||||
"3 - Snapshot. Number of snapshots a user can create." +
|
||||
"4 - Template. Number of templates that a user can register/create.")
|
||||
"4 - Template. Number of templates that a user can register/create." +
|
||||
"5 - Project. Number of projects that a user can create." +
|
||||
"6 - Network. Number of guest network a user can create." +
|
||||
"7 - VPC. Number of VPC a user can create." +
|
||||
"8 - CPU. Total number of CPU cores a user can use." +
|
||||
"9 - Memory. Total Memory (in MB) a user can use." )
|
||||
private Integer resourceType;
|
||||
|
||||
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.UUID, entityType = ProjectResponse.class,
|
||||
|
||||
@ -54,11 +54,15 @@ public class UpdateResourceLimitCmd extends BaseCmd {
|
||||
@Parameter(name=ApiConstants.MAX, type=CommandType.LONG, description=" Maximum resource limit.")
|
||||
private Long max;
|
||||
|
||||
@Parameter(name=ApiConstants.RESOURCE_TYPE, type=CommandType.INTEGER, required=true, description="Type of resource to update. Values are 0, 1, 2, 3, and 4. 0 - Instance. Number of instances a user can create. " +
|
||||
@Parameter(name=ApiConstants.RESOURCE_TYPE, type=CommandType.INTEGER, required=true, description="Type of resource to update. Values are 0, 1, 2, 3, 4, 6, 7, 8 and 9. 0 - Instance. Number of instances a user can create. " +
|
||||
"1 - IP. Number of public IP addresses a user can own. " +
|
||||
"2 - Volume. Number of disk volumes a user can create." +
|
||||
"3 - Snapshot. Number of snapshots a user can create." +
|
||||
"4 - Template. Number of templates that a user can register/create.")
|
||||
"4 - Template. Number of templates that a user can register/create." +
|
||||
"6 - Network. Number of guest network a user can create." +
|
||||
"7 - VPC. Number of VPC a user can create." +
|
||||
"8 - CPU. Total number of CPU cores a user can use." +
|
||||
"9 - Memory. Total Memory (in MB) a user can use." )
|
||||
private Integer resourceType;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@ -240,7 +240,7 @@ import com.cloud.user.UserContext;
|
||||
@Override
|
||||
public void create() throws ResourceAllocationException {
|
||||
VirtualMachineTemplate template = null;
|
||||
template = _userVmService.createPrivateTemplateRecord(this, _accountService.getAccount(getEntityOwnerId()));
|
||||
template = this._templateService.createPrivateTemplateRecord(this, _accountService.getAccount(getEntityOwnerId()));
|
||||
if (template != null) {
|
||||
this.setEntityId(template.getId());
|
||||
this.setEntityUuid(template.getUuid());
|
||||
@ -255,7 +255,7 @@ import com.cloud.user.UserContext;
|
||||
public void execute() {
|
||||
UserContext.current().setEventDetails("Template Id: "+getEntityId()+((getSnapshotId() == null) ? " from volume Id: " + getVolumeId() : " from snapshot Id: " + getSnapshotId()));
|
||||
VirtualMachineTemplate template = null;
|
||||
template = _userVmService.createPrivateTemplate(this);
|
||||
template = this._templateService.createPrivateTemplate(this);
|
||||
|
||||
if (template != null){
|
||||
List<TemplateResponse> templateResponses;
|
||||
|
||||
@ -111,6 +111,10 @@ public class RegisterTemplateCmd extends BaseCmd {
|
||||
description="Register template for the project")
|
||||
private Long projectId;
|
||||
|
||||
@Parameter(name=ApiConstants.IMAGE_STORE_UUID, type=CommandType.STRING,
|
||||
description="Image store uuid")
|
||||
private String imageStoreUuid;
|
||||
|
||||
@Parameter(name=ApiConstants.DETAILS, type=CommandType.MAP, description="Template details in key/value pairs.")
|
||||
protected Map details;
|
||||
|
||||
@ -190,6 +194,10 @@ public class RegisterTemplateCmd extends BaseCmd {
|
||||
return templateTag;
|
||||
}
|
||||
|
||||
public String getImageStoreUuid() {
|
||||
return this.imageStoreUuid;
|
||||
}
|
||||
|
||||
public Map getDetails() {
|
||||
if (details == null || details.isEmpty()) {
|
||||
return null;
|
||||
|
||||
11
api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
Normal file → Executable file
11
api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
Normal file → Executable file
@ -306,9 +306,6 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
|
||||
if (requestedIpv6 != null) {
|
||||
requestedIpv6 = requestedIpv6.toLowerCase();
|
||||
}
|
||||
if (requestedIpv6 != null) {
|
||||
throw new InvalidParameterValueException("Cannot support specified IPv6 address!");
|
||||
}
|
||||
IpAddresses addrs = new IpAddresses(requestedIp, requestedIpv6);
|
||||
ipToNetworkMap.put(networkId, addrs);
|
||||
}
|
||||
@ -388,7 +385,7 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
|
||||
} catch (InsufficientCapacityException ex) {
|
||||
s_logger.info(ex);
|
||||
s_logger.trace(ex);
|
||||
s_logger.info(ex.getMessage(), ex);
|
||||
throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage());
|
||||
}
|
||||
} else {
|
||||
@ -407,10 +404,6 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
|
||||
@Override
|
||||
public void create() throws ResourceAllocationException{
|
||||
try {
|
||||
if (getIp6Address() != null) {
|
||||
throw new InvalidParameterValueException("Cannot support specified IPv6 address!");
|
||||
}
|
||||
|
||||
//Verify that all objects exist before passing them to the service
|
||||
Account owner = _accountService.getActiveAccountById(getEntityOwnerId());
|
||||
|
||||
@ -477,7 +470,7 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
|
||||
}
|
||||
} catch (InsufficientCapacityException ex) {
|
||||
s_logger.info(ex);
|
||||
s_logger.trace(ex);
|
||||
s_logger.trace(ex.getMessage(), ex);
|
||||
throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage());
|
||||
} catch (ResourceUnavailableException ex) {
|
||||
s_logger.warn("Exception: ", ex);
|
||||
|
||||
@ -22,6 +22,7 @@ import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseAsyncCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.TemplateResponse;
|
||||
import org.apache.cloudstack.api.response.UserVmResponse;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
@ -34,7 +35,7 @@ import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
import com.cloud.uservm.UserVm;
|
||||
|
||||
@APICommand(name = "restoreVirtualMachine", description="Restore a VM to original template or specific snapshot", responseObject=UserVmResponse.class, since="3.0.0")
|
||||
@APICommand(name = "restoreVirtualMachine", description="Restore a VM to original template or new template", responseObject=UserVmResponse.class, since="3.0.0")
|
||||
public class RestoreVMCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(RestoreVMCmd.class);
|
||||
private static final String s_name = "restorevmresponse";
|
||||
@ -43,6 +44,9 @@ public class RestoreVMCmd extends BaseAsyncCmd {
|
||||
required=true, description="Virtual Machine ID")
|
||||
private Long vmId;
|
||||
|
||||
@Parameter(name=ApiConstants.TEMPLATE_ID, type=CommandType.UUID, entityType = TemplateResponse.class, description="an optional template Id to restore vm from the new template")
|
||||
private Long templateId;
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_VM_RESTORE;
|
||||
@ -85,4 +89,8 @@ public class RestoreVMCmd extends BaseAsyncCmd {
|
||||
public long getVmId() {
|
||||
return vmId;
|
||||
}
|
||||
|
||||
public Long getTemplateId() {
|
||||
return templateId;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,125 @@
|
||||
// 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.api.command.user.vmsnapshot;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseAsyncCreateCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.UserVmResponse;
|
||||
import org.apache.cloudstack.api.response.VMSnapshotResponse;
|
||||
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.user.UserContext;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.vm.snapshot.VMSnapshot;
|
||||
|
||||
@APICommand(name = "createVMSnapshot", description = "Creates snapshot for a vm.", responseObject = VMSnapshotResponse.class)
|
||||
public class CreateVMSnapshotCmd extends BaseAsyncCreateCmd {
|
||||
|
||||
public static final Logger s_logger = Logger
|
||||
.getLogger(CreateVMSnapshotCmd.class.getName());
|
||||
private static final String s_name = "createvmsnapshotresponse";
|
||||
|
||||
@Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID, type = CommandType.UUID, required = true, entityType=UserVmResponse.class, description = "The ID of the vm")
|
||||
private Long vmId;
|
||||
|
||||
@Parameter(name = ApiConstants.VM_SNAPSHOT_DESCRIPTION, type = CommandType.STRING, required = false, description = "The discription of the snapshot")
|
||||
private String description;
|
||||
|
||||
@Parameter(name = ApiConstants.VM_SNAPSHOT_DISPLAYNAME, type = CommandType.STRING, required = false, description = "The display name of the snapshot")
|
||||
private String displayName;
|
||||
|
||||
@Parameter(name = ApiConstants.VM_SNAPSHOT_MEMORY, type = CommandType.BOOLEAN, required = false, description = "snapshot memory if true")
|
||||
private Boolean snapshotMemory;
|
||||
|
||||
public Boolean snapshotMemory() {
|
||||
if (snapshotMemory == null) {
|
||||
return false;
|
||||
} else {
|
||||
return snapshotMemory;
|
||||
}
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public Long getVmId() {
|
||||
return vmId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create() throws ResourceAllocationException {
|
||||
VMSnapshot vmsnapshot = _vmSnapshotService.allocVMSnapshot(getVmId(),getDisplayName(),getDescription(),snapshotMemory());
|
||||
if (vmsnapshot != null) {
|
||||
this.setEntityId(vmsnapshot.getId());
|
||||
} else {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,
|
||||
"Failed to create vm snapshot");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "creating snapshot for VM: " + getVmId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_VM_SNAPSHOT_CREATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
UserContext.current().setEventDetails("VM Id: " + getVmId());
|
||||
VMSnapshot result = _vmSnapshotService.creatVMSnapshot(getVmId(),getEntityId());
|
||||
if (result != null) {
|
||||
VMSnapshotResponse response = _responseGenerator
|
||||
.createVMSnapshotResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(
|
||||
ApiErrorCode.INTERNAL_ERROR,
|
||||
"Failed to create vm snapshot due to an internal error creating snapshot for vm "
|
||||
+ getVmId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
UserVm userVM = _userVmService.getUserVm(vmId);
|
||||
return userVM.getAccountId();
|
||||
}
|
||||
|
||||
}
|
||||
@ -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.api.command.user.vmsnapshot;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseAsyncCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.SuccessResponse;
|
||||
import org.apache.cloudstack.api.response.VMSnapshotResponse;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
import com.cloud.vm.snapshot.VMSnapshot;
|
||||
|
||||
@APICommand(name="deleteVMSnapshot", description = "Deletes a vmsnapshot.", responseObject = SuccessResponse.class)
|
||||
public class DeleteVMSnapshotCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger
|
||||
.getLogger(DeleteVMSnapshotCmd.class.getName());
|
||||
private static final String s_name = "deletevmsnapshotresponse";
|
||||
|
||||
@Parameter(name=ApiConstants.VM_SNAPSHOT_ID, type=CommandType.UUID, entityType=VMSnapshotResponse.class,
|
||||
required=true, description="The ID of the VM snapshot")
|
||||
private Long id;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
VMSnapshot vmSnapshot = _entityMgr.findById(VMSnapshot.class, getId());
|
||||
if (vmSnapshot != null) {
|
||||
return vmSnapshot.getAccountId();
|
||||
}
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
UserContext.current().setEventDetails("vmsnapshot id: " + getId());
|
||||
boolean result = _vmSnapshotService.deleteVMSnapshot(getId());
|
||||
if (result) {
|
||||
SuccessResponse response = new SuccessResponse(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete vm snapshot");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "Delete VM snapshot: " + getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_VM_SNAPSHOT_DELETE;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,89 @@
|
||||
// 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.api.command.user.vmsnapshot;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseListTaggedResourcesCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.api.response.UserVmResponse;
|
||||
import org.apache.cloudstack.api.response.VMSnapshotResponse;
|
||||
|
||||
import com.cloud.vm.snapshot.VMSnapshot;
|
||||
|
||||
@APICommand(name="listVMSnapshot", description = "List virtual machine snapshot by conditions", responseObject = VMSnapshotResponse.class)
|
||||
public class ListVMSnapshotCmd extends BaseListTaggedResourcesCmd {
|
||||
|
||||
private static final String s_name = "listvmsnapshotresponse";
|
||||
|
||||
@Parameter(name=ApiConstants.VM_SNAPSHOT_ID, type=CommandType.UUID, entityType=VMSnapshotResponse.class,
|
||||
description="The ID of the VM snapshot")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name=ApiConstants.STATE, type=CommandType.STRING, description="state of the virtual machine snapshot")
|
||||
private String state;
|
||||
|
||||
@Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID, type = CommandType.UUID, entityType=UserVmResponse.class, description = "the ID of the vm")
|
||||
private Long vmId;
|
||||
|
||||
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "lists snapshot by snapshot name or display name")
|
||||
private String vmSnapshotName;
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public String getVmSnapshotName() {
|
||||
return vmSnapshotName;
|
||||
}
|
||||
|
||||
public Long getVmId() {
|
||||
return vmId;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
List<? extends VMSnapshot> result = _vmSnapshotService
|
||||
.listVMSnapshots(this);
|
||||
ListResponse<VMSnapshotResponse> response = new ListResponse<VMSnapshotResponse>();
|
||||
List<VMSnapshotResponse> snapshotResponses = new ArrayList<VMSnapshotResponse>();
|
||||
for (VMSnapshot r : result) {
|
||||
VMSnapshotResponse vmSnapshotResponse = _responseGenerator
|
||||
.createVMSnapshotResponse(r);
|
||||
vmSnapshotResponse.setObjectName("vmSnapshot");
|
||||
snapshotResponses.add(vmSnapshotResponse);
|
||||
}
|
||||
response.setResponses(snapshotResponses);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,92 @@
|
||||
// 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.api.command.user.vmsnapshot;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseAsyncCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.UserVmResponse;
|
||||
import org.apache.cloudstack.api.response.VMSnapshotResponse;
|
||||
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.vm.snapshot.VMSnapshot;
|
||||
|
||||
@APICommand(name = "revertToSnapshot",description = "Revert VM from a vmsnapshot.", responseObject = UserVmResponse.class)
|
||||
public class RevertToSnapshotCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger
|
||||
.getLogger(RevertToSnapshotCmd.class.getName());
|
||||
private static final String s_name = "reverttosnapshotresponse";
|
||||
|
||||
@Parameter(name = ApiConstants.VM_SNAPSHOT_ID, type = CommandType.UUID, required = true,entityType=VMSnapshotResponse.class,description = "The ID of the vm snapshot")
|
||||
private Long vmSnapShotId;
|
||||
|
||||
public Long getVmSnapShotId() {
|
||||
return vmSnapShotId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
VMSnapshot vmSnapshot = _entityMgr.findById(VMSnapshot.class, getVmSnapShotId());
|
||||
if (vmSnapshot != null) {
|
||||
return vmSnapshot.getAccountId();
|
||||
}
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ResourceAllocationException, ConcurrentOperationException {
|
||||
UserContext.current().setEventDetails(
|
||||
"vmsnapshot id: " + getVmSnapShotId());
|
||||
UserVm result = _vmSnapshotService.revertToSnapshot(getVmSnapShotId());
|
||||
if (result != null) {
|
||||
UserVmResponse response = _responseGenerator.createUserVmResponse(
|
||||
"virtualmachine", result).get(0);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,"Failed to revert VM snapshot");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "Revert from VM snapshot: " + getVmSnapShotId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_VM_SNAPSHOT_REVERT;
|
||||
}
|
||||
|
||||
}
|
||||
@ -119,7 +119,7 @@ public class AttachVolumeCmd extends BaseAsyncCmd {
|
||||
@Override
|
||||
public void execute(){
|
||||
UserContext.current().setEventDetails("Volume Id: "+getId()+" VmId: "+getVirtualMachineId());
|
||||
Volume result = _userVmService.attachVolumeToVM(this);
|
||||
Volume result = _volumeService.attachVolumeToVM(this);
|
||||
if (result != null) {
|
||||
VolumeResponse response = _responseGenerator.createVolumeResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
|
||||
@ -153,7 +153,7 @@ public class CreateVolumeCmd extends BaseAsyncCreateCmd {
|
||||
@Override
|
||||
public void create() throws ResourceAllocationException{
|
||||
|
||||
Volume volume = _storageService.allocVolume(this);
|
||||
Volume volume = this._volumeService.allocVolume(this);
|
||||
if (volume != null) {
|
||||
this.setEntityId(volume.getId());
|
||||
this.setEntityUuid(volume.getUuid());
|
||||
@ -165,7 +165,7 @@ public class CreateVolumeCmd extends BaseAsyncCreateCmd {
|
||||
@Override
|
||||
public void execute(){
|
||||
UserContext.current().setEventDetails("Volume Id: "+getEntityId()+((getSnapshotId() == null) ? "" : " from snapshot: " + getSnapshotId()));
|
||||
Volume volume = _storageService.createVolume(this);
|
||||
Volume volume = _volumeService.createVolume(this);
|
||||
if (volume != null) {
|
||||
VolumeResponse response = _responseGenerator.createVolumeResponse(volume);
|
||||
//FIXME - have to be moved to ApiResponseHelper
|
||||
|
||||
@ -80,7 +80,7 @@ public class DeleteVolumeCmd extends BaseCmd {
|
||||
@Override
|
||||
public void execute() throws ConcurrentOperationException {
|
||||
UserContext.current().setEventDetails("Volume Id: "+getId());
|
||||
boolean result = _storageService.deleteVolume(id, UserContext.current().getCaller());
|
||||
boolean result = this._volumeService.deleteVolume(id, UserContext.current().getCaller());
|
||||
if (result) {
|
||||
SuccessResponse response = new SuccessResponse(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
|
||||
@ -130,7 +130,7 @@ public class DetachVolumeCmd extends BaseAsyncCmd {
|
||||
@Override
|
||||
public void execute(){
|
||||
UserContext.current().setEventDetails("Volume Id: "+getId()+" VmId: "+getVirtualMachineId());
|
||||
Volume result = _userVmService.detachVolumeFromVM(this);
|
||||
Volume result = _volumeService.detachVolumeFromVM(this);
|
||||
if (result != null){
|
||||
VolumeResponse response = _responseGenerator.createVolumeResponse(result);
|
||||
response.setResponseName("volume");
|
||||
|
||||
@ -92,7 +92,7 @@ public class MigrateVolumeCmd extends BaseAsyncCmd {
|
||||
public void execute(){
|
||||
Volume result;
|
||||
try {
|
||||
result = _storageService.migrateVolume(getVolumeId(), getStoragePoolId());
|
||||
result = _volumeService.migrateVolume(this);
|
||||
if (result != null) {
|
||||
VolumeResponse response = _responseGenerator.createVolumeResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
|
||||
@ -133,7 +133,7 @@ public class ResizeVolumeCmd extends BaseAsyncCmd {
|
||||
@Override
|
||||
public void execute(){
|
||||
UserContext.current().setEventDetails("Volume Id: " + getEntityId() + " to size " + getSize() + "G");
|
||||
Volume volume = _storageService.resizeVolume(this);
|
||||
Volume volume = _volumeService.resizeVolume(this);
|
||||
if (volume != null) {
|
||||
VolumeResponse response = _responseGenerator.createVolumeResponse(volume);
|
||||
//FIXME - have to be moved to ApiResponseHelper
|
||||
|
||||
@ -68,6 +68,10 @@ public class UploadVolumeCmd extends BaseAsyncCmd {
|
||||
@Parameter(name=ApiConstants.CHECKSUM, type=CommandType.STRING, description="the MD5 checksum value of this volume")
|
||||
private String checksum;
|
||||
|
||||
@Parameter(name=ApiConstants.IMAGE_STORE_UUID, type=CommandType.STRING,
|
||||
description="Image store uuid")
|
||||
private String imageStoreUuid;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@ -100,6 +104,10 @@ public class UploadVolumeCmd extends BaseAsyncCmd {
|
||||
return checksum;
|
||||
}
|
||||
|
||||
public String getImageStoreUuid() {
|
||||
return this.imageStoreUuid;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@ -110,7 +118,7 @@ public class UploadVolumeCmd extends BaseAsyncCmd {
|
||||
ConcurrentOperationException, ResourceAllocationException,
|
||||
NetworkRuleConflictException {
|
||||
|
||||
Volume volume = _storageService.uploadVolume(this);
|
||||
Volume volume = _volumeService.uploadVolume(this);
|
||||
if (volume != null){
|
||||
VolumeResponse response = _responseGenerator.createVolumeResponse(volume);
|
||||
response.setResponseName(getCommandName());
|
||||
|
||||
@ -34,7 +34,7 @@ import com.cloud.user.UserContext;
|
||||
public class CreateVpnCustomerGatewayCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(CreateVpnCustomerGatewayCmd.class.getName());
|
||||
|
||||
private static final String s_name = "createcustomergatewayresponse";
|
||||
private static final String s_name = "createvpncustomergatewayresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
|
||||
@ -132,6 +132,24 @@ public class AccountResponse extends BaseResponse {
|
||||
@SerializedName("vpcavailable") @Param(description="the total number of vpcs available to be created for this account", since="4.0.0")
|
||||
private String vpcAvailable;
|
||||
|
||||
@SerializedName("cpulimit") @Param(description="the total number of cpu cores the account can own", since="4.1.0")
|
||||
private String cpuLimit;
|
||||
|
||||
@SerializedName("cputotal") @Param(description="the total number of cpu cores owned by account", since="4.1.0")
|
||||
private Long cpuTotal;
|
||||
|
||||
@SerializedName("cpuavailable") @Param(description="the total number of cpu cores available to be created for this account", since="4.1.0")
|
||||
private String cpuAvailable;
|
||||
|
||||
@SerializedName("memorylimit") @Param(description="the total memory (in MB) the account can own", since="4.1.0")
|
||||
private String memoryLimit;
|
||||
|
||||
@SerializedName("memorytotal") @Param(description="the total memory (in MB) owned by account", since="4.1.0")
|
||||
private Long memoryTotal;
|
||||
|
||||
@SerializedName("memoryavailable") @Param(description="the total memory (in MB) available to be created for this account", since="4.1.0")
|
||||
private String memoryAvailable;
|
||||
|
||||
|
||||
@SerializedName(ApiConstants.STATE) @Param(description="the state of the account")
|
||||
private String state;
|
||||
@ -294,6 +312,30 @@ public class AccountResponse extends BaseResponse {
|
||||
this.networkAvailable = networkAvailable;
|
||||
}
|
||||
|
||||
public void setCpuLimit(String cpuLimit) {
|
||||
this.cpuLimit = cpuLimit;
|
||||
}
|
||||
|
||||
public void setCpuTotal(Long cpuTotal) {
|
||||
this.cpuTotal = cpuTotal;
|
||||
}
|
||||
|
||||
public void setCpuAvailable(String cpuAvailable) {
|
||||
this.cpuAvailable = cpuAvailable;
|
||||
}
|
||||
|
||||
public void setMemoryLimit(String memoryLimit) {
|
||||
this.memoryLimit = memoryLimit;
|
||||
}
|
||||
|
||||
public void setMemoryTotal(Long memoryTotal) {
|
||||
this.memoryTotal = memoryTotal;
|
||||
}
|
||||
|
||||
public void setMemoryAvailable(String memoryAvailable) {
|
||||
this.memoryAvailable = memoryAvailable;
|
||||
}
|
||||
|
||||
public void setDefaultZone(String defaultZoneId) {
|
||||
this.defaultZoneId = defaultZoneId;
|
||||
}
|
||||
|
||||
@ -62,6 +62,12 @@ public class ClusterResponse extends BaseResponse {
|
||||
@SerializedName("capacity") @Param(description="the capacity of the Cluster", responseObject = CapacityResponse.class)
|
||||
private List<CapacityResponse> capacitites;
|
||||
|
||||
@SerializedName("cpuovercommitratio") @Param(description = "The cpu overcommit ratio of the cluster")
|
||||
private String cpuovercommitratio;
|
||||
|
||||
@SerializedName("memoryovercommitratio") @Param (description = "The ram overcommit ratio of the cluster")
|
||||
private String memoryovercommitratio;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
@ -149,4 +155,18 @@ public class ClusterResponse extends BaseResponse {
|
||||
public void setCapacitites(ArrayList<CapacityResponse> arrayList) {
|
||||
this.capacitites = arrayList;
|
||||
}
|
||||
public void setCpuovercommitratio(String cpuovercommitratio){
|
||||
this.cpuovercommitratio= cpuovercommitratio;
|
||||
}
|
||||
public void setRamovercommitratio (String memoryOvercommitRatio){
|
||||
this.memoryovercommitratio= memoryOvercommitRatio;
|
||||
}
|
||||
|
||||
public String getCpuovercommitratio (){
|
||||
return cpuovercommitratio;
|
||||
}
|
||||
|
||||
public String getRamovercommitratio (){
|
||||
return memoryovercommitratio;
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ public class LDAPConfigResponse extends BaseResponse {
|
||||
@SerializedName(ApiConstants.PORT) @Param(description="Specify the LDAP port if required, default is 389")
|
||||
private String port;
|
||||
|
||||
@SerializedName(ApiConstants.PORT) @Param(description="Check Use SSL if the external LDAP server is configured for LDAP over SSL")
|
||||
@SerializedName(ApiConstants.USE_SSL) @Param(description="Check Use SSL if the external LDAP server is configured for LDAP over SSL")
|
||||
private String useSSL;
|
||||
|
||||
@SerializedName(ApiConstants.SEARCH_BASE) @Param(description="The search base defines the starting point for the search in the directory tree Example: dc=cloud,dc=com")
|
||||
|
||||
@ -52,9 +52,15 @@ public class NetworkResponse extends BaseResponse implements ControlledEntityRes
|
||||
@SerializedName(ApiConstants.NETMASK) @Param(description="the network's netmask")
|
||||
private String netmask;
|
||||
|
||||
@SerializedName(ApiConstants.CIDR) @Param(description="the cidr the network")
|
||||
@SerializedName(ApiConstants.CIDR) @Param(description="Cloudstack managed address space, all CloudStack managed VMs get IP address from CIDR")
|
||||
private String cidr;
|
||||
|
||||
@SerializedName(ApiConstants.NETWORK_CIDR) @Param(description="the network CIDR of the guest network configured with IP reservation. It is the summation of CIDR and RESERVED_IP_RANGE")
|
||||
private String networkCidr;
|
||||
|
||||
@SerializedName(ApiConstants.RESERVED_IP_RANGE) @Param(description="the network's IP range not to be used by CloudStack guest VMs and can be used for non CloudStack purposes")
|
||||
private String reservedIpRange;
|
||||
|
||||
@SerializedName(ApiConstants.ZONE_ID) @Param(description="zone id of the network")
|
||||
private String zoneId;
|
||||
|
||||
@ -289,6 +295,14 @@ public class NetworkResponse extends BaseResponse implements ControlledEntityRes
|
||||
this.cidr = cidr;
|
||||
}
|
||||
|
||||
public void setNetworkCidr(String networkCidr) {
|
||||
this.networkCidr = networkCidr;
|
||||
}
|
||||
|
||||
public void setReservedIpRange(String reservedIpRange) {
|
||||
this.reservedIpRange = reservedIpRange;
|
||||
}
|
||||
|
||||
public void setRestartRequired(Boolean restartRequired) {
|
||||
this.restartRequired = restartRequired;
|
||||
}
|
||||
|
||||
@ -40,7 +40,7 @@ public class ResourceCountResponse extends BaseResponse implements ControlledEnt
|
||||
@SerializedName(ApiConstants.DOMAIN) @Param(description="the domain name for which resource count's are updated")
|
||||
private String domainName;
|
||||
|
||||
@SerializedName(ApiConstants.RESOURCE_TYPE) @Param(description="resource type. Values include 0, 1, 2, 3, 4. See the resourceType parameter for more information on these values.")
|
||||
@SerializedName(ApiConstants.RESOURCE_TYPE) @Param(description="resource type. Values include 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. See the resourceType parameter for more information on these values.")
|
||||
private String resourceType;
|
||||
|
||||
@SerializedName("resourcecount") @Param(description="resource count")
|
||||
|
||||
@ -36,7 +36,7 @@ public class ResourceLimitResponse extends BaseResponse implements ControlledEnt
|
||||
@SerializedName(ApiConstants.DOMAIN) @Param(description="the domain name of the resource limit")
|
||||
private String domainName;
|
||||
|
||||
@SerializedName(ApiConstants.RESOURCE_TYPE) @Param(description="resource type. Values include 0, 1, 2, 3, 4. See the resourceType parameter for more information on these values.")
|
||||
@SerializedName(ApiConstants.RESOURCE_TYPE) @Param(description="resource type. Values include 0, 1, 2, 3, 4, 6, 7, 8, 9. See the resourceType parameter for more information on these values.")
|
||||
private String resourceType;
|
||||
|
||||
@SerializedName("max") @Param(description="the maximum number of the resource. A -1 means the resource currently has no limit.")
|
||||
|
||||
@ -0,0 +1,220 @@
|
||||
// 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.api.response;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
import org.apache.cloudstack.api.EntityReference;
|
||||
|
||||
import com.cloud.serializer.Param;
|
||||
import com.cloud.vm.snapshot.VMSnapshot;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
@EntityReference(value=VMSnapshot.class)
|
||||
public class VMSnapshotResponse extends BaseResponse implements ControlledEntityResponse{
|
||||
|
||||
@SerializedName(ApiConstants.ID)
|
||||
@Param(description = "the ID of the vm snapshot")
|
||||
private String id;
|
||||
|
||||
@SerializedName(ApiConstants.NAME)
|
||||
@Param(description = "the name of the vm snapshot")
|
||||
private String name;
|
||||
|
||||
@SerializedName(ApiConstants.STATE)
|
||||
@Param(description = "the state of the vm snapshot")
|
||||
private VMSnapshot.State state;
|
||||
|
||||
@SerializedName(ApiConstants.DESCRIPTION)
|
||||
@Param(description = "the description of the vm snapshot")
|
||||
private String description;
|
||||
|
||||
@SerializedName(ApiConstants.DISPLAY_NAME)
|
||||
@Param(description = "the display name of the vm snapshot")
|
||||
private String displayName;
|
||||
|
||||
@SerializedName(ApiConstants.ZONE_ID)
|
||||
@Param(description = "the Zone ID of the vm snapshot")
|
||||
private String zoneId;
|
||||
|
||||
@SerializedName(ApiConstants.VIRTUAL_MACHINE_ID)
|
||||
@Param(description = "the vm ID of the vm snapshot")
|
||||
private String virtualMachineid;
|
||||
|
||||
@SerializedName("parent")
|
||||
@Param(description = "the parent ID of the vm snapshot")
|
||||
private String parent;
|
||||
|
||||
@SerializedName("parentName")
|
||||
@Param(description = "the parent displayName of the vm snapshot")
|
||||
private String parentName;
|
||||
|
||||
@SerializedName("current")
|
||||
@Param(description = "indiates if this is current snapshot")
|
||||
private Boolean current;
|
||||
|
||||
@SerializedName("type")
|
||||
@Param(description = "VM Snapshot type")
|
||||
private String type;
|
||||
|
||||
@SerializedName(ApiConstants.CREATED)
|
||||
@Param(description = "the create date of the vm snapshot")
|
||||
private Date created;
|
||||
|
||||
@SerializedName(ApiConstants.ACCOUNT)
|
||||
@Param(description = "the account associated with the disk volume")
|
||||
private String accountName;
|
||||
|
||||
@SerializedName(ApiConstants.PROJECT_ID) @Param(description="the project id of the vpn")
|
||||
private String projectId;
|
||||
|
||||
@SerializedName(ApiConstants.PROJECT) @Param(description="the project name of the vpn")
|
||||
private String projectName;
|
||||
|
||||
@SerializedName(ApiConstants.DOMAIN_ID)
|
||||
@Param(description = "the ID of the domain associated with the disk volume")
|
||||
private String domainId;
|
||||
|
||||
@SerializedName(ApiConstants.DOMAIN)
|
||||
@Param(description = "the domain associated with the disk volume")
|
||||
private String domainName;
|
||||
|
||||
@Override
|
||||
public String getObjectId() {
|
||||
return getId();
|
||||
}
|
||||
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
public void setZoneId(String zoneId) {
|
||||
this.zoneId = zoneId;
|
||||
}
|
||||
|
||||
public String getVirtualMachineid() {
|
||||
return virtualMachineid;
|
||||
}
|
||||
|
||||
public void setVirtualMachineid(String virtualMachineid) {
|
||||
this.virtualMachineid = virtualMachineid;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setState(VMSnapshot.State state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public VMSnapshot.State getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public Boolean getCurrent() {
|
||||
return current;
|
||||
}
|
||||
|
||||
public void setCurrent(Boolean current) {
|
||||
this.current = current;
|
||||
}
|
||||
|
||||
public void setParentName(String parentName) {
|
||||
this.parentName = parentName;
|
||||
}
|
||||
|
||||
public String getParentName() {
|
||||
return parentName;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAccountName(String accountName) {
|
||||
this.accountName = accountName;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProjectId(String projectId) {
|
||||
this.projectId = projectId;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProjectName(String projectName) {
|
||||
this.projectName = projectName;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDomainId(String domainId) {
|
||||
this.domainId = domainId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDomainName(String domainName) {
|
||||
this.domainName = domainName;
|
||||
|
||||
}
|
||||
}
|
||||
@ -58,7 +58,6 @@ import com.cloud.exception.PermissionDeniedException;
|
||||
|
||||
/**
|
||||
* Service used for list api query.
|
||||
* @author minc
|
||||
*
|
||||
*/
|
||||
public interface QueryService {
|
||||
|
||||
@ -133,15 +133,15 @@ public class BackupSnapshotCommandTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStorageProvider() {
|
||||
public Long getStorageProviderId() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStorageType() {
|
||||
public boolean isInMaintenance() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return false;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@ -115,15 +115,15 @@ public class SnapshotCommandTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStorageProvider() {
|
||||
public Long getStorageProviderId() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStorageType() {
|
||||
public boolean isInMaintenance() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return false;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@ -0,0 +1,69 @@
|
||||
// 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.api.command.test;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.apache.cloudstack.api.command.admin.usage.GetUsageRecordsCmd;
|
||||
import org.apache.cloudstack.usage.Usage;
|
||||
import org.apache.cloudstack.usage.UsageService;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class UsageCmdTest extends TestCase {
|
||||
|
||||
private GetUsageRecordsCmd getUsageRecordsCmd;
|
||||
|
||||
@Rule
|
||||
public ExpectedException expectedException = ExpectedException.none();
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
|
||||
getUsageRecordsCmd = new GetUsageRecordsCmd() {
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExecuteSuccess() {
|
||||
UsageService usageService = Mockito.mock(UsageService.class);
|
||||
getUsageRecordsCmd._usageService = usageService;
|
||||
getUsageRecordsCmd.execute();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExecuteEmptyResult() {
|
||||
|
||||
UsageService usageService = Mockito.mock(UsageService.class);
|
||||
|
||||
List usageRecords = new ArrayList<Usage>();
|
||||
|
||||
Mockito.when(usageService.getUsageRecords(getUsageRecordsCmd)).thenReturn(
|
||||
usageRecords);
|
||||
|
||||
getUsageRecordsCmd._usageService = usageService;
|
||||
getUsageRecordsCmd.execute();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -134,15 +134,15 @@ public class ResizeVolumeCommandTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStorageProvider() {
|
||||
public Long getStorageProviderId() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStorageType() {
|
||||
public boolean isInMaintenance() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return false;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack</artifactId>
|
||||
<version>4.1.0-SNAPSHOT</version>
|
||||
<version>4.2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
||||
@ -707,12 +707,20 @@ public class EC2RestServlet extends HttpServlet {
|
||||
else break;
|
||||
|
||||
String[] fromPort = request.getParameterValues( "IpPermissions." + nCount + ".FromPort" );
|
||||
if ( null != fromPort && 0 < fromPort.length)
|
||||
perm.setFromPort( Integer.parseInt( fromPort[0]));
|
||||
if ( null != fromPort && 0 < fromPort.length ) {
|
||||
if ( protocol[0].equalsIgnoreCase("icmp") )
|
||||
perm.setIcmpType( fromPort[0] ) ;
|
||||
else
|
||||
perm.setFromPort( Integer.parseInt( fromPort[0]) );
|
||||
}
|
||||
|
||||
String[] toPort = request.getParameterValues( "IpPermissions." + nCount + ".ToPort" );
|
||||
if ( null != toPort && 0 < toPort.length)
|
||||
perm.setToPort( Integer.parseInt( toPort[0]));
|
||||
if ( null != toPort && 0 < toPort.length ) {
|
||||
if ( protocol[0].equalsIgnoreCase("icmp") )
|
||||
perm.setIcmpCode( toPort[0] );
|
||||
else
|
||||
perm.setToPort( Integer.parseInt( toPort[0]) );
|
||||
}
|
||||
|
||||
// -> list: IpPermissions.n.IpRanges.m.CidrIp
|
||||
mCount = 1;
|
||||
@ -780,12 +788,20 @@ public class EC2RestServlet extends HttpServlet {
|
||||
else break;
|
||||
|
||||
String[] fromPort = request.getParameterValues( "IpPermissions." + nCount + ".FromPort" );
|
||||
if ( null != fromPort && 0 < fromPort.length)
|
||||
perm.setFromPort( Integer.parseInt( fromPort[0]));
|
||||
if ( null != fromPort && 0 < fromPort.length ) {
|
||||
if ( protocol[0].equalsIgnoreCase("icmp") )
|
||||
perm.setIcmpType( fromPort[0] ) ;
|
||||
else
|
||||
perm.setFromPort( Integer.parseInt( fromPort[0]) );
|
||||
}
|
||||
|
||||
String[] toPort = request.getParameterValues( "IpPermissions." + nCount + ".ToPort" );
|
||||
if ( null != toPort && 0 < toPort.length)
|
||||
perm.setToPort( Integer.parseInt( toPort[0]));
|
||||
if ( null != toPort && 0 < toPort.length ) {
|
||||
if ( protocol[0].equalsIgnoreCase("icmp") )
|
||||
perm.setIcmpCode( toPort[0] );
|
||||
else
|
||||
perm.setToPort( Integer.parseInt( toPort[0]) );
|
||||
}
|
||||
|
||||
// -> list: IpPermissions.n.IpRanges.m.CidrIp
|
||||
int mCount = 1;
|
||||
@ -1142,14 +1158,26 @@ public class EC2RestServlet extends HttpServlet {
|
||||
else { response.sendError(530, "Missing ImageId parameter" ); return; }
|
||||
|
||||
String[] minCount = request.getParameterValues( "MinCount" );
|
||||
if ( null != minCount && 0 < minCount.length )
|
||||
EC2request.setMinCount( Integer.parseInt( minCount[0] ));
|
||||
else { response.sendError(530, "Missing MinCount parameter" ); return; }
|
||||
if ( minCount == null || minCount.length < 1) {
|
||||
response.sendError(530, "Missing MinCount parameter" );
|
||||
return;
|
||||
} else if ( Integer.parseInt(minCount[0]) < 1) {
|
||||
throw new EC2ServiceException(ClientError.InvalidParameterValue,
|
||||
"Value of parameter MinCount should be greater than 0");
|
||||
} else {
|
||||
EC2request.setMinCount( Integer.parseInt( minCount[0]) );
|
||||
}
|
||||
|
||||
String[] maxCount = request.getParameterValues( "MaxCount" );
|
||||
if ( null != maxCount && 0 < maxCount.length )
|
||||
EC2request.setMaxCount( Integer.parseInt( maxCount[0] ));
|
||||
else { response.sendError(530, "Missing MaxCount parameter" ); return; }
|
||||
if ( maxCount == null || maxCount.length < 1) {
|
||||
response.sendError(530, "Missing MaxCount parameter" );
|
||||
return;
|
||||
} else if ( Integer.parseInt(maxCount[0]) < 1) {
|
||||
throw new EC2ServiceException(ClientError.InvalidParameterValue,
|
||||
"Value of parameter MaxCount should be greater than 0");
|
||||
} else {
|
||||
EC2request.setMaxCount( Integer.parseInt( maxCount[0]) );
|
||||
}
|
||||
|
||||
String[] instanceType = request.getParameterValues( "InstanceType" );
|
||||
if ( null != instanceType && 0 < instanceType.length )
|
||||
@ -1257,6 +1285,11 @@ public class EC2RestServlet extends HttpServlet {
|
||||
}
|
||||
if (0 == count) { response.sendError(530, "Missing InstanceId parameter" ); return; }
|
||||
|
||||
String[] force = request.getParameterValues("Force");
|
||||
if ( force != null) {
|
||||
EC2request.setForce( Boolean.parseBoolean(force[0]));
|
||||
}
|
||||
|
||||
// -> execute the request
|
||||
StopInstancesResponse EC2response = EC2SoapServiceImpl.toStopInstancesResponse( ServiceProvider.getInstance().getEC2Engine().stopInstances( EC2request ));
|
||||
serializeResponse(response, EC2response);
|
||||
@ -1899,10 +1932,14 @@ public class EC2RestServlet extends HttpServlet {
|
||||
String paramName = (String) params.nextElement();
|
||||
// exclude the signature string obviously. ;)
|
||||
if (paramName.equalsIgnoreCase("Signature")) continue;
|
||||
// URLEncoder performs application/x-www-form-urlencoded-type encoding and not Percent encoding
|
||||
// according to RFC 3986 as required by Amazon, we need to Percent-encode (URL Encode)
|
||||
String encodedValue = URLEncoder.encode(request.getParameter(paramName), "UTF-8")
|
||||
.replace("+", "%20").replace("*", "%2A");
|
||||
if (queryString == null)
|
||||
queryString = paramName + "=" + URLEncoder.encode(request.getParameter(paramName), "UTF-8");
|
||||
queryString = paramName + "=" + encodedValue;
|
||||
else
|
||||
queryString = queryString + "&" + paramName + "=" + URLEncoder.encode(request.getParameter(paramName), "UTF-8");
|
||||
queryString = queryString + "&" + paramName + "=" + encodedValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,6 +41,7 @@ import com.cloud.bridge.service.core.ec2.EC2DescribeAvailabilityZones;
|
||||
import com.cloud.bridge.service.core.ec2.EC2DescribeAvailabilityZonesResponse;
|
||||
import com.cloud.bridge.service.core.ec2.EC2DescribeImageAttribute;
|
||||
|
||||
import com.cloud.bridge.service.core.ec2.EC2AvailabilityZone;
|
||||
import com.cloud.bridge.service.core.ec2.EC2DescribeImages;
|
||||
import com.cloud.bridge.service.core.ec2.EC2DescribeImagesResponse;
|
||||
import com.cloud.bridge.service.core.ec2.EC2DescribeInstances;
|
||||
@ -730,8 +731,17 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface {
|
||||
EC2RunInstances request = new EC2RunInstances();
|
||||
|
||||
request.setTemplateId(rit.getImageId());
|
||||
request.setMinCount(rit.getMinCount());
|
||||
request.setMaxCount(rit.getMaxCount());
|
||||
|
||||
if (rit.getMinCount() < 1) {
|
||||
throw new EC2ServiceException(ClientError.InvalidParameterValue,
|
||||
"Value of parameter MinCount should be greater than 0");
|
||||
} else request.setMinCount( rit.getMinCount() );
|
||||
|
||||
if (rit.getMaxCount() < 1) {
|
||||
throw new EC2ServiceException(ClientError.InvalidParameterValue,
|
||||
"Value of parameter MaxCount should be greater than 0");
|
||||
} else request.setMaxCount(rit.getMaxCount());
|
||||
|
||||
if (null != type) request.setInstanceType(type);
|
||||
if (null != prt) request.setZoneName(prt.getAvailabilityZone());
|
||||
if (null != userData) request.setUserData(userData.getData());
|
||||
@ -763,6 +773,7 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface {
|
||||
public StopInstancesResponse stopInstances(StopInstances stopInstances) {
|
||||
EC2StopInstances request = new EC2StopInstances();
|
||||
StopInstancesType sit = stopInstances.getStopInstances();
|
||||
Boolean force = sit.getForce();
|
||||
|
||||
// -> toEC2StopInstances
|
||||
InstanceIdSetType iist = sit.getInstancesSet();
|
||||
@ -770,6 +781,8 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface {
|
||||
if (null != items) { // -> should not be empty
|
||||
for( int i=0; i < items.length; i++ ) request.addInstanceId( items[i].getInstanceId());
|
||||
}
|
||||
|
||||
if (force) request.setForce(sit.getForce());
|
||||
return toStopInstancesResponse( engine.stopInstances( request ));
|
||||
}
|
||||
|
||||
@ -1289,7 +1302,7 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface {
|
||||
param5.setInstanceId(vol.getInstanceId().toString());
|
||||
String devicePath = engine.cloudDeviceIdToDevicePath( vol.getHypervisor(), vol.getDeviceId());
|
||||
param5.setDevice( devicePath );
|
||||
param5.setStatus( toVolumeAttachmentState( vol.getInstanceId(), vol.getVMState()));
|
||||
param5.setStatus(vol.getAttachmentState());
|
||||
if (vol.getAttached() == null) {
|
||||
param5.setAttachTime( cal );
|
||||
} else {
|
||||
@ -1546,24 +1559,6 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface {
|
||||
else return new String( "running" );
|
||||
}
|
||||
|
||||
/**
|
||||
* We assume a state for the volume based on what its associated VM is doing.
|
||||
*
|
||||
* @param vmId
|
||||
* @param vmState
|
||||
* @return
|
||||
*/
|
||||
public static String toVolumeAttachmentState(String instanceId, String vmState ) {
|
||||
if (null == instanceId || null == vmState) return "detached";
|
||||
|
||||
if (vmState.equalsIgnoreCase( "Destroyed" )) return "detached";
|
||||
else if (vmState.equalsIgnoreCase( "Stopped" )) return "attached";
|
||||
else if (vmState.equalsIgnoreCase( "Running" )) return "attached";
|
||||
else if (vmState.equalsIgnoreCase( "Starting" )) return "attaching";
|
||||
else if (vmState.equalsIgnoreCase( "Stopping" )) return "attached";
|
||||
else if (vmState.equalsIgnoreCase( "Error" )) return "detached";
|
||||
else return "detached";
|
||||
}
|
||||
|
||||
public static StopInstancesResponse toStopInstancesResponse(EC2StopInstancesResponse engineResponse) {
|
||||
StopInstancesResponse response = new StopInstancesResponse();
|
||||
@ -1776,13 +1771,17 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface {
|
||||
DescribeAvailabilityZonesResponseType param1 = new DescribeAvailabilityZonesResponseType();
|
||||
AvailabilityZoneSetType param2 = new AvailabilityZoneSetType();
|
||||
|
||||
String[] zones = engineResponse.getZoneSet();
|
||||
for (String zone : zones) {
|
||||
EC2AvailabilityZone[] zones = engineResponse.getAvailabilityZoneSet();
|
||||
for (EC2AvailabilityZone zone : zones) {
|
||||
AvailabilityZoneItemType param3 = new AvailabilityZoneItemType();
|
||||
AvailabilityZoneMessageSetType param4 = new AvailabilityZoneMessageSetType();
|
||||
param3.setZoneName( zone );
|
||||
param3.setZoneName( zone.getName() );
|
||||
param3.setZoneState( "available" );
|
||||
param3.setRegionName( "" );
|
||||
|
||||
AvailabilityZoneMessageSetType param4 = new AvailabilityZoneMessageSetType();
|
||||
AvailabilityZoneMessageType param5 = new AvailabilityZoneMessageType();
|
||||
param5.setMessage(zone.getMessage());
|
||||
param4.addItem(param5);
|
||||
param3.setMessageSet( param4 );
|
||||
param2.addItem( param3 );
|
||||
}
|
||||
@ -1803,10 +1802,7 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface {
|
||||
param1.setVolumeId( engineResponse.getId().toString());
|
||||
param1.setInstanceId( engineResponse.getInstanceId().toString());
|
||||
param1.setDevice( engineResponse.getDevice());
|
||||
if ( null != engineResponse.getState())
|
||||
param1.setStatus( engineResponse.getState());
|
||||
else param1.setStatus( "" ); // ToDo - throw an Soap Fault
|
||||
|
||||
param1.setStatus(engineResponse.getAttachmentState());
|
||||
param1.setAttachTime( cal );
|
||||
|
||||
param1.setRequestId( UUID.randomUUID().toString());
|
||||
@ -1823,10 +1819,7 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface {
|
||||
param1.setVolumeId( engineResponse.getId().toString());
|
||||
param1.setInstanceId( (null == engineResponse.getInstanceId() ? "" : engineResponse.getInstanceId().toString()));
|
||||
param1.setDevice( (null == engineResponse.getDevice() ? "" : engineResponse.getDevice()));
|
||||
if ( null != engineResponse.getState())
|
||||
param1.setStatus( engineResponse.getState());
|
||||
else param1.setStatus( "" ); // ToDo - throw an Soap Fault
|
||||
|
||||
param1.setStatus(engineResponse.getAttachmentState());
|
||||
param1.setAttachTime( cal );
|
||||
|
||||
param1.setRequestId( UUID.randomUUID().toString());
|
||||
@ -1912,7 +1905,10 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface {
|
||||
param3.setStartTime( cal );
|
||||
|
||||
param3.setOwnerId(ownerId);
|
||||
param3.setVolumeSize( snap.getVolumeSize().toString());
|
||||
if ( snap.getVolumeSize() == null )
|
||||
param3.setVolumeSize("0");
|
||||
else
|
||||
param3.setVolumeSize( snap.getVolumeSize().toString() );
|
||||
param3.setDescription( snap.getName());
|
||||
param3.setOwnerAlias( snap.getAccountName() );
|
||||
|
||||
|
||||
@ -14,22 +14,42 @@
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.baremetal;
|
||||
package com.cloud.bridge.service.core.ec2;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
public class EC2AvailabilityZone {
|
||||
|
||||
public class PxeServerResponse extends BaseResponse {
|
||||
@SerializedName(ApiConstants.ID) @Param(description="the ID of the PXE server")
|
||||
private String id;
|
||||
private String name;
|
||||
private String message;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
public EC2AvailabilityZone() {
|
||||
id = null;
|
||||
name = null;
|
||||
message = null;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
public void setId( String id ) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setName( String name ) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setMessage( String message ) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return this.message;
|
||||
}
|
||||
|
||||
}
|
||||
@ -36,6 +36,7 @@ public class EC2AvailabilityZonesFilterSet {
|
||||
public EC2AvailabilityZonesFilterSet() {
|
||||
// -> use these values to check that the proper filter is passed to this type of filter set
|
||||
filterTypes.put( "zone-name", "String" );
|
||||
filterTypes.put( "message", "String");
|
||||
}
|
||||
|
||||
public void addFilter( EC2Filter param ) {
|
||||
@ -55,13 +56,14 @@ public class EC2AvailabilityZonesFilterSet {
|
||||
return filterSet.toArray(new EC2Filter[0]);
|
||||
}
|
||||
|
||||
public List<String> evaluate( EC2DescribeAvailabilityZonesResponse availabilityZones) throws ParseException {
|
||||
List<String> resultList = new ArrayList<String>();
|
||||
public EC2DescribeAvailabilityZonesResponse evaluate( EC2DescribeAvailabilityZonesResponse availabilityZones)
|
||||
throws ParseException {
|
||||
EC2DescribeAvailabilityZonesResponse resultList = new EC2DescribeAvailabilityZonesResponse();
|
||||
|
||||
boolean matched;
|
||||
|
||||
EC2Filter[] filterSet = getFilterSet();
|
||||
for ( String availableZone : availabilityZones.getZoneSet() ) {
|
||||
for ( EC2AvailabilityZone availableZone : availabilityZones.getAvailabilityZoneSet() ) {
|
||||
matched = true;
|
||||
if (filterSet != null) {
|
||||
for (EC2Filter filter : filterSet) {
|
||||
@ -71,18 +73,21 @@ public class EC2AvailabilityZonesFilterSet {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (matched == true)
|
||||
resultList.add(availableZone);
|
||||
if (matched)
|
||||
resultList.addAvailabilityZone(availableZone);
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
private boolean filterMatched( String availableZone, EC2Filter filter ) throws ParseException {
|
||||
private boolean filterMatched( EC2AvailabilityZone availableZone, EC2Filter filter ) throws ParseException {
|
||||
String filterName = filter.getName();
|
||||
String[] valueSet = filter.getValueSet();
|
||||
|
||||
if ( filterName.equalsIgnoreCase("zone-name")) {
|
||||
return containsString(availableZone, valueSet);
|
||||
return containsString(availableZone.getName(), valueSet);
|
||||
}
|
||||
else if (filterName.equalsIgnoreCase("message")) {
|
||||
return containsString(availableZone.getMessage(), valueSet);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -20,31 +20,17 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class EC2DescribeAvailabilityZonesResponse {
|
||||
|
||||
private List<String> zoneIds = new ArrayList<String>();
|
||||
private List<String> zoneNames = new ArrayList<String>();
|
||||
private List<EC2AvailabilityZone> availabilityZoneSet = new ArrayList<EC2AvailabilityZone>();
|
||||
|
||||
public EC2DescribeAvailabilityZonesResponse() {
|
||||
}
|
||||
|
||||
public void addZone(String id, String name) {
|
||||
zoneIds.add(id);
|
||||
zoneNames.add(name);
|
||||
public void addAvailabilityZone( EC2AvailabilityZone param ) {
|
||||
availabilityZoneSet.add( param );
|
||||
}
|
||||
|
||||
/**
|
||||
* The Amazon API only cares about the names of zones not their ID value.
|
||||
*
|
||||
* @return an array containing a set of zone names
|
||||
*/
|
||||
public String[] getZoneSet() {
|
||||
return zoneNames.toArray(new String[0]);
|
||||
public EC2AvailabilityZone[] getAvailabilityZoneSet() {
|
||||
return availabilityZoneSet.toArray(new EC2AvailabilityZone[0]);
|
||||
}
|
||||
|
||||
public String getZoneIdAt(int index) {
|
||||
if (zoneIds.isEmpty() || index >= zoneIds.size()) {
|
||||
return null;
|
||||
}
|
||||
return zoneIds.get(index);
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,9 +25,12 @@ import java.security.SignatureException;
|
||||
import java.sql.SQLException;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@ -443,25 +446,35 @@ public class EC2Engine extends ManagerBase {
|
||||
*/
|
||||
public EC2DescribeSnapshotsResponse handleRequest( EC2DescribeSnapshots request )
|
||||
{
|
||||
EC2DescribeVolumesResponse volumes = new EC2DescribeVolumesResponse();
|
||||
EC2SnapshotFilterSet sfs = request.getFilterSet();
|
||||
EC2TagKeyValue[] tagKeyValueSet = request.getResourceTagSet();
|
||||
|
||||
try {
|
||||
// -> query to get the volume size for each snapshot
|
||||
EC2DescribeSnapshotsResponse response = listSnapshots( request.getSnapshotSet(),
|
||||
getResourceTags(tagKeyValueSet));
|
||||
if (response == null) {
|
||||
return new EC2DescribeSnapshotsResponse();
|
||||
}
|
||||
EC2Snapshot[] snapshots = response.getSnapshotSet();
|
||||
for (EC2Snapshot snap : snapshots) {
|
||||
volumes = listVolumes(snap.getVolumeId(), null, volumes, null);
|
||||
EC2Volume[] volSet = volumes.getVolumeSet();
|
||||
if (0 < volSet.length) snap.setVolumeSize(volSet[0].getSize());
|
||||
volumes.reset();
|
||||
// -> query to get the volume size for each snapshot
|
||||
HashMap<String, Long> volumeIdSize = new HashMap<String, Long>();
|
||||
for( EC2Snapshot snap : snapshots ) {
|
||||
Boolean duplicateVolume = false;
|
||||
Long size = null;
|
||||
if ( volumeIdSize.containsKey(snap.getVolumeId()) ) {
|
||||
size = volumeIdSize.get(snap.getVolumeId());
|
||||
duplicateVolume = true;
|
||||
break;
|
||||
}
|
||||
if ( !duplicateVolume ) {
|
||||
EC2DescribeVolumesResponse volumes = new EC2DescribeVolumesResponse();
|
||||
volumes = listVolumes(snap.getVolumeId(), null, volumes, null);
|
||||
EC2Volume[] volumeSet = volumes.getVolumeSet();
|
||||
if (volumeSet.length > 0) size = volumeSet[0].getSize();
|
||||
volumeIdSize.put(snap.getVolumeId(), size);
|
||||
}
|
||||
snap.setVolumeSize(size);
|
||||
}
|
||||
|
||||
if ( null == sfs )
|
||||
return response;
|
||||
else return sfs.evaluate( response );
|
||||
@ -1060,12 +1073,8 @@ public class EC2Engine extends ManagerBase {
|
||||
EC2AvailabilityZonesFilterSet azfs = request.getFilterSet();
|
||||
if ( null == azfs )
|
||||
return availableZones;
|
||||
else {
|
||||
List<String> matchedAvailableZones = azfs.evaluate(availableZones);
|
||||
if (matchedAvailableZones.isEmpty())
|
||||
return new EC2DescribeAvailabilityZonesResponse();
|
||||
return listZones(matchedAvailableZones.toArray(new String[0]), null);
|
||||
}
|
||||
else
|
||||
return azfs.evaluate(availableZones);
|
||||
} catch( EC2ServiceException error ) {
|
||||
logger.error( "EC2 DescribeAvailabilityZones - ", error);
|
||||
throw error;
|
||||
@ -1129,6 +1138,7 @@ public class EC2Engine extends ManagerBase {
|
||||
resp.setState(vol.getState());
|
||||
resp.setType(vol.getVolumeType());
|
||||
resp.setVMState(vol.getVirtualMachineState());
|
||||
resp.setAttachmentState(mapToAmazonVolumeAttachmentState(vol.getVirtualMachineState()));
|
||||
resp.setZoneName(vol.getZoneName());
|
||||
return resp;
|
||||
}
|
||||
@ -1215,6 +1225,7 @@ public class EC2Engine extends ManagerBase {
|
||||
resp.setState(vol.getState());
|
||||
resp.setType(vol.getVolumeType());
|
||||
resp.setVMState(vol.getVirtualMachineState());
|
||||
resp.setAttachmentState("detached");
|
||||
resp.setZoneName(vol.getZoneName());
|
||||
return resp;
|
||||
}
|
||||
@ -1412,6 +1423,7 @@ public class EC2Engine extends ManagerBase {
|
||||
|
||||
// now actually deploy the vms
|
||||
for( int i=0; i < createInstances; i++ ) {
|
||||
try{
|
||||
CloudStackUserVm resp = getApi().deployVirtualMachine(svcOffering.getId(),
|
||||
request.getTemplateId(), zoneId, null, null, null, null,
|
||||
null, null, null, request.getKeyName(), null, (network != null ? network.getId() : null),
|
||||
@ -1447,12 +1459,17 @@ public class EC2Engine extends ManagerBase {
|
||||
vm.setKeyPairName(resp.getKeyPairName());
|
||||
instances.addInstance(vm);
|
||||
countCreated++;
|
||||
}catch(Exception e){
|
||||
logger.error("Failed to deploy VM number: "+ (i+1) +" due to error: "+e.getMessage());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (0 == countCreated) {
|
||||
// TODO, we actually need to destroy left-over VMs when the exception is thrown
|
||||
throw new EC2ServiceException(ServerError.InsufficientInstanceCapacity, "Insufficient Instance Capacity" );
|
||||
throw new EC2ServiceException(ServerError.InternalError, "Failed to deploy instances" );
|
||||
}
|
||||
logger.debug("Could deploy "+ countCreated + " VM's successfully");
|
||||
|
||||
return instances;
|
||||
} catch( Exception e ) {
|
||||
@ -1514,6 +1531,7 @@ public class EC2Engine extends ManagerBase {
|
||||
// -> first determine the current state of each VM (becomes it previous state)
|
||||
try {
|
||||
String[] instanceSet = request.getInstancesSet();
|
||||
Boolean forced = request.getForce();
|
||||
|
||||
EC2DescribeInstancesResponse previousState = listVirtualMachines( instanceSet, null, null );
|
||||
virtualMachines = previousState.getInstanceSet();
|
||||
@ -1535,7 +1553,7 @@ public class EC2Engine extends ManagerBase {
|
||||
instances.addInstance(vm);
|
||||
continue;
|
||||
}
|
||||
resp = getApi().stopVirtualMachine(vm.getId(), false);
|
||||
resp = getApi().stopVirtualMachine(vm.getId(), forced);
|
||||
if(logger.isDebugEnabled())
|
||||
logger.debug("Stopping VM " + vm.getId() + " job " + resp.getJobId());
|
||||
}
|
||||
@ -1643,11 +1661,16 @@ public class EC2Engine extends ManagerBase {
|
||||
ec2Vol.setSize(vol.getSize());
|
||||
ec2Vol.setType(vol.getVolumeType());
|
||||
|
||||
if(vol.getVirtualMachineId() != null)
|
||||
if(vol.getVirtualMachineId() != null) {
|
||||
ec2Vol.setInstanceId(vol.getVirtualMachineId());
|
||||
|
||||
if(vol.getVirtualMachineState() != null)
|
||||
if (vol.getVirtualMachineState() != null) {
|
||||
ec2Vol.setVMState(vol.getVirtualMachineState());
|
||||
ec2Vol.setAttachmentState(mapToAmazonVolumeAttachmentState(vol.getVirtualMachineState()));
|
||||
}
|
||||
} else {
|
||||
ec2Vol.setAttachmentState("detached");
|
||||
}
|
||||
|
||||
ec2Vol.setZoneName(vol.getZoneName());
|
||||
|
||||
List<CloudStackKeyValue> resourceTags = vol.getTags();
|
||||
@ -1691,9 +1714,11 @@ public class EC2Engine extends ManagerBase {
|
||||
|
||||
zones = listZones(interestedZones, domainId);
|
||||
|
||||
if (zones == null || zones.getZoneIdAt( 0 ) == null)
|
||||
if (zones == null || zones.getAvailabilityZoneSet().length == 0)
|
||||
throw new EC2ServiceException(ClientError.InvalidParameterValue, "Unknown zoneName value - " + zoneName);
|
||||
return zones.getZoneIdAt(0);
|
||||
|
||||
EC2AvailabilityZone[] zoneSet = zones.getAvailabilityZoneSet();
|
||||
return zoneSet[0].getId();
|
||||
}
|
||||
|
||||
|
||||
@ -1768,24 +1793,31 @@ public class EC2Engine extends ManagerBase {
|
||||
*
|
||||
* @return EC2DescribeAvailabilityZonesResponse
|
||||
*/
|
||||
private EC2DescribeAvailabilityZonesResponse listZones(String[] interestedZones, String domainId) throws Exception
|
||||
{
|
||||
private EC2DescribeAvailabilityZonesResponse listZones(String[] interestedZones, String domainId)
|
||||
throws Exception {
|
||||
EC2DescribeAvailabilityZonesResponse zones = new EC2DescribeAvailabilityZonesResponse();
|
||||
|
||||
List<CloudStackZone> cloudZones = getApi().listZones(true, domainId, null, null);
|
||||
|
||||
if(cloudZones != null) {
|
||||
if(cloudZones != null && cloudZones.size() > 0) {
|
||||
for(CloudStackZone cloudZone : cloudZones) {
|
||||
if ( null != interestedZones && 0 < interestedZones.length ) {
|
||||
for( int j=0; j < interestedZones.length; j++ ) {
|
||||
if (interestedZones[j].equalsIgnoreCase( cloudZone.getName())) {
|
||||
zones.addZone(cloudZone.getId().toString(), cloudZone.getName());
|
||||
boolean matched = false;
|
||||
if (interestedZones.length > 0) {
|
||||
for (String zoneName : interestedZones){
|
||||
if (zoneName.equalsIgnoreCase( cloudZone.getName())) {
|
||||
matched = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
zones.addZone(cloudZone.getId().toString(), cloudZone.getName());
|
||||
matched = true;
|
||||
}
|
||||
if (!matched) continue;
|
||||
EC2AvailabilityZone ec2Zone = new EC2AvailabilityZone();
|
||||
ec2Zone.setId(cloudZone.getId().toString());
|
||||
ec2Zone.setMessage(cloudZone.getAllocationState());
|
||||
ec2Zone.setName(cloudZone.getName());
|
||||
|
||||
zones.addAvailabilityZone(ec2Zone);
|
||||
}
|
||||
}
|
||||
return zones;
|
||||
@ -1952,7 +1984,7 @@ public class EC2Engine extends ManagerBase {
|
||||
* @throws ParserConfigurationException
|
||||
* @throws ParseException
|
||||
*/
|
||||
public EC2DescribeSecurityGroupsResponse listSecurityGroups( String[] interestedGroups ) throws Exception {
|
||||
private EC2DescribeSecurityGroupsResponse listSecurityGroups( String[] interestedGroups ) throws Exception {
|
||||
try {
|
||||
EC2DescribeSecurityGroupsResponse groupSet = new EC2DescribeSecurityGroupsResponse();
|
||||
|
||||
@ -2399,6 +2431,25 @@ public class EC2Engine extends ManagerBase {
|
||||
return "error";
|
||||
}
|
||||
|
||||
/**
|
||||
* Map CloudStack VM state to Amazon volume attachment state
|
||||
*
|
||||
* @param CloudStack VM state
|
||||
* @return Amazon Volume attachment state
|
||||
*/
|
||||
private String mapToAmazonVolumeAttachmentState (String vmState) {
|
||||
if ( vmState.equalsIgnoreCase("Running") || vmState.equalsIgnoreCase("Stopping") ||
|
||||
vmState.equalsIgnoreCase("Stopped") ) {
|
||||
return "attached";
|
||||
}
|
||||
else if (vmState.equalsIgnoreCase("Starting")) {
|
||||
return "attaching";
|
||||
}
|
||||
else { // VM state is 'destroyed' or 'error' or other
|
||||
return "detached";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Map Amazon resourceType to CloudStack resourceType
|
||||
*
|
||||
|
||||
@ -50,6 +50,7 @@ public class EC2InstanceFilterSet {
|
||||
filterTypes.put( "group-id", "string" );
|
||||
filterTypes.put( "tag-key", "string" );
|
||||
filterTypes.put( "tag-value", "string" );
|
||||
filterTypes.put( "dns-name", "string" );
|
||||
}
|
||||
|
||||
|
||||
@ -184,6 +185,8 @@ public class EC2InstanceFilterSet {
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}else if (filterName.equalsIgnoreCase( "dns-name" )){
|
||||
return containsString( vm.getName(), valueSet );
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
@ -23,6 +23,7 @@ public class EC2StopInstances {
|
||||
|
||||
private List<String> instancesSet = new ArrayList<String>(); // a list of strings identifying instances
|
||||
private boolean destroyInstances; // we are destroying the instances rather than stopping them
|
||||
private Boolean force = false;
|
||||
|
||||
public EC2StopInstances() {
|
||||
destroyInstances = false;
|
||||
@ -44,4 +45,12 @@ public class EC2StopInstances {
|
||||
return this.destroyInstances;
|
||||
}
|
||||
|
||||
public void setForce( Boolean force ) {
|
||||
this.force = force;
|
||||
}
|
||||
|
||||
public Boolean getForce() {
|
||||
return this.force;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -35,6 +35,7 @@ public class EC2Volume {
|
||||
private String hypervisor;
|
||||
private String created;
|
||||
private String attached;
|
||||
private String attachmentState;
|
||||
private List<EC2TagKeyValue> tagsSet;
|
||||
|
||||
public EC2Volume() {
|
||||
@ -50,6 +51,7 @@ public class EC2Volume {
|
||||
hypervisor = null;
|
||||
created = null;
|
||||
attached = null;
|
||||
attachmentState = null;
|
||||
tagsSet = new ArrayList<EC2TagKeyValue>();
|
||||
}
|
||||
|
||||
@ -236,6 +238,20 @@ public class EC2Volume {
|
||||
this.attached = attached;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param state of the attached VM to set
|
||||
*/
|
||||
public void setAttachmentState(String attachedState) {
|
||||
this.attachmentState = attachedState;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return state of the vm
|
||||
*/
|
||||
public String getAttachmentState() {
|
||||
return attachmentState;
|
||||
}
|
||||
|
||||
public void addResourceTag( EC2TagKeyValue param ) {
|
||||
tagsSet.add( param );
|
||||
}
|
||||
|
||||
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