Skip to content

Commit

Permalink
update for pep8
Browse files Browse the repository at this point in the history
  • Loading branch information
DjangoPeng committed Sep 26, 2017
1 parent cc8e38b commit c49db53
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions examples/deployment_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

DEPLOYMENT_NAME = "nginx-deployment"


def create_deployment_object():
# Instantiate an empty deployment object
deployment = client.ExtensionsV1beta1Deployment()
Expand All @@ -44,23 +45,26 @@ def create_deployment_object():

return deployment


def create_deployment(api_instance, deployment):
# Create deployement
api_response = api_instance.create_namespaced_deployment(
body=deployment,
namespace="default")
body=deployment,
namespace="default")
print("Deployment created. status='%s'" % str(api_response.status))


def update_deployment(api_instance, deployment):
# Update container image
deployment.container.image = "nginx:1.9.1"
# Update the deployment
api_response = api_instance.replace_namespaced_deployment(
name=DEPLOYMENT_NAME,
namespace="default",
body=deployment)
name=DEPLOYMENT_NAME,
namespace="default",
body=deployment)
print("Deployment updated. status='%s'" % str(api_response.status))


def roll_back_deployment(api_instance):
# Instanciate an empty DeploymentRollback object
rollback = client.ExtensionsV1beta1DeploymentRollback()
Expand All @@ -73,18 +77,19 @@ def roll_back_deployment(api_instance):
rollback.rollback_to.revision = 0
# Execute the rollback
api_response = api_instance.create_namespaced_deployment_rollback(
name=DEPLOYMENT_NAME,
namespace="default",
body=rollback)
name=DEPLOYMENT_NAME,
namespace="default",
body=rollback)
print("Deployment rolled back. status='%s'" % str(api_response.status))


def delete_deployment(api_instance):
# Delete deployment
api_response = api_instance.delete_namespaced_deployment(
name=DEPLOYMENT_NAME,
namespace="default",
client.V1DeleteOptions(propagation_policy='Foreground',
grace_period_seconds=5))
name=DEPLOYMENT_NAME,
namespace="default",
client.V1DeleteOptions(propagation_policy='Foreground',
grace_period_seconds=5))
print("Deployment deleted. status='%s'" % str(api_response.status))


Expand All @@ -106,5 +111,6 @@ def main():

delete_deployment(extensions_v1beta1)


if __name__ == '__main__':
main()

0 comments on commit c49db53

Please sign in to comment.