当前位置: 首页>>代码示例>>Python>>正文


Python Edge.id方法代码示例

本文整理汇总了Python中edge.Edge.id方法的典型用法代码示例。如果您正苦于以下问题:Python Edge.id方法的具体用法?Python Edge.id怎么用?Python Edge.id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在edge.Edge的用法示例。


在下文中一共展示了Edge.id方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: delete_all_edges

# 需要导入模块: from edge import Edge [as 别名]
# 或者: from edge.Edge import id [as 别名]
def delete_all_edges(options):
    """ Function to delete all edges on given VSM

    @param options cli options to this script
    @return None
    """
    edge  = Edge(vsm_obj)
    edges = (edge.query())
    edge_id = None
    for item in edges.edgePage.list_schema:
       edge.id = item.objectId
       edge.delete()
开发者ID:carriercomm,项目名称:MyProject,代码行数:14,代码来源:nsx_network.py

示例2: delete_network

# 需要导入模块: from edge import Edge [as 别名]
# 或者: from edge.Edge import id [as 别名]
def delete_network(options, vsm_obj):
    """ function to delete network

    @param options cli options to this script
    @param vsm_obj reference to vsm client object
    @return True/False True - success False - error
    """
    print("Disconnecting edge interface attached to this network")
    edge_id = get_edge(vsm_obj)
    edge = Edge(vsm_obj, '4.0')
    edge.id = edge_id
    vnics = Vnics(edge)
    vnics_schema = vnics.query()
    network = get_network_id(options, get_network_name_on_vc(options))
    for vnic in vnics_schema.vnics:
       if network and vnic.portgroupId == network:
          print("Found a matching vnic %s %s" % (options.name, vnic.index))
          vnic.isConnected = "False"
          vnic.portgroupId = None
          vnic.name = "vnic%s" % vnic.index
          vnics_schema = VnicsSchema()
          vnics_schema.vnics = [vnic]
          result = vnics.create(vnics_schema)
          if (result[0].response.status != 204):
             print "update vnic error: %s %s" \
                % (result[0].response.status, result[0].response.reason)
             return False
          else:
             break
    else:
        print ("No matching vnic found")

    vdn_scope = get_transport_zone(options)
    virtual_wire = VirtualWire(vdn_scope)
    vwire = virtual_wire.read_by_name(get_network_name(options))
    name = get_network_name(options)
    if vwire != "FAILURE":
       print("Found a matching network %s" % (options.name))
       virtual_wire.id = vwire.objectId
       result = virtual_wire.delete()
       if (result.response.status != 200):
          print ("Delete vwire error: %s" % result.response.reason)
          return False
    else:
        print ("No matching network found")
    print("Network %s deleted" % (options.name))

    return True
开发者ID:carriercomm,项目名称:MyProject,代码行数:50,代码来源:nsx_network.py

示例3: create_dhcp_pool

# 需要导入模块: from edge import Edge [as 别名]
# 或者: from edge.Edge import id [as 别名]
def create_dhcp_pool(options, vsm_obj, range, default_gateway):
    """ function to create dhcp ip pool

    @param options cli options to this script
    @param vsm_obj reference to vsm client object
    @param range dhcp ip range
    @param default_gateway default gateway
    @return True/False True - success False - error
    """
    edge = Edge(vsm_obj, '4.0')
    edge_id = get_edge(vsm_obj)
    edge.id = edge_id

    dhcp_py_dict = {
        'enabled': True,
        'logging': {'loglevel': 'info', 'enable': False},
        'ippools': [
                   {
                       'autoconfiguredns': True,
                       'defaultGateway': default_gateway,
                       'iprange': range,
                   }
        ],
    }
    dhcp_client = DHCP(edge)
    print("Creating dhcp ippool with range %s" % range)
    dhcp_schema_object = dhcp_client.get_schema_object(dhcp_py_dict)
    existing_dhcp_schema = dhcp_client.read()
    if existing_dhcp_schema and existing_dhcp_schema.ipPools:
       print "append dhcp ippool to existing list"
       dhcp_schema_object.ipPools = existing_dhcp_schema.ipPools + \
          dhcp_schema_object.ipPools
    result = dhcp_client.create(dhcp_schema_object)

    if (result[0].response.status != 204):
       r_vars = vars(result[0])
       print("Create IP Pool error: %s" % result[0].response.reason)
       print ', '.join("%s: %s" % item for item in r_vars.items())
       return False
    return True
开发者ID:carriercomm,项目名称:MyProject,代码行数:42,代码来源:nsx_network.py

示例4: add_edge_interface

# 需要导入模块: from edge import Edge [as 别名]
# 或者: from edge.Edge import id [as 别名]
def add_edge_interface(options, edge_id):
    """ function to add an interface on edge

    @param options cli options to this script
    @param edge_id edge id on vsm
    @return True/False True - success False - error
    """
    vsm_obj = get_vsm_object(options)
    edge = Edge(vsm_obj, '4.0')
    edge.id = edge_id
    vnics = Vnics(edge)
    vnics_schema = vnics.query()
    active = []*10
    index = 0
    active_nics = 0
    for vnic in vnics_schema.vnics:
       if vnic.isConnected == "true":
          active.append(True)
          active_nics =+ 1
       else:
          active.append(False)
    if active_nics < 10:
       free_index = next((i for i, x in enumerate(active) if not x), None)
       vnic_schema =  VnicSchema()
       vnics_schema =  VnicsSchema()
       vnic_schema = get_vnic(options, free_index)
       vnics_schema.vnics = [vnic_schema]
       print("Creating vnic on edge %s" % edge_id)
       result = vnics.create(vnics_schema)
       if (result[0].response.status != 204):
          r_vars = vars(result[0])
          print("Create vnic error: %s" % result[0].response.reason)
          print ', '.join("%s: %s" % item for item in r_vars.items())
          return False
       range = get_dhcp_range(options, free_index)
       default_gateway = get_primary_ip(options, free_index)
       return create_dhcp_pool(options, vsm_obj, range, default_gateway)
    return True
开发者ID:carriercomm,项目名称:MyProject,代码行数:40,代码来源:nsx_network.py

示例5: get_interface

# 需要导入模块: from edge import Edge [as 别名]
# 或者: from edge.Edge import id [as 别名]
           self.schema_class = 'interfaces_schema.InterfacesSchema'
           return interface_obj.addressGroups[0].primaryAddress

    def get_interface(self):
           self.schema_class = 'interface_schema.InterfaceSchema'
           interface_obj = self.read()
           return interface_obj

if __name__ == '__main__':
    import base_client
    py_dict = {'ipAddress': '10.115.173.172', 'userName': 'root', 'password': 'vmware'}
    vsm_obj = VSM("10.115.173.172:443", "admin", "default")

    # Bulk Create
    edge = Edge(vsm_obj)
    edge.id = "edge-1"
    py_dict = {'interfaces': [{'name': 'lif-vwire-1-20758',
                               'addressgroups':      [{'subnetmask': '255.255.0.0',
                                                       'addresstype': 'primary',
                                                       'primaryaddress': '172.31.1.1'}
                                                     ],
                               'isconnected': 'true',
                               'mtu': '1500',
                               'connectedtoid': 'virtualwire-1',
                               'type': 'internal'
                              }]
              }



    interface_create = Interfaces(edge)
开发者ID:carriercomm,项目名称:MyProject,代码行数:33,代码来源:interfaces.py

示例6: super

# 需要导入模块: from edge import Edge [as 别名]
# 或者: from edge.Edge import id [as 别名]
        super(OSPF, self).__init__()
        self.log.debug("Configuring Ospf on Edge %s" % edge.id)
        self.schema_class = 'OSPF_routing_schema.OSPFSchema'
        self.set_content_type('application/xml')
        self.set_accept_type('application/xml')
        self.auth_type = "vsm"
        if edge is not None:
            self.set_connection(edge.get_connection())
        self.connection.api_header = '/api/4.0'
        self.set_create_endpoint("/edges/" + edge.id + "/routing/config/ospf")

        self.create_as_put = True
        self.id = None

if __name__ == '__main__':
    import base_client
    vsm_obj = VSM("10.24.20.207:443", "admin", "default", "")
    edge = Edge(vsm_obj)
    edge.id = "edge-4"
    SR_client = OSPF(edge)
    py_dict = {
       'enabled': 'true',
       'ospfareas': [{'areaid': '1', 'type': 'nssa',
       'authentication': {'type': 'password', 'value':'pawan'}}],
       'ospfinterfaces': [{'vnic': '1', 'areaid': '1',
       'hellointerval': '10', 'deadinterval': '40',
       'priority': '128', 'cost': '1'}]}
    schema_obj = OSPF_routing_schema.OSPFSchema(py_dict)
    result_obj = SR_client.create(schema_obj)
    print result_obj.get_response_data()
开发者ID:carriercomm,项目名称:MyProject,代码行数:32,代码来源:OSPF_routing.py

示例7: super

# 需要导入模块: from edge import Edge [as 别名]
# 或者: from edge.Edge import id [as 别名]
        @param edge object
        on which static Routing has to be configured
        """
        super(StaticRouting, self).__init__()
        self.log = logger.setup_logging(self.__class__.__name__)
        self.schema_class = 'static_routing_schema.StaticRoutingSchema'
        self.set_content_type('application/xml')
        self.set_accept_type('application/xml')
        self.auth_type = "vsm"
        if edge is not None:
            self.set_connection(edge.get_connection())
        self.connection.api_header = '/api/4.0'
        self.set_create_endpoint("/edges/"+ edge.id + "/routing/config/static")
        self.create_as_put = True
        self.id = None

if __name__ == '__main__':
    import base_client
    vsm_obj = VSM("10.24.20.161:443", "admin", "default", "")

    edge = Edge(vsm_obj)
    edge.id = "edge-9"
    SR_client = StaticRouting(edge)
    py_dict = {
        'staticroutes': [{'network': '80.50.50.0/24',
        'nexthop': '3.3.3.123'}, {'network': '70.50.50.0/24',
        'nexthop': '3.3.3.125'}]}
    schema_obj = static_routing_schema.StaticRoutingSchema(py_dict)
    result_obj = SR_client.create(schema_obj)
    print result_obj.get_response_data()
开发者ID:carriercomm,项目名称:MyProject,代码行数:32,代码来源:static_routing.py

示例8: GlobalRouting

# 需要导入模块: from edge import Edge [as 别名]
# 或者: from edge.Edge import id [as 别名]
class GlobalRouting(vsm_client.VSMClient):
    def __init__(self, edge=None):
        """ Constructor to create Global Routing object
        @param edge object
        on which global Routing has to be configured
        """
        super(GlobalRouting, self).__init__()
        self.log = logger.setup_logging(self.__class__.__name__)
        self.schema_class = 'routing_global_config_schema.RoutingGlobalConfigSchema'
        self.set_content_type('application/xml')
        self.set_accept_type('application/xml')
        self.auth_type = "vsm"
        if edge is not None:
            self.set_connection(edge.get_connection())
        self.connection.api_header = '/api/4.0'
        self.set_create_endpoint("/edges/" + edge.id + "/routing/config/global")
        self.create_as_put = True
        self.id = None

if __name__ == '__main__':
    import base_client
    vsm_obj = VSM("10.24.20.24:443", "admin", "default", "")
    edge = Edge(vsm_obj)
    edge.id = "edge-5"
    SR_client = GlobalRouting(edge)
    py_dict = { 'ecmp': 'true'}
    schema_obj = routing_global_config_schema.RoutingGlobalConfigSchema(py_dict)
    result_obj = SR_client.create(schema_obj)
    print result_obj.get_response_data()

开发者ID:carriercomm,项目名称:MyProject,代码行数:31,代码来源:global_routing.py


注:本文中的edge.Edge.id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。