Skip to main content

A Python client for the Weblogic REST API

Project description

https://travis-ci.org/magnuswatn/wls-rest-python.svg?branch=master https://codecov.io/gh/magnuswatn/wls-rest-python/branch/master/graph/badge.svg https://badge.fury.io/py/wls-rest-python.svg https://img.shields.io/badge/code%20style-black-000000.svg

This is a Python client for Weblogics RESTful Management Services. It takes care of some of the quirks with the API, without being so closely linked that it becomes limiting.

It creates Python objects dynamically based on the response from the server, so that it’s easy to quickly write useful and Pythonic scripts.

It’s tested against 12.2.1.3, but should work fine with all 12c R2 releases.

Installation

$ pipenv install wls-rest-python

Example usage

Explore the API, change properties and undeploy applications:

>>> from wls_rest_python import WLS
>>>
>>> wls = WLS('https://wls.example.com:7001', 'weblogic', 'welcome1')
>>>
>>> dir(wls.edit.batchConfig)
['canonical', 'dynamicallyCreated', 'id', 'identity', 'name', 'notes','parent',
'schemaName', 'self', 'tags', 'type']
>>>
>>> wls.edit.servers.myServer.nativeIOEnabled
True
>>> wls.edit.servers.myServer.update(nativeIOEnabled=False)
>>> wls.edit.servers.myServer.nativeIOEnabled
False
>>> wls.domainRuntime.deploymentManager.appDeploymentRuntimes.myApp.getState(
... target='myServer')
{'return': 'STATE_ACTIVE'}
>>>
>>> wls.domainRuntime.deploymentManager.appDeploymentRuntimes.myApp.undeploy()
>>>

Start all managed servers asynchronously:

from wls_rest_python import WLS

wls = WLS('https://wls.example.com:7001', 'weblogic', 'welcome1')

admin_server_name = wls.edit.adminServerName

running_jobs = []
for server in wls.domainRuntime.serverLifeCycleRuntimes:
    if server.name != admin_server_name:
        running_jobs.append(server.start(prefer_async=True))

while running_jobs:
    for job in running_jobs:
        if job.completed:
            running_jobs.remove(job)
    time.sleep(10)

Undeploy all applications and deploy a new one:

import json
from wls_rest_python import WLS

wls = WLS('https://wls.example.com:7001', 'weblogic', 'welcome1')

for deployment in wls.edit.appDeployments:
    deployment.delete()

deployment_model = {
    'name': 'myWebApp',
    'targets': [
        {'identity': [
            'servers',
            'myServer'
            ]
        }
    ]
}

deployment_info = {
    'model': (None, json.dumps(deployment_model)),
    'sourcePath': open('/u01/wars/myWebApp.war', 'rb'),
    'planPath': open('/u01/wars/myWebAppPlan.xml', 'rb')
}
wls.edit.appDeployments.create(files=deployment_info)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wls-rest-python-0.1.5.tar.gz (6.3 kB view details)

Uploaded Source

File details

Details for the file wls-rest-python-0.1.5.tar.gz.

File metadata

  • Download URL: wls-rest-python-0.1.5.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.2 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.3

File hashes

Hashes for wls-rest-python-0.1.5.tar.gz
Algorithm Hash digest
SHA256 a26df32737acf99b995e0fae13ac2ef25310e598e1904c181682632f2869d531
MD5 11ccd94c3ff0fc86ca34ccb7bf78d294
BLAKE2b-256 19ffa0023e299d04884adb98396fd961ae242f72e98ea59c985b5d43a957b138

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page