-
Notifications
You must be signed in to change notification settings - Fork 1.2k
enhancement: add instance info as Libvirt metadata #11061
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
phsm
wants to merge
1
commit into
apache:4.20
Choose a base branch
from
phsm:4.20-libvirt-metadata
base: 4.20
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
182 changes: 182 additions & 0 deletions
182
api/src/main/java/com/cloud/agent/api/to/VirtualMachineMetadataTO.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
// 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.to; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class VirtualMachineMetadataTO { | ||
// VM details | ||
private final String name; | ||
private final String internalName; | ||
private final String displayName; | ||
private final String instanceUuid; | ||
private final Integer cpuCores; | ||
private final Integer memory; | ||
private final Long created; | ||
private final Long started; | ||
|
||
// Owner details | ||
private final String ownerDomainUuid; | ||
private final String ownerDomainName; | ||
private final String ownerAccountUuid; | ||
private final String ownerAccountName; | ||
private final String ownerProjectUuid; | ||
private final String ownerProjectName; | ||
|
||
// Host and service offering | ||
private final String serviceOfferingName; | ||
private final List<String> serviceOfferingHostTags; | ||
|
||
// zone, pod, and cluster details | ||
private final String zoneName; | ||
private final String zoneUuid; | ||
private final String podName; | ||
private final String podUuid; | ||
private final String clusterName; | ||
private final String clusterUuid; | ||
|
||
// resource tags | ||
private final Map<String, String> resourceTags; | ||
|
||
public VirtualMachineMetadataTO( | ||
String name, String internalName, String displayName, String instanceUuid, Integer cpuCores, Integer memory, Long created, Long started, | ||
String ownerDomainUuid, String ownerDomainName, String ownerAccountUuid, String ownerAccountName, String ownerProjectUuid, String ownerProjectName, | ||
String serviceOfferingName, List<String> serviceOfferingHostTags, | ||
String zoneName, String zoneUuid, String podName, String podUuid, String clusterName, String clusterUuid, Map<String, String> resourceTags) { | ||
/* | ||
* Something failed in the metadata shall not be a fatal error, the VM can still be started | ||
* Thus, the unknown fields just get an explicit "unknown" value so it can be fixed in case | ||
* there are bugs on some execution paths. | ||
* */ | ||
|
||
this.name = (name != null) ? name : "unknown"; | ||
this.internalName = (internalName != null) ? internalName : "unknown"; | ||
this.displayName = (displayName != null) ? displayName : "unknown"; | ||
this.instanceUuid = (instanceUuid != null) ? instanceUuid : "unknown"; | ||
this.cpuCores = (cpuCores != null) ? cpuCores : -1; | ||
this.memory = (memory != null) ? memory : -1; | ||
this.created = (created != null) ? created : 0; | ||
this.started = (started != null) ? started : 0; | ||
this.ownerDomainUuid = (ownerDomainUuid != null) ? ownerDomainUuid : "unknown"; | ||
this.ownerDomainName = (ownerDomainName != null) ? ownerDomainName : "unknown"; | ||
this.ownerAccountUuid = (ownerAccountUuid != null) ? ownerAccountUuid : "unknown"; | ||
this.ownerAccountName = (ownerAccountName != null) ? ownerAccountName : "unknown"; | ||
this.ownerProjectUuid = (ownerProjectUuid != null) ? ownerProjectUuid : "unknown"; | ||
this.ownerProjectName = (ownerProjectName != null) ? ownerProjectName : "unknown"; | ||
this.serviceOfferingName = (serviceOfferingName != null) ? serviceOfferingName : "unknown"; | ||
this.serviceOfferingHostTags = (serviceOfferingHostTags != null) ? serviceOfferingHostTags : new ArrayList<>(); | ||
this.zoneName = (zoneName != null) ? zoneName : "unknown"; | ||
this.zoneUuid = (zoneUuid != null) ? zoneUuid : "unknown"; | ||
this.podName = (podName != null) ? podName : "unknown"; | ||
this.podUuid = (podUuid != null) ? podUuid : "unknown"; | ||
this.clusterName = (clusterName != null) ? clusterName : "unknown"; | ||
this.clusterUuid = (clusterUuid != null) ? clusterUuid : "unknown"; | ||
|
||
this.resourceTags = (resourceTags != null) ? resourceTags : new HashMap<>(); | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public String getInternalName() { | ||
return internalName; | ||
} | ||
|
||
public String getDisplayName() { | ||
return displayName; | ||
} | ||
|
||
public String getInstanceUuid() { | ||
return instanceUuid; | ||
} | ||
|
||
public Integer getCpuCores() { | ||
return cpuCores; | ||
} | ||
|
||
public Integer getMemory() { | ||
return memory; | ||
} | ||
|
||
public Long getCreated() { return created; } | ||
|
||
public Long getStarted() { | ||
return started; | ||
} | ||
|
||
public String getOwnerDomainUuid() { | ||
return ownerDomainUuid; | ||
} | ||
|
||
public String getOwnerDomainName() { | ||
return ownerDomainName; | ||
} | ||
|
||
public String getOwnerAccountUuid() { | ||
return ownerAccountUuid; | ||
} | ||
|
||
public String getOwnerAccountName() { | ||
return ownerAccountName; | ||
} | ||
|
||
public String getOwnerProjectUuid() { | ||
return ownerProjectUuid; | ||
} | ||
|
||
public String getOwnerProjectName() { | ||
return ownerProjectName; | ||
} | ||
|
||
public String getserviceOfferingName() { | ||
return serviceOfferingName; | ||
} | ||
|
||
public List<String> getserviceOfferingHostTags() { | ||
return serviceOfferingHostTags; | ||
} | ||
|
||
public String getZoneName() { | ||
return zoneName; | ||
} | ||
|
||
public String getZoneUuid() { | ||
return zoneUuid; | ||
} | ||
|
||
public String getPodName() { | ||
return podName; | ||
} | ||
|
||
public String getPodUuid() { | ||
return podUuid; | ||
} | ||
|
||
public String getClusterName() { | ||
return clusterName; | ||
} | ||
|
||
public String getClusterUuid() { | ||
return clusterUuid; | ||
} | ||
|
||
public Map<String, String> getResourceTags() { return resourceTags; } | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.