本文整理汇总了Python中xmlbuilder.XMLBuilder.description方法的典型用法代码示例。如果您正苦于以下问题:Python XMLBuilder.description方法的具体用法?Python XMLBuilder.description怎么用?Python XMLBuilder.description使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xmlbuilder.XMLBuilder
的用法示例。
在下文中一共展示了XMLBuilder.description方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build_snapshot_xml
# 需要导入模块: from xmlbuilder import XMLBuilder [as 别名]
# 或者: from xmlbuilder.XMLBuilder import description [as 别名]
def build_snapshot_xml(self, name=None, description=None):
"""
:rtype : String
:type name: String
:type description: String
"""
xml_builder = XMLBuilder('domainsnapshot')
if not (name is None):
xml_builder.name(name)
if not (description is None):
xml_builder.description(description)
return str(xml_builder)
示例2: create_snapshot
# 需要导入模块: from xmlbuilder import XMLBuilder [as 别名]
# 或者: from xmlbuilder.XMLBuilder import description [as 别名]
def create_snapshot(self, domain, snapshot_name, \
snapshot_description):
"""Create VM snapshot
connection: object with a connection to the Hypervisor
domain: VM name
snapshot_name
snapshot_description
"""
try:
libvirt_domain = self.libvirt_connection.lookupByName(domain)
xml_base = XMLBuilder('domainsnapshot')
xml_base.name(snapshot_name)
xml_base.description(snapshot_description)
xml = str(xml_base)
libvirt_domain.snapshotCreateXML(xml)
except:
print 'Unable to create snapshot'
sys.exit(1)
print 'Snapshot has been created successfully.'
示例3: build_snapshot_xml
# 需要导入模块: from xmlbuilder import XMLBuilder [as 别名]
# 或者: from xmlbuilder.XMLBuilder import description [as 别名]
def build_snapshot_xml(self, name=None, description=None, node=None,
disk_only=False, external=False, external_dir=None):
"""Generate snapshot XML
:rtype : String
:type name: String
:type description: String
"""
xml_builder = XMLBuilder('domainsnapshot')
if name is not None:
xml_builder.name(name)
if description is not None:
xml_builder.description(description)
if external:
domain = self.driver.conn.lookupByUUIDString(node.uuid)
# Add memory file for active machines
if domain.isActive() and not disk_only:
memory_file = '{0}/snapshot-memory-{1}_{2}.{3}'.format(
external_dir,
node.environment.name,
node.name,
name)
file_count = 0
tmp_memory_file = memory_file
while os.path.exists(tmp_memory_file):
tmp_memory_file = memory_file + '-' + str(file_count)
file_count += 1
xml_builder.memory(
file=tmp_memory_file,
snapshot='external')
else:
xml_builder.memory(snapshot='no')
for disk in node.disk_devices:
if disk.device == 'disk':
with xml_builder.disks:
xml_builder.disk(name=disk.target_dev,
file=disk.volume.get_path(),
snapshot='external')
return str(xml_builder)
示例4: make_story_xml
# 需要导入模块: from xmlbuilder import XMLBuilder [as 别名]
# 或者: from xmlbuilder.XMLBuilder import description [as 别名]
def make_story_xml(self, name=None, description=None, story_type=None,
owned_by=None, requested_by=None, estimate=None, current_state=None, labels=None):
story = XMLBuilder('story')
if name is not None:
story.name(name)
if description is not None:
story.description(description)
if requested_by is not None:
story.requested_by(requested_by)
if owned_by is not None:
story.owned_by(owned_by)
if story_type is not None:
story.story_type(story_type)
if estimate is not None:
story.estimate(str(estimate), type='integer')
if current_state is not None:
story.current_state(current_state)
if labels is not None:
label_string = ','
if labels:
label_string = ','.join(labels)
story.labels(label_string)
return str(story)