Azure / azure-sdk-for-python

This repository is for active development of the Azure SDK for Python. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/python/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-python.
MIT License
4.59k stars 2.8k forks source link

Issue with 'job_type' in azure.mgmt.recoveryservicesbackup.models.job when using backup_jobs.list() #1214

Closed de115042 closed 7 years ago

de115042 commented 7 years ago

When I am trying to to retrieve the list for all backup using : client.backup_jobs.list(vault_name=vault_name,resource_group_name=resource_group_name)

I am getting the following error message.

Error message: msrest.exceptions.DeserializationError: Unable to deserialize {'status': u'Completed', 'entity_friendly_name': u's-win-iis-01', 'activity_id': u'6ac58dea-4b55-4551-b7da-c58b40d86d2e', 'start_time': datetime.datetime(2017, 6, 8, 7, 12, 56, 552187, tzinfo=<isodate.tzinfo.Utc object at 0x03247AB0>), 'job_type': u'AzureIaaSVMJob', 'end_time': datetime.datetime(2017, 6, 8, 9, 34, 29, 97785, tzinfo=<isodate.tzinfo.Utc object at 0x03247AB0>), 'backup_management_type': u'AzureIaasVM', 'operation': u'Backup'} into model <class 'azure.mgmt.recoveryservicesbackup.models.job.Job'>. init() got an unexpected keyword argument 'job_type

The only quick and dirty way to make it work is to change it to ...

_attribute_map = {
    'entity_friendly_name': {'key': 'entityFriendlyName', 'type': 'str'},
    'backup_management_type': {'key': 'backupManagementType', 'type': 'str'},
    'operation': {'key': 'operation', 'type': 'str'},
    'status': {'key': 'status', 'type': 'str'},
    'start_time': {'key': 'startTime', 'type': 'iso-8601'},
    'end_time': {'key': 'endTime', 'type': 'iso-8601'},
    'activity_id': {'key': 'activityId', 'type': 'str'},
    #'job_type': {'key': 'jobType', 'type': 'str'},
}

I am using python 2.7 version recoveryservicesbackup version 0.1.0

lmazuel commented 7 years ago

Hi @de115042 Could you do a pip freeze in your environment? It seems to me it's an issue solved in msrest 0.4.7. Since pip is not good in recursive dependency check, could you check if your msrest is at least 0.4.7 or directly type "pip install -U msrest"

Thanks,

de115042 commented 7 years ago

Hi, (thanks a lot for your help.)

my msrest lib was 0.4.0 and I updated it to 0.4.7. To ensure that there was no others outdated I ran pip install -U azure. All original files have been restored.

Now I am getting the following errror message. msrest.exceptions.DeserializationError: Cannot deserialize duration object., ISO8601Error: Unable to parse duration string u'02:41:42.7941535'

here is the list regarding pip freeze: adal==0.4.5 applicationinsights==0.10.0 argcomplete==1.8.2 asn1crypto==0.22.0 azure==2.0.0rc6 azure-batch==1.0.0 azure-cli==2.0.7 azure-cli-acr==2.0.5 azure-cli-acs==2.0.7 azure-cli-appservice==0.1.7 azure-cli-batch==3.0.0 azure-cli-billing==0.1.0 azure-cli-cdn==0.0.3 azure-cli-cloud==2.0.3 azure-cli-cognitiveservices==0.1.3 azure-cli-command-modules-nspkg==2.0.0 azure-cli-component==2.0.5 azure-cli-configure==2.0.7 azure-cli-consumption==0.1.0 azure-cli-core==2.0.7 azure-cli-cosmosdb==0.1.7 azure-cli-dla==0.0.7 azure-cli-dls==0.0.7 azure-cli-feedback==2.0.3 azure-cli-find==0.2.3 azure-cli-interactive==0.3.3 azure-cli-iot==0.1.6 azure-cli-keyvault==2.0.5 azure-cli-lab==0.0.5 azure-cli-monitor==0.0.5 azure-cli-network==2.0.7 azure-cli-nspkg==3.0.0 azure-cli-profile==2.0.5 azure-cli-rdbms==0.0.2 azure-cli-redis==0.2.4 azure-cli-resource==2.0.7 azure-cli-role==2.0.5 azure-cli-sf==1.0.2 azure-cli-shell==0.2.2 azure-cli-sql==2.0.4 azure-cli-storage==2.0.7 azure-cli-vm==2.0.7 azure-common==1.1.4 azure-datalake-store==0.0.11 azure-graphrbac==0.30.0 azure-keyvault==0.3.4 azure-mgmt==0.30.0rc6 azure-mgmt-authorization==0.30.0 azure-mgmt-batch==1.0.0 azure-mgmt-billing==0.1.0 azure-mgmt-cdn==0.30.3 azure-mgmt-cognitiveservices==1.0.0 azure-mgmt-compute==0.30.0rc6 azure-mgmt-consumption==0.1.0 azure-mgmt-containerregistry==0.2.1 azure-mgmt-datalake-analytics==0.1.4 azure-mgmt-datalake-nspkg==2.0.0 azure-mgmt-datalake-store==0.1.4 azure-mgmt-devtestlabs==2.0.0 azure-mgmt-dns==1.0.1 azure-mgmt-documentdb==0.1.3 azure-mgmt-iothub==0.2.2 azure-mgmt-keyvault==0.30.0rc6 azure-mgmt-logic==1.0.0 azure-mgmt-monitor==0.2.1 azure-mgmt-network==0.30.0rc6 azure-mgmt-nspkg==2.0.0 azure-mgmt-rdbms==0.1.0 azure-mgmt-recoveryservicesbackup==0.1.0 azure-mgmt-redis==1.0.0 azure-mgmt-resource==0.30.0rc6 azure-mgmt-scheduler==1.0.0 azure-mgmt-sql==0.5.3 azure-mgmt-storage==0.30.0rc6 azure-mgmt-trafficmanager==0.30.0 azure-mgmt-web==0.32.0 azure-monitor==0.3.0 azure-multiapi-storage==0.1.0 azure-nspkg==2.0.0 azure-servicebus==0.20.3 azure-servicefabric==5.6.130 azure-servicemanagement-legacy==0.20.4 azure-storage==0.33.0 backports-abc==0.5 backports.ssl-match-hostname==3.5.0.1 blinker==1.4 blueprint==3.4.2 boto==2.42.0 certifi==2017.4.17 cffi==1.10.0 chardet==3.0.4 checksumdir==1.1.0 ciscoconfparse==1.2.44 click==6.7 colorama==0.3.7 cryptography==1.9 cssselect==1.0.0 cssutils==1.0.1 dnspython==1.15.0 dominate==2.3.1 email==4.0.2 emails==0.5.10 enum34==1.1.6 et-xmlfile==1.0.1 Flask==0.12 Flask-AutoIndex==0.6 Flask-Bootstrap==3.3.7.1 flask-emails==0.4 Flask-Login==0.3.2 Flask-Mail==0.9.1 Flask-Silk==0.2 Flask-SQLAlchemy==2.1 Flask-WTF==0.13 functools==0.5 future==0.15.2 futures==3.1.1 haikunator==2.1.0 humanfriendly==3.2 idna==2.5 ipaddr==2.1.11 ipaddress==1.0.18 isodate==0.5.4 itsdangerous==0.24 jdcal==1.3 Jinja==1.2 Jinja2==2.9.5 jmespath==0.9.3 keyring==10.3.3 libxml2-python==2.9.3 lxml==3.4.0 MarkupSafe==0.23 meld3==1.0.2 monotonic==1.3 msrest==0.4.9 msrestazure==0.4.8 numpy==1.11.2 oauthlib==2.0.2 openpyxl==2.4.2 pandas==0.19.0 paramiko==2.1.2 pathlib2==2.2.1 premailer==3.0.1 prompt-toolkit==1.0.14 py2exe-py2==0.6.9 pyasn1==0.1.9 pycparser==2.17 pydocumentdb==2.2.0 pydot==1.2.3 Pygments==2.2.0 PyInstaller==3.2.1 PyJWT==1.5.0 pymongo==3.3.0 pyOpenSSL==17.0.0 pyparsing==2.1.10 pypiwin32==219 python-dateutil==2.6.0 python-ldap==2.4.27 pytz==2016.7 pywin32-ctypes==0.0.1 PyYAML==3.12 requests==2.17.3 requests-oauthlib==0.8.0 scandir==1.5 scp==0.10.2 simpleldap==0.8 singledispatch==3.4.0.3 six==1.10.0 skim==1.2 slackclient==1.0.5 SQLAlchemy==1.0.15 sshtunnel==0.1.2 supervisor==3.3.1 tabulate==0.7.7 testfixtures==4.10.1 tornado==4.4.2 tzlocal==1.4 urllib3==1.21.1 virtualenv==12.0.6 visitor==0.1.3 vsts-cd-manager==0.118.0 wcwidth==0.1.7 websocket-client==0.40.0 Werkzeug==0.11.15 Whoosh==2.7.4 WTForms==2.1 XlsxWriter==0.9.6 xmltodict==0.11.0

de115042 commented 7 years ago

here is the complete error message: Traceback (most recent call last): File "C:/Users/mweber/Documents/pycharm/Azure/azure_recoveryservicebackup_20170608.py", line 51, in for x in test: File "C:\Python27\lib\site-packages\msrest\paging.py", line 109, in next self.advance_page() File "C:\Python27\lib\site-packages\msrest\paging.py", line 96, in advance_page self._derserializer(self, self._response) File "C:\Python27\lib\site-packages\msrest\serialization.py", line 761, in call value = self.deserialize_data(raw_value, attr_type) File "C:\Python27\lib\site-packages\msrest\serialization.py", line 868, in deserialize_data return self.deserialize_type[iter_type](data, data_type[1:-1]) File "C:\Python27\lib\site-packages\msrest\serialization.py", line 890, in deserialize_iter return [self.deserialize_data(a, iter_type) for a in attr] File "C:\Python27\lib\site-packages\msrest\serialization.py", line 879, in deserialize_data return self(obj_type, data) File "C:\Python27\lib\site-packages\msrest\serialization.py", line 761, in call value = self.deserialize_data(raw_value, attr_type) File "C:\Python27\lib\site-packages\msrest\serialization.py", line 879, in deserialize_data return self(obj_type, data) File "C:\Python27\lib\site-packages\msrest\serialization.py", line 761, in call value = self.deserialize_data(raw_value, attr_type) File "C:\Python27\lib\site-packages\msrest\serialization.py", line 863, in deserialize_data data_val = self.deserialize_typedata_type File "C:\Python27\lib\site-packages\msrest\serialization.py", line 1073, in deserialize_duration raise_with_traceback(DeserializationError, msg, err) File "C:\Python27\lib\site-packages\msrest\exceptions.py", line 50, in raise_with_traceback raise error msrest.exceptions.DeserializationError: Cannot deserialize duration object., ISO8601Error: Unable to parse duration string u'02:41:42.7941535'

de115042 commented 7 years ago

Hi, I can fix it by changing the msrest/serialization.py file in line 1070 from

    @staticmethod
    def deserialize_duration(attr):
        """Deserialize ISO-8601 formatted string into TimeDelta object.

        :param str attr: response string to be deserialized.
        :rtype: TimeDelta
        :raises: DeserializationError if string format invalid.
        """
        try:
            duration = isodate.parse_duration(attr)

to

    @staticmethod
    def deserialize_duration(attr):
        """Deserialize ISO-8601 formatted string into TimeDelta object.

        :param str attr: response string to be deserialized.
        :rtype: TimeDelta
        :raises: DeserializationError if string format invalid.
        """
        try:
            duration = isodate.parse_time(attr)

because the object ('02:41:42.7941535') that is passed looks like a time.

lmazuel commented 7 years ago

Thank you @de115042 @DheerendraRathor I remember we talked about that, the duration must be in ISO8601, could you give us some insights about this?

DheerendraRathor commented 7 years ago

@de115042 @lmazuel Yes it is ISO 8601 issue in duration and known bug. We are fixing it on service side and will release in July cycle. Assume it will be released in July end.

de115042 commented 7 years ago

Thanks for the feedback. In the meantime I keep my fix in place because without it brakes the backup_job list call. .... looking forward to the update... thanks to all of you.

lmazuel commented 7 years ago

Hi @de115042 This should be fixed in 0.1.1, could you confirm? Thanks!

lmazuel commented 7 years ago

Closing, since I have no reason to believe that it's not fixed in 0.1.1. Please open a new issue if the problem still persists in 0.1.1. Thanks!