public Controller(Profile profile) { if (profile == null) throw new ArgumentNullException("profile"); this.profile = profile; connectionTimeout = TimeSpan.FromSeconds(Constants.DefaultConnectionTimeoutSeconds); }
public CCNetController(Profile profile) : base(profile) { }
public ClientController(Profile profile) : base(profile) { }
public override bool Validate(Profile profile, ClientOptions options) { return base.Validate(profile, options) && Check(profile.VM != null, "--vm or --profile required for this command."); }
public static int Main(string[] args) { try { var options = new ClientOptions(); var parser = new CommandLineParser(); if (!parser.ParseArguments(args, options, Console.Error)) return 1; if (options.Values == null || options.Values.Count == 0) { PrintErrorMessageAndHelp(options,"Must specify a command."); return 1; } string commandName = options.Values[0]; Command command = CreateCommand(commandName); if (command == null) { PrintErrorMessageAndHelp(options, "Unrecognized command name."); return 1; } bool haveMaster = options.Master != null; bool haveProfile = options.Configuration != null || options.Profile != null; if (haveMaster && haveProfile || ! haveMaster && ! haveProfile || (options.Configuration != null) != (options.Profile != null)) { PrintErrorMessageAndHelp(options, "Must specify either --master or both --configuration and --profile."); return 1; } Profile profile; if (options.Configuration != null && options.Profile != null) { XmlConfiguration xmlConfiguration = ConfigurationFileHelper.LoadConfiguration(options.Configuration); XmlProfile xmlProfile = xmlConfiguration.GetProfileById(options.Profile); if (xmlProfile == null) { PrintErrorMessageAndHelp(options, "Profile not found in configuration file."); return 1; } profile = xmlProfile.ToProfile(); } else { profile = new Profile() { Master = options.Master, MasterPort = options.MasterPort, Slave = options.Slave, SlavePort = options.SlavePort, VM = options.VM, Snapshot = options.Snapshot }; } if (!command.Validate(profile, options)) return 1; using (var controller = new ClientController(profile)) { controller.Quiet = options.Quiet; controller.ConnectionTimeout = TimeSpan.FromSeconds(options.ConnectionTimeout); try { return command.Execute(controller, options); } catch (OperationFailedException ex) { Console.Error.WriteLine("Operation failed."); Console.Error.WriteLine(ex.Why); if (ex.__isset.details) { Console.Error.WriteLine("Details:"); Console.Error.WriteLine(ex.Details); } return 1; } } } catch (Exception ex) { Console.WriteLine("Fatal exception: " + ex); return 1; } }
public virtual bool Validate(Profile profile, ClientOptions options) { return CheckValues(options) && CheckUnusedRecursive(options) && CheckUnusedForce(options) && CheckUnusedEnvironmentVariables(options) && CheckUnusedWorkingDirectory(options) && CheckUnusedTimeout(options); }