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")
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)
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')
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)
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)
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]
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)
def get_temporal_scenario_id(webdb, scenario): return common.get_field(webdb, "scenarios", "temporal_scenario_id", scenario_name=scenario)
def get_project_specified_capacity_scenario_id(webdb, scenario): return common.get_field(webdb, "scenarios", "project_specified_capacity_scenario_id", scenario_name=scenario)