本文整理汇总了Python中xen.xend.XendAPIStore类的典型用法代码示例。如果您正苦于以下问题:Python XendAPIStore类的具体用法?Python XendAPIStore怎么用?Python XendAPIStore使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了XendAPIStore类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: remove_PPCI
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
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: get_PSCSI_HBAs
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
示例4: _init_networks
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)
示例5: get_DSCSIs
def get_DSCSIs(self):
DSCSIs = []
uuid = self.get_uuid()
for dscsi in XendAPIStore.get_all('DSCSI'):
if dscsi.get_VM() == self.VM and dscsi.get_HBA() == uuid:
DSCSIs.append(dscsi.get_uuid())
return DSCSIs
示例6: _get_ovs_name
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
示例7: get_by_uuid
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!"
示例8: unplug
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()})
示例9: recreate_active_pools
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))
示例10: move_domain
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()
示例11: __init__
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)
示例12: _init_PIFs
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))
示例13: remove_PSCSI
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
示例14: get_all_managed
def get_all_managed(cls):
""" Query all managed pools.
@return: uuids of all managed pools
@rtype: list of str
"""
cls.pool_lock.acquire()
try:
managed_pools = [ inst.get_uuid()
for inst in XendAPIStore.get_all(cls.getClass())
if inst.is_managed() ]
finally:
cls.pool_lock.release()
return managed_pools
示例15: get_by_name_label
def get_by_name_label(cls, name_label):
""" Query a Pool(ref) by its name.
@return: ref of pool
@rtype: str
"""
cls.pool_lock.acquire()
try:
return [ inst.get_uuid()
for inst in XendAPIStore.get_all(cls.getClass())
if inst.name_label == name_label
]
finally:
cls.pool_lock.release()