當前位置: 首頁>>代碼示例>>Python>>正文


Python Edge.create方法代碼示例

本文整理匯總了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
開發者ID:carriercomm,項目名稱:MyProject,代碼行數:39,代碼來源:nsx_network.py

示例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',
開發者ID:carriercomm,項目名稱:MyProject,代碼行數:33,代碼來源:dhcp_ippool.py


注:本文中的edge.Edge.create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。