Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions readme.md → README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ the CLI documentation to find the pass-through arguments a given interaction req
Setup-Prerequisites
1. You will require certain pip packages, use the following command to install them when at the root folder of the repository.

```editorconfig
```bash
sudo pip install -r requirements.txt
```
2. Download and install the OpenShift [command-line Tools](https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/) needed to access your OpenShift cluster.
Expand Down Expand Up @@ -111,7 +111,7 @@ with oc.project('openshift-infra'), oc.timeout(10*60):
for owner in pod_model.metadata.ownerReferences: # ownerReferences == oc.Missing if not present in resource
# elements of a Model are also instances of Model or ListModel
if owner.kind is not oc.Missing: # Compare as singleton
print ' pod owned by a {}'.format(owner.kind) # e.g. pod was created by a StatefulSet
print(' pod owned by a {}'.format(owner.kind)) # e.g. pod was created by a StatefulSet

```

Expand All @@ -127,10 +127,10 @@ used again and again to select rows from a database.
project_selector = oc.selector("projects")

# Print the qualified name (i.e. "kind/name") of each resource selected.
print "Project names: " + str(project_selector.qnames())
print("Project names: " + project_selector.qnames())

# Count the number of projects on the server.
print "Number of projects: " + str(project_selector.count_existing())
print("Number of projects: " + project_selector.count_existing())

# Selectors can also be created with a list of names.
sa_selector = oc.selector(["serviceaccount/deployer", "serviceaccount/builder"])
Expand All @@ -143,7 +143,7 @@ sa_selector.label({"mylabel" : "myvalue"})
sa_label_selector = oc.selector("sa", labels={"mylabel":"myvalue"})

# We should find the service accounts we just labeled.
print("Found labeled serviceaccounts: " + str(sa_label_selector.names()))
print("Found labeled serviceaccounts: " + sa_label_selector.names())

# Create a selector for a set of kinds.
print(oc.selector(['dc', 'daemonset']).describe())
Expand All @@ -169,7 +169,7 @@ projects_sel = oc.selector("projects")
# which model the selected resources.
projects = projects_sel.objects()

print("Selected " + str(len(projects)) + " projects")
print("Selected " + len(projects) + " projects")

# Let's store one of the project APIObjects for easy access.
project = projects[0]
Expand Down Expand Up @@ -306,7 +306,7 @@ with oc.tracking() as tracker:
print('Error acquiring current username')

# Print out details about the invocations made within this context.
print tracker.get_result()
print(tracker.get_result())
```

In this case, the tracking output would look something like:
Expand Down Expand Up @@ -385,10 +385,10 @@ def node_is_ready(node):
return ready


print "Waiting for up to 15 minutes for at least 6 nodes to be ready..."
print("Waiting for up to 15 minutes for at least 6 nodes to be ready...")
with oc.timeout(15 * 60):
oc.selector('nodes').until_all(6, success_func=node_is_ready)
print "All detected nodes are reporting ready"
print("All detected nodes are reporting ready")
```

You will be able to see in `tracking` context results that a timeout occurred for an affected
Expand All @@ -404,10 +404,10 @@ context information.
with oc.api_server('https:///....'): # use the specified api server for nested oc invocations.

with oc.token('abc..'): # --server=... --token=abc... will be included in inner oc invocations.
print "Current project: " + oc.get_project_name()
print("Current project: " + oc.get_project_name())

with oc.token('def..'): # --server=... --token=def... will be included in inner oc invocations.
print "Current project: " + oc.get_project_name()
print("Current project: " + oc.get_project_name())
```

You can control the loglevel specified for `oc` invocations.
Expand Down Expand Up @@ -443,7 +443,7 @@ appropriate to the target client host.
```python
with openshift.client_host(hostname="my.cluster.com", username="root", auto_add_host=True):
# oc invocations will take place on my.cluster.com host as the root user.
print "Current project: " + oc.get_project_name()
print("Current project: " + oc.get_project_name())
```

Using this model, your Python script will run exactly where you launch it, but all oc invocations will
Expand Down
50 changes: 50 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/python

from setuptools import setup, find_packages


def get_requirements(filename="requirements.txt"):
"""Extract requirements from a pip formatted requirements file."""

with open(filename, "r") as requirements_file:
return requirements_file.read().splitlines()


def get_long_description():
"""Returns README.md content."""
return open("README.md", "r").read()


setup(
name="openshift-client",
version="0.1.0",
author="Justin Pierce",
author_email="jupierce@redhat.com",
maintainer="Brad Williams",
maintainer_email="brawilli@redhat.com",
url="https://github.com/openshift/openshift-client-python",
description="OpenShift python client",
packages=find_packages(include="openshift"),
package_dir={"": "packages"},
install_requires=get_requirements(),
keywords=["OpenShift"],
include_package_data=True,
data_files=[
("requirements.txt", ["requirements.txt"]),
],
long_description=get_long_description(),
long_description_content_type="text/markdown",
classifiers=[
"Development Status :: 4 - Beta",
"Topic :: Utilities",
"Intended Audience :: Developers",
"Intended Audience :: Information Technology",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
],
)