Skip to content
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

[BUG] PowerCLI New-TagAssignment is not sending an event #1081

Closed
cabarria opened this issue Jul 18, 2023 · 3 comments
Closed

[BUG] PowerCLI New-TagAssignment is not sending an event #1081

cabarria opened this issue Jul 18, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@cabarria
Copy link

Describe the bug
When using PowerCLI to tag a VM no event is registered.

To Reproduce
Run the following PowerCLI script (update values as needed)

$vmName = "VMName"
$categoryName = "Category"
$tagValue = "TagValue"
$clusterName = "ClusterName"
$vCenter_FQDN = "vCenter IP or DNS Name"
$credential = Get-Credential -Message "Enter your vCenter credentials"
Connect-VIServer -Server $vCenter_FQDN -Credential $credential
$cluster = Get-Cluster -Name $clusterName
$vm = Get-VM -Name $vmName -Location $cluster
$category = Get-TagCategory -Name $categoryName
$tag = Get-Tag -Name $tagValue -Category $category
New-TagAssignment -Tag $tag -Entity $vm

Here is the output from running the script:
Name Port User
vcenter_server 443 domain.com\UserName

Uid : /VIServer=domain.com\UserName@vcenter_server:443/VirtualMachine=VirtualMachine-vm-2111/TagAssignment=/Tag=urn:vmomi:InventoryServiceTag:b74
7ab6f-c49c-4593-9578-8ab5e3c96e2f:GLOBAL/
Tag : category_name/tag_value
Entity : vmautotag-99
Id : com.vmware.cis.tagging.TagAssociationModel
Name : com.vmware.cis.tagging.TagAssociationModel

Expected behavior
The following event should have been generated:
image

{
"Key": 109354,
"ChainId": 109354,
"CreatedTime": "2023-07-18T19:06:56.401Z",
"UserName": "domain.com\UserName",
"Datacenter": null,
"ComputeResource": null,
"Host": null,
"Vm": null,
"Ds": null,
"Net": null,
"Dvs": null,
"FullFormattedMessage": "User domain.co\UserName attached tag tag_value to object vmautotag-99",
"ChangeTag": "",
"EventTypeId": "com.vmware.cis.tagging.attach",
"Severity": "info",
"Message": "",
"Arguments": [
{
"Key": "Tag",
"Value": "tag_value"
},
{
"Key": "Object",
"Value": "vmautotag-99"
},
{
"Key": "User",
"Value": "domain.com\UserName"
}
],
"ObjectId": "",
"ObjectType": "",
"ObjectName": "",
"Fault": null
}

Version (please complete the following information):

  • VEBA Form Factor: Appliance
  • VEBA Version: v0.7.5
  • vCenter Versions: 7.0.3.01400 and 7.0.3.00500

Additional context
Adding/Removing tags through the UI works as expected.

@cabarria cabarria added the bug Something isn't working label Jul 18, 2023
@github-actions
Copy link

Howdy 🖐   cabarria ! Thank you for your interest in this project. We value your feedback and will respond soon.

@lamw
Copy link
Contributor

lamw commented Jul 18, 2023

Unfortunately, I believe this is a limitation in vSphere Tagging when it is triggered through PowerCLI which might be using a different backend API than the one used by vSphere. Since the vCenter Event isn't being generated, VEBA won't receive any event.

I would recommend filing an SR w/VMware Support to identify the API, so that you could initiate via PowerCLI to get the same behavior as vSphere UI, but this isn't a defect with VEBA itself as vCenter Server itself isn't producing the event in the first place

@cabarria
Copy link
Author

In case someone else runs into the same issue, here is the workaround:

    $category = Get-TagCategory -Name $categoryName
    $vm = Get-VM -Name $vmName
    $tag = Get-Tag -Name $tagValue -Category $category
    $vminfo = $vm.ExtensionData.MoRef
    $vmid = Initialize-StdDynamicID -Type $vminfo.Type -Id $vminfo.value
    $tagAssociation = Initialize-TaggingTagAssociationAttachRequestBody -ObjectId $vmid
    Invoke-AttachTagIdTagAssociation -TagId $tag.Id -TaggingTagAssociationAttachRequestBody $tagAssociation

@lamw lamw closed this as completed Jul 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants