4362 Commits

Author SHA1 Message Date
Rohit Yadav
3d8ea4f3b3 Merge remote-tracking branch 'origin/4.17'
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2022-11-30 21:02:17 +05:30
Abhishek Kumar
47946db888
server: fix volume migration on user vm scale (#6704)
Fixes #6701

When volume migration is initiated by system, account check is not needed.

Introduces a new global setting - allow.diskoffering.change.during.scale.vm. This determines whether to allow or disallow disk offering change for root volume during scaling of a stopped or running VM.

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
Co-authored-by: Harikrishna Patnala <harikrishna.patnala@gmail.com>
Co-authored-by: Rohit Yadav <rohityadav89@gmail.com>
Co-authored-by: Daniel Augusto Veronezi Salvador <38945620+GutoVeronezi@users.noreply.github.com>
Co-authored-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
2022-11-30 12:58:48 +05:30
John Bampton
e65c22d883
Fix spelling (#6860) 2022-11-13 10:56:15 +01:00
John Bampton
fa39e61a4c
Fix spelling (#6609) 2022-11-01 08:30:01 +01:00
Bryan Lima
23033fbb74
Add live migration of system VMs (KVM) (#6491)
Co-authored-by: Rodrigo D. Lopez <19981369+RodrigoDLopez@users.noreply.github.com>
2022-10-28 13:14:09 +02:00
João Jandre
14937e1adb
Fixed NPE on volume creation from snapshot (#6839)
Co-authored-by: João Jandre <joao@scclouds.com.br>
2022-10-26 08:44:01 +02:00
Daniel Augusto Veronezi Salvador
2ca164ac96
Quota custom tariffs (#5909)
Co-authored-by: GutoVeronezi <daniel@scclouds.com.br>
Co-authored-by: dahn <daan.hoogland@gmail.com>
2022-10-17 10:03:50 +02:00
SadiJr
a7ba6a18e6
[Veeam] Improve remove backup process (#6580)
* Allow delete backups but keep backup offering

Co-authored-by: SadiJr <sadi@scclouds.com.br>
2022-10-14 10:14:12 +02:00
Eduardo Zanetta
5a54dc19b6
Rename validateUUID method to isUuid (#6793)
* Rename validateUUID method to isUuid

* adds JavaDoc to isUuid method

Co-authored-by: Eduardo Zanetta <eduardo.zanetta@scclouds.com.br>
2022-10-12 20:42:12 +02:00
João Jandre
d6044fb5a6
Fix to make recovered volumes be accounted for by Usage (#6772) 2022-10-11 14:05:14 +02:00
João Jandre
82d91d596b
api: Return object name in the listHypervisorCapabilities API (#6771)
The hypervisorCapabilitiesResponse does not set an object name, returning a null object name instead. This PR adds an object name to the response.
2022-10-09 08:46:08 +05:30
Harikrishna
713a236843
UserData as first class resource (#6202)
This PR introduces a new feature to make userdata as a first class resource much like existing SSH keys.

Detailed feature specification document:
https://cwiki.apache.org/confluence/display/CLOUDSTACK/Userdata+as+a+first+class+resource
2022-10-05 17:34:59 +05:30
Rohit Yadav
784578d46c Merge remote-tracking branch 'origin/4.17' 2022-09-30 13:48:27 +05:30
dahn
89d9a70dce
server: Allow template names upto 255 chars (#6768)
* Allow template names upto 255 chars

* Update error message

* externalise name length in constant

Fixes: #6766
2022-09-30 10:46:50 +05:30
Abhishek Kumar
432a03fb02
api: fix event type and description for createTag (#6779)
Fixes #6777

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
2022-09-29 11:10:30 +05:30
Marcus Sorensen
697e12f8f7
kvm: volume encryption feature (#6522)
This PR introduces a feature designed to allow CloudStack to manage a generic volume encryption setting. The encryption is handled transparently to the guest OS, and is intended to handle VM guest data encryption at rest and possibly over the wire, though the actual encryption implementation is up to the primary storage driver.

In some cases cloud customers may still prefer to maintain their own guest-level volume encryption, if they don't trust the cloud provider. However, for private cloud cases this greatly simplifies the guest OS experience in terms of running volume encryption for guests without the user having to manage keys, deal with key servers and guest booting being dependent on network connectivity to them (i.e. Tang), etc, especially in cases where users are attaching/detaching data disks and moving them between VMs occasionally.

The feature can be thought of as having two parts - the API/control plane (which includes scheduling aspects), and the storage driver implementation.

This initial PR adds the encryption setting to disk offerings and service offerings (for root volume), and implements encryption support for KVM SharedMountPoint, NFS, Local, and ScaleIO storage pools.

NOTE: While not required, operations can be significantly sped up by ensuring that hosts have the `rng-tools` package and service installed and running on the management server and hypervisors. For EL hosts the service is `rngd` and for Debian it is `rng-tools`. In particular, the use of SecureRandom for generating volume passphrases can be slow if there isn't a good source of entropy. This could affect testing and build environments, and otherwise would only affect users who actually use the encryption feature. If you find tests or volume creates blocking on encryption, check this first.

### Management Server

##### API

* createDiskOffering now has an 'encrypt' Boolean
* createServiceOffering now has an 'encryptroot' Boolean. The 'root' suffix is added here in case there is ever any other need to encrypt something related to the guest configuration, like the RAM of a VM.  This has been refactored to deal with the new separation of service offering from disk offering internally.
* listDiskOfferings shows encryption support on each offering, and has an encrypt boolean to choose to list only offerings that do or do not support encryption
* listServiceOfferings shows encryption support on each offering, and has an encrypt boolean to choose to list only offerings that do or do not support encryption
* listHosts now shows encryption support of each hypervisor host via `encryptionsupported`
* Volumes themselves don't show encryption on/off, rather the offering should be referenced. This follows the same pattern as other disk offering based settings such as the IOPS of the volume.

##### Volume functions

A decent effort has been made to ensure that the most common volume functions have either been cleanly supported or blocked. However, for the first release it is advised to mark this feature as *experimental*, as the code base is complex and there are certainly edge cases to be found.

Many of these features could eventually be supported over time, such as creating templates from encrypted volumes, but the effort and size of the change is already overwhelming.

Supported functions:
* Data Volume create
* VM root volume create
* VM root volume reinstall
* Offline volume snapshot/restore
* Migration of VM with storage (e.g. local storage VM migration)
* Resize volume
* Detach/attach volume

Blocked functions:
* Online volume snapshot
* VM snapshot w/memory
* Scheduled snapshots (would fail when VM is running)
* Disk offering migration to offerings that don't have matching encryption
* Creating template from encrypted volume
* Creating volume from encrypted volume
* Volume extraction (would we decrypt it first, or expose the key? Probably the former).

##### Primary Storage Support

For storage developers, adding encryption support involves:

1. Updating the `StoragePoolType` for your primary storage to advertise encryption support. This is used during allocation of storage to match storage types that support encryption to storage that supports it.

2. Implementing encryption feature when your `PrimaryDataStoreDriver` is called to perform volume lifecycle functions on volumes that are requesting encryption. You are free to do what your storage supports - this could be as simple as calling a storage API with the right flag when creating a volume. Or (as is the case with the KVM storage types), as complex as managing volume details directly at the hypervisor host. The data objects passed to the storage driver will contain volume passphrases, if encryption is requested.

##### Scheduling

For the KVM implementations specified above, we are dependent on the KVM hosts having support for volume encryption tools. As such, the hosts `StartupRoutingCommand` has been modified to advertise whether the host supports encryption. This is done via a probe during agent startup to look for functioning `cryptsetup` and support in `qemu-img`. This is also visible via the listHosts API and the host details in the UI.  This was patterned after other features that require hypervisor support such as UEFI.

The `EndPointSelector` interface and `DefaultEndpointSelector` have had new methods added, which allow the caller to ask for endpoints that support encryption.  This can be used by storage drivers to find the proper hosts to send storage commands that involve encryption. Not all volume activities will require a host to support encryption (for example a snapshot backup is a simple file copy), and this is the reason why the interface has been modified to allow for the storage driver to decide, rather than just passing the data objects to the EndpointSelector and letting the implementation decide.

VM scheduling has also been modified. When a VM start is requested, if any volume that requires encryption is attached, it will filter out hosts that don't support encryption.

##### DB Changes

A volume whose disk offering enables encryption will get a passphrase generated for it before its first use. This is stored in the new 'passphrase' table, and is encrypted using the CloudStack installation's standard configured DB encryption. A field has been added to the volumes table, referencing this passphrase, and a foreign key added to ensure passphrases that are referenced can't be removed from the database.  The volumes table now also contains an encryption format field, which is set by the implementer of the encryption and used as it sees fit.

#### KVM Agent

For the KVM storage pool types supported, the encryption has been implemented at Qemu itself, using the built-in LUKS storage support. This means that the storage remains encrypted all the way to the VM process, and decrypted before the block device is visible to the guest.  This may not be necessary in order to implement encryption for /your/ storage pool type, maybe you have a kernel driver that decrypts before the block device on the system, or something like that. However, it seemed like the simplest, common place to terminate the encryption, and provides the lowest surface area for decrypted guest data.

For qcow2 based storage, `qemu-img` is used to set up a qcow2 file with LUKS encryption. For block based (currently just ScaleIO storage), the `cryptsetup` utility is used to format the block device as LUKS for data disks, but `qemu-img` and its LUKS support is used for template copy.

Any volume that requires encryption will contain a passphrase ID as a byte array when handed down to the KVM agent. Care has been taken to ensure this doesn't get logged, and it is cleared after use in attempt to avoid exposing it before garbage collection occurs.  On the agent side, this passphrase is used in two ways:

1. In cases where the volume experiences some libvirt interaction it is loaded into libvirt as an ephemeral, private secret and then referenced by secret UUID in any libvirt XML. This applies to things like VM startup, migration preparation, etc.

2. In cases where `qemu-img` needs to use this passphrase for volume operations, it is written to a `KeyFile` on the cloudstack agent's configured tmpfs and passed along. The `KeyFile` is a `Closeable` and when it is closed, it is deleted. This allows us to try-with-resources any volume operations and get the KeyFile removed regardless.

In order to support the advanced syntax required to handle encryption and passphrases with `qemu-img`, the `QemuImg` utility has been modified to support the new `--object` and `--image-opts` flags. These are modeled as `QemuObject` and `QemuImageOptions`.  These `qemu-img` flags have been designed to supersede some of the existing, older flags being used today (such as choosing file formats and paths), and an effort could be made to switch over to these wholesale. However, for now we have instead opted to keep existing functions and do some wrapping to ensure backward compatibility, so callers of `QemuImg` can choose to use either way.

It should be noted that there are also a few different Enums that represent the encryption format for various purposes. While these are analogous in principle, they represent different things and should not be confused. For example, the supported encryption format strings for the `cryptsetup` utility has `LuksType.LUKS` while `QemuImg` has a `QemuImg.PhysicalDiskFormat.LUKS`.

Some additional effort could potentially be made to support advanced encryption configurations, such as choosing between LUKS1 and LUKS2 or changing cipher details. These may require changes all the way up through the control plane. However, in practice Libvirt and Qemu currently only support LUKS1 today. Additionally, the cipher details aren't required in order to use an encrypted volume, as they're stored in the LUKS header on the volume there is no need to store these elsewhere.  As such, we need only set the one encryption format upon volume creation, which is persisted in the volumes table and then available later as needed.  In the future when LUKS2 is standard and fully supported, we could move to it as the default and old volumes will still reference LUKS1 and have the headers on-disk to ensure they remain usable. We could also possibly support an automatic upgrade of the headers down the road, or a volume migration mechanism.

Every version of cryptsetup and qemu-img tested on variants of EL7 and Ubuntu that support encryption use the XTS-AES 256 cipher, which is the leading industry standard and widely used cipher today (e.g. BitLocker and FileVault).

Signed-off-by: Marcus Sorensen <mls@apple.com>
Co-authored-by: Marcus Sorensen <mls@apple.com>
2022-09-27 10:20:59 +05:30
João Jandre
d4c6586546
Return vm userdata (#6683)
* [UI] Update vm userdata

* fix vm id

* Address review

* Address review

Co-authored-by: João Paraquetti <joao@scclouds.com.br>
2022-09-26 19:12:28 -03:00
Marcus Sorensen
1a0a61fd9f
Allow option of exposing VM domain info via instance metadata (#6710)
This PR allows the cloud admin to set either a global or domain-specific value "metadata.allow.expose.domain", and when set this allows the VM to see the name and ID of the immediate domain that contains the VM in instance metadata. This can be useful or a variety of things such as bootstrapping VM configuration and access according to domain.

This PR also deletes the CloudZonesNetworkElement because it isn't referred to anywhere, and there was initially some confusion as to whether this code needed to be updated when extending metadata. If it needs to be kept we can remove that delete from the PR.

Signed-off-by: Marcus Sorensen <mls@apple.com>
Co-authored-by: Marcus Sorensen <mls@apple.com>
Co-authored-by: dahn <daan.hoogland@gmail.com>
Co-authored-by: Daniel Augusto Veronezi Salvador <38945620+GutoVeronezi@users.noreply.github.com>
2022-09-22 15:14:21 +05:30
Abhishek Kumar
d724a9d15c Updating pom.xml version numbers for release 4.17.2.0-SNAPSHOT
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
2022-09-19 16:21:35 +05:30
dahn
bbc1260576
Resource reservation framework (#6694)
This PR addresses parallel resource allocation as a generalization of the problem and solution described in #6644. Instead of the Global lock on the resources a reservation record is created which is added in the resource check count in the ResourceLimitService/ResourceLimitManagerImpl. As a convenience a CheckedReservation is created. This is an implementation of AutoClosable and can be used as a guard in a try-with-resource fashion. The close method of the CheckedReservation wil delete the reservation record.

Co-authored-by: Boris Stoyanov - a.k.a Bobby <bss.stoyanov@gmail.com>
2022-09-16 15:44:35 +05:30
Abhishek Kumar
350ef38e1c Updating pom.xml version numbers for release 4.17.1.0
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
2022-09-14 12:58:03 +05:30
Nicolas Vazquez
b2fbe7bb12
console: Console access enhancements (#6577)
This PR creates a new API createConsoleAccess to create VM console URL allowing it to connect using other UI implementations. To avoid reply attacks, the console access is enhanced to use a one time token per session

New configuration added:
consoleproxy.extra.security.validation.enabled: Enable/disable extra security validation for console proxy using a token

Documentation PR: apache/cloudstack-documentation#284
2022-09-14 12:39:59 +05:30
Abhishek Kumar
78b68fd7e6
api,server: custom dns for guest network (#6425)
Adds option to provide custom DNS servers for isolated network, shared network and VPC tier.
New API parameters added in createNetwork API along with the corresponding response parameters.

Doc PR: apache/cloudstack-documentation#276
2022-09-10 13:05:40 +05:30
Suresh Kumar Anaparti
75da982d73
Updated resource counter to include correct size after volume creation/resize and other improvements (#6587)
* Updated resource counter to include correct size after volume creation/resize and other improvements
- Recalculate resource counters for root domain in the periodic task
- Update correct size in the primary_storage resource counter after volume creation/resize
- Some code improvements

* review and sonarcloud issues

Co-authored-by: Suresh Kumar Anaparti <suresh.anaparti@shapeblue.com>
Co-authored-by: Daan Hoogland <daan@onecht.net>
2022-08-16 10:41:42 +02:00
Abhishek Kumar
d9b770eb48 Merge remote-tracking branch 'apache/4.17' into main 2022-08-12 23:44:42 +05:30
Gabriel Beims Bräscher
9410a70454
schema: increase size of column 'value' at table 'account_details' (#6080)
This PR increases the column value at table account_details from 255 chars to 4096, matching with the value allowed in the API command for updating the configuration of accounts.

When the value length is bigger than 255, the following log is presented right after the updateConfiguration API call:

2022-03-09 17:50:24,627 ERROR [c.c.a.ApiServer] (qtp30578394-234766:ctx-cad18b45 ctx-32e954dd) (logid:0948e203) unhandled exception executing api command: [Ljava.lang.String;@117c6ba7
com.cloud.utils.exception.CloudRuntimeException: DB Exception on: com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO account_details (account_details.account_id, account_details.name, account_details.value) VALUES (123, _binary'api.allowed.source.cidr.list', _binary'<huge binary>')
	at com.cloud.utils.db.GenericDaoBase.persist(GenericDaoBase.java:1450)
	at jdk.internal.reflect.GeneratedMethodAccessor168.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	....
	....
	....
Caused by: com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Data too long for column 'value' at row 1
	at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:104)
	at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:953)
	at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1092)
	... 83 more


Co-authored-by: Bart Meyers <bart.meyers@cldin.eu>
2022-08-12 23:42:50 +05:30
Rohit Yadav
840c3f6a7a Merge remote-tracking branch 'origin/4.17' 2022-08-10 23:11:09 +02:00
slavkap
76f52af8f3
removed the use of SharedMountPoint storage type for the StorPool plugin (#6552)
Fixes #6455

The default storage adaptor - LibvirtStorageAdaptor - is used by different storage types and doesn't use the annotation @StorageAdaptorInfo. In this case, a storage plugin that wants to adopt one of the predefined storage pool types will override the default behaviour. If fixing the issue in general (for new storage plugins or current ones that want to reuse the existing storage pool types) would affect all volume/snapshot/VM cases. This will lead to the need of extensive testing for each storage plugin for which we don't have the resources to do it. That's why this patch fixes the old behaviour for the SharedMountPoint by adding a new storage pool type for the StorPool plugin.
2022-08-10 14:41:32 +05:30
João Jandre
9c63c39371
Add new parameter to createLoadBalancerRule API (#6460)
* Add new parameter to createLoadBalancerRule API

* address review

Co-authored-by: João Paraquetti <joao@scclouds.com.br>
2022-08-08 10:48:21 +02:00
John Bampton
f9347ecf2c
Fix spelling (#6597) 2022-08-03 15:43:47 +05:30
Rodrigo D. Lopez
ac2857158d
externalizes used protocol to upload isos, volumes and templates (#6506)
Co-authored-by: Lopez <rodrigo@scclouds.com.br>
2022-08-02 08:46:55 +02:00
Abhishek Kumar
3cba4266c8 Merge remote-tracking branch 'apache/4.17' into main 2022-08-01 08:13:43 +05:30
Abhishek Kumar
9a264c1369
api: fix ipv6 firewall apis default role permissions (#6579)
Fixes #6575

* fixes ipv6 firewall apis default role permissions
* test: use user apiclient for ipv6 firewall apis

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
2022-07-31 16:49:29 +05:30
Rohit Yadav
5f04018bf0 Merge remote-tracking branch 'origin/4.17' 2022-07-27 12:41:31 +02:00
Rohit Yadav
441edf3ca7
utils: use safer parsing utility across codebase (#6562)
This addresses SonarQube/SonarCloud quality checks to use safer xml
parser to resist potential XXE attacks.

https://sonarcloud.io/organizations/apache/rules?open=java%3AS2755&rule_key=java%3AS2755

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2022-07-27 14:31:51 +05:30
Ruben Bosch
3bedddba4b
Update API documentation for resizing (#6556)
The correct parameter is `cpuspeed` and not `cpu`. This led me to some
confusion when resizing a VM attached to an offering allowing custom
values.

Co-authored-by: Ruben Bosch <ruben.bosch@cldin.eu>
2022-07-20 16:11:07 +05:30
Bryan Lima
71bc088a70
Improve login time (#6412)
* Improve slow login

* Address review

* Address Daan's review

* Address Daniel reviews
2022-07-20 11:30:17 +05:30
Rohit Yadav
4baaf736b9 Merge remote-tracking branch 'origin/4.17'
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2022-07-18 19:42:44 +05:30
dahn
731a83babf
add global setting to allow parallel execution on vmware (#6413)
* add global setting to allow parallel execution on vmware

* cleanup setting distribution for vmware.create.full.clone

* query setting in vmware guru

* don´t touch other hypervisor's commands

* guru hierarchy cleanup
2022-07-15 10:01:35 +02:00
Abhishek Kumar
4b8af6f0fa
test: add, refactor ipv6 network, vpc tests (#6338)
- Refactor IPv6 related tests
- Adds smoke test for IPv4 network to IPv6 upgrade
- Adds smoke test for IPv6 VPC

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
2022-07-12 12:54:53 +05:30
Harikrishna
65b0bcb069
api: Deprecated changeServiceForVirtualMachine API and replaced all the occurences in the tests with scaleVirtualMachine (#6540) 2022-07-09 21:52:51 +05:30
mprokopchuk
aa7dd309db
Create event TEMPLATE_UPDATE for virtual machine image update calls. (#6521)
* Create event TEMPLATE_UPDATE for virtual machine image update calls.

(cherry picked from commit e7eec8d0daf5c3d0d5d7c636504f963094788311)

* Added ISO.UPDATE event for update ISO command.

(cherry picked from commit 277f76f398e089af1795d0a3e75749d9a475cae0)

Co-authored-by: Maxim Prokopchuk <mprokopchuk@apple.com>
2022-07-05 10:41:02 +02:00
Daan Hoogland
a470f3353a Merge branch '4.17' 2022-07-05 09:11:45 +02:00
John Bampton
7d23a0a759
Fix spelling (#6272) 2022-07-05 09:08:53 +02:00
Rohit Yadav
6607a98597 Merge remote-tracking branch 'origin/4.17' 2022-07-01 10:44:29 +05:30
Harikrishna
2326164c17
api: Added information about deviceid 0 to attach root volume to VM (#6518)
This is in the workflow of attaching and detaching a root volume of a VM. We can detach the root volume from a VM and Cloudstack marks it as datadisk. We can reattach the volume to make it root volume again. During attach Device ID 0 has to be passed so that the volume will be converted back to ROOT again

Added a small information in the DeviceID section in Attach volume form.
2022-06-30 17:36:42 +05:30
Rohit Yadav
3fc825e246 Merge remote-tracking branch 'origin/4.17' 2022-06-30 12:17:29 +05:30
John Bampton
7ba43e447c
Enable flake8 rule W292 No newline at end of file (#6274)
https://www.flake8rules.com/rules/W292.html
2022-06-30 12:08:27 +05:30
Harikrishna
089e9647f1
Fix global setting reference for max secondary storage (#6496)
* Fix global setting reference for max secondary storage usage based on account or project

* Changed a variable naming

* Replaced config enum usage with configkey class for global settings

* Fixed grammar mistake

* Fixed code smells
2022-06-30 11:42:58 +05:30
Marcus Sorensen
7b0ebe2e37
Allow for arbitrary disk offering details to be saved/displayed (#6474)
* Allow for arbitrary disk offering details to be saved/displayed

Similar to service offering details, allow details to be provided and
displayed. Can be used for classification of offerings, etc.

Signed-off-by: Marcus Sorensen <mls@apple.com>

* Update server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java

Co-authored-by: Daniel Augusto Veronezi Salvador <38945620+GutoVeronezi@users.noreply.github.com>

Co-authored-by: Daniel Augusto Veronezi Salvador <38945620+GutoVeronezi@users.noreply.github.com>
2022-06-28 08:57:18 +02:00