Ejemplo n.º 1
0
 public IRestResponse<ApiTicket> Login(User user)
 {
     var restClient = new RestClient (_baseUrl);
     var request = new RestRequest("access/ticket", Method.POST) {RequestFormat = DataFormat.Json};
     request.AddParameter ("username", user.Username);
     request.AddParameter ("password", user.Password);
     request.AddParameter ("realm", user.Realm);
     request.RootElement = RequestRootElement;
     var response = restClient.Execute<ApiTicket>(request);
     _apiTicket = response.Data;
     return response;
 }
Ejemplo n.º 2
0
        public void ApiClientSetup()
        {
            var appConfig = new AppConfig ();

            var config = appConfig.Data ["TestProxmox"];
            user = new User { Username = config["Username"], Password = config["Password"], Realm = config["Realm"] };
            server = new Server { Ip = config["Ip"], Port = config["Port"] };
            node = config ["Node"];
            pool = config["Pool"];
            vmId = config ["VmId"];

            client = new ApiClient (server, node);

            ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;

            response = client.Login (user);

            var tasks = client.TaskStatusList().Data;

            if (tasks.Count > 0)
            {
                upid =  tasks[0].Upid;
            }

            template = new LxcTemplate {
                Cpuunits = "1",
                Password = "******",
                Hostname = "api.proxmox.test",
                Net = "name=eth0,bridge=vmbr0,hwaddr=DE:88:0F:D7:79:33,ip=dhcp,ip6=dhcp,type=veth",
                Memory = "1000",
                Ostemplate = "disk1:vztmpl/debian-8.0-standard_8.6-1_amd64.tar.gz",
                Ostype = "debian",
                Storage = "disk1",
                Swap = "512",
                Vmid = vmId,
                Pool = pool,
            };
        }