public async Task <OpenStackServerAddressResponse> GetServerAddresses(string serverId, string computeUrl, string tenantId, string Username, string tokenID) { OpenStackServerAddressResponse resp = new OpenStackServerAddressResponse(); resp = await OpenStackGetServerAddresses(computeUrl, tenantId, this.Username, tokenID, serverId); return(resp); }
private async Task <OpenStackServerAddressResponse> OpenStackGetServerAddresses(string uri = null, string tenantId = null, string username = null, string tokenId = null, string serverId = null) { OpenStackServerAddressResponse ossar = new OpenStackServerAddressResponse(); using (var clientServer = new HttpClient()) { clientServer.BaseAddress = new Uri(uri); clientServer.DefaultRequestHeaders.Accept.Clear(); clientServer.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); //add token to header clientServer.DefaultRequestHeaders.Add("X-Auth-Token", tokenId); HttpResponseMessage response = await clientServer.GetAsync(tenantId + "/servers/" + serverId + "/ips"); if (response.IsSuccessStatusCode) { ossar = response.Content.ReadAsAsync <OpenStackServerAddressResponse>().Result; } } return(ossar); }