本文整理匯總了Python中nova.virt.xenapi.volumeops.VolumeOps.attach_volume方法的典型用法代碼示例。如果您正苦於以下問題:Python VolumeOps.attach_volume方法的具體用法?Python VolumeOps.attach_volume怎麽用?Python VolumeOps.attach_volume使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類nova.virt.xenapi.volumeops.VolumeOps
的用法示例。
在下文中一共展示了VolumeOps.attach_volume方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: XenAPIConnection
# 需要導入模塊: from nova.virt.xenapi.volumeops import VolumeOps [as 別名]
# 或者: from nova.virt.xenapi.volumeops.VolumeOps import attach_volume [as 別名]
#.........這裏部分代碼省略.........
"""suspend the specified instance"""
self._vmops.suspend(instance, callback)
def resume(self, instance, callback):
"""resume the specified instance"""
self._vmops.resume(instance, callback)
def rescue(self, instance, callback, network_info):
"""Rescue the specified instance"""
self._vmops.rescue(instance, callback)
def unrescue(self, instance, callback, network_info):
"""Unrescue the specified instance"""
self._vmops.unrescue(instance, callback)
def poll_rescued_instances(self, timeout):
"""Poll for rescued instances"""
self._vmops.poll_rescued_instances(timeout)
def reset_network(self, instance):
"""reset networking for specified instance"""
self._vmops.reset_network(instance)
def inject_network_info(self, instance, network_info):
"""inject network info for specified instance"""
self._vmops.inject_network_info(instance, network_info)
def plug_vifs(self, instance_ref, network_info):
self._vmops.plug_vifs(instance_ref, network_info)
def get_info(self, instance_id):
"""Return data about VM instance"""
return self._vmops.get_info(instance_id)
def get_diagnostics(self, instance):
"""Return data about VM diagnostics"""
return self._vmops.get_diagnostics(instance)
def get_console_output(self, instance):
"""Return snapshot of console"""
return self._vmops.get_console_output(instance)
def get_ajax_console(self, instance):
"""Return link to instance's ajax console"""
return self._vmops.get_ajax_console(instance)
def get_host_ip_addr(self):
xs_url = urlparse.urlparse(FLAGS.xenapi_connection_url)
return xs_url.netloc
def attach_volume(self, instance_name, device_path, mountpoint):
"""Attach volume storage to VM instance"""
return self._volumeops.attach_volume(instance_name,
device_path,
mountpoint)
def detach_volume(self, instance_name, mountpoint):
"""Detach volume storage to VM instance"""
return self._volumeops.detach_volume(instance_name, mountpoint)
def get_console_pool_info(self, console_type):
xs_url = urlparse.urlparse(FLAGS.xenapi_connection_url)
return {'address': xs_url.netloc,
'username': FLAGS.xenapi_connection_username,
'password': FLAGS.xenapi_connection_password}
def update_available_resource(self, ctxt, host):
"""This method is supported only by libvirt."""
return
def compare_cpu(self, xml):
"""This method is supported only by libvirt."""
raise NotImplementedError('This method is supported only by libvirt.')
def ensure_filtering_rules_for_instance(self, instance_ref):
"""This method is supported only libvirt."""
return
def live_migration(self, context, instance_ref, dest,
post_method, recover_method):
"""This method is supported only by libvirt."""
return
def unfilter_instance(self, instance_ref, network_info):
"""This method is supported only by libvirt."""
raise NotImplementedError('This method is supported only by libvirt.')
def update_host_status(self):
"""Update the status info of the host, and return those values
to the calling program."""
return self.HostState.update_status()
def get_host_stats(self, refresh=False):
"""Return the current state of the host. If 'refresh' is
True, run the update first."""
return self.HostState.get_host_stats(refresh=refresh)
def set_host_enabled(self, host, enabled):
"""Sets the specified host's ability to accept new instances."""
return self._vmops.set_host_enabled(host, enabled)
示例2: XenAPIConnection
# 需要導入模塊: from nova.virt.xenapi.volumeops import VolumeOps [as 別名]
# 或者: from nova.virt.xenapi.volumeops.VolumeOps import attach_volume [as 別名]
#.........這裏部分代碼省略.........
bwusage = []
start_time = time.mktime(start_time.timetuple())
if stop_time:
stop_time = time.mktime(stop_time.timetuple())
for iusage in self._vmops.get_all_bw_usage(start_time, stop_time).\
values():
for macaddr, usage in iusage.iteritems():
vi = db.virtual_interface_get_by_address(
context.get_admin_context(),
macaddr)
if vi:
bwusage.append(dict(virtual_interface=vi,
bw_in=usage['bw_in'],
bw_out=usage['bw_out']))
return bwusage
def get_console_output(self, instance):
"""Return snapshot of console"""
return self._vmops.get_console_output(instance)
def get_ajax_console(self, instance):
"""Return link to instance's ajax console"""
return self._vmops.get_ajax_console(instance)
def get_vnc_console(self, instance):
"""Return link to instance's ajax console"""
return self._vmops.get_vnc_console(instance)
@staticmethod
def get_host_ip_addr():
xs_url = urlparse.urlparse(FLAGS.xenapi_connection_url)
return xs_url.netloc
def attach_volume(self, connection_info, instance_name, mountpoint):
"""Attach volume storage to VM instance"""
return self._volumeops.attach_volume(connection_info,
instance_name,
mountpoint)
def detach_volume(self, connection_info, instance_name, mountpoint):
"""Detach volume storage to VM instance"""
return self._volumeops.detach_volume(connection_info,
instance_name,
mountpoint)
def get_console_pool_info(self, console_type):
xs_url = urlparse.urlparse(FLAGS.xenapi_connection_url)
return {'address': xs_url.netloc,
'username': FLAGS.xenapi_connection_username,
'password': FLAGS.xenapi_connection_password}
def update_available_resource(self, ctxt, host):
"""Updates compute manager resource info on ComputeNode table.
This method is called when nova-compute launches, and
whenever admin executes "nova-manage service update_resource".
:param ctxt: security context
:param host: hostname that compute manager is currently running
"""
try:
service_ref = db.service_get_all_compute_by_host(ctxt, host)[0]
except exception.NotFound:
raise exception.ComputeServiceUnavailable(host=host)
示例3: XenAPIConnection
# 需要導入模塊: from nova.virt.xenapi.volumeops import VolumeOps [as 別名]
# 或者: from nova.virt.xenapi.volumeops.VolumeOps import attach_volume [as 別名]
class XenAPIConnection(object):
"""A connection to XenServer or Xen Cloud Platform"""
def __init__(self, url, user, pw):
session = XenAPISession(url, user, pw)
self._vmops = VMOps(session)
self._volumeops = VolumeOps(session)
def init_host(self, host):
#FIXME(armando): implement this
#NOTE(armando): would we need a method
#to call when shutting down the host?
#e.g. to do session logout?
pass
def list_instances(self):
"""List VM instances"""
return self._vmops.list_instances()
def spawn(self, instance):
"""Create VM instance"""
self._vmops.spawn(instance)
def snapshot(self, instance, image_id):
""" Create snapshot from a running VM instance """
self._vmops.snapshot(instance, image_id)
def reboot(self, instance):
"""Reboot VM instance"""
self._vmops.reboot(instance)
def set_admin_password(self, instance, new_pass):
"""Set the root/admin password on the VM instance"""
self._vmops.set_admin_password(instance, new_pass)
def inject_file(self, instance, b64_path, b64_contents):
"""Create a file on the VM instance. The file path and contents
should be base64-encoded.
"""
self._vmops.inject_file(instance, b64_path, b64_contents)
def destroy(self, instance):
"""Destroy VM instance"""
self._vmops.destroy(instance)
def pause(self, instance, callback):
"""Pause VM instance"""
self._vmops.pause(instance, callback)
def unpause(self, instance, callback):
"""Unpause paused VM instance"""
self._vmops.unpause(instance, callback)
def suspend(self, instance, callback):
"""suspend the specified instance"""
self._vmops.suspend(instance, callback)
def resume(self, instance, callback):
"""resume the specified instance"""
self._vmops.resume(instance, callback)
def reset_network(self, instance):
"""reset networking for specified instance"""
self._vmops.reset_network(instance)
def get_info(self, instance_id):
"""Return data about VM instance"""
return self._vmops.get_info(instance_id)
def get_diagnostics(self, instance):
"""Return data about VM diagnostics"""
return self._vmops.get_diagnostics(instance)
def get_console_output(self, instance):
"""Return snapshot of console"""
return self._vmops.get_console_output(instance)
def get_ajax_console(self, instance):
"""Return link to instance's ajax console"""
return self._vmops.get_ajax_console(instance)
def attach_volume(self, instance_name, device_path, mountpoint):
"""Attach volume storage to VM instance"""
return self._volumeops.attach_volume(instance_name,
device_path,
mountpoint)
def detach_volume(self, instance_name, mountpoint):
"""Detach volume storage to VM instance"""
return self._volumeops.detach_volume(instance_name, mountpoint)
def get_console_pool_info(self, console_type):
xs_url = urlparse.urlparse(FLAGS.xenapi_connection_url)
return {'address': xs_url.netloc,
'username': FLAGS.xenapi_connection_username,
'password': FLAGS.xenapi_connection_password}
示例4: XenAPIConnection
# 需要導入模塊: from nova.virt.xenapi.volumeops import VolumeOps [as 別名]
# 或者: from nova.virt.xenapi.volumeops.VolumeOps import attach_volume [as 別名]
#.........這裏部分代碼省略.........
"""Poll for rescued instances"""
self._vmops.poll_rescued_instances(timeout)
def poll_unconfirmed_resizes(self, resize_confirm_window):
"""Poll for unconfirmed resizes"""
self._vmops.poll_unconfirmed_resizes(resize_confirm_window)
def reset_network(self, instance):
"""reset networking for specified instance"""
self._vmops.reset_network(instance)
def inject_network_info(self, instance, network_info):
"""inject network info for specified instance"""
self._vmops.inject_network_info(instance, network_info)
def plug_vifs(self, instance_ref, network_info):
self._vmops.plug_vifs(instance_ref, network_info)
def get_info(self, instance_id):
"""Return data about VM instance"""
return self._vmops.get_info(instance_id)
def get_diagnostics(self, instance):
"""Return data about VM diagnostics"""
return self._vmops.get_diagnostics(instance)
def get_console_output(self, instance):
"""Return snapshot of console"""
return self._vmops.get_console_output(instance)
def get_ajax_console(self, instance):
"""Return link to instance's ajax console"""
return self._vmops.get_ajax_console(instance)
def get_host_ip_addr(self):
xs_url = urlparse.urlparse(FLAGS.xenapi_connection_url)
return xs_url.netloc
def attach_volume(self, instance_name, device_path, mountpoint):
"""Attach volume storage to VM instance"""
return self._volumeops.attach_volume(instance_name, device_path, mountpoint)
def detach_volume(self, instance_name, mountpoint):
"""Detach volume storage to VM instance"""
return self._volumeops.detach_volume(instance_name, mountpoint)
def get_console_pool_info(self, console_type):
xs_url = urlparse.urlparse(FLAGS.xenapi_connection_url)
return {
"address": xs_url.netloc,
"username": FLAGS.xenapi_connection_username,
"password": FLAGS.xenapi_connection_password,
}
def update_available_resource(self, ctxt, host):
"""This method is supported only by libvirt."""
return
def compare_cpu(self, xml):
"""This method is supported only by libvirt."""
raise NotImplementedError("This method is supported only by libvirt.")
def ensure_filtering_rules_for_instance(self, instance_ref, network_info):
"""This method is supported only libvirt."""
return
def live_migration(self, context, instance_ref, dest, post_method, recover_method, block_migration=False):
"""This method is supported only by libvirt."""
return
def unfilter_instance(self, instance_ref, network_info):
"""This method is supported only by libvirt."""
raise NotImplementedError("This method is supported only by libvirt.")
def update_host_status(self):
"""Update the status info of the host, and return those values
to the calling program."""
return self.HostState.update_status()
def get_host_stats(self, refresh=False):
"""Return the current state of the host. If 'refresh' is
True, run the update first."""
return self.HostState.get_host_stats(refresh=refresh)
def host_power_action(self, host, action):
"""The only valid values for 'action' on XenServer are 'reboot' or
'shutdown', even though the API also accepts 'startup'. As this is
not technically possible on XenServer, since the host is the same
physical machine as the hypervisor, if this is requested, we need to
raise an exception.
"""
if action in ("reboot", "shutdown"):
return self._vmops.host_power_action(host, action)
else:
msg = _("Host startup on XenServer is not supported.")
raise NotImplementedError(msg)
def set_host_enabled(self, host, enabled):
"""Sets the specified host's ability to accept new instances."""
return self._vmops.set_host_enabled(host, enabled)