//--------------------------------------------------------------------------------------------------------------------- public static void FromItemXml(OcciStorage storage, CloudProvider provider, XmlElement elem) { storage.RemoteId = (elem.HasAttribute("href") ? elem.Attributes["href"].Value : null); if (storage.RemoteId != null) { storage.RemoteId = Regex.Replace(storage.RemoteId, "^.*/", String.Empty); } foreach (XmlNode node in elem) { XmlElement subElem = node as XmlElement; if (subElem == null) { continue; } switch (subElem.Name) { case "NAME": storage.Name = subElem.InnerXml; break; case "TYPE": storage.Type = subElem.InnerXml; break; case "CLASS": storage.Class = subElem.InnerXml; break; } } }
//--------------------------------------------------------------------------------------------------------------------- /// <summary> /// Initializes a new instance of the <see cref="Terradue.Cloud.XmlRpcVMTemplate"/> class. /// </summary> /// <param name="context">Context.</param> /// <param name="template">Template.</param> public OneVMTemplate (IfyContext context, VMTEMPLATE template, CloudProvider provider) : base (context) { this.RemoteId = template.ID; this.Name = template.NAME; this.Provider = provider; this.OneTemplate = template; }
//--------------------------------------------------------------------------------------------------------------------- public static OcciCloudAppliance FromItemXml(IfyContext context, CloudProvider provider, XmlElement elem) { OcciCloudAppliance result = new OcciCloudAppliance(context); result.Provider = provider; result.Load(elem); return(result); }
//--------------------------------------------------------------------------------------------------------------------- public static OcciStorage FromRemoteId(IfyContext context, CloudProvider provider, string remoteId) { OcciStorage result = new OcciStorage(context); result.Provider = provider; result.RemoteId = remoteId; return(result); }
//--------------------------------------------------------------------------------------------------------------------- /// <summary>Returns an instance of a CloudProvider subclass representing the cloud provider with the specified ID.</summary> /// <param name="context">the execution environment context</param> /// <param name="id">the cloud provider ID</param> /// <returns>the created CloudProvider subclass instance</returns> public static CloudProvider FromId(IfyContext context, int id) { EntityType entityType = EntityType.GetEntityType(typeof(CloudProvider)); CloudProvider result = (CloudProvider)entityType.GetEntityInstanceFromId(context, id); result.Id = id; result.Load(); return(result); }
//--------------------------------------------------------------------------------------------------------------------- public static OcciNetwork FromRemoteId(IfyContext context, CloudProvider provider, string remoteId) { OcciNetwork result = new OcciNetwork(context); result.Name = provider.GetNetwork(remoteId).Name; result.Provider = provider; result.RemoteId = remoteId; return(result); }
//--------------------------------------------------------------------------------------------------------------------- public static VirtualNetwork FromXmlElement(IfyContext context, CloudProvider provider, XmlElement elem) { VirtualNetwork result = new VirtualNetwork(context); result.Provider = provider; result.RemoteId = (elem.HasAttribute("href") ? elem.Attributes["href"].Value : null); if (result.RemoteId != null) { result.RemoteId = Regex.Replace(result.RemoteId, "^.*/", String.Empty); } result.Name = (elem.HasAttribute("name") ? elem.Attributes["name"].Value : null); return(result); }
//--------------------------------------------------------------------------------------------------------------------- public static OcciCloudAppliance FromListXml(IfyContext context, CloudProvider provider, XmlElement elem) { OcciCloudAppliance result = new OcciCloudAppliance(context); result.Provider = provider; result.RemoteId = (elem.HasAttribute("href") ? elem.Attributes["href"].Value : null); if (result.RemoteId != null) { result.RemoteId = Regex.Replace(result.RemoteId, "^.*/", String.Empty); } result.Name = (elem.HasAttribute("name") ? elem.Attributes["name"].Value : null); return(result); }
//--------------------------------------------------------------------------------------------------------------------- public static OcciNetwork FromItemXml(IfyContext context, CloudProvider provider, XmlElement elem) { OcciNetwork result = new OcciNetwork(context); result.Provider = provider; result.RemoteId = (elem.HasAttribute("href") ? elem.Attributes["href"].Value : null); if (result.RemoteId != null) { result.RemoteId = Regex.Replace(result.RemoteId, "^.*/", String.Empty); } XmlNode subElem = elem.SelectSingleNode("NAME"); result.Name = (subElem == null ? result.RemoteId : subElem.InnerXml); return(result); }
//--------------------------------------------------------------------------------------------------------------------- public static OcciInstanceType FromItemXml(IfyContext context, CloudProvider provider, XmlElement elem) { OcciInstanceType result = new OcciInstanceType(context); result.Provider = provider; result.RemoteId = (elem.HasAttribute("href") ? elem.Attributes["href"].Value : null); if (result.RemoteId != null) { result.RemoteId = Regex.Replace(result.RemoteId, "^.*/", String.Empty); } result.Name = (elem.HasAttribute("name") ? elem.Attributes["name"].Value : null); XmlNode node; if ((node = elem.SelectSingleNode("CLASS")) != null) { result.Class = node.InnerXml; } return(result); }
//--------------------------------------------------------------------------------------------------------------------- /// <summary> /// Froms the OCCI interface. /// </summary> /// <returns> /// The OCCI interface. /// </returns> /// <param name='context'> /// Context. /// </param> /// <param name='provider'> /// Provider. /// </param> public static OcciCloudAppliance FromOCCIInterface(IfyContext context, CloudProvider provider, string remoteId) { OcciCloudAppliance result = new OcciCloudAppliance(context); result.Provider = provider; result.RemoteId = remoteId; HttpWebRequest httpRequest = context.GetSslRequest(String.Format("{0}/compute/{1}", provider.AccessPoint, remoteId), "GET", null); HttpWebResponse response = null; try { // Get response stream. response = (HttpWebResponse)httpRequest.GetResponse(); XmlDocument doc = new XmlDocument(); doc.Load(response.GetResponseStream()); result.Load(doc.DocumentElement); response.Close(); } catch (WebException we) { throw new WebException("Error during request to " + httpRequest.RequestUri, we, we.Status, response); } return(result); }
//--------------------------------------------------------------------------------------------------------------------- public OneNetwork(IfyContext context, VNET xmlrpcNet, CloudProvider provider) : base(context) { this.Name = xmlrpcNet.NAME; this.RemoteId = xmlrpcNet.ID; this.Provider = provider; }
//--------------------------------------------------------------------------------------------------------------------- public OneImage(IfyContext context, IMAGE image, CloudProvider provider) : base(context) { this.RemoteId = image.ID; this.Name = image.NAME; this.Provider = Provider; }