Beispiel #1
0
 static bool TestStats(IList<string> unparsed)
 {
     string appname = unparsed[0];
     IVcapClient vc = new VcapClient();
     Application app = vc.GetApplication(appname);
     IEnumerable<StatInfo> result = vc.GetStats(app);
     Console.WriteLine(JsonConvert.SerializeObject(result, Formatting.Indented));
     return true;
 }
Beispiel #2
0
        static bool TestStats(IList <string> unparsed)
        {
            string                 appname = unparsed[0];
            IVcapClient            vc      = new VcapClient();
            Application            app     = vc.GetApplication(appname);
            IEnumerable <StatInfo> result  = vc.GetStats(app);

            Console.WriteLine(JsonConvert.SerializeObject(result, Formatting.Indented));
            return(true);
        }
        public ProviderResponse <SafeObservableCollection <StatInfo> > GetStats(Cloud cloud, Application application)
        {
            ProviderResponse <SafeObservableCollection <StatInfo> > response = new ProviderResponse <SafeObservableCollection <StatInfo> >();

            try
            {
                IVcapClient client = new VcapClient(cloud);
                response.Response = new SafeObservableCollection <StatInfo>(client.GetStats(application));
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
            }
            return(response);
        }
        public ProviderResponse <IEnumerable <StatInfo> > GetStats(Application app, Cloud cloud)
        {
            var response = new ProviderResponse <IEnumerable <StatInfo> >();

            try
            {
                IVcapClient client = new VcapClient(cloud);
                response.Response = client.GetStats(app);
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
            }
            return(response);
        }
        public ProviderResponse <IEnumerable <Instance> > GetInstances(Cloud cloud, Application app)
        {
            var response = new ProviderResponse <IEnumerable <Instance> >();

            try
            {
                IVcapClient client    = new VcapClient(cloud);
                var         stats     = client.GetStats(app);
                var         instances = new SafeObservableCollection <Instance>();
                if (stats != null)
                {
                    foreach (var stat in stats)
                    {
                        var instance = new Instance()
                        {
                            ID    = stat.ID,
                            State = stat.State
                        };
                        if (stat.Stats != null)
                        {
                            instance.Cores       = stat.Stats.Cores;
                            instance.MemoryQuota = stat.Stats.MemQuota / 1048576;
                            instance.DiskQuota   = stat.Stats.DiskQuota / 1048576;
                            instance.Host        = stat.Stats.Host;
                            instance.Parent      = app;
                            instance.Uptime      = TimeSpan.FromSeconds(Convert.ToInt32(stat.Stats.Uptime));

                            if (stat.Stats.Usage != null)
                            {
                                instance.Cpu    = stat.Stats.Usage.CpuTime / 100;
                                instance.Memory = Convert.ToInt32(stat.Stats.Usage.MemoryUsage) / 1024;
                                instance.Disk   = Convert.ToInt32(stat.Stats.Usage.DiskUsage) / 1048576;
                            }
                        }
                        instances.Add(instance);
                    }
                }
                response.Response = instances;
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
            }
            return(response);
        }
 public ProviderResponse<SafeObservableCollection<StatInfo>> GetStats(Cloud cloud, Application application)
 {
     var response = new ProviderResponse<SafeObservableCollection<StatInfo>>();
     try
     {
         IVcapClient client = new VcapClient(cloud);
         response.Response = new SafeObservableCollection<StatInfo>(client.GetStats(application));
     }
     catch (Exception ex)
     {
         response.Message = ex.Message;
     }
     return response;
 }
 public ProviderResponse<IEnumerable<StatInfo>> GetStats(Application app, Cloud cloud)
 {
     var response = new ProviderResponse<IEnumerable<StatInfo>>();
     try
     {
         IVcapClient client = new VcapClient(cloud);
         response.Response = client.GetStats(app);
     }
     catch (Exception ex)
     {
         response.Message = ex.Message;
     }
     return response;
 }
        public ProviderResponse<IEnumerable<Instance>> GetInstances(Cloud cloud, Application app)
        {
            var response = new ProviderResponse<IEnumerable<Instance>>();
            try
            {
                IVcapClient client = new VcapClient(cloud);
                var stats = client.GetStats(app);
                var instances = new SafeObservableCollection<Instance>();
                if (stats != null)
                {

                    foreach (var stat in stats)
                    {
                        var instance = new Instance()
                                       {
                                           Id = stat.ID,
                                           State = stat.State
                                       };
                        if (stat.Stats != null)
                        {
                            instance.Cores = stat.Stats.Cores;
                            instance.MemoryQuota = stat.Stats.MemQuota/1048576;
                            instance.DiskQuota = stat.Stats.DiskQuota/1048576;
                            instance.Host = stat.Stats.Host;
                            instance.Parent = app;
                            instance.Uptime = TimeSpan.FromSeconds(Convert.ToInt32(stat.Stats.Uptime));

                            if (stat.Stats.Usage != null)
                            {
                                instance.Cpu = stat.Stats.Usage.CpuTime/100;
                                instance.Memory = Convert.ToInt32(stat.Stats.Usage.MemoryUsage)/1024;
                                instance.Disk = Convert.ToInt32(stat.Stats.Usage.DiskUsage)/1048576;
                            }
                        }
                        instances.Add(instance);
                    }
                }
                response.Response = instances;
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
            }
            return response;
        }