Exemplo n.º 1
0
 private static void AuthenticateIaas()
 {
     try
     {
         Log.Info(typeof(Initializer), "Authenticating " + Runtime.Settings.IaasName + "...");
         Log.Info(typeof(Initializer), "Service URL: " + Runtime.Settings.IaasServiceURL);
         ApDashboardService service = new ApDashboardService();
         service.AuthorizeIaasClient();
         Log.Info(typeof(Initializer), "Authenticated " + Runtime.Settings.IaasName + " successfully");
     }
     catch(Exception e)
     {
         string message = "Could not connect to " + Runtime.Settings.IaasServiceURL;
         throw new MonoscapeException(message, e);
     }
 }
Exemplo n.º 2
0
        private string FindInstanceId(string ipAddress)
        {
            try
            {
                ApDashboardService service = new ApDashboardService();
                MonoscapeCredentials credentials = new MonoscapeCredentials(Settings.MonoscapeAccessKey, Settings.MonoscapeSecretKey);
                ApDescribeInstancesRequest request = new ApDescribeInstancesRequest(credentials);
                ApDescribeInstancesResponse response = service.DescribeInstances(request);

                foreach (Instance instance in response.Instances)
                {
                    if (instance.IpAddress.Equals(ipAddress))
                        return instance.InstanceId;
                }
            }
            catch (Exception)
            {
                Log.Error(this, "Could not find Instance ID of " + ipAddress);
            }
            return null;
        }