//--------------------------------------------------------------------------------------------------------------------- public static CloudUser FromIdAndProvider(IfyContext context, int usrId, int providerId) { CloudUser result = new CloudUser(context); result.UserId = usrId; result.ProviderId = providerId; result.Load(); return(result); }
//--------------------------------------------------------------------------------------------------------------------- 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); }