"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "cinder/volume/drivers/dell_emc/powerstore/client.py" between
cinder-17.0.1.tar.gz and cinder-17.1.0.tar.gz

About: OpenStack Cinder (Core Service: Block Storage) provides persistent block storage to running instances. Its pluggable driver architecture facilitates the creation and management of block storage devices.
The "Victoria" series (latest release).

client.py  (cinder-17.0.1):client.py  (cinder-17.1.0)
skipping to change at line 22 skipping to change at line 22
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
"""REST client for Dell EMC PowerStore Cinder Driver.""" """REST client for Dell EMC PowerStore Cinder Driver."""
import functools import functools
import json import json
from oslo_log import log as logging from oslo_log import log as logging
from oslo_utils import strutils
import requests import requests
from cinder import exception from cinder import exception
from cinder.i18n import _ from cinder.i18n import _
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
VOLUME_NOT_MAPPED_ERROR = "0xE0A08001000F" VOLUME_NOT_MAPPED_ERROR = "0xE0A08001000F"
class PowerStoreClient(object): class PowerStoreClient(object):
def __init__(self, configuration): def __init__(self, configuration):
skipping to change at line 84 skipping to change at line 85
"False.") "False.")
LOG.debug("Successfully initialized PowerStore REST client. " LOG.debug("Successfully initialized PowerStore REST client. "
"Server IP: %(ip)s, username: %(username)s. " "Server IP: %(ip)s, username: %(username)s. "
"Verify server's certificate: %(verify_cert)s.", "Verify server's certificate: %(verify_cert)s.",
{ {
"ip": self.rest_ip, "ip": self.rest_ip,
"username": self.rest_username, "username": self.rest_username,
"verify_cert": self._verify_cert, "verify_cert": self._verify_cert,
}) })
def _send_request(self, method, url, payload=None, params=None): def _send_request(self,
method,
url,
payload=None,
params=None,
log_response_data=True):
if not payload: if not payload:
payload = {} payload = {}
if not params: if not params:
params = {} params = {}
request_params = { request_params = {
"auth": (self.rest_username, self.rest_password), "auth": (self.rest_username, self.rest_password),
"verify": self._verify_cert, "verify": self._verify_cert,
} }
if method == "GET": if method == "GET":
request_params["params"] = params request_params["params"] = params
skipping to change at line 107 skipping to change at line 113
request_url = self.base_url + url request_url = self.base_url + url
r = requests.request(method, request_url, **request_params) r = requests.request(method, request_url, **request_params)
log_level = logging.DEBUG log_level = logging.DEBUG
if r.status_code not in self.ok_codes: if r.status_code not in self.ok_codes:
log_level = logging.ERROR log_level = logging.ERROR
LOG.log(log_level, LOG.log(log_level,
"REST Request: %s %s with body %s", "REST Request: %s %s with body %s",
r.request.method, r.request.method,
r.request.url, r.request.url,
r.request.body) strutils.mask_password(r.request.body))
LOG.log(log_level, if log_response_data or log_level == logging.ERROR:
"REST Response: %s with data %s", msg = "REST Response: %s with data %s" % (r.status_code, r.text)
r.status_code, else:
r.text) msg = "REST Response: %s" % r.status_code
LOG.log(log_level, msg)
try: try:
response = r.json() response = r.json()
except ValueError: except ValueError:
response = None response = None
return r, response return r, response
_send_get_request = functools.partialmethod(_send_request, "GET") _send_get_request = functools.partialmethod(_send_request, "GET")
_send_post_request = functools.partialmethod(_send_request, "POST") _send_post_request = functools.partialmethod(_send_request, "POST")
_send_patch_request = functools.partialmethod(_send_request, "PATCH") _send_patch_request = functools.partialmethod(_send_request, "PATCH")
_send_delete_request = functools.partialmethod(_send_request, "DELETE") _send_delete_request = functools.partialmethod(_send_request, "DELETE")
def get_chap_config(self):
r, response = self._send_get_request(
"/chap_config/0",
params={
"select": "mode"
}
)
if r.status_code not in self.ok_codes:
msg = _("Failed to query PowerStore CHAP configuration.")
LOG.error(msg)
raise exception.VolumeBackendAPIException(data=msg)
return response
def get_appliance_id_by_name(self, appliance_name): def get_appliance_id_by_name(self, appliance_name):
r, response = self._send_get_request( r, response = self._send_get_request(
"/appliance", "/appliance",
params={ params={
"name": "eq.%s" % appliance_name, "name": "eq.%s" % appliance_name,
} }
) )
if r.status_code not in self.ok_codes: if r.status_code not in self.ok_codes:
msg = _("Failed to query PowerStore appliances.") msg = _("Failed to query PowerStore appliances.")
LOG.error(msg) LOG.error(msg)
skipping to change at line 149 skipping to change at line 169
msg = _("PowerStore appliance %s is not found.") % appliance_name msg = _("PowerStore appliance %s is not found.") % appliance_name
LOG.error(msg) LOG.error(msg)
raise exception.VolumeBackendAPIException(data=msg) raise exception.VolumeBackendAPIException(data=msg)
def get_appliance_metrics(self, appliance_id): def get_appliance_metrics(self, appliance_id):
r, response = self._send_post_request( r, response = self._send_post_request(
"/metrics/generate", "/metrics/generate",
payload={ payload={
"entity": "space_metrics_by_appliance", "entity": "space_metrics_by_appliance",
"entity_id": appliance_id, "entity_id": appliance_id,
} },
log_response_data=False
) )
if r.status_code not in self.ok_codes: if r.status_code not in self.ok_codes:
msg = (_("Failed to query metrics for " msg = (_("Failed to query metrics for "
"PowerStore appliance with id %s.") % appliance_id) "PowerStore appliance with id %s.") % appliance_id)
LOG.error(msg) LOG.error(msg)
raise exception.VolumeBackendAPIException(data=msg) raise exception.VolumeBackendAPIException(data=msg)
try: try:
latest_metrics = response[-1] latest_metrics = response[-1]
return latest_metrics return latest_metrics
except IndexError: except IndexError:
 End of changes. 5 change blocks. 
7 lines changed or deleted 28 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)