示例#1
0
def client_test():
    print 'testing ifmap client (this requires a running server)'
    mapclient = client("https://127.0.0.1:8443", 'test', 'test', namespaces)

    result = mapclient.call('newSession', NewSessionRequest())
    mapclient.set_session_id(newSessionResult(result).get_session_id())
    mapclient.set_publisher_id(newSessionResult(result).get_publisher_id())

    meta = str(Metadata('role', 'employee', {'ifmap-cardinality':'multiValue'}))
    pubreq = PublishRequest(mapclient.get_session_id(), str(PublishUpdateOperation(id1=str(IPAddress("10.0.0.1")), metadata=meta, lifetime='forever')))
    result = mapclient.call('publish', pubreq)

    searchreq = SearchRequest(mapclient.get_session_id(), str(IPAddress("10.0.0.1")), validation="None")
    result = mapclient.call('search', searchreq)

    subreq = SubscribeRequest(mapclient.get_session_id(), operations=str(SubscribeUpdateOperation('subscription-1',str(IPAddress("10.0.0.1")))))
    result = mapclient.call('subscribe', subreq)

    pollreq = PollRequest(mapclient.get_session_id())
    result = mapclient.call('poll', pollreq)

    subreq = SubscribeRequest(mapclient.get_session_id(), operations=str(SubscribeDeleteOperation('subscription-1')))
    result = mapclient.call('subscribe', subreq)

    purgereq = PurgeRequest(mapclient.get_session_id(), mapclient.get_publisher_id())
    result = mapclient.call('purge', purgereq)

    endreq = EndSessionRequest(mapclient.get_session_id())
    result = mapclient.call('endSession', endreq)
def ifmap_server_connect(args):
    _CLIENT_NAMESPACES = {
        'env':  _SOAP_XSD,
        'ifmap':  _IFMAP_XSD,
        'meta':  _IFMAP_META_XSD,
        _CT_NS:  _CONTRAIL_XSD
    }

    ssl_options = None
    if args.use_certs:
        ssl_options = {
            'keyfile': args.keyfile,
            'certfile': args.certfile,
            'ca_certs': args.ca_certs,
            'cert_reqs': ssl.CERT_REQUIRED,
            'ciphers': 'ALL'
        }
    return client(("%s" % (args.ifmap_server_ip),
                   "%s" % (args.ifmap_server_port)),
                  args.ifmap_username, args.ifmap_password,
                  _CLIENT_NAMESPACES, ssl_options)
示例#3
0
def client_test():
    print 'testing ifmap client (this requires a running server)'
    mapclient = client("https://127.0.0.1:443", 'test', 'test', namespaces)

    result = mapclient.call('newSession', NewSessionRequest())
    mapclient.set_session_id(newSessionResult(result).get_session_id())
    mapclient.set_publisher_id(newSessionResult(result).get_publisher_id())

    meta = str(Metadata('iperms', 'rwxrwxrwx',
                        {'ifmap-cardinality':'multiValue'}, ns_prefix = "ct",
                        elements = '<ct:mperms>rwxrwxrwx</ct:mperms>'))
    pubreq = PublishRequest(mapclient.get_session_id(),
                 str(PublishUpdateOperation(
                        id1=str(Identity(name = "ct:cloud", type = "other",
                                         other_type = "extended")),
                        metadata=meta,
                        lifetime='forever')))
    result = mapclient.call('publish', pubreq)

    meta = str(Metadata('iperms', 'rwxrwxrwx',
                        {'ifmap-cardinality':'multiValue'}, ns_prefix = "ct",
                        elements = '<ct:mperms>rwxrwxrwx</ct:mperms>'))
    pubreq = PublishRequest(mapclient.get_session_id(),
                 str(PublishUpdateOperation(
                        id1=str(Identity(name = "ct:tenant:infra", type = "other",
                                         other_type = "extended")),
                        metadata=meta,
                        lifetime='forever')))
    result = mapclient.call('publish', pubreq)

    meta = str(Metadata('belongs-to', '',
                       {'ifmap-cardinality':'singleValue'}, ns_prefix = "ct",
                       elements = '<ct:mperms>rwxrwxrwx</ct:mperms>'))
    pubreq = PublishRequest(mapclient.get_session_id(),
                 str(PublishUpdateOperation(
                        id1=str(Identity(name = "ct:cloud", type = "other",
                                         other_type = "extended")),
                        id2=str(Identity(name = "ct:tenant:infra", type = "other",
                                         other_type = "extended")),
                        metadata=meta,
                        lifetime='forever')))
    result = mapclient.call('publish', pubreq)

    #meta = str(Metadata('role', 'employee', {'ifmap-cardinality':'multiValue'}))
    #pubreq = PublishRequest(mapclient.get_session_id(), str(PublishUpdateOperation(id1=str(IPAddress("10.0.0.1")), metadata=meta, lifetime='forever')))
    #result = mapclient.call('publish', pubreq)

    #searchreq = SearchRequest(mapclient.get_session_id(), str(IPAddress("10.0.0.1")), validation="None")
    #result = mapclient.call('search', searchreq)

    #subreq = SubscribeRequest(mapclient.get_session_id(), operations=str(SubscribeUpdateOperation('subscription-1',str(IPAddress("10.0.0.1")))))
    #result = mapclient.call('subscribe', subreq)

    #pollreq = PollRequest(mapclient.get_session_id())
    #result = mapclient.call('poll', pollreq)

    #subreq = SubscribeRequest(mapclient.get_session_id(), operations=str(SubscribeDeleteOperation('subscription-1')))
    #result = mapclient.call('subscribe', subreq)

    #purgereq = PurgeRequest(mapclient.get_session_id(), mapclient.get_publisher_id())
    #result = mapclient.call('purge', purgereq)

    #endreq = EndSessionRequest(mapclient.get_session_id())
    #result = mapclient.call('endSession', endreq)
    import time
    while True:
        time.sleep(10)