4191 Commits

Author SHA1 Message Date
Rohit Yadav
fab4fc2a14 Merge remote-tracking branch 'origin/4.17' 2022-12-22 22:55:15 +05:30
Paula Oliveira
0fe2e6950e
Improving code related to the Agent properties (#6348)
Co-authored-by: Paula Zomignani Oliveira <paula@scclouds.com.br>
Co-authored-by: João Jandre <48719461+JoaoJandre@users.noreply.github.com>
Co-authored-by: GutoVeronezi <daniel@scclouds.com.br>
2022-12-22 12:00:49 +01:00
Wei Zhou
889045fba5
new plugins: Add non-strict affinity groups (#6845) 2022-12-20 15:09:52 +01:00
Vladimir Dombrovski
cc676cbc83
Metrics plugin: expose full domain path instead of name (#6959)
Co-authored-by: Vladimir DOMBROVSKI <vladimir.dombrovski@bso.co>
2022-12-20 12:43:55 +01:00
Abhishek Kumar
fb22c5c3c9
kvm: correctly set vm cpu topology (#6870)
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
2022-12-19 11:01:10 +01:00
Rohit Yadav
458883575a Updating pom.xml version numbers for release 4.17.3.0-SNAPSHOT
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2022-12-16 15:25:16 +00:00
Rodrigo D. Lopez
2ed7868f27
Inserts timer in check detach volume (#6508)
Co-authored-by: Lopez <rodrigo@scclouds.com.br>
Co-authored-by: Stephan Krug <stekrug@icloud.com>
2022-12-16 09:35:27 +01:00
dahn
162af93e11
make api rate limit test more robust (#6984)
* make api rate limit test a little more robust

* Update condition for time exeeded
2022-12-16 08:49:17 +01:00
Rohit Yadav
5b9a989ab0 Updating pom.xml version numbers for release 4.17.2.0
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2022-12-14 05:22:52 +00:00
Rohit Yadav
f7f03adddb Merge remote-tracking branch 'origin/4.17' into main 2022-12-14 05:21:35 +00:00
Abhishek Kumar
0075717612
api: fix listVirtuaMachinesMetrics API for user (#6985)
Fixes #6983

In case of multiple classes for and API class, ApiServer returns an API command class for User role only when ResponseView is set to Restricted in annotation.
This PR set Restricted ResponseView for ListVMsMetrics class. It also adds a smoke test for User role account for the listVirtualMachinesMetrics API.

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
2022-12-14 10:48:40 +05:30
John Bampton
def7ce655d
Fix spelling (#6898)
Co-authored-by: davidjumani <dj.davidjumani1994@gmail.com>
2022-12-13 14:58:14 +01:00
Rohit Yadav
1be7c2f348 Merge remote-tracking branch 'origin/4.17' 2022-12-12 13:29:28 +05:30
slavkap
66747d04c4
storpool: fix on remove the Iops limits (#6902)
Remove the Iops limits when resizing a volume with disk offering without iops limits or with a custom Iops limits in offerings.
2022-12-12 12:53:54 +05:30
SadiJr
19a4e9dd50
veeam: Fix escape powershell comand when listing Veeam repository names (#6943)
PR #5774 introduced a functionality to allow operators to choose in which Veeam's repository, if more than one is configured, ACS' clone job will be executed. However, a change was missing in the PR and caused the errors reported in #6599.

This PR addresses the fix for #6599.

Co-authored-by: SadiJr <sadi@scclouds.com.br>
2022-12-12 12:46:30 +05:30
Abhishek Kumar
4de66f9855
server: fix listing vm metrics for infra resources (#6851)
Fixes #6786 

listVirtualMachinesMetrics does not support some of the params that are supported by admin API call for listVirtualMachines.
These parameters are used in UI.

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

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
Co-authored-by: Rohit Yadav <rohityadav89@gmail.com>
Co-authored-by: Daan Hoogland <daan@onecht.net>
2022-12-12 11:22:07 +05:30
Wei Zhou
74623aa3d3 Merge remote-tracking branch 'apache/4.17' 2022-12-07 13:37:30 +01:00
Abhishek Kumar
9fd2d82af9
vmware: fix vmware vm snapshot operations for datastorecluster (#6912)
Fixes #6894

Fixes NPE observed when VM volume is present on the same child datastore.

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
2022-12-07 14:43:44 +05:30
GaOrtiga
684f3f4c49
Improvements and cleanup on the javadocs of QemuImg (#6917)
* Cleanup in the javadocs of QemuImg

* Update QemuImg.java

* Apply suggestions from code review

Co-authored-by: Stephan Krug <stekrug@icloud.com>

Co-authored-by: cloudstack-lab-gabriel <gabriel.fernandes@scclouds.com.br>
Co-authored-by: Stephan Krug <stekrug@icloud.com>
2022-12-06 17:59:03 -03:00
Wei Zhou
d182eacf86
host affinity: fix vm cannot be started if a vm is stopped in the affinity group (#6936) 2022-12-06 10:05:49 +01:00
Wei Zhou
a63b2aba7a
VM Autoscaling with virtual router (#6571) 2022-12-05 15:23:03 +01:00
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
yannizhou05
94fd03df13
fix flaky tests (#6905)
Co-authored-by: Yanni <yz97@illinois.edu>
2022-11-30 08:53:11 +01:00
John Bampton
8e538028b2
Enable Flake8 rule W391 (#6606)
Best practice is to have one blank line at the end of Python files.

Remove unneeded blank lines from the end of files
2022-11-13 11:00:07 +01:00
John Bampton
e65c22d883
Fix spelling (#6860) 2022-11-13 10:56:15 +01:00
Daniel Augusto Veronezi Salvador
b8b66b7a3d
Fix typos and improve javadocs on ByteScaleUtils (#6877)
Co-authored-by: GutoVeronezi <daniel@scclouds.com.br>
2022-11-10 10:14:24 +01:00
José Flauzino
1843632c24
Fix memory stats for KVM (#6358)
Co-authored-by: joseflauzino <jose@scclouds.com.br>
2022-11-09 18:00:12 +01:00
Codegass
1ee58ec347
Introducing Hamcrest API to simplify assertion in ImplicitPlannerTest (#6676)
Co-authored-by: Daniel Augusto Veronezi Salvador <38945620+GutoVeronezi@users.noreply.github.com>
2022-11-04 21:41:54 +01:00
Wei Zhou
296035d9a5
XenServer/XCP-ng: fix vm memory usage is always 99.9x% (#6852)
According to https://docs.citrix.com/en-us/citrix-hypervisor/monitor-performance.html
The metrics "memory_internal_free" is already in KiB, no need to convert.

"Memory used as reported by the guest agent (KiB). Enabled by default"
2022-11-02 09:36:16 +01:00
John Bampton
fa39e61a4c
Fix spelling (#6609) 2022-11-01 08:30:01 +01:00
Bryan Lima
f580a8d7a2
Quota enable config to user/domain scope (#6690)
* Add quota plugin to accout/domain scope

* Add check in quota usage calculation to skip accounts with quota disabled

* Set quota config enabled default to true

* Fix if condition

* Update condition to use primitive boolean expression

Co-authored-by: dahn <daan.hoogland@gmail.com>

* Remove unused var

* Add quota state as a column in the Quota Summary view

* Remove trailling spaces

* Address review

Co-authored-by: dahn <daan.hoogland@gmail.com>
2022-10-27 08:48:54 -03: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
Wei Zhou
48ffa5dc0b
Support multiple ceph monitors (#6792) 2022-10-21 10:37:30 +02:00
Bryan Lima
17fe98432d
Remove unnecessary escape method (#6692) 2022-10-20 14:37:05 +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
Peinthor Rene
ff961c9594
linstor: support QoS(IOPs) and small improvements (#6682)
This PR has 3 improvements for the Linstor primary storage driver:

- Create a separate jar of it and move all Linstor related classes into the correct project (similar to the storpool plugin)
- Add aux properties for Cloudstack volumes in Linstor to make it easier to identify them in Linstor
- Add support for IOPs settings with the Linstor storage plugin
2022-10-08 12:06:49 +05:30
Wei Zhou
6786c24138
kvm: fix backup volume snapshot fails on RBD storage (#6790)
This PR fixes the issue that volume snapshot fails on RBD storage with the following error

qemu-img: Could not open 'driver=raw,file.filename=rbd:cloudstack/test_wei.img:mon_host=10.0.32.254:auth_supported=cephx:id=cloudstack:key=AQDwHTNjjHXRKRAAJb+AToFr6x4a1AvKUc4Ksg==:rbd_default_format=2:client_mount_timeout=30': Could not open 'rbd:cloudstack/test_wei.img:mon_host=10.0.32.254:auth_supported=cephx:id=cloudstack:key=AQDwHTNjjHXRKRAAJb+AToFr6x4a1AvKUc4Ksg==:rbd_default_format=2:client_mount_timeout=30': No such file or directory

However, it works without using image options

Therefore, do not pass the image options if the image format is not QCOW2 and LUKS.
2022-10-08 11:55:33 +05:30
Marcus Sorensen
8785f781b6
Ignore calls to PowerFlex for host revocation when host is null (#6742)
This PR Fixes #6739 (for PowerFlex/ScaleIO only, Datera still needs to be addressed), which can occur if the last host the VM ran on is deleted from CloudStack. At the point the VM is deleted, cloudstack attempts to make a final call to revoke access to volumes, passing the last host the VM ran on. If this host is gone, we get an error and are unable to delete the VM.

It's possible that there may be a more holistic fix to this by identifying all of the places where revokeAccess() is called and checking for null host. It's possible other storage plugins don't even need host information to revoke access to volumes and may need this call to revoke. Therefore I'm only applying this fix to the ScaleIOPrimaryDataStoreDriver to skip revoking access when there is no host to revoke access for, and this should protect us as well when a new part of the code tries to use revokeAccess() in the future.

Signed-off-by: Marcus Sorensen <mls@apple.com>
Co-authored-by: Marcus Sorensen <mls@apple.com>
2022-10-08 07:19:19 +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
Sina Kashipazha
4e2f461b31
Prometheus exporter enhancement (#4438)
* Export count of total/up/down hosts by tags

* Export count of vms by state and host tag.

* Add host tags to host cpu/cores/memory usage in Prometheus exporter

* Cloudstack Prometheus exporter: Add allocated capacity group by host tag.

* Show count of Active domains on grafana.

* Show count of Active accounts and vms by size on grafana

* Use prepared statement to query database for a number of VM who use a specific tag.

* Extract repeated codes to new methods.
2022-09-30 17:02:01 +02:00
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
efbf74ee06
Added new logs to volume creation (#6689)
Co-authored-by: João Paraquetti <joao@scclouds.com.br>
2022-09-26 19:11:14 -03:00
Rohit Yadav
5669888c16 mvn: fix build and use the 4.17.2.0-SNAPSHOT in version
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2022-09-21 13:41: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
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
Bryan Lima
14656733d8
Fix min balance for API quotaCredits to be optional (#6691) 2022-09-14 12:51:03 +05:30
Rohit Yadav
68c09f92d1 Merge remote-tracking branch 'origin/4.17' 2022-09-12 21:30:03 +05:30
Wei Zhou
20950e0e1d
jacoco: fix no coverage result in server and some other modules (#6730)
According to https://www.eclemma.org/jacoco/trunk/doc/prepare-agent-mojo.html
we need to add "@{argLine}" to argLine if it exists in pom.xml
2022-09-12 21:27:55 +05:30