From 1ed8279f14e0e85e8ac3dd758e5410e2c3d37c07 Mon Sep 17 00:00:00 2001 From: sowmyahsg Date: Tue, 14 Aug 2018 04:22:34 -0700 Subject: [PATCH] Updated --- examples/appliance_time_and_locale_configuration.py | 4 ++-- examples/config-rename.json | 2 +- hpOneView/resources/resource.py | 7 +++++-- .../settings/appliance_time_and_locale_configuration.py | 4 ++-- .../test_appliance_time_and_locale_configuration.py | 2 +- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/examples/appliance_time_and_locale_configuration.py b/examples/appliance_time_and_locale_configuration.py index 61494bf2..c43d8ffa 100644 --- a/examples/appliance_time_and_locale_configuration.py +++ b/examples/appliance_time_and_locale_configuration.py @@ -50,12 +50,12 @@ # Update NTP servers and locale # Set to use appliance local time and date server -time_and_locale['ntpServers'] = ['127.0.0.1'] +# time_and_locale['ntpServers'] = ['127.0.0.1'] # Set locale to Chinese (China) with charset UTF-8 time_and_locale['locale'] = 'zh_CN.UTF-8' # Remove the date and time, we do not want to update it manually time_and_locale.pop('dateTime') -time_and_locale = oneview_client.appliance_time_and_locale_configuration.update(time_and_locale) +time_and_locale = oneview_client.appliance_time_and_locale_configuration.update(time_and_locale, force=False) print("\n## Updated appliance time and locale configurations successfully!") pprint(time_and_locale) diff --git a/examples/config-rename.json b/examples/config-rename.json index 28a8ebee..056a758b 100644 --- a/examples/config-rename.json +++ b/examples/config-rename.json @@ -1,7 +1,7 @@ { "ip": "172.16.102.59", "image_streamer_ip": "172.16.102.60", - "api_version": 500, + "api_version": 600, "ssl_certificate": "", "credentials": { "userName": "administrator", diff --git a/hpOneView/resources/resource.py b/hpOneView/resources/resource.py index 1d0fd441..d1fdba9c 100755 --- a/hpOneView/resources/resource.py +++ b/hpOneView/resources/resource.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# -*- ccding: utf-8 -*- ### # (C) Copyright (2012-2018) Hewlett Packard Enterprise Development LP # @@ -408,7 +408,7 @@ def create_with_zero_body(self, uri=None, timeout=-1, custom_headers=None): return self.__do_post(uri, {}, timeout, custom_headers) - def create(self, resource, uri=None, timeout=-1, custom_headers=None, default_values={}): + def create(self, resource, force=False, uri=None, timeout=-1, custom_headers=None, default_values={}): """ Makes a POST request to create a resource when a request body is required. @@ -442,6 +442,9 @@ def create(self, resource, uri=None, timeout=-1, custom_headers=None, default_va if not uri: uri = self._uri + if force: + uri += '?force=True' + logger.debug('Create (uri = %s, resource = %s)' % (uri, str(resource))) diff --git a/hpOneView/resources/settings/appliance_time_and_locale_configuration.py b/hpOneView/resources/settings/appliance_time_and_locale_configuration.py index e1796f33..4c0d22a6 100644 --- a/hpOneView/resources/settings/appliance_time_and_locale_configuration.py +++ b/hpOneView/resources/settings/appliance_time_and_locale_configuration.py @@ -57,7 +57,7 @@ def get(self): """ return self._client.get(self.URI) - def update(self, resource, timeout=-1): + def update(self, resource, force=False, timeout=-1): """ Updates the appliance time and locale configuration. @@ -71,4 +71,4 @@ def update(self, resource, timeout=-1): dict: Updated appliance time and locale configuration. """ - return self._client.create(resource, timeout=timeout, default_values=self.DEFAULT_VALUES) + return self._client.create(resource, force=force, timeout=timeout, default_values=self.DEFAULT_VALUES) diff --git a/tests/unit/resources/settings/test_appliance_time_and_locale_configuration.py b/tests/unit/resources/settings/test_appliance_time_and_locale_configuration.py index d3e77e9e..e52d85f6 100644 --- a/tests/unit/resources/settings/test_appliance_time_and_locale_configuration.py +++ b/tests/unit/resources/settings/test_appliance_time_and_locale_configuration.py @@ -52,4 +52,4 @@ def test_update_called_once(self, mock_create): 'uri': None } self._time_and_locale.update(resource) - mock_create.assert_called_once_with(resource, timeout=-1, default_values=self._time_and_locale.DEFAULT_VALUES) + mock_create.assert_called_once_with(resource, force=False, timeout=-1, default_values=self._time_and_locale.DEFAULT_VALUES)