示例#1
0
        //---------------------------------------------------------------------------------------------------------------------

        public static OneCloudAppliance FromResources(IfyContext context, OneVMTemplate template, OneImage[] storages, OneNetwork network)
        {
            OneCloudAppliance result = new OneCloudAppliance(context);

            result.VMTemplate = template;
            result.Images     = storages;
            result.Network    = network;
            return(result);
        }
示例#2
0
        //---------------------------------------------------------------------------------------------------------------------

        public override CloudAppliance CreateInstance(string name, VirtualMachineTemplate template, VirtualDisk[] disks, VirtualNetwork network)
        {
            OneCloudAppliance appliance = OneCloudAppliance.FromResources(context, template as OneVMTemplate, disks as OneImage[], network as OneNetwork);

            appliance.XmlRpcProvider     = this;
            appliance.Name               = name;
            appliance.AdditionalTemplate = template.AdditionalContent;

            //delegate client user
            CloudUser owner = CloudUser.FromIdAndProvider(context, context.OwnerId, this.Id);

            this.StartDelegate(owner.CloudUsername);
            appliance.Create();
            this.EndDelegate();

            foreach (OneImage disk in disks)
            {
                this.XmlRpc.VMAttachDisk(Int32.Parse(appliance.Vm.ID), "<TEMPLATE><DISK><IMAGE_ID>" + disk.RemoteId + "</IMAGE_ID></DISK></TEMPLATE>");
            }

            return(appliance);
        }
示例#3
0
        //---------------------------------------------------------------------------------------------------------------------

        public static CloudAppliance FromOneXmlTemplate(IfyContext context, string sbXmlTemplate)
        {
            OneCloudAppliance result = new OneCloudAppliance(context);

            // One of the parameter is a base64 xml template from opennebula
            XmlDocument sbXmlDoc = new XmlDocument();

            sbXmlDoc.LoadXml(sbXmlTemplate);

            result.Name     = sbXmlDoc.SelectSingleNode("/VM/NAME").InnerText;
            result.RemoteId = sbXmlDoc.SelectSingleNode("/VM/ID").InnerText;
            XmlNode itnode = sbXmlDoc.SelectSingleNode("/VM/TEMPLATE/INSTANCE_TYPE");

            if (itnode != null)
            {
                result.VMTemplate = new OneVMTemplate(context);
            }
            result.Network           = new OneNetwork(context);
            result.Network.IpAddress = sbXmlDoc.SelectSingleNode("/VM/TEMPLATE/NIC/IP").InnerText;
            result.State             = MachineState.Active;
            result.StatusText        = "UNKNOWN";
            return(result);
        }