Merge "Don't translate debug level logs in oslo-vmware"
This commit is contained in:
commit
c1670bebdc
@ -78,13 +78,13 @@ class RetryDecorator(object):
|
||||
def _func(*args, **kwargs):
|
||||
func_name = f.__name__
|
||||
try:
|
||||
LOG.debug(_("Invoking %(func_name)s; retry count is "
|
||||
"%(retry_count)d."),
|
||||
LOG.debug("Invoking %(func_name)s; retry count is "
|
||||
"%(retry_count)d.",
|
||||
{'func_name': func_name,
|
||||
'retry_count': self._retry_count})
|
||||
result = f(*args, **kwargs)
|
||||
LOG.debug(_("Function %(func_name)s returned successfully "
|
||||
"after %(retry_count)d retries."),
|
||||
LOG.debug("Function %(func_name)s returned successfully "
|
||||
"after %(retry_count)d retries.",
|
||||
{'func_name': func_name,
|
||||
'retry_count': self._retry_count})
|
||||
except self._exceptions as excep:
|
||||
@ -115,7 +115,7 @@ class RetryDecorator(object):
|
||||
def func(*args, **kwargs):
|
||||
loop = loopingcall.DynamicLoopingCall(_func, *args, **kwargs)
|
||||
evt = loop.start(periodic_interval_max=self._max_sleep_time)
|
||||
LOG.debug(_("Waiting for function %s to return."), f.__name__)
|
||||
LOG.debug("Waiting for function %s to return.", f.__name__)
|
||||
return evt.wait()
|
||||
|
||||
return func
|
||||
@ -192,7 +192,7 @@ class VMwareAPISession(object):
|
||||
"""Establish session with the server."""
|
||||
session_manager = self.vim.service_content.sessionManager
|
||||
# Login and create new session with the server for making API calls.
|
||||
LOG.debug(_("Logging in with username = %s."), self._server_username)
|
||||
LOG.debug("Logging in with username = %s.", self._server_username)
|
||||
session = self.vim.Login(session_manager,
|
||||
userName=self._server_username,
|
||||
password=self._server_password)
|
||||
@ -244,7 +244,7 @@ class VMwareAPISession(object):
|
||||
"ID = %s."),
|
||||
self._session_id)
|
||||
else:
|
||||
LOG.debug(_("No session exists to log out."))
|
||||
LOG.debug("No session exists to log out.")
|
||||
|
||||
def invoke_api(self, module, method, *args, **kwargs):
|
||||
"""Wrapper method for invoking APIs.
|
||||
@ -266,7 +266,7 @@ class VMwareAPISession(object):
|
||||
exceptions=(exceptions.VimSessionOverLoadException,
|
||||
exceptions.VimConnectionException))
|
||||
def _invoke_api(module, method, *args, **kwargs):
|
||||
LOG.debug(_("Invoking method %(module)s.%(method)s."),
|
||||
LOG.debug("Invoking method %(module)s.%(method)s.",
|
||||
{'module': module,
|
||||
'method': method})
|
||||
try:
|
||||
@ -284,8 +284,8 @@ class VMwareAPISession(object):
|
||||
# case of an inactive session. Therefore, we need a way to
|
||||
# differentiate between these two cases.
|
||||
if self._is_current_session_active():
|
||||
LOG.debug(_("Returning empty response for "
|
||||
"%(module)s.%(method)s invocation."),
|
||||
LOG.debug("Returning empty response for "
|
||||
"%(module)s.%(method)s invocation.",
|
||||
{'module': module,
|
||||
'method': method})
|
||||
return []
|
||||
@ -307,7 +307,7 @@ class VMwareAPISession(object):
|
||||
# InvalidArgument
|
||||
# Raise specific exceptions here if possible
|
||||
if excep.fault_list:
|
||||
LOG.debug(_("Fault list: %s"), excep.fault_list)
|
||||
LOG.debug("Fault list: %s", excep.fault_list)
|
||||
raise exceptions.get_fault_class(excep.fault_list[0])
|
||||
raise
|
||||
|
||||
@ -328,7 +328,7 @@ class VMwareAPISession(object):
|
||||
|
||||
:returns: True if the session is active; False otherwise
|
||||
"""
|
||||
LOG.debug(_("Checking if the current session: %s is active."),
|
||||
LOG.debug("Checking if the current session: %s is active.",
|
||||
self._session_id)
|
||||
|
||||
is_active = False
|
||||
@ -359,7 +359,7 @@ class VMwareAPISession(object):
|
||||
"""
|
||||
loop = loopingcall.FixedIntervalLoopingCall(self._poll_task, task)
|
||||
evt = loop.start(self._task_poll_interval)
|
||||
LOG.debug(_("Waiting for the task: %s to complete."), task)
|
||||
LOG.debug("Waiting for the task: %s to complete.", task)
|
||||
return evt.wait()
|
||||
|
||||
def _poll_task(self, task):
|
||||
@ -371,7 +371,7 @@ class VMwareAPISession(object):
|
||||
|
||||
:param task: managed object reference of the task
|
||||
"""
|
||||
LOG.debug(_("Invoking VIM API to read info of task: %s."), task)
|
||||
LOG.debug("Invoking VIM API to read info of task: %s.", task)
|
||||
try:
|
||||
task_info = self.invoke_api(vim_util,
|
||||
'get_object_property',
|
||||
@ -385,11 +385,11 @@ class VMwareAPISession(object):
|
||||
else:
|
||||
if task_info.state in ['queued', 'running']:
|
||||
if hasattr(task_info, 'progress'):
|
||||
LOG.debug(_("Task: %(task)s progress is %(progress)s%%."),
|
||||
LOG.debug("Task: %(task)s progress is %(progress)s%%.",
|
||||
{'task': task,
|
||||
'progress': task_info.progress})
|
||||
elif task_info.state == 'success':
|
||||
LOG.debug(_("Task: %s status is success."), task)
|
||||
LOG.debug("Task: %s status is success.", task)
|
||||
raise loopingcall.LoopingCallDone(task_info)
|
||||
else:
|
||||
error_msg = six.text_type(task_info.error.localizedMessage)
|
||||
@ -414,7 +414,7 @@ class VMwareAPISession(object):
|
||||
"""
|
||||
loop = loopingcall.FixedIntervalLoopingCall(self._poll_lease, lease)
|
||||
evt = loop.start(self._task_poll_interval)
|
||||
LOG.debug(_("Waiting for the lease: %s to be ready."), lease)
|
||||
LOG.debug("Waiting for the lease: %s to be ready.", lease)
|
||||
evt.wait()
|
||||
|
||||
def _poll_lease(self, lease):
|
||||
@ -425,7 +425,7 @@ class VMwareAPISession(object):
|
||||
|
||||
:param lease: lease whose state is to be polled
|
||||
"""
|
||||
LOG.debug(_("Invoking VIM API to read state of lease: %s."), lease)
|
||||
LOG.debug("Invoking VIM API to read state of lease: %s.", lease)
|
||||
try:
|
||||
state = self.invoke_api(vim_util,
|
||||
'get_object_property',
|
||||
@ -439,12 +439,12 @@ class VMwareAPISession(object):
|
||||
raise excep
|
||||
else:
|
||||
if state == 'ready':
|
||||
LOG.debug(_("Lease: %s is ready."), lease)
|
||||
LOG.debug("Lease: %s is ready.", lease)
|
||||
raise loopingcall.LoopingCallDone()
|
||||
elif state == 'initializing':
|
||||
LOG.debug(_("Lease: %s is initializing."), lease)
|
||||
LOG.debug("Lease: %s is initializing.", lease)
|
||||
elif state == 'error':
|
||||
LOG.debug(_("Invoking VIM API to read lease: %s error."),
|
||||
LOG.debug("Invoking VIM API to read lease: %s error.",
|
||||
lease)
|
||||
error_msg = self._get_error_message(lease)
|
||||
excep_msg = _("Lease: %(lease)s is in error state. Details: "
|
||||
|
@ -126,8 +126,8 @@ class DynamicLoopingCall(LoopingCallBase):
|
||||
|
||||
if periodic_interval_max is not None:
|
||||
idle = min(idle, periodic_interval_max)
|
||||
LOG.debug(_('Dynamic looping call sleeping for %.02f '
|
||||
'seconds'), idle)
|
||||
LOG.debug('Dynamic looping call sleeping for %.02f '
|
||||
'seconds', idle)
|
||||
greenthread.sleep(idle)
|
||||
except LoopingCallDone as e:
|
||||
self.stop()
|
||||
|
@ -203,6 +203,6 @@ def get_fault_class(name):
|
||||
name = str(name)
|
||||
fault_class = _fault_classes_registry.get(name)
|
||||
if not fault_class:
|
||||
LOG.debug(_('Fault %s not matched.'), name)
|
||||
LOG.debug('Fault %s not matched.', name)
|
||||
fault_class = VMwareDriverException
|
||||
return fault_class
|
||||
|
@ -66,7 +66,7 @@ class BlockingQueue(queue.LightQueue):
|
||||
self._transferred += len(data_item)
|
||||
return data_item
|
||||
else:
|
||||
LOG.debug(_("Completed transfer of size %s."), self._transferred)
|
||||
LOG.debug("Completed transfer of size %s.", self._transferred)
|
||||
return ""
|
||||
|
||||
def write(self, data):
|
||||
@ -74,7 +74,7 @@ class BlockingQueue(queue.LightQueue):
|
||||
|
||||
:param data: data to be written
|
||||
"""
|
||||
LOG.debug(_("Writing %d data items into the queue."), len(data))
|
||||
LOG.debug("Writing %d data items into the queue.", len(data))
|
||||
self.put(data)
|
||||
|
||||
# Below methods are provided in order to enable treating the queue
|
||||
@ -143,8 +143,8 @@ class ImageWriter(object):
|
||||
|
||||
:raises: ImageTransferException
|
||||
"""
|
||||
LOG.debug(_("Calling image service update on image: %(image)s "
|
||||
"with meta: %(meta)s"),
|
||||
LOG.debug("Calling image service update on image: %(image)s "
|
||||
"with meta: %(meta)s",
|
||||
{'image': self._image_id,
|
||||
'meta': self._image_meta})
|
||||
|
||||
@ -155,14 +155,14 @@ class ImageWriter(object):
|
||||
data=self._input_file)
|
||||
self._running = True
|
||||
while self._running:
|
||||
LOG.debug(_("Retrieving status of image: %s."),
|
||||
LOG.debug("Retrieving status of image: %s.",
|
||||
self._image_id)
|
||||
image_meta = self._image_service.show(self._context,
|
||||
self._image_id)
|
||||
image_status = image_meta.get('status')
|
||||
if image_status == 'active':
|
||||
self.stop()
|
||||
LOG.debug(_("Image: %s is now active."),
|
||||
LOG.debug("Image: %s is now active.",
|
||||
self._image_id)
|
||||
self._done.send(True)
|
||||
elif image_status == 'killed':
|
||||
@ -173,8 +173,8 @@ class ImageWriter(object):
|
||||
excep = exceptions.ImageTransferException(excep_msg)
|
||||
self._done.send_exception(excep)
|
||||
elif image_status in ['saving', 'queued']:
|
||||
LOG.debug(_("Image: %(image)s is in %(state)s state; "
|
||||
"sleeping for %(sleep)d seconds."),
|
||||
LOG.debug("Image: %(image)s is in %(state)s state; "
|
||||
"sleeping for %(sleep)d seconds.",
|
||||
{'image': self._image_id,
|
||||
'state': image_status,
|
||||
'sleep': IMAGE_SERVICE_POLL_INTERVAL})
|
||||
@ -195,8 +195,8 @@ class ImageWriter(object):
|
||||
excep = exceptions.ImageTransferException(excep_msg, excep)
|
||||
self._done.send_exception(excep)
|
||||
|
||||
LOG.debug(_("Starting image write task for image: %(image)s with"
|
||||
" source: %(source)s."),
|
||||
LOG.debug("Starting image write task for image: %(image)s with"
|
||||
" source: %(source)s.",
|
||||
{'source': self._input_file,
|
||||
'image': self._image_id})
|
||||
greenthread.spawn(_inner)
|
||||
@ -204,7 +204,7 @@ class ImageWriter(object):
|
||||
|
||||
def stop(self):
|
||||
"""Stop the image writing task."""
|
||||
LOG.debug(_("Stopping the writing task for image: %s."),
|
||||
LOG.debug("Stopping the writing task for image: %s.",
|
||||
self._image_id)
|
||||
self._running = False
|
||||
|
||||
@ -260,7 +260,7 @@ class FileReadWriteTask(object):
|
||||
try:
|
||||
data = self._input_file.read(rw_handles.READ_CHUNKSIZE)
|
||||
if not data:
|
||||
LOG.debug(_("File read-write task is done."))
|
||||
LOG.debug("File read-write task is done.")
|
||||
self.stop()
|
||||
self._done.send(True)
|
||||
self._output_file.write(data)
|
||||
@ -280,8 +280,8 @@ class FileReadWriteTask(object):
|
||||
excep = exceptions.ImageTransferException(excep_msg, excep)
|
||||
self._done.send_exception(excep)
|
||||
|
||||
LOG.debug(_("Starting file read-write task with source: %(source)s "
|
||||
"and destination: %(dest)s."),
|
||||
LOG.debug("Starting file read-write task with source: %(source)s "
|
||||
"and destination: %(dest)s.",
|
||||
{'source': self._input_file,
|
||||
'dest': self._output_file})
|
||||
greenthread.spawn(_inner)
|
||||
@ -289,7 +289,7 @@ class FileReadWriteTask(object):
|
||||
|
||||
def stop(self):
|
||||
"""Stop the read-write task."""
|
||||
LOG.debug(_("Stopping the file read-write task."))
|
||||
LOG.debug("Stopping the file read-write task.")
|
||||
self._running = False
|
||||
|
||||
def wait(self):
|
||||
@ -366,8 +366,8 @@ def _start_transfer(context, timeout_secs, read_file_handle, max_data_size,
|
||||
raise ValueError(excep_msg)
|
||||
|
||||
# Start the reader and writer
|
||||
LOG.debug(_("Starting image transfer with reader: %(reader)s and writer: "
|
||||
"%(writer)s"),
|
||||
LOG.debug("Starting image transfer with reader: %(reader)s and writer: "
|
||||
"%(writer)s",
|
||||
{'reader': reader,
|
||||
'writer': writer})
|
||||
reader.start()
|
||||
@ -408,7 +408,7 @@ def download_flat_image(context, timeout_secs, image_service, image_id,
|
||||
file write handle
|
||||
:raises: VimConnectionException, ImageTransferException, ValueError
|
||||
"""
|
||||
LOG.debug(_("Downloading image: %s from image service as a flat file."),
|
||||
LOG.debug("Downloading image: %s from image service as a flat file.",
|
||||
image_id)
|
||||
|
||||
# TODO(vbala) catch specific exceptions raised by download call
|
||||
@ -426,7 +426,7 @@ def download_flat_image(context, timeout_secs, image_service, image_id,
|
||||
read_handle,
|
||||
file_size,
|
||||
write_file_handle=write_handle)
|
||||
LOG.debug(_("Downloaded image: %s from image service as a flat file."),
|
||||
LOG.debug("Downloaded image: %s from image service as a flat file.",
|
||||
image_id)
|
||||
|
||||
|
||||
@ -476,8 +476,8 @@ def download_stream_optimized_image(context, timeout_secs, image_service,
|
||||
VimSessionOverLoadException, VimConnectionException,
|
||||
ImageTransferException, ValueError
|
||||
"""
|
||||
LOG.debug(_("Downloading image: %s from image service as a stream "
|
||||
"optimized file."),
|
||||
LOG.debug("Downloading image: %s from image service as a stream "
|
||||
"optimized file.",
|
||||
image_id)
|
||||
|
||||
# TODO(vbala) catch specific exceptions raised by download call
|
||||
@ -486,8 +486,8 @@ def download_stream_optimized_image(context, timeout_secs, image_service,
|
||||
imported_vm = download_stream_optimized_data(context, timeout_secs,
|
||||
read_handle, **kwargs)
|
||||
|
||||
LOG.debug(_("Downloaded image: %s from image service as a stream "
|
||||
"optimized file."),
|
||||
LOG.debug("Downloaded image: %s from image service as a stream "
|
||||
"optimized file.",
|
||||
image_id)
|
||||
return imported_vm
|
||||
|
||||
@ -507,7 +507,7 @@ def upload_image(context, timeout_secs, image_service, image_id, owner_id,
|
||||
ImageTransferException, ValueError
|
||||
"""
|
||||
|
||||
LOG.debug(_("Uploading to image: %s."), image_id)
|
||||
LOG.debug("Uploading to image: %s.", image_id)
|
||||
file_size = kwargs.get('vmdk_size')
|
||||
read_handle = rw_handles.VmdkReadHandle(kwargs.get('session'),
|
||||
kwargs.get('host'),
|
||||
@ -539,4 +539,4 @@ def upload_image(context, timeout_secs, image_service, image_id, owner_id,
|
||||
image_service=image_service,
|
||||
image_id=image_id,
|
||||
image_meta=image_metadata)
|
||||
LOG.debug(_("Uploaded image: %s."), image_id)
|
||||
LOG.debug("Uploaded image: %s.", image_id)
|
||||
|
@ -24,7 +24,6 @@ import logging
|
||||
import suds
|
||||
import suds.sax.element as element
|
||||
|
||||
from oslo.vmware.openstack.common.gettextutils import _
|
||||
from oslo.vmware import vim
|
||||
from oslo.vmware import vim_util
|
||||
|
||||
@ -77,7 +76,7 @@ def get_all_profiles(session):
|
||||
:raises: VimException, VimFaultException, VimAttributeException,
|
||||
VimSessionOverLoadException, VimConnectionException
|
||||
"""
|
||||
LOG.debug(_("Fetching all the profiles defined in VC server."))
|
||||
LOG.debug("Fetching all the profiles defined in VC server.")
|
||||
|
||||
pbm = session.pbm
|
||||
profile_manager = pbm.service_content.profileManager
|
||||
@ -88,7 +87,7 @@ def get_all_profiles(session):
|
||||
'PbmQueryProfile',
|
||||
profile_manager,
|
||||
resourceType=res_type)
|
||||
LOG.debug(_("Fetched profile IDs: %s."), profile_ids)
|
||||
LOG.debug("Fetched profile IDs: %s.", profile_ids)
|
||||
if profile_ids:
|
||||
profiles = session.invoke_api(pbm,
|
||||
'PbmRetrieveContent',
|
||||
@ -105,11 +104,11 @@ def get_profile_id_by_name(session, profile_name):
|
||||
:raises: VimException, VimFaultException, VimAttributeException,
|
||||
VimSessionOverLoadException, VimConnectionException
|
||||
"""
|
||||
LOG.debug(_("Retrieving profile ID for profile: %s."), profile_name)
|
||||
LOG.debug("Retrieving profile ID for profile: %s.", profile_name)
|
||||
for profile in get_all_profiles(session):
|
||||
if profile.name == profile_name:
|
||||
profile_id = profile.profileId
|
||||
LOG.debug(_("Retrieved profile ID: %(id)s for profile: %(name)s."),
|
||||
LOG.debug("Retrieved profile ID: %(id)s for profile: %(name)s.",
|
||||
{'id': profile_id,
|
||||
'name': profile_name})
|
||||
return profile_id
|
||||
@ -125,7 +124,7 @@ def filter_hubs_by_profile(session, hubs, profile_id):
|
||||
:raises: VimException, VimFaultException, VimAttributeException,
|
||||
VimSessionOverLoadException, VimConnectionException
|
||||
"""
|
||||
LOG.debug(_("Filtering hubs: %(hubs)s that match profile: %(profile)s."),
|
||||
LOG.debug("Filtering hubs: %(hubs)s that match profile: %(profile)s.",
|
||||
{'hubs': hubs,
|
||||
'profile': profile_id})
|
||||
|
||||
@ -136,7 +135,7 @@ def filter_hubs_by_profile(session, hubs, profile_id):
|
||||
placement_solver,
|
||||
hubsToSearch=hubs,
|
||||
profile=profile_id)
|
||||
LOG.debug(_("Filtered hubs: %s"), filtered_hubs)
|
||||
LOG.debug("Filtered hubs: %s", filtered_hubs)
|
||||
return filtered_hubs
|
||||
|
||||
|
||||
|
@ -128,7 +128,7 @@ class FileHandle(object):
|
||||
|
||||
def _find_vmdk_url(self, lease_info, host):
|
||||
"""Find the URL corresponding to a VMDK file in lease info."""
|
||||
LOG.debug(_("Finding VMDK URL from lease info."))
|
||||
LOG.debug("Finding VMDK URL from lease info.")
|
||||
url = None
|
||||
for deviceUrl in lease_info.deviceUrl:
|
||||
if deviceUrl.disk:
|
||||
@ -138,7 +138,7 @@ class FileHandle(object):
|
||||
excep_msg = _("Could not retrieve VMDK URL from lease info.")
|
||||
LOG.error(excep_msg)
|
||||
raise exceptions.VimException(excep_msg)
|
||||
LOG.debug(_("Found VMDK URL: %s from lease info."), url)
|
||||
LOG.debug("Found VMDK URL: %s from lease info.", url)
|
||||
return url
|
||||
|
||||
|
||||
@ -171,8 +171,8 @@ class FileWriteHandle(FileHandle):
|
||||
|
||||
def _create_connection(self, url, file_size, cookies):
|
||||
"""Create HTTP connection to write to the file with given URL."""
|
||||
LOG.debug(_("Creating HTTP connection to write to file with "
|
||||
"size = %(file_size)d and URL = %(url)s."),
|
||||
LOG.debug("Creating HTTP connection to write to file with "
|
||||
"size = %(file_size)d and URL = %(url)s.",
|
||||
{'file_size': file_size,
|
||||
'url': url})
|
||||
_urlparse = urlparse.urlparse(url)
|
||||
@ -193,8 +193,8 @@ class FileWriteHandle(FileHandle):
|
||||
conn.putheader('Content-Length', file_size)
|
||||
conn.putheader('Cookie', self._build_vim_cookie_header(cookies))
|
||||
conn.endheaders()
|
||||
LOG.debug(_("Created HTTP connection to write to file with "
|
||||
"URL = %s."), url)
|
||||
LOG.debug("Created HTTP connection to write to file with "
|
||||
"URL = %s.", url)
|
||||
return conn
|
||||
except (httplib.InvalidURL, httplib.CannotSendRequest,
|
||||
httplib.CannotSendHeader) as excep:
|
||||
@ -209,7 +209,7 @@ class FileWriteHandle(FileHandle):
|
||||
:param data: data to be written
|
||||
:raises: VimConnectionException, VimException
|
||||
"""
|
||||
LOG.debug(_("Writing data to %s."), self._url)
|
||||
LOG.debug("Writing data to %s.", self._url)
|
||||
try:
|
||||
self._file_handle.send(data)
|
||||
except (socket.error, httplib.NotConnected) as excep:
|
||||
@ -228,14 +228,14 @@ class FileWriteHandle(FileHandle):
|
||||
|
||||
def close(self):
|
||||
"""Get the response and close the connection."""
|
||||
LOG.debug(_("Closing write handle for %s."), self._url)
|
||||
LOG.debug("Closing write handle for %s.", self._url)
|
||||
try:
|
||||
self.conn.getresponse()
|
||||
except Exception:
|
||||
LOG.warn(_("Error occurred while reading the HTTP response."),
|
||||
exc_info=True)
|
||||
super(FileWriteHandle, self).close()
|
||||
LOG.debug(_("Closed write handle for %s."), self._url)
|
||||
LOG.debug("Closed write handle for %s.", self._url)
|
||||
|
||||
def __str__(self):
|
||||
return "File write handle for %s" % self._url
|
||||
@ -272,7 +272,7 @@ class VmdkWriteHandle(FileHandle):
|
||||
rp_ref,
|
||||
import_spec,
|
||||
vm_folder_ref)
|
||||
LOG.debug(_("Invoking VIM API for reading info of lease: %s."),
|
||||
LOG.debug("Invoking VIM API for reading info of lease: %s.",
|
||||
self._lease)
|
||||
lease_info = session.invoke_api(vim_util,
|
||||
'get_object_property',
|
||||
@ -295,16 +295,16 @@ class VmdkWriteHandle(FileHandle):
|
||||
def _create_and_wait_for_lease(self, session, rp_ref, import_spec,
|
||||
vm_folder_ref):
|
||||
"""Create and wait for HttpNfcLease lease for vApp import."""
|
||||
LOG.debug(_("Creating HttpNfcLease lease for vApp import into resource"
|
||||
" pool: %s."),
|
||||
LOG.debug("Creating HttpNfcLease lease for vApp import into resource"
|
||||
" pool: %s.",
|
||||
rp_ref)
|
||||
lease = session.invoke_api(session.vim,
|
||||
'ImportVApp',
|
||||
rp_ref,
|
||||
spec=import_spec,
|
||||
folder=vm_folder_ref)
|
||||
LOG.debug(_("Lease: %(lease)s obtained for vApp import into resource"
|
||||
" pool %(rp_ref)s."),
|
||||
LOG.debug("Lease: %(lease)s obtained for vApp import into resource"
|
||||
" pool %(rp_ref)s.",
|
||||
{'lease': lease,
|
||||
'rp_ref': rp_ref})
|
||||
session.wait_for_lease_ready(lease)
|
||||
@ -312,8 +312,8 @@ class VmdkWriteHandle(FileHandle):
|
||||
|
||||
def _create_connection(self, session, url, vmdk_size):
|
||||
"""Create HTTP connection to write to VMDK file."""
|
||||
LOG.debug(_("Creating HTTP connection to write to VMDK file with "
|
||||
"size = %(vmdk_size)d and URL = %(url)s."),
|
||||
LOG.debug("Creating HTTP connection to write to VMDK file with "
|
||||
"size = %(vmdk_size)d and URL = %(url)s.",
|
||||
{'vmdk_size': vmdk_size,
|
||||
'url': url})
|
||||
cookies = session.vim.client.options.transport.cookiejar
|
||||
@ -339,8 +339,8 @@ class VmdkWriteHandle(FileHandle):
|
||||
conn.putheader('Cookie', self._build_vim_cookie_header(cookies))
|
||||
conn.putheader('Content-Type', 'binary/octet-stream')
|
||||
conn.endheaders()
|
||||
LOG.debug(_("Created HTTP connection to write to VMDK file with "
|
||||
"URL = %s."),
|
||||
LOG.debug("Created HTTP connection to write to VMDK file with "
|
||||
"URL = %s.",
|
||||
url)
|
||||
return conn
|
||||
except (httplib.InvalidURL, httplib.CannotSendRequest,
|
||||
@ -356,13 +356,13 @@ class VmdkWriteHandle(FileHandle):
|
||||
:param data: data to be written
|
||||
:raises: VimConnectionException, VimException
|
||||
"""
|
||||
LOG.debug(_("Writing data to VMDK file with URL = %s."), self._url)
|
||||
LOG.debug("Writing data to VMDK file with URL = %s.", self._url)
|
||||
|
||||
try:
|
||||
self._file_handle.send(data)
|
||||
self._bytes_written += len(data)
|
||||
LOG.debug(_("Total %(bytes_written)d bytes written to VMDK file "
|
||||
"with URL = %(url)s."),
|
||||
LOG.debug("Total %(bytes_written)d bytes written to VMDK file "
|
||||
"with URL = %(url)s.",
|
||||
{'bytes_written': self._bytes_written,
|
||||
'url': self._url})
|
||||
except (socket.error, httplib.NotConnected) as excep:
|
||||
@ -389,8 +389,8 @@ class VmdkWriteHandle(FileHandle):
|
||||
VimSessionOverLoadException, VimConnectionException
|
||||
"""
|
||||
percent = int(float(self._bytes_written) / self._vmdk_size * 100)
|
||||
LOG.debug(_("Calling VIM API to update write progress of VMDK file"
|
||||
" with URL = %(url)s to %(percent)d%%."),
|
||||
LOG.debug("Calling VIM API to update write progress of VMDK file"
|
||||
" with URL = %(url)s to %(percent)d%%.",
|
||||
{'url': self._url,
|
||||
'percent': percent})
|
||||
try:
|
||||
@ -398,8 +398,8 @@ class VmdkWriteHandle(FileHandle):
|
||||
'HttpNfcLeaseProgress',
|
||||
self._lease,
|
||||
percent=percent)
|
||||
LOG.debug(_("Updated write progress of VMDK file with "
|
||||
"URL = %(url)s to %(percent)d%%."),
|
||||
LOG.debug("Updated write progress of VMDK file with "
|
||||
"URL = %(url)s to %(percent)d%%.",
|
||||
{'url': self._url,
|
||||
'percent': percent})
|
||||
except exceptions.VimException as excep:
|
||||
@ -414,25 +414,25 @@ class VmdkWriteHandle(FileHandle):
|
||||
:raises: VimException, VimFaultException, VimAttributeException,
|
||||
VimSessionOverLoadException, VimConnectionException
|
||||
"""
|
||||
LOG.debug(_("Getting lease state for %s."), self._url)
|
||||
LOG.debug("Getting lease state for %s.", self._url)
|
||||
try:
|
||||
state = self._session.invoke_api(vim_util,
|
||||
'get_object_property',
|
||||
self._session.vim,
|
||||
self._lease,
|
||||
'state')
|
||||
LOG.debug(_("Lease for %(url)s is in state: %(state)s."),
|
||||
LOG.debug("Lease for %(url)s is in state: %(state)s.",
|
||||
{'url': self._url,
|
||||
'state': state})
|
||||
if state == 'ready':
|
||||
LOG.debug(_("Releasing lease for %s."), self._url)
|
||||
LOG.debug("Releasing lease for %s.", self._url)
|
||||
self._session.invoke_api(self._session.vim,
|
||||
'HttpNfcLeaseComplete',
|
||||
self._lease)
|
||||
LOG.debug(_("Lease for %s released."), self._url)
|
||||
LOG.debug("Lease for %s released.", self._url)
|
||||
else:
|
||||
LOG.debug(_("Lease for %(url)s is in state: %(state)s; no "
|
||||
"need to release."),
|
||||
LOG.debug("Lease for %(url)s is in state: %(state)s; no "
|
||||
"need to release.",
|
||||
{'url': self._url,
|
||||
'state': state})
|
||||
except exceptions.VimException:
|
||||
@ -440,7 +440,7 @@ class VmdkWriteHandle(FileHandle):
|
||||
self._url,
|
||||
exc_info=True)
|
||||
super(VmdkWriteHandle, self).close()
|
||||
LOG.debug(_("Closed VMDK write handle for %s."), self._url)
|
||||
LOG.debug("Closed VMDK write handle for %s.", self._url)
|
||||
|
||||
def __str__(self):
|
||||
return "VMDK write handle for %s" % self._url
|
||||
@ -471,7 +471,7 @@ class VmdkReadHandle(FileHandle):
|
||||
|
||||
# Obtain lease for VM export
|
||||
self._lease = self._create_and_wait_for_lease(session, vm_ref)
|
||||
LOG.debug(_("Invoking VIM API for reading info of lease: %s."),
|
||||
LOG.debug("Invoking VIM API for reading info of lease: %s.",
|
||||
self._lease)
|
||||
lease_info = session.invoke_api(vim_util,
|
||||
'get_object_property',
|
||||
@ -486,24 +486,24 @@ class VmdkReadHandle(FileHandle):
|
||||
|
||||
def _create_and_wait_for_lease(self, session, vm_ref):
|
||||
"""Create and wait for HttpNfcLease lease for VM export."""
|
||||
LOG.debug(_("Creating HttpNfcLease lease for exporting VM: %s."),
|
||||
LOG.debug("Creating HttpNfcLease lease for exporting VM: %s.",
|
||||
vm_ref)
|
||||
lease = session.invoke_api(session.vim, 'ExportVm', vm_ref)
|
||||
LOG.debug(_("Lease: %(lease)s obtained for exporting VM: %(vm_ref)s."),
|
||||
LOG.debug("Lease: %(lease)s obtained for exporting VM: %(vm_ref)s.",
|
||||
{'lease': lease,
|
||||
'vm_ref': vm_ref})
|
||||
session.wait_for_lease_ready(lease)
|
||||
return lease
|
||||
|
||||
def _create_connection(self, session, url):
|
||||
LOG.debug(_("Opening URL: %s for reading."), url)
|
||||
LOG.debug("Opening URL: %s for reading.", url)
|
||||
try:
|
||||
cookies = session.vim.client.options.transport.cookiejar
|
||||
headers = {'User-Agent': USER_AGENT,
|
||||
'Cookie': self._build_vim_cookie_header(cookies)}
|
||||
request = urllib2.Request(url, None, headers)
|
||||
conn = urllib2.urlopen(request)
|
||||
LOG.debug(_("URL: %s opened for reading."), url)
|
||||
LOG.debug("URL: %s opened for reading.", url)
|
||||
return conn
|
||||
except Exception as excep:
|
||||
# TODO(vbala) We need to catch and raise specific exceptions
|
||||
@ -521,13 +521,13 @@ class VmdkReadHandle(FileHandle):
|
||||
:returns: the data
|
||||
:raises: VimException
|
||||
"""
|
||||
LOG.debug(_("Reading data from VMDK file with URL = %s."), self._url)
|
||||
LOG.debug("Reading data from VMDK file with URL = %s.", self._url)
|
||||
|
||||
try:
|
||||
data = self._file_handle.read(READ_CHUNKSIZE)
|
||||
self._bytes_read += len(data)
|
||||
LOG.debug(_("Total %(bytes_read)d bytes read from VMDK file "
|
||||
"with URL = %(url)s."),
|
||||
LOG.debug("Total %(bytes_read)d bytes read from VMDK file "
|
||||
"with URL = %(url)s.",
|
||||
{'bytes_read': self._bytes_read,
|
||||
'url': self._url})
|
||||
return data
|
||||
@ -550,8 +550,8 @@ class VmdkReadHandle(FileHandle):
|
||||
VimSessionOverLoadException, VimConnectionException
|
||||
"""
|
||||
percent = int(float(self._bytes_read) / self._vmdk_size * 100)
|
||||
LOG.debug(_("Calling VIM API to update read progress of VMDK file"
|
||||
" with URL = %(url)s to %(percent)d%%."),
|
||||
LOG.debug("Calling VIM API to update read progress of VMDK file"
|
||||
" with URL = %(url)s to %(percent)d%%.",
|
||||
{'url': self._url,
|
||||
'percent': percent})
|
||||
try:
|
||||
@ -559,8 +559,8 @@ class VmdkReadHandle(FileHandle):
|
||||
'HttpNfcLeaseProgress',
|
||||
self._lease,
|
||||
percent=percent)
|
||||
LOG.debug(_("Updated read progress of VMDK file with "
|
||||
"URL = %(url)s to %(percent)d%%."),
|
||||
LOG.debug("Updated read progress of VMDK file with "
|
||||
"URL = %(url)s to %(percent)d%%.",
|
||||
{'url': self._url,
|
||||
'percent': percent})
|
||||
except exceptions.VimException as excep:
|
||||
@ -575,25 +575,25 @@ class VmdkReadHandle(FileHandle):
|
||||
:raises: VimException, VimFaultException, VimAttributeException,
|
||||
VimSessionOverLoadException, VimConnectionException
|
||||
"""
|
||||
LOG.debug(_("Getting lease state for %s."), self._url)
|
||||
LOG.debug("Getting lease state for %s.", self._url)
|
||||
try:
|
||||
state = self._session.invoke_api(vim_util,
|
||||
'get_object_property',
|
||||
self._session.vim,
|
||||
self._lease,
|
||||
'state')
|
||||
LOG.debug(_("Lease for %(url)s is in state: %(state)s."),
|
||||
LOG.debug("Lease for %(url)s is in state: %(state)s.",
|
||||
{'url': self._url,
|
||||
'state': state})
|
||||
if state == 'ready':
|
||||
LOG.debug(_("Releasing lease for %s."), self._url)
|
||||
LOG.debug("Releasing lease for %s.", self._url)
|
||||
self._session.invoke_api(self._session.vim,
|
||||
'HttpNfcLeaseComplete',
|
||||
self._lease)
|
||||
LOG.debug(_("Lease for %s released."), self._url)
|
||||
LOG.debug("Lease for %s released.", self._url)
|
||||
else:
|
||||
LOG.debug(_("Lease for %(url)s is in state: %(state)s; no "
|
||||
"need to release."),
|
||||
LOG.debug("Lease for %(url)s is in state: %(state)s; no "
|
||||
"need to release.",
|
||||
{'url': self._url,
|
||||
'state': state})
|
||||
except exceptions.VimException:
|
||||
@ -602,7 +602,7 @@ class VmdkReadHandle(FileHandle):
|
||||
exc_info=True)
|
||||
raise
|
||||
super(VmdkReadHandle, self).close()
|
||||
LOG.debug(_("Closed VMDK read handle for %s."), self._url)
|
||||
LOG.debug("Closed VMDK read handle for %s.", self._url)
|
||||
|
||||
def __str__(self):
|
||||
return "VMDK read handle for %s" % self._url
|
||||
@ -627,10 +627,10 @@ class ImageReadHandle(object):
|
||||
"""
|
||||
try:
|
||||
data = self._iter.next()
|
||||
LOG.debug(_("Read %d bytes from the image iterator."), len(data))
|
||||
LOG.debug("Read %d bytes from the image iterator.", len(data))
|
||||
return data
|
||||
except StopIteration:
|
||||
LOG.debug(_("Completed reading data from the image iterator."))
|
||||
LOG.debug("Completed reading data from the image iterator.")
|
||||
return ""
|
||||
|
||||
def get_next(self):
|
||||
|
@ -114,7 +114,7 @@ class Vim(object):
|
||||
:param response: response from RetrievePropertiesEx API call
|
||||
:raises: VimFaultException
|
||||
"""
|
||||
LOG.debug(_("Checking RetrievePropertiesEx API response for faults."))
|
||||
LOG.debug("Checking RetrievePropertiesEx API response for faults.")
|
||||
fault_list = []
|
||||
if not response:
|
||||
# This is the case when the session has timed out. ESX SOAP
|
||||
@ -124,8 +124,8 @@ class Vim(object):
|
||||
# session. It is as bad as a terminated session for we cannot
|
||||
# use the session. Therefore setting fault to NotAuthenticated
|
||||
# fault.
|
||||
LOG.debug(_("RetrievePropertiesEx API response is empty; setting "
|
||||
"fault to %s."),
|
||||
LOG.debug("RetrievePropertiesEx API response is empty; setting "
|
||||
"fault to %s.",
|
||||
exceptions.NOT_AUTHENTICATED)
|
||||
fault_list = [exceptions.NOT_AUTHENTICATED]
|
||||
else:
|
||||
@ -141,7 +141,7 @@ class Vim(object):
|
||||
raise exceptions.VimFaultException(fault_list,
|
||||
_("Error occurred while calling"
|
||||
" RetrievePropertiesEx."))
|
||||
LOG.debug(_("No faults found in RetrievePropertiesEx API response."))
|
||||
LOG.debug("No faults found in RetrievePropertiesEx API response.")
|
||||
|
||||
def __getattr__(self, attr_name):
|
||||
"""Returns the method to invoke API identified by param attr_name."""
|
||||
@ -168,14 +168,14 @@ class Vim(object):
|
||||
if managed_object is None:
|
||||
return
|
||||
request = getattr(self.client.service, attr_name)
|
||||
LOG.debug(_("Invoking %(attr_name)s on %(moref)s."),
|
||||
LOG.debug("Invoking %(attr_name)s on %(moref)s.",
|
||||
{'attr_name': attr_name,
|
||||
'moref': managed_object})
|
||||
response = request(managed_object, **kwargs)
|
||||
if (attr_name.lower() == 'retrievepropertiesex'):
|
||||
Vim._retrieve_properties_ex_fault_checker(response)
|
||||
LOG.debug(_("Invocation of %(attr_name)s on %(moref)s "
|
||||
"completed successfully."),
|
||||
LOG.debug("Invocation of %(attr_name)s on %(moref)s "
|
||||
"completed successfully.",
|
||||
{'attr_name': attr_name,
|
||||
'moref': managed_object})
|
||||
return response
|
||||
|
Loading…
x
Reference in New Issue
Block a user