Skip to content

Commit

Permalink
add cli entry
Browse files Browse the repository at this point in the history
  • Loading branch information
mayn committed Jun 6, 2018
1 parent 78216ee commit ba4410b
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 46 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
*.idea
.tox
.pytest_cache
dist
.cache
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
v0.0.1 First working version
v0.2.0 python 3 compatibility, add cli entrypoint
9 changes: 0 additions & 9 deletions CustomInstall.py

This file was deleted.

9 changes: 4 additions & 5 deletions License2Deploy/AWSConn.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/python

import boto.ec2 as ec2
import boto.ec2.autoscale as a
import boto.ec2.elb as elb
Expand All @@ -8,6 +6,7 @@
import logging
import yaml


class AWSConn(object):

@staticmethod
Expand All @@ -20,7 +19,7 @@ def aws_conn_auto(region, profile='default'):

@staticmethod
def aws_conn_ec2(region, profile='default'):
try:
try:
conn = ec2.connect_to_region(region, profile_name=profile)
return conn
except Exception as e:
Expand All @@ -36,7 +35,7 @@ def aws_conn_elb(region, profile='default'):

@staticmethod
def aws_conn_cloudwatch(region, profile='default'):
try:
try:
conn = cloudwatch.connect_to_region(region, profile_name=profile)
return conn
except Exception as e:
Expand All @@ -51,7 +50,7 @@ def get_boto3_client(client_type, region, profile='default', session=None):
@staticmethod
def load_config(config):
with open(config, 'r') as stream:
return yaml.load(stream)
return yaml.safe_load(stream)

@staticmethod
def determine_region(reg):
Expand Down
1 change: 0 additions & 1 deletion License2Deploy/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
#
3 changes: 1 addition & 2 deletions License2Deploy/rolling_deploy.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python

import logging
import argparse
from sys import exit, argv
Expand All @@ -8,6 +6,7 @@
from .set_logging import SetLogging
from retry.api import retry_call


class RollingDeploy(object):

MAX_RETRIES = 10
Expand Down
5 changes: 1 addition & 4 deletions License2Deploy/set_logging.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
#!/usr/bin/python

import logging


class SetLogging(object):

@staticmethod
def setup_logging(): # pragma: no cover
logging.basicConfig(format='%(asctime)s: %(levelname)s: %(message)s',level=logging.INFO)
logging.info("Begin Logging...")

if __name__ == '__main__':
SetLogging.setup_logging() # pragma: no cover
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Rolling deploys for AWS AutoScale Groups
What is License2Deploy?
==================

License2Deploy is an automated solution for rolling deployments in AWS written in python.
License2Deploy is an automated solution for rolling deployments in AWS written in python.

The rolling deployment will:
- Double your instances in your autoscale group
Expand All @@ -20,7 +20,7 @@ The rolling deployment will:
Usage
==================
```
usage: rolling_deploy.py [-h] -e ENV -p PROJECT -b BUILD_NUM -a AMI_ID
usage: rolling_deploy [-h] -e ENV -p PROJECT -b BUILD_NUM -a AMI_ID
[-P PROFILE] [-c CONFIG] [-s STACK_NAME] [-f FORCE_REDEPLOY]
[-C CREATION_WAIT] [-r READY_WAIT] [-H HEALTH_WAIT] [-o ONLY_NEW_WAIT]
Expand Down Expand Up @@ -72,7 +72,7 @@ There are a few requirements in order for the automated rolling deployments to w
4. All instances in the autoscale group need to be tagged with a build number
* This is an important step as when the script runs, it will differentiate the old builds
from the new builds based off of the build number that is passed in as a command line parameter
5. The credentials for the user need to be in the ~/.aws/credentials file and if not passed in as a
5. The credentials for the user need to be in the ~/.aws/credentials file and if not passed in as a
command line argument, the script will look at the 'default' profile.
6. The script needs the AMI ID of the instances that will be built.
* The reason for the AMI ID is to ensure that if it was just created, it is not in a pending state
Expand All @@ -84,8 +84,10 @@ There are a few requirements in order for the automated rolling deployments to w
Development
============

python setup.py install
To run unit tests:

python setup.py test
```sh
$ tox
```

python License2Deploy/rolling_deploy.py
37 changes: 20 additions & 17 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#!/usr/bin/python

import os
import sys
from CustomInstall import CustomInstall
from setuptools import setup, Command
from setuptools import setup

install_requires = [
"boto",
Expand All @@ -25,23 +21,30 @@
'coverage',
]


def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()


setup(
name = "License2Deploy",
version = "0.0.1",
author = "Dun and Bradstreet",
author_email = "license2deploy@dandb.com",
description = ("Rolling deploys by changing desired amount of instances AWS EC2 Autoscale Group"),
license = "GPLv3",
keywords = "AWS EC2 AutoScale Group AMI desired capacity",
url = "https://github.com/dandb/License2Deploy",
name="License2Deploy",
version="0.2.0",
author="Dun and Bradstreet",
author_email="license2deploy@dandb.com",
description="Rolling deploys by changing desired amount of instances AWS EC2 Autoscale Group",
license="GPLv3",
keywords="AWS EC2 AutoScale Group AMI desired capacity",
url="https://github.com/dandb/License2Deploy",
packages=['License2Deploy'],
entry_points={
'console_scripts': [
'rolling_deploy = License2Deploy.rolling_deploy:main'
]
},
include_package_data=True,
install_requires = install_requires,
tests_require = tests_require,
install_requires=install_requires,
tests_require=tests_require,
extras_require={'test': tests_require},
long_description=read('README.md') + '\n\n' + read('CHANGES'),
test_suite = 'tests'
long_description=read('README.md'),
test_suite='tests'
)
1 change: 0 additions & 1 deletion tests/cloudformation_client_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python
import os
import placebo
from boto3.session import Session
Expand Down
2 changes: 0 additions & 2 deletions tests/rolling_deploy_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python

import sys
import pytest
import unittest
Expand Down

0 comments on commit ba4410b

Please sign in to comment.