本文整理汇总了Python中vnc_api.vnc_api.VncApi.device_image_create方法的典型用法代码示例。如果您正苦于以下问题:Python VncApi.device_image_create方法的具体用法?Python VncApi.device_image_create怎么用?Python VncApi.device_image_create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vnc_api.vnc_api.VncApi
的用法示例。
在下文中一共展示了VncApi.device_image_create方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SanityBase
# 需要导入模块: from vnc_api.vnc_api import VncApi [as 别名]
# 或者: from vnc_api.vnc_api.VncApi import device_image_create [as 别名]
#.........这里部分代码省略.........
namespace.set_tag_list([{'to': ['label=fabric-as-number']}])
try:
ns_uuid = self._api.fabric_namespace_create(namespace)
namespace = self._api.fabric_namespace_read(id=ns_uuid)
except RefsExistError:
self._logger.warn(
"Fabric namespace '%s' already exists", ns_name)
namespace = self._api.fabric_namespace_read(fq_name=ns_fq_name)
self._logger.debug(
"Fabric namespace created:\n%s",
pprint.pformat(self._api.obj_to_dict(namespace), indent=4))
return namespace
# end _add_asn_namespace
def create_image(self, img_name, img_uri, img_version,
img_family, img_vendor):
"""create image"""
img_fqname = None
# device_fqname = None
try:
self._logger.info('Creating image: %s', img_name)
img_fqname = ['default-global-system-config', img_name]
image = DeviceImage(
name=img_name,
fq_name=img_fqname,
parent_type='global-system-config',
device_image_file_uri=img_uri,
device_image_os_version=img_version,
device_image_device_family=img_family,
device_image_vendor_name=img_vendor
)
img_uuid = self._api.device_image_create(image)
image = self._api.device_image_read(id=img_uuid)
except RefsExistError:
self._logger.warn("Image '%s' already exists", img_name)
image = self._api.device_image_read(fq_name=img_fqname)
self._logger.debug(
"Image created:\n%s",
pprint.pformat(self._api.obj_to_dict(image), indent=4))
return image
# end create_image_and_device
def cleanup_fabric(self, fab_name):
"""delete fabric including all prouters in the fabric"""
try:
self._logger.info('Deleting fabric "%s" ...', fab_name)
fab_fqname = ['default-global-system-config', fab_name]
fab = self._api.fabric_read(fq_name=fab_fqname)
# delete all namespaces in this fabric
fab_namespaces = self._api.fabric_namespaces_list(
parent_id=fab.uuid)
for namespace in fab_namespaces.get('fabric-namespaces') or []:
self._logger.debug(
"Delete namespace: %s", namespace.get('fq_name'))
self._api.fabric_namespace_delete(namespace.get('fq_name'))
# delete fabric
self._logger.debug("Delete fabric: %s", fab_fqname)
self._api.fabric_delete(fab_fqname)