Remove some comments and things that are not applicable

This commit is contained in:
Peter Jausovec 2017-01-18 16:11:00 -08:00
Родитель 7f2beaf931
Коммит 1771dd1f2d
4 изменённых файлов: 24 добавлений и 24 удалений

Просмотреть файл

@ -85,10 +85,12 @@ class ACSClient(object):
log.setLevel(logging.INFO)
forwarder = SSHTunnelForwarder(
ssh_address_or_host=(self.cluster_info.host, int(self.cluster_info.port)),
ssh_address_or_host=(self.cluster_info.host,
int(self.cluster_info.port)),
ssh_username=self.cluster_info.username,
ssh_pkey=self._get_private_key(),
remote_bind_address=('localhost', self.cluster_info.get_api_endpoint_port()),
remote_bind_address=(
'localhost', self.cluster_info.get_api_endpoint_port()),
local_bind_address=('0.0.0.0', int(local_port)),
logger=log)
forwarder.start()
@ -109,7 +111,9 @@ class ACSClient(object):
"""
if self.is_direct:
url = '{}:{}/{}'.format(
self.cluster_info.api_endpoint, self.cluster_info.get_api_endpoint_port(), path.strip('/'))
self.cluster_info.api_endpoint,
self.cluster_info.get_api_endpoint_port(),
path.strip('/'))
else:
local_port = self._setup_tunnel_server()
url = 'http://127.0.0.1:{}/{}'.format(str(local_port), path)
@ -134,14 +138,11 @@ class ACSClient(object):
else:
response = method_to_call(
url, data, headers=headers, **kwargs)
# if response.status_code > 400:
# raise Exception('Call to "%s" failed with: %s', url, response.text)
return response
def get_request(self, path):
"""
Makes a GET request to an endpoint (localhost:80 on the cluster)
Makes a GET request to an endpoint on the cluster
:param path: Path part of the URL to make the request to
:type path: String
"""
@ -149,7 +150,7 @@ class ACSClient(object):
def delete_request(self, path):
"""
Makes a DELETE request to an endpoint (localhost:80 on the cluster)
Makes a DELETE request to an endpoint on the cluster
:param path: Path part of the URL to make the request to
:type path: String
"""
@ -157,7 +158,7 @@ class ACSClient(object):
def post_request(self, path, post_data):
"""
Makes a POST request to an endpoint (localhost:80 on the cluster)
Makes a POST request to an endpoint on the cluster
:param path: Path part of the URL to make the request to
:type path: String
"""
@ -165,7 +166,7 @@ class ACSClient(object):
def put_request(self, path, put_data=None, **kwargs):
"""
Makes a POST request to Marathon endpoint (localhost:80 on the cluster)
Makes a POST request to an endpoint on the cluster)
:param path: Path part of the URL to make the request to
:type path: String
"""

Просмотреть файл

@ -8,6 +8,7 @@ from clusterinfo import ClusterInfo
from registryinfo import RegistryInfo
from groupinfo import GroupInfo
class VstsLogFormatter(logging.Formatter):
error_format = logging.Formatter('##[error]%(message)s')
warning_format = logging.Formatter('##[warning]%(message)s')
@ -23,6 +24,7 @@ class VstsLogFormatter(logging.Formatter):
return self.debug_format.format(record)
return self.default_format.format(record)
def get_arg_parser():
"""
Sets up the argument parser
@ -44,8 +46,6 @@ def get_arg_parser():
help='[required] Application group qualifier')
parser.add_argument('--group-version',
help='[required] Application group version')
parser.add_argument('--minimum-health-capacity', type=int,
help='[required] Minimum health capacity')
parser.add_argument('--registry-host',
help='Registry host (e.g. myregistry.azurecr-test.io:1234)')
@ -70,6 +70,7 @@ def get_arg_parser():
action='store_true')
return parser
def process_arguments():
"""
Makes sure required arguments are provided
@ -89,6 +90,7 @@ def process_arguments():
arg_parser.error('argument --minimum-health-capacity is required')
return args
def init_logger(verbose):
"""
Initializes the logger and sets the custom formatter for VSTS
@ -115,14 +117,16 @@ if __name__ == '__main__':
registry_info = RegistryInfo(
arguments.registry_host, arguments.registry_username, arguments.registry_password)
group_info = GroupInfo(arguments.group_name, arguments.group_qualifier, arguments.group_version)
group_info = GroupInfo(arguments.group_name,
arguments.group_qualifier, arguments.group_version)
try:
with dockercomposeparser.DockerComposeParser(
arguments.compose_file, cluster_info, registry_info, group_info,
arguments.minimum_health_capacity) as compose_parser:
arguments.compose_file, cluster_info, registry_info, group_info) as compose_parser:
compose_parser.deploy()
sys.exit(0)
except Exception as deployment_exc:
import traceback
traceback.print_exc()
logging.error('Error occurred during deployment: %s', deployment_exc)
sys.exit(1)

Просмотреть файл

@ -14,8 +14,7 @@ from ingress_controller import IngressController
class DockerComposeParser(object):
def __init__(self, compose_file, cluster_info, registry_info, group_info,
minimum_health_capacity):
def __init__(self, compose_file, cluster_info, registry_info, group_info):
self.cleanup_needed = False
self._ensure_docker_compose(compose_file)
@ -26,8 +25,6 @@ class DockerComposeParser(object):
self.registry_info = registry_info
self.group_info = group_info
self.minimum_health_capacity = minimum_health_capacity
self.acs_client = acsclient.ACSClient(self.cluster_info)
self.kubernetes = Kubernetes(self.acs_client)
self.ingress_controller = IngressController(self.kubernetes)
@ -83,7 +80,7 @@ class DockerComposeParser(object):
def _parse_compose(self):
"""
Parses the docker-compose file and returns the initial marathon.json file
Parses the docker-compose file and returns the list of all deployments
"""
all_deployments = []
needs_ingress_controller = False

Просмотреть файл

@ -7,8 +7,7 @@ class PortParser(object):
def parse_private_ports(self):
"""
Parses the 'expose' key in the docker-compose file and returns a
list of tuples with port numbers. These tuples are used
to create portMappings (blue/green only) in the marathon.json file
list of tuples with port numbers.
"""
port_tuple_list = []
@ -26,8 +25,7 @@ class PortParser(object):
def parse_internal_ports(self):
"""
Parses the 'ports' key in the docker-compose file and returns a list of
tuples with port numbers. These tuples are used to create
portMappings (blue/green and cyan) in the marathon.json file
tuples with port numbers.
"""
port_tuple_list = []