本文整理汇总了Python中edge.Edge.create方法的典型用法代码示例。如果您正苦于以下问题:Python Edge.create方法的具体用法?Python Edge.create怎么用?Python Edge.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edge.Edge
的用法示例。
在下文中一共展示了Edge.create方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_edge
# 需要导入模块: from edge import Edge [as 别名]
# 或者: from edge.Edge import create [as 别名]
def add_edge(options):
""" function to add on edge
@param options cli options to this script
@return True/False True - success False - error
"""
vsm_obj = get_vsm_object(options, '4.0')
edge = Edge(vsm_obj, '4.0')
edge_schema = EdgeSchema(None)
edge_schema.datacenterMoid = get_datacenter_id(options)
edge_schema.appliances.applianceSize = 'compact'
appliance_schema = ApplianceSchema()
appliance_schema.datastoreId = get_datastore_id(options)
appliance_schema.resourcePoolId = get_cluster_id(options)
# XXX(hchilkot):
# set default firewall rule to accept for edge,
# this is required to pass any traffic across networks.
result, features_schema = set_edge_features_schema(default_firewall_rule = FW_DEFAULT_RULE_ACCEPT)
if not result:
print("Result : %r. Received: %r for features schema. \
Failed to set edge features." % (result, features_schema))
return False
edge_schema.features = features_schema
edge_schema.appliances.appliance = [appliance_schema]
edge_schema.vnics = [get_vnic(options, 0)]
edge_schema.name = get_edge_name(options)
print ("Creating edge %s" % edge_schema.name)
result = edge.create(edge_schema)
if (result[0].response.status != 201):
r_vars = vars(result[0])
print("Create edge error: %s" % result[0].response.reason)
print ', '.join("%s: %s" % item for item in r_vars.items())
return False
return True
示例2:
# 需要导入模块: from edge import Edge [as 别名]
# 或者: from edge.Edge import create [as 别名]
'autoconfiguration': {'enabled': True, 'rulepriority': 'high'},
'querydaemon': {'enabled': True, 'port': 5666},
'vnics': [{'label': 'vNic_0', 'name': 'NIC-1',
'addressgroups': [{
'primaryaddress': '192.168.0.1',
'subnetmask': '255.255.255.224',
'subnetprefixlength': 27
}],
'mtu': 1500, 'type': 'internal', 'isconnected': True, 'index': 0,
'portgroupid': 'dvportgroup-164',
'enableproxyarp': False, 'enablesendredirects': False
}],
}
edge_schema_object = edge_client.get_schema_object(py_dict)
result_obj_1 = edge_client.create(edge_schema_object)
print result_obj_1.status_code
edge_schema = edge_client.read()
edge_schema.print_object()
edge_client.get_ip()
#Configure DHCP
dhcp_py_dict = {
'enabled': True,
'logging': {'loglevel': 'info', 'enable': False},
'ippools': [
{
'autoconfiguredns': True,
'defaultGateway': '192.168.0.3',