本文整理汇总了Python中xen.xend.XendAPIStore.get方法的典型用法代码示例。如果您正苦于以下问题:Python XendAPIStore.get方法的具体用法?Python XendAPIStore.get怎么用?Python XendAPIStore.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xen.xend.XendAPIStore
的用法示例。
在下文中一共展示了XendAPIStore.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: remove_PPCI
# 需要导入模块: from xen.xend import XendAPIStore [as 别名]
# 或者: from xen.xend.XendAPIStore import get [as 别名]
def remove_PPCI(self, pci_name):
# Update lspci info
PciUtil.create_lspci_info()
# Remove the PPCI
(domain, bus, slot, func) = PciUtil.parse_pci_name(pci_name)
ppci_ref = XendPPCI.get_by_sbdf(domain, bus, slot, func)
XendAPIStore.get(ppci_ref, "PPCI").destroy()
self.save_PPCIs()
示例2: remove_PSCSI
# 需要导入模块: from xen.xend import XendAPIStore [as 别名]
# 或者: from xen.xend.XendAPIStore import get [as 别名]
def remove_PSCSI(self, rem_HCTL):
saved_pscsis = self.state_store.load_state('pscsi')
if not saved_pscsis:
return
# Remove the PSCSI
for pscsi_record in saved_pscsis.values():
if rem_HCTL == pscsi_record['physical_HCTL']:
pscsi_ref = XendPSCSI.get_by_HCTL(rem_HCTL)
XendAPIStore.get(pscsi_ref, "PSCSI").destroy()
self.save_PSCSIs()
return
示例3: _init_networks
# 需要导入模块: from xen.xend import XendAPIStore [as 别名]
# 或者: from xen.xend.XendAPIStore import get [as 别名]
def _init_networks(self):
# Initialise networks
# First configure ones off disk
saved_networks = self.state_store.load_state('network')
if saved_networks:
for net_uuid, network in saved_networks.items():
try:
XendNetwork.recreate(network, net_uuid)
except CreateUnspecifiedAttributeError:
log.warn("Error recreating network %s", net_uuid)
# Next discover any existing bridges and check
# they are not already configured
# 'tmpbridge' is a temporary bridge created by network-bridge script.
# Wait a couple of seconds for it to be renamed.
for i in xrange(20):
bridges = Brctl.get_state().keys()
if 'tmpbridge' in bridges:
time.sleep(0.1)
else:
break
configured_bridges = [XendAPIStore.get(
network_uuid, "network")
.get_name_label()
for network_uuid in XendNetwork.get_all()]
unconfigured_bridges = [bridge
for bridge in bridges
if bridge not in configured_bridges]
for unconfigured_bridge in unconfigured_bridges:
if unconfigured_bridge != 'tmpbridge':
XendNetwork.create_phy(unconfigured_bridge)
示例4: _get_ovs_name
# 需要导入模块: from xen.xend import XendAPIStore [as 别名]
# 或者: from xen.xend.XendAPIStore import get [as 别名]
def _get_ovs_name(self):
network_refs = XendNetwork.get_all()
network_names = []
for ref in network_refs:
network = XendAPIStore.get(ref, "network")
namelabel = network.get_name_label()
network_names.append(namelabel)
return network_names
示例5: unplug
# 需要导入模块: from xen.xend import XendAPIStore [as 别名]
# 或者: from xen.xend.XendAPIStore import get [as 别名]
def unplug(self):
"""Unplug the PIF from the network"""
network = XendAPIStore.get(self.network, "network")
bridge_name = network.get_name_label()
from xen.util import Brctl
Brctl.vif_bridge_rem({"bridge": bridge_name, "vif": self.get_interface_name()})
示例6: get_by_uuid
# 需要导入模块: from xen.xend import XendAPIStore [as 别名]
# 或者: from xen.xend.XendAPIStore import get [as 别名]
def get_by_uuid(cls, uuid):
# Sanity check the uuid is one of us
me = XendAPIStore.get(uuid, cls.getClass())
if me is not None and me.getClass() == cls.getClass():
# In OSS, ref == uuid
return uuid
else:
raise "Big Error.. TODO!"
示例7: recreate_active_pools
# 需要导入模块: from xen.xend import XendAPIStore [as 别名]
# 或者: from xen.xend.XendAPIStore import get [as 别名]
def recreate_active_pools(cls):
""" Read active pool config from hypervisor and create pool instances.
- Query pool ids and assigned CPUs from hypervisor.
- Query additional information for any pool from xenstore.
If an entry for a pool id is missing in xenstore, it will be
recreated with a new uuid and generic name (this is an error case)
- Create an XendCPUPool instance for any pool id
Function have to be called after recreation of managed pools.
"""
log.debug('recreate_active_pools')
for pool_rec in xc.cpupool_getinfo():
pool = pool_rec['cpupool']
# read pool data from xenstore
path = XS_POOLROOT + "%s/" % pool
uuid = xstransact.Read(path, 'uuid')
if not uuid:
# xenstore entry missing / invaild; create entry with new uuid
uuid = genuuid.createString()
name = "Pool-%s" % pool
try:
inst = XendCPUPool( { 'name_label' : name }, uuid, False )
inst.update_XS(pool)
except PoolError, ex:
# log error and skip domain
log.error('cannot recreate pool %s; skipping (reason: %s)' \
% (name, ex))
else:
(name, descr) = xstransact.Read(path, 'name', 'description')
other_config = {}
for key in xstransact.List(path + 'other_config'):
other_config[key] = xstransact.Read(
path + 'other_config/%s' % key)
# check existance of pool instance
inst = XendAPIStore.get(uuid, cls.getClass())
if inst:
# update attributes of existing instance
inst.name_label = name
inst.name_description = descr
inst.other_config = other_config
else:
# recreate instance
try:
inst = XendCPUPool(
{ 'name_label' : name,
'name_description' : descr,
'other_config' : other_config,
'proposed_CPUs' : pool_rec['cpulist'],
'ncpu' : len(pool_rec['cpulist']),
},
uuid, False )
except PoolError, ex:
# log error and skip domain
log.error(
'cannot recreate pool %s; skipping (reason: %s)' \
% (name, ex))
示例8: __init__
# 需要导入模块: from xen.xend import XendAPIStore [as 别名]
# 或者: from xen.xend.XendAPIStore import get [as 别名]
def __init__(self):
self.host_instance = XendNode.instance()
self.host_cpus = self.host_instance.get_host_cpu_refs()
pif_refs = self.host_instance.get_PIF_refs()
self.host_pifs = []
for pif_ref in pif_refs:
pif = XendAPIStore.get(pif_ref, "PIF")
self.host_pifs.append(pif)
示例9: move_domain
# 需要导入模块: from xen.xend import XendAPIStore [as 别名]
# 或者: from xen.xend.XendAPIStore import get [as 别名]
def move_domain(cls, pool_ref, domid):
cls.pool_lock.acquire()
try:
pool = XendAPIStore.get(pool_ref, cls.getClass())
pool_id = pool.query_pool_id()
xc.cpupool_movedomain(pool_id, domid)
finally:
cls.pool_lock.release()
示例10: _init_PIFs
# 需要导入模块: from xen.xend import XendAPIStore [as 别名]
# 或者: from xen.xend.XendAPIStore import get [as 别名]
def _init_PIFs(self):
# Initialise PIFs
# First configure ones off disk
saved_pifs = self.state_store.load_state('pif')
if saved_pifs:
for pif_uuid, pif in saved_pifs.items():
try:
XendPIF.recreate(pif, pif_uuid)
except CreateUnspecifiedAttributeError:
log.warn("Error recreating PIF %s", pif_uuid)
# Next discover any existing PIFs and check
# they are not already configured
configured_pifs = [XendAPIStore.get(
pif_uuid, "PIF")
.get_interface_name()
for pif_uuid in XendPIF.get_all()]
unconfigured_pifs = [(name, mtu, mac)
for name, mtu, mac in linux_get_phy_ifaces()
if name not in configured_pifs]
# Get a mapping from interface to bridge
if_to_br = dict([(i,b)
for (b,ifs) in Brctl.get_state().items()
for i in ifs])
for name, mtu, mac in unconfigured_pifs:
# Check PIF is on bridge
# if not, ignore
bridge_name = if_to_br.get(name, None)
if bridge_name is not None:
# Translate bridge name to network uuid
for network_uuid in XendNetwork.get_all():
network = XendAPIStore.get(
network_uuid, 'network')
if network.get_name_label() == bridge_name:
XendPIF.create_phy(network_uuid, name,
mac, mtu)
break
else:
log.debug("Cannot find network for bridge %s "
"when configuring PIF %s",
(bridge_name, name))
示例11: remove_PSCSI
# 需要导入模块: from xen.xend import XendAPIStore [as 别名]
# 或者: from xen.xend.XendAPIStore import get [as 别名]
def remove_PSCSI(self, rem_HCTL):
saved_pscsis = self.state_store.load_state('pscsi')
if not saved_pscsis:
return
# Remove the PSCSI
for pscsi_record in saved_pscsis.values():
if rem_HCTL == pscsi_record['physical_HCTL']:
pscsi_ref = XendPSCSI.get_by_HCTL(rem_HCTL)
XendAPIStore.get(pscsi_ref, "PSCSI").destroy()
self.save_PSCSIs()
physical_host = int(rem_HCTL.split(':')[0])
pscsi_HBA_ref = XendPSCSI_HBA.get_by_physical_host(physical_host)
if pscsi_HBA_ref:
if not XendAPIStore.get(pscsi_HBA_ref, 'PSCSI_HBA').get_PSCSIs():
XendAPIStore.get(pscsi_HBA_ref, 'PSCSI_HBA').destroy()
self.save_PSCSI_HBAs()
return
示例12: get_PSCSI_HBAs
# 需要导入模块: from xen.xend import XendAPIStore [as 别名]
# 或者: from xen.xend.XendAPIStore import get [as 别名]
def get_PSCSI_HBAs(self):
PSCSIs = []
uuid = self.get_uuid()
for dscsi in XendAPIStore.get_all('DSCSI'):
if dscsi.get_VM() == self.VM and dscsi.get_HBA() == uuid:
PSCSIs.append(dscsi.get_PSCSI())
PSCSI_HBAs = []
for pscsi_uuid in PSCSIs:
pscsi_HBA_uuid = XendAPIStore.get(pscsi_uuid, 'PSCSI').get_HBA()
if not pscsi_HBA_uuid in PSCSI_HBAs:
PSCSI_HBAs.append(pscsi_HBA_uuid)
return PSCSI_HBAs
示例13: lookup_pool
# 需要导入模块: from xen.xend import XendAPIStore [as 别名]
# 或者: from xen.xend.XendAPIStore import get [as 别名]
def lookup_pool(cls, id_or_name):
""" Search XendCPUPool instance with given id_or_name.
@param id_or_name: pool id or pool nameto search
@type id_or_name: [int, str]
@return: instane or None if not found
@rtype: XendCPUPool
"""
pool_uuid = None
try:
pool_id = int(id_or_name)
# pool id given ?
pool_uuid = cls.query_pool_ref(pool_id)
if not pool_uuid:
# not found -> search name
pool_uuid = cls.get_by_name_label(id_or_name)
except ValueError:
# pool name given
pool_uuid = cls.get_by_name_label(id_or_name)
if len(pool_uuid) > 0:
return XendAPIStore.get(pool_uuid[0], cls.getClass())
else:
return None
示例14: bridge_to_network
# 需要导入模块: from xen.xend import XendAPIStore [as 别名]
# 或者: from xen.xend.XendAPIStore import get [as 别名]
def bridge_to_network(self, bridge):
"""
Determine which network a particular bridge is attached to.
@param bridge The name of the bridge. If empty, the default bridge
will be used instead (the first one in the list returned by brctl
show); this is the behaviour of the vif-bridge script.
@return The XendNetwork instance to which this bridge is attached.
@raise Exception if the interface is not connected to a network.
"""
if not bridge:
rc, bridge = commands.getstatusoutput(
'brctl show | cut -d "\n" -f 2 | cut -f 1')
if rc != 0 or not bridge:
raise Exception(
'Could not find default bridge, and none was specified')
for network_uuid in XendNetwork.get_all():
network = XendAPIStore.get(network_uuid, "network")
if network.get_name_label() == bridge:
return network
else:
raise Exception('Cannot find network for bridge %s' % bridge)
示例15: get_pif_metrics
# 需要导入模块: from xen.xend import XendAPIStore [as 别名]
# 或者: from xen.xend.XendAPIStore import get [as 别名]
def get_pif_metrics(self, pif):
return XendAPIStore.get(pif.get_metrics(), "PIF_metrics")