This repository has been archived by the owner on Oct 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 803
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create replication_settings_obj_builder.py
- Loading branch information
1 parent
6c7f239
commit e6b2df1
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
DRS/DRS-Settings-Tool/object_builders/replication_settings_obj_builder.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from classes.replication_settings import ReplicationSettings | ||
from classes.replication_settings import PitPolicy | ||
from utils.str2bool import str2bool | ||
from utils.obj_to_dict import obj_to_dict | ||
import ast | ||
|
||
def replication_settings_obj_builder_for_csv(info): | ||
info.pop('ResponseMetadata') | ||
replication_settings_obj = ReplicationSettings(**info) | ||
return replication_settings_obj | ||
|
||
def pit_policy_obj_builder_for_csv(info): | ||
for policy in info: | ||
if policy['units'] == 'DAY': | ||
pit_policy_obj = PitPolicy(**policy) | ||
return pit_policy_obj | ||
|
||
|
||
|
||
def replication_settings_obj_builder(row): | ||
replication_settings_obj = ReplicationSettings() | ||
pit_settings_obj = PitPolicy(enabled=True, interval=1, ruleID=3, units='DAY') | ||
|
||
replication_settings_obj.associateDefaultSecurityGroup = str2bool(row[18]) | ||
replication_settings_obj.autoReplicateNewDisks = None | ||
if row[19].upper != "": | ||
replication_settings_obj.autoReplicateNewDisks = str2bool(row[19]) | ||
replication_settings_obj.bandwidthThrottling = ast.literal_eval(row[20]) | ||
replication_settings_obj.createPublicIP = str2bool(row[21]) | ||
replication_settings_obj.dataPlaneRouting = row[22].upper() | ||
replication_settings_obj.defaultLargeStagingDiskType = row[23].upper() | ||
pit_settings_obj.retentionDuration = ast.literal_eval(row[24]) | ||
replication_settings_obj.pitPolicy = obj_to_dict(pit_settings_obj) | ||
replication_settings_obj.replicationServerInstanceType = row[25].lower() | ||
replication_settings_obj.replicatedDisks = ast.literal_eval(row[26]) | ||
replication_settings_obj.ebsEncryption = row[27] | ||
replication_settings_obj.ebsEncryptionKeyArn = row[28] | ||
if row[29] != "": | ||
replication_settings_obj.replicationServersSecurityGroupsIDs = row[29].split(', ') | ||
replication_settings_obj.stagingAreaSubnetId = row[30] | ||
replication_settings_obj.useDedicatedReplicationServer = str2bool(row[31]) | ||
replication_settings_obj.stagingAreaTags = ast.literal_eval(row[32]) | ||
replication_settings_obj.sourceServerID = row[1] | ||
|
||
return replication_settings_obj |