本文整理汇总了Python中model.Node.cdrom方法的典型用法代码示例。如果您正苦于以下问题:Python Node.cdrom方法的具体用法?Python Node.cdrom怎么用?Python Node.cdrom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.Node
的用法示例。
在下文中一共展示了Node.cdrom方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse_node
# 需要导入模块: from model import Node [as 别名]
# 或者: from model.Node import cdrom [as 别名]
def parse_node(environment, data):
if data.has_key('name'):
name = data['name']
elif data.has_key('node'):
name = data['node']
else:
raise ConfigError, "Unnamed node"
node = Node(name)
if data.has_key('cpu'):
node.cpu = data['cpu']
if data.has_key('memory'):
node.memory = data['memory']
if data.has_key('vnc'):
node.vnc = data['vnc']
if data.has_key('cdrom'):
isopath = data['cdrom']
if not isinstance(isopath, (str,)):
raise ConfigError, "It must be string containing path to iso image file"
node.cdrom = Cdrom(isopath)
if data.has_key('disk'):
disks_data = data['disk']
if type(disks_data) != list:
disks_data = (disks_data,)
for disk_data in disks_data:
if type(disk_data) == str:
try:
size = parse_size(disk_data)
node.disks.append(Disk(size=size))
except ValueError:
path = disk_data
node.disks.append(Disk(path=path))
elif isinstance(disk_data, dict):
node.disks.append(Disk(**disk_data))
else:
raise ConfigError, "Unknown disk config: %s" % str(disk_data)
if data.has_key('networks'):
networks_data = data['networks']
if type(networks_data) != list:
networks_data = (networks_data,)
for network_data in networks_data:
if type(network_data) == str:
network = None
for n in environment.networks:
if n.name == network_data:
network = n
break
# Inline networks
# if network is None:
# network = parse_network(environment, {'name': network_data})
# self.networks.append(network)
# TODO: add support for specifying additional network interface params (e.g. mac address)
if network is None:
raise ConfigError, "Unknown network %s" % network_data
node.interfaces.append(Interface(network))
if data.has_key('boot'):
boot_data = data['boot']
if type(boot_data) != list:
boot_data = list(boot_data)
for boot in boot_data:
if not boot in ('disk', 'network', 'cdrom'):
raise ConfigError, "Unknown boot option: %s" % boot
node.boot.append(boot)
else:
if len(node.disks) > 0:
node.boot.append('disk')
if node.cdrom:
node.boot.append('cdrom')
if len(node.interfaces) > 0:
node.boot.append('network')
for existing_node in environment.nodes:
if existing_node.name == node.name:
raise ConfigError, "Node with given name already exists: %s" % node.name
environment.nodes.append(node)