Esempio n. 1
0
 def get_environment_status(self, environment, region_vpc_dict):
     """Get environment status."""
     ah_obj = AtlasHelper()
     vpc_status_dict = {}
     organizations = self.awshelper_obj.get_organizations()
     org_attributes = self.ah_obj.get_nested_attribute_values(
         self.awshelper_obj.get_instances_details(), 'organizations')[1]
     for organization in organizations:
         if self.environment_groups and environment in self.environment_groups[
                 1].keys():
             env_status_dict = {}
             if environment == 'all':
                 env_group_for_env = self.awshelper_obj.get_environments(
                     organization)
             else:
                 env_group_for_env = self.environment_groups[1][environment]
             for env in env_group_for_env:
                 env_attributes = self.ah_obj.get_nested_attribute_values(
                     org_attributes[organization], env)[1]
                 env_status_dict = self.determine_environment_status(
                     env, env_attributes, region_vpc_dict)
                 if not vpc_status_dict:
                     vpc_status_dict.update(env_status_dict)
                 else:
                     for vpc in env_status_dict.keys():
                         vpc_status_dict[vpc]['status'] = map(
                             add, vpc_status_dict[vpc]['status'],
                             env_status_dict[vpc]['status'])
         else:
             env_attributes = self.ah_obj.get_nested_attribute_values(
                 org_attributes[organization], environment)[1]
             vpc_status_dict = self.determine_environment_status(
                 environment, env_attributes, region_vpc_dict)
     return vpc_status_dict
Esempio n. 2
0
 def __init__(self, request=None, environment=None):
     self.ah_obj = AtlasHelper()
     self.aws_helperobj = AwsHelper()
     self.module = "jenkins_module"
     if environment is None:
         self.awsact_obj = AwsActions()
         self.jenkinsact_obj = JenkinsActions(request)
     else:
         self.jenkinsact_obj = JenkinsActions(request,environment)
Esempio n. 3
0
    def __init__(self, request=None, environment=None):

        self.module = "cloudability_module"
        self.ah_obj = AtlasHelper()
        self.cloud_obj = Cloudability()
        self.awshelper_obj = AwsHelper()
        self.request = request
        self.aws_object = AwsModule(request, environment)
        self.instance_cost = 0.0
        self.storage_cost = 0.0
Esempio n. 4
0
 def __init__(self):
     self.awshelper_obj = AwsHelper()
     self.ah_obj = AtlasHelper()
     self.connection_obj = ""
     self.module = "aws_module"
     self.memcache_var = memcache.Client([
         self.ah_obj.get_atlas_config_data("global_config_data",
                                           'memcache_server_location')
     ],
                                         debug=0)
Esempio n. 5
0
    def __init__(self, environment=None):
        """Initialize variables."""

        self.ah_obj = AtlasHelper()
        self.awshelper_obj = AwsHelper()
        self.module = 'aws_module'
        self.environment_dict = {}
        self.env_subnet_dict = {}
        self.env_details_dict = {}
        self.environment_groups = self.ah_obj.get_atlas_config_data(
            "global_config_data", "environment_groups")
Esempio n. 6
0
 def __init__(self, request=None, environment=None):
     self.module = "chef_module"
     self.ah_obj = AtlasHelper()
     self.chef_obj = ChefHelper()
     self.chef_actionsobj = ChefActions()
     self.instance_obj = AwsInstanceHelper()
     self.request = request
     self.session_obj = SessionHandler()
     if environment is None:
         pass
     else:
         self.environment = environment
Esempio n. 7
0
 def __init__(self, request=None, environment=None):
     self.ah_obj = AtlasHelper()
     self.awshelper_obj = AwsHelper()
     self.instance_obj = AwsInstanceHelper()
     self.actions_obj = AwsActions()
     self.session_obj = SessionHandler()
     self.region_vpc_dict = self.session_obj.load_region_session(request)
     self.module = 'aws_module'
     if environment == None:
         self.information_dict = {'aggregates': {}, 'details': {}}
         self.aws_details_dict = self.instance_obj.get_aws_details(
             self.region_vpc_dict)
     else:
         self.information_dict = self.instance_obj.get_environment_details(
             environment, self.region_vpc_dict)
Esempio n. 8
0
 def __init__(self):
     self.cloudability_dict = {}
     self.ah_obj = AtlasHelper()
     self.aws_helper_object = AwsHelper()
     self.module = "cloudability_module"
     self.auth_token = os.environ.get('CLOUDABILITY_AUTH_TOKEN')
     self.cl_base_url = self.ah_obj.get_atlas_config_data(
         self.module, "cloudability_base_url")
     self.cl_cost_url = self.ah_obj.get_atlas_config_data(
         self.module, "cloudability_cost_url")
     self.report_query = ""
     self.memcache_var = memcache.Client([
         self.ah_obj.get_atlas_config_data("global_config_data",
                                           'memcache_server_location')
     ],
                                         debug=1)
     self.environment_subnets_details = self.aws_helper_object.get_environment_subnets_details(
     )
Esempio n. 9
0
    def __init__(self, request=None, environment=None):

        self.ah_obj = AtlasHelper()
        self.module = "jenkins_module"
        self.python_jenkinsurl = self.ah_obj.get_atlas_config_data(
            self.module, "python_jenkins_url")
        self.build_record_count = self.ah_obj.get_atlas_config_data(
            self.module, "build_record_count")
        self.jenkins_password = os.environ.get('JENKINS_PASSWORD')
        self.jenkins_username = os.environ.get('JENKINS_USERNAME')
        self.jenkinsurl = os.environ.get('JENKINS_URL')
        self.python_jenkinsurl = self.jenkinsurl + "/job/"
        self.memcache_var = memcache.Client([
            self.ah_obj.get_atlas_config_data("global_config_data",
                                              'memcache_server_location')
        ],
                                            debug=0)
        if environment:
            self.aws_obj = AwsModule(request, environment)
Esempio n. 10
0
 def __init__(self, request=None, environment=None):
     self.module = 'graphite_module'
     self.ah_obj = AtlasHelper()
     self.aws_helperobj = AwsHelper()
     self.module_config_data = self.ah_obj.get_atlas_configuration_data(
         self.module)
     self.graphite_url = " "
     self.framework = ""
     self.parameters_list = []
     self.time_interval = 0.0
     self.server_monitored = []
     self.format = ""
     self.from_time = ""
     self.to_time = ""
     self.memcache_var = memcache.Client([
         self.ah_obj.get_atlas_config_data("global_config_data",
                                           'memcache_server_location')
     ],
                                         debug=0)
     if environment is not None:
         self.aws_moduleobj = AwsModule(request=request,
                                        environment=environment)
Esempio n. 11
0
 def __init__(self, request=None, environment=None):
     self.ah_obj = AtlasHelper()
     self.module = "graphite_module"
     self.graphite_obj = GraphiteHelper(request=request,
                                        environment=environment)
Esempio n. 12
0
 def __init__(self):
     self.awshelper_obj = AwsHelper()
     self.session_obj = SessionHandler()
     self.objhelper_obj = ObjectHelper()
     self.ah_obj = AtlasHelper()
     self.awshelper_obj = AwsHelper()
Esempio n. 13
0
    def get_aws_details(self, regionvpcselected):
        organizations = self.awshelper_obj.get_organizations()
        aws_details_dict = {}
        environment_list = []
        aws_details = self.awshelper_obj.get_instances_details()
        for organization in organizations:
            environment_list = self.awshelper_obj.get_environments(
                organization)
            environment_list.append('uncategorized')
            environment_list.append('all')
            ah_obj = AtlasHelper()
            total_count, total_running, total_stopped = 0, 0, 0
            region_dict = {}
            region_env_list = []
            for environment in environment_list:
                if environment != 'all':
                    env_attributes = self.ah_obj.get_nested_attribute_values(
                        aws_details, environment)[1]
                    for region in regionvpcselected.keys():
                        if 'regions' in env_attributes.keys(
                        ) and region in env_attributes['regions'].keys():
                            region_keys, region_attributes = ah_obj.get_nested_attribute_values(
                                env_attributes['regions'], region)
                            if 'count' in region_keys and 'running' in region_keys and 'stopped' in region_keys:
                                region_count = region_attributes['count']
                                region_running = region_attributes['running']
                                region_stopped = region_attributes['stopped']

                                if environment == "uncategorized":
                                    total_count += region_count
                                    total_running += region_running
                                    total_stopped += region_stopped
                                    region_env_list.append([
                                        region, "none", environment,
                                        region_count, region_running,
                                        region_stopped
                                    ])
                                else:
                                    vpc_list = regionvpcselected[region]
                                    for vpc in vpc_list:
                                        if 'vpc' in region_attributes.keys():
                                            vpc_attributes = self.ah_obj.get_nested_attribute_values(
                                                region_attributes['vpc'],
                                                vpc)[1]
                                            vpc_count = vpc_attributes['count']
                                            vpc_running = vpc_attributes[
                                                'running']
                                            vpc_stopped = vpc_attributes[
                                                'stopped']
                                            total_count += vpc_count
                                            total_running += vpc_running
                                            total_stopped += vpc_stopped
                                    region_env_list.append([
                                        region, vpc, environment, vpc_count,
                                        vpc_running, vpc_stopped
                                    ])
                else:
                    region_env_list.append([
                        region, vpc, environment, total_count, total_running,
                        total_stopped
                    ])

        temp_list, total_list = [], []
        for count in range(0, len(environment_list)):
            total_list.append([environment_list[count], 0, 0, 0])

        for index in range(0, len(region_env_list)):
            for index1 in range(0, len(total_list)):
                if region_env_list[index][2] == total_list[index1][0]:
                    temp_list = [
                        region_env_list[index][3], region_env_list[index][4],
                        region_env_list[index][5]
                    ]
                    total_list[index1][1] += temp_list[0]
                    total_list[index1][2] += temp_list[1]
                    total_list[index1][3] += temp_list[2]
        aws_details_dict['total_count'] = total_count
        aws_details_dict['total_running'] = total_running
        aws_details_dict['total_stopped'] = total_stopped
        aws_details_dict['environment_list'] = environment_list
        aws_details_dict['region_dict'] = region_dict
        aws_details_dict['total_list'] = total_list
        return aws_details_dict
Esempio n. 14
0
#function to save session variables
from appv1.models import UserProfile, UserEnvironmentSelections, UserRegion, UserConfigSelections
import ast, sys
from atlas_helper_methods import AtlasHelper
from aws_helper import AwsHelper

ah = AtlasHelper()

class SessionHandler:
    def __init__(self, request=None):
        pass

    def save_on_logout(self, request):
        up = UserProfile.objects.get(user__username=request.user.username)
        up.url = request.POST.get("url", "")
        up.save()

    def save_dash_session(self, request, env_status_dict):
        try:
            up = UserProfile.objects.get(user__username=request.user.username)
            if up and env_status_dict:
                user_profile_record = UserProfile.objects.filter(user__username=request.user.username)
                if user_profile_record and user_profile_record.count()==1:
                    for u_profile in user_profile_record:
                        config_record =  UserConfigSelections.objects.filter(abstractuser_id = up.id)
                        if config_record:
                            if env_status_dict['config_status']<> []:
                                config_record.update(status_selected = env_status_dict['config_status'])
                            if env_status_dict['env_status'] <> []:
                                config_record.update(envs_selected = env_status_dict['env_status'])
                        else: