public List<RackSpaceCloudServerImage> ListImages(bool details) { List<RackSpaceCloudServerImage> listImages = new List<RackSpaceCloudServerImage>(); var request = new RackSpaceCloudRequest(this._authInfo.ServerManagementUrl, this._authInfo.AuthToken); if (!details) { var images = request.GetRequest("/images"); foreach (var image in images.images) { listImages.Add(new RackSpaceCloudServerImage { id = image.id, name = image.name }); } } else { var images = request.GetRequest("/images/detail"); foreach (var image in images.images) { listImages.Add(ExpandoToRackSpaceCloudImageObject(image)); } } return listImages; }
public RackSpaceCloudServer GetServerDetails(string serverId) { var request = new RackSpaceCloudRequest(this._authInfo.ServerManagementUrl, this._authInfo.AuthToken); var serverDetails = request.GetRequest(String.Format("/servers/{0}",serverId)); var server = ExpandoToRackSpaceCloudServerObject(serverDetails.server); return server; }
public RackSpaceCloudServerImage GetImageDetails(int imageId) { var request = new RackSpaceCloudRequest(this._authInfo.ServerManagementUrl, this._authInfo.AuthToken); var image = request.GetRequest("/images/" + imageId.ToString()); var result = ExpandoToRackSpaceCloudImageObject(image.image); return result; }
public bool DeleteServer(string serverId) { try { var request = new RackSpaceCloudRequest(this._authInfo.ServerManagementUrl, this._authInfo.AuthToken); dynamic response = request.Request("DELETE", "/servers/" + serverId); } catch { return false; } return true; }
public RackSpaceCloudServer CreateServer(string serverName, int imageId, RackSpaceCloudServerFlavor flavorId, Dictionary<string, string> metadata = null, List<Personality> personality = null) { var request = new RackSpaceCloudRequest(this._authInfo.ServerManagementUrl, this._authInfo.AuthToken); dynamic data = new ExpandoObject(); data.server = new ExpandoObject(); data.server.name = serverName; data.server.imageId = imageId; data.server.flavorId = flavorId; data.server.metadata = metadata; data.server.personality = personality; dynamic response = request.Request("POST", "/servers", data); return ExpandoToRackSpaceCloudServerObject(response.server); }
public bool UpdateServerPass(string serverId, string newPassword) { try { var request = new RackSpaceCloudRequest(this._authInfo.ServerManagementUrl, this._authInfo.AuthToken); dynamic data = new ExpandoObject(); data.server = new ExpandoObject(); //data.server.name = newServerName; data.server.adminPass = newPassword; dynamic response = request.Request("PUT", "/servers/" + serverId, data); } catch (Exception ex) { return false; } return true; }
public List<RackSpaceCloudServer> ListServers(bool details = false) { List<RackSpaceCloudServer> result = new List<RackSpaceCloudServer>(); var request = new RackSpaceCloudRequest(this._authInfo.ServerManagementUrl, this._authInfo.AuthToken); dynamic serverList; if (details) { serverList = request.GetRequest("/servers/detail"); } else { serverList = request.GetRequest("/servers"); } foreach (var server in serverList.servers) { if (details) { result.Add(ExpandoToRackSpaceCloudServerObject(server)); } else { result.Add(new RackSpaceCloudServer { id = server.id, name = server.name }); } } return result; }