コード例 #1
0
    def set_extra_info(self, db_object, extra_args=None):
        ec2 = extra_args.get("ec2")
        db = db_object
        pg_dict = {}

        storage_type = get_field(db, 'StorageType')
        if storage_type == 'standard':
            pg_dict['storage_type'] = storage_type + ": Magnetic"
        elif storage_type == 'gp2':
            pg_dict['storage_type'] = storage_type + ": General Purpose (SSD)"
        elif storage_type == 'io2':
            pg_dict['storage_type'] = storage_type + ": Provisioned IOPS (SSD)"
        else:
            pg_dict['storage_type'] = storage_type

        pg_dict['vpc'] = ""
        try:
            vpc_id = get_field(db, 'DBSubnetGroup', 'VpcId')
            pg_dict['vpc'] = vpc_id
            my_vpcs = ec2.describe_vpcs(VpcIds=[vpc_id, ])
            for my_vpc in my_vpcs['Vpcs']:
                for tag in my_vpc['Tags']:
                    if tag['Key'] == "Name":
                        vpc_name = tag['Value']
                        pg_dict['vpc'] = vpc_name
                        break
        except Exception as e:
            pass

        for d in pg_dict.keys():
            if not hasattr(self, d):
                setattr(self, d, pg_dict[d])
        self._set_extra_info(db_object, cloud_type="aws")
コード例 #2
0
def get_hydro_ops_chars_scenario_id(webdb, scenario, project):
    pocs_id = common.get_field(webdb,
                               "scenarios",
                               "project_operational_chars_scenario_id",
                               scenario_name=scenario)

    return common.get_field(webdb,
                            "inputs_project_operational_chars",
                            "hydro_operational_chars_scenario_id",
                            project_operational_chars_scenario_id=pocs_id,
                            project=project)
コード例 #3
0
 def __init__(self, db_object, info=False):
     Database.__init__(self)
     self.id = get_field(db_object, 'DBInstanceArn')
     self.instance = get_field(db_object, 'DBInstanceIdentifier')
     self.user = get_field(db_object, 'MasterUsername')
     self.db_name = get_field(db_object, 'DBName')
     self.host = get_field(db_object, 'Endpoint', 'Address')
     self.status = get_field(db_object, 'DBInstanceStatus')
     self.db_class = get_field(db_object, 'DBInstanceClass')
     self.engine_version = get_field(db_object, 'EngineVersion')
     self.storage_allocated = get_field(db_object, 'AllocatedStorage')
     self.port = get_field(db_object, 'Endpoint', 'Port')
コード例 #4
0
def get_capacity(webdb, scenario, project):
    capacity_scenario_id = get_project_specified_capacity_scenario_id(
        webdb, scenario)
    return common.get_field(
        webdb,
        "inputs_project_specified_capacity",
        "specified_capacity_mw",
        project=project,
        project_specified_capacity_scenario_id=capacity_scenario_id)
コード例 #5
0
def get_power_mw_dataset(webdb, scenario, project):
    scenario_id = common.get_field(webdb,
                                   'scenarios',
                                   "scenario_id",
                                   scenario_name=scenario)
    rows = webdb.where("results_project_dispatch",
                       scenario_id=scenario_id,
                       project=project,
                       operational_type='gen_hydro').list()

    return pd.DataFrame(rows)
コード例 #6
0
def get_projects(webdb, scenario):
    proj_ops_char_sc_id = common.get_field(
        webdb,
        "scenarios",
        "project_operational_chars_scenario_id",
        scenario_name=scenario)
    rows = webdb.where(
        "inputs_project_operational_chars",
        project_operational_chars_scenario_id=proj_ops_char_sc_id,
        operational_type="gen_hydro")
    return [row['project'] for row in rows]
コード例 #7
0
def get_balancing_type(webdb, scenario):
    temporal_scenario_id = get_temporal_scenario_id(webdb, scenario)
    return common.get_field(webdb,
                            "inputs_temporal_horizons",
                            "balancing_type_horizon",
                            temporal_scenario_id=temporal_scenario_id)
コード例 #8
0
def get_temporal_scenario_id(webdb, scenario):
    return common.get_field(webdb,
                            "scenarios",
                            "temporal_scenario_id",
                            scenario_name=scenario)
コード例 #9
0
def get_project_specified_capacity_scenario_id(webdb, scenario):
    return common.get_field(webdb,
                            "scenarios",
                            "project_specified_capacity_scenario_id",
                            scenario_name=scenario)