Commvault / cvpysdk

Developer SDK - Python
https://commvault.github.io/cvpysdk/
Apache License 2.0
54 stars 41 forks source link

Credential cannot be instantiated #161

Closed tapaskchowdhury closed 8 months ago

tapaskchowdhury commented 1 year ago

Credential class cannot be instantiated for credential of type: "Amazon Web Services (STS Assume Role with IAM Role Policy)":

Error received:

from cvpysdk.credential_manager import Credential
credential_name = "arn:aws:iam::123456789012:role/my-commvault-role_mycred"
cred = Credential(commvault, credential_name, credentials._credentials[credential_name.lower()])

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "~/.venv/lib/python3.9/site-packages/cvpysdk/credential_manager.py", line 389, in __init__
    self._get_credential_properties()
  File "~/.venv/lib/python3.9/site-packages/cvpysdk/credential_manager.py", line 554, in _get_credential_properties
    self._credential_owner = self._credential_owner_json.get('user', {}).get(
AttributeError: 'NoneType' object has no attribute 'get'

This fails since the method expects a different dictionary than the one returned by system generated credential:

{
    "recordType": 16,
    "description": "System created record during creation of cloud account [mycred]",
    "createdTime": 1679596555,
    "additionalInformation": {},
    "securityAssociations": {
        "ownerAssociations": {},
        "tagWithCompany": {
            "providerId": 0,
            "providerDomainName": "Commcell"
        }
    },
    "credentialRecord": {
        "credentialId": 7013,
        "credentialName": "arn:aws:iam::123456789012:role/my-commvault-role_mycred",
        "entityInfo": {
            "companyId": 0,
            "companyName": "Commcell",
            "multiCommcellId": 0
        }
    },
    "record": {
        "userName": "arn:aws:iam::123456789012:role/my-commvault-role"
    },
    "flags": {
        "hasAzureKeyVaultAccess": False,
        "isWorkflowRecord": False,
        "hasAzureKeyVaultStorageAccess": False,
        "hasAzureRSVAccess": False
    }
}
spakhare commented 1 year ago

Hi @tapaskchowdhury,

Can you please confirm if this worked with the latest version available on the master branch?

Thanks

tapaskchowdhury commented 8 months ago

Hi @spakhare , sorry I cannot confirm this since I do not have access to the code base where I used this. Perhaps @mvangoor could help you.