Ejemplo n.º 1
0
        public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems)
        {
            AmazonRDSConfig config = new AmazonRDSConfig();

            config.RegionEndpoint = region;
            ConfigureClient(config);
            AmazonRDSClient client = new AmazonRDSClient(creds, config);

            DescribeDBInstancesResponse resp = new DescribeDBInstancesResponse();

            do
            {
                DescribeDBInstancesRequest req = new DescribeDBInstancesRequest
                {
                    Marker = resp.Marker
                    ,
                    MaxRecords = maxItems
                };

                resp = client.DescribeDBInstances(req);
                CheckError(resp.HttpStatusCode, "200");

                foreach (var obj in resp.DBInstances)
                {
                    AddObject(obj);
                }
            }while (!string.IsNullOrEmpty(resp.Marker));
        }
Ejemplo n.º 2
0
        internal static void WriteRds(DateTime captureTime, string accountId, RegionEndpoint regionEndPoint)
        {
            var rdsClient           = new AmazonRDSClient(regionEndPoint);
            var rdsInstanceResponse = rdsClient.DescribeDBInstances();

            foreach (var dbInstance in rdsInstanceResponse.DBInstances)
            {
                string dbJson = JsonConvert.SerializeObject(dbInstance);
                Common.UpdateTopology(captureTime, accountId, regionEndPoint.SystemName, "rds", dbInstance.DBInstanceIdentifier, dbJson, "UPDATE");
            }
        }
        public List <DBDetail> GetDBProperties()
        {
            List <AWSProfile> profile;
            List <DBDetail>   list = new List <DBDetail>();

            profile = SqlHelper.GetAWSAccounts();
            //foreach (var profile_ in profile)
            //{
            //    Amazon.Util.ProfileManager.RegisterProfile(profile_.ProfileName, profile_.Accesskey, profile_.Secretkey);
            //}

            try
            {
                foreach (var profile_ in profile)
                {
                    var regions = Amazon.RegionEndpoint.EnumerableAllRegions;
                    //Amazon.Runtime.AWSCredentials credentials = new Amazon.Runtime.StoredProfileAWSCredentials(profile_.ProfileName);
                    foreach (var r in regions)
                    {
                        string region_;
                        if (r.SystemName != "us-gov-west-1" && r.SystemName != "cn-north-1")
                        {
                            region_ = r.SystemName;
                            var                         region   = RegionEndpoint.GetBySystemName(region_);
                            AmazonRDSClient             rds      = new AmazonRDSClient(profile_.Accesskey, profile_.Secretkey, region);
                            DescribeDBInstancesRequest  request  = new DescribeDBInstancesRequest();
                            DescribeDBInstancesResponse response = rds.DescribeDBInstances(request);
                            List <DBInstance>           result   = response.DBInstances;
                            foreach (var db in result)
                            {
                                DBDetail dbdetail = new DBDetail();
                                dbdetail.Name        = db.DBInstanceIdentifier;
                                dbdetail.Size        = db.AllocatedStorage.ToString() + " GB";
                                dbdetail.Status      = db.DBInstanceStatus;
                                dbdetail.Type        = db.StorageType;
                                dbdetail.Key         = db.DbiResourceId;
                                dbdetail.ServerName  = db.Engine;
                                dbdetail.accountId   = profile_.accountId;
                                dbdetail.ProfileName = profile_.ProfileName;
                                dbdetail.Region      = region_;
                                list.Add(dbdetail);
                            }
                        }
                    }
                }

                return(list);
            }
            catch (Exception e)
            {
                this.log.Error(e);
                return(null);
            }
        }