Skip to content

Commit

Permalink
Merge pull request #23 from chaturanga50/bugfix/load-balanced-server-…
Browse files Browse the repository at this point in the history
…instance-id-issue-18

Bugfix/load balanced server instance id issue 18
  • Loading branch information
chaturanga50 authored Jul 19, 2019
2 parents ceaa7ff + 010fa34 commit e351aeb
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 51 deletions.
3 changes: 0 additions & 3 deletions modules/common_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ def get_status_instances_main(region, deploymentid, instances, success_count, sk
summary(success_count, skipped_count, failed_count)
print("\nCheck the deployment logs...\n")
get_log_url(describe_deployment['Commands'])
return describe_deployment


def get_status_instances_sub(region, deploymentid, instances, success_count, fail_skip_count, success_fail_count):
Expand All @@ -81,7 +80,6 @@ def get_status_instances_sub(region, deploymentid, instances, success_count, fai
summary_fail_skipped(success_count, fail_skip_count, success_fail_count)
print("\nCheck the deployment logs...\n")
get_log_url(describe_deployment['Commands'])
return describe_deployment


def get_status(deploymentid, region, instances):
Expand Down Expand Up @@ -126,7 +124,6 @@ def get_status(deploymentid, region, instances):
elif int(success_count) + int(failed_count) == int(instances):
success_fail_count = int(instances)
get_status_instances_sub(region, deploymentid, instances, success_count, fail_skip_count, success_fail_count)
return describe_deployment
except Exception as e:
print(e)

Expand Down
20 changes: 10 additions & 10 deletions modules/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ def deploy_with_layer(region, stack, layer, app, custom_json=None):
get_intance_count = client.describe_instances(
LayerId=layer
)
all_instance_ids = []
for instanceid in get_intance_count['Instances']:
ec2id = instanceid['Ec2InstanceId']
all_instance_ids.append(ec2id)
instances = len(all_instance_ids)
all_instance_status = []
for instancestatus in get_intance_count['Instances']:
ec2status = instancestatus['Status']
all_instance_status.append(ec2status)
instances = len(all_instance_status)

deploymentid = run_recipes['DeploymentId']
# sending describe command to get status""" """
Expand Down Expand Up @@ -86,11 +86,11 @@ def deploy_without_layer(region, stack, app, custom_json=None):
get_intance_count = client.describe_instances(
StackId=stack
)
all_instance_ids = []
for instanceid in get_intance_count['Instances']:
ec2id = instanceid['Ec2InstanceId']
all_instance_ids.append(ec2id)
instances = len(all_instance_ids)
all_instance_status = []
for instancestatus in get_intance_count['Instances']:
ec2status = instancestatus['Status']
all_instance_status.append(ec2status)
instances = len(all_instance_status)

deploymentid = run_recipes['DeploymentId']
# sending describe command to get status""" """
Expand Down
20 changes: 10 additions & 10 deletions modules/execute_recipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ def run_recipes_with_layer(region, stack, layer, cookbook, custom_json=None):
get_intance_count = client.describe_instances(
LayerId=layer
)
all_instance_ids = []
for instanceid in get_intance_count['Instances']:
ec2id = instanceid['Ec2InstanceId']
all_instance_ids.append(ec2id)
instances = len(all_instance_ids)
all_instance_status = []
for instancestatus in get_intance_count['Instances']:
ec2status = instancestatus['Status']
all_instance_status.append(ec2status)
instances = len(all_instance_status)
# deployment id
deploymentid = run_recipes['DeploymentId']
# sending describe command to get status""" """
Expand Down Expand Up @@ -92,11 +92,11 @@ def run_recipes_without_layer(region, stack, cookbook, custom_json=None):
get_intance_count = client.describe_instances(
StackId=stack
)
all_instance_ids = []
for instanceid in get_intance_count['Instances']:
ec2id = instanceid['Ec2InstanceId']
all_instance_ids.append(ec2id)
instances = len(all_instance_ids)
all_instance_status = []
for instancestatus in get_intance_count['Instances']:
ec2status = instancestatus['Status']
all_instance_status.append(ec2status)
instances = len(all_instance_status)
# deployment id
deploymentid = run_recipes['DeploymentId']
# sending describe command to get status""" """
Expand Down
20 changes: 10 additions & 10 deletions modules/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ def setup_with_layer(region, stack, layer):
get_intance_count = client.describe_instances(
LayerId=layer
)
all_instance_ids = []
for instanceid in get_intance_count['Instances']:
ec2id = instanceid['Ec2InstanceId']
all_instance_ids.append(ec2id)
instances = len(all_instance_ids)
all_instance_status = []
for instancestatus in get_intance_count['Instances']:
ec2status = instancestatus['Status']
all_instance_status.append(ec2status)
instances = len(all_instance_status)

deploymentid = run_setup['DeploymentId']
# sending describe command to get status""" """
Expand Down Expand Up @@ -71,11 +71,11 @@ def setup_without_layer(region, stack):
get_intance_count = client.describe_instances(
StackId=stack
)
all_instance_ids = []
for instanceid in get_intance_count['Instances']:
ec2id = instanceid['Ec2InstanceId']
all_instance_ids.append(ec2id)
instances = len(all_instance_ids)
all_instance_status = []
for instancestatus in get_intance_count['Instances']:
ec2status = instancestatus['Status']
all_instance_status.append(ec2status)
instances = len(all_instance_status)

deploymentid = run_setup['DeploymentId']
# sending describe command to get status""" """
Expand Down
20 changes: 10 additions & 10 deletions modules/update_custom_cookbooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ def update_custom_cookbooks_with_layer(region, stack, layer):
get_intance_count = client.describe_instances(
LayerId=layer
)
all_instance_ids = []
for instanceid in get_intance_count['Instances']:
ec2id = instanceid['Ec2InstanceId']
all_instance_ids.append(ec2id)
instances = len(all_instance_ids)
all_instance_status = []
for instancestatus in get_intance_count['Instances']:
ec2status = instancestatus['Status']
all_instance_status.append(ec2status)
instances = len(all_instance_status)

deploymentid = run_update_custom_cookbooks['DeploymentId']
# sending describe command to get status""" """
Expand Down Expand Up @@ -73,11 +73,11 @@ def update_custom_cookbooks_without_layer(region, stack):
get_intance_count = client.describe_instances(
StackId=stack
)
all_instance_ids = []
for instanceid in get_intance_count['Instances']:
ec2id = instanceid['Ec2InstanceId']
all_instance_ids.append(ec2id)
instances = len(all_instance_ids)
all_instance_status = []
for instancestatus in get_intance_count['Instances']:
ec2status = instancestatus['Status']
all_instance_status.append(ec2status)
instances = len(all_instance_status)

deploymentid = run_update_custom_cookbooks['DeploymentId']
# sending describe command to get status""" """
Expand Down
2 changes: 1 addition & 1 deletion opsworks-cli
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ArgParser(argparse.ArgumentParser):
def OpsWorksCLI():
parser = ArgParser()
subparser = parser.add_subparsers(dest='subcommand')
parser.add_argument('-v', '--version', action='version', version='%(prog)s 0.5.1')
parser.add_argument('-v', '--version', action='version', version='%(prog)s 0.5.2')
execute_recipes = subparser.add_parser('execute-recipes')
execute_recipes.add_argument('-r', '--region', required=True, dest='region', help='add the region you wanted to run this on [required]')
execute_recipes.add_argument('-s', '--stack', required=True, dest='stack', help='add the opsworks stack ID [required]')
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
],
packages=find_packages(),
include_package_data=True,
version="0.5.1",
version="0.5.2",
install_requires=[
'boto3',
'prettytable'
Expand Down
12 changes: 6 additions & 6 deletions test/test_common_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_get_status_success(self):
with open('test/json_data/describe_commands_success.json') as json_file:
data = json.load(json_file)
boto_describe_commands.return_value = data
modules.get_status('DEPLOYMENTID', 'REGION', '1')
modules.get_status('DEPLOYMENTID', 'REGION', '0')
self.assertEqual(mock_client.call_count, 1)

def test_get_status_skipped(self):
Expand All @@ -24,7 +24,7 @@ def test_get_status_skipped(self):
with open('test/json_data/describe_commands_skipped.json') as json_file:
data = json.load(json_file)
boto_describe_commands.return_value = data
modules.get_status('DEPLOYMENTID', 'REGION', '1')
modules.get_status('DEPLOYMENTID', 'REGION', '0')
self.assertEqual(mock_client.call_count, 1)

def test_get_status_failed(self):
Expand All @@ -33,7 +33,7 @@ def test_get_status_failed(self):
with open('test/json_data/describe_commands_failed.json') as json_file:
data = json.load(json_file)
boto_describe_commands.return_value = data
modules.get_status('DEPLOYMENTID', 'REGION', '1')
modules.get_status('DEPLOYMENTID', 'REGION', '0')
self.assertEqual(mock_client.call_count, 1)

def test_get_status_success_skip(self):
Expand All @@ -42,7 +42,7 @@ def test_get_status_success_skip(self):
with open('test/json_data/describe_commands_success_skiped.json') as json_file:
data = json.load(json_file)
boto_describe_commands.return_value = data
modules.get_status('DEPLOYMENTID', 'REGION', '2')
modules.get_status('DEPLOYMENTID', 'REGION', '0')
self.assertEqual(mock_client.call_count, 1)

def test_get_status_success_failed(self):
Expand All @@ -51,7 +51,7 @@ def test_get_status_success_failed(self):
with open('test/json_data/describe_commands_success_failed.json') as json_file:
data = json.load(json_file)
boto_describe_commands.return_value = data
modules.get_status('DEPLOYMENTID', 'REGION', '2')
modules.get_status('DEPLOYMENTID', 'REGION', '0')
self.assertEqual(mock_client.call_count, 1)

def test_get_status_failed_skipped(self):
Expand All @@ -60,7 +60,7 @@ def test_get_status_failed_skipped(self):
with open('test/json_data/describe_commands_failed_skipped.json') as json_file:
data = json.load(json_file)
boto_describe_commands.return_value = data
modules.get_status('DEPLOYMENTID', 'REGION', '2')
modules.get_status('DEPLOYMENTID', 'REGION', '0')
self.assertEqual(mock_client.call_count, 1)

def test_get_status_instances_sub_fail_skip_count(self):
Expand Down

0 comments on commit e351aeb

Please sign in to comment.