Пример #1
0
        static bool Passwd(IList<string> unparsed)
        {
            if (unparsed.Count != 0)
            {
                Console.Error.WriteLine("Too many arguments for [change_password]: {0}", String.Join(", ", unparsed.Select(s => String.Format("'{0}'", s))));
                Console.Error.WriteLine("Usage: vmc passwd");
                return false;
            }

            IVcapClient vc = new VcapClient();
            VcapClientResult rslt = vc.Info();
            Info info = rslt.GetResponseMessage<Info>();

            Console.WriteLine("Changing password for '{0}'", info.User);

            Console.Write("New Password: "******"Verify Password: "******"Passwords did not match!");
                return false;
            }
        }
Пример #2
0
        static bool Info(IList<string> unparsed)
        {
            if (unparsed.Count != 0)
            {
                Console.Error.WriteLine("Usage: vmc info");
                return false;
            }

            IVcapClient vc = new VcapClient();
            VcapClientResult rslt = vc.Info();
            if (rslt.Success)
            {
                var info = rslt.GetResponseMessage<Info>();
                if (result_as_json || result_as_rawjson)
                {
                    if (result_as_rawjson)
                    {
                        Console.WriteLine(info.RawJson);
                    }
                    if (result_as_json)
                    {
                        Console.WriteLine(JsonConvert.SerializeObject(info, Formatting.Indented));
                    }
                }
                else
                {
                    Version ver = Assembly.GetExecutingAssembly().GetName().Version;

                    Console.WriteLine(String.Format(Resources.Vmc_InfoDisplay_1_Fmt,
                        info.Description, info.Support, vc.CurrentUri, info.Version, ver));

                    if (false == info.User.IsNullOrEmpty())
                    {
                        Console.WriteLine(String.Format(Resources.Vmc_InfoDisplay_2_Fmt, info.User));
                    }

                    if (null != info.Usage && null != info.Limits)
                    {
                        string tmem = PrettySize(info.Limits.Memory * 1024 * 1024);
                        string mem = PrettySize(info.Usage.Memory * 1024 * 1024);

                        Console.WriteLine(String.Format(Resources.Vmc_InfoDisplay_3_Fmt,
                            mem, tmem,
                            info.Usage.Services, info.Limits.Services,
                            info.Usage.Apps, info.Limits.Apps));
                    }
                }
            }
            else
            {
                Console.Error.WriteLine(String.Format("Error: {0}", rslt.Message));
            }

            return rslt.Success;
        }