本文整理汇总了C#中SR.GetStorageHost方法的典型用法代码示例。如果您正苦于以下问题:C# SR.GetStorageHost方法的具体用法?C# SR.GetStorageHost怎么用?C# SR.GetStorageHost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SR
的用法示例。
在下文中一共展示了SR.GetStorageHost方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SrAction
public SrAction(SrActionKind kind, SR sr)
: base(sr.Connection, GetTitle(kind, sr))
{
this.kind = kind;
this.SR = sr;
Pool pool = Helpers.GetPoolOfOne(sr.Connection);
if (pool != null)
Pool = pool;
Host host = sr.GetStorageHost();
if (host != null)
Host = host;
}
示例2: UploadSupplementalPack
private string UploadSupplementalPack(SR sr)
{
this.Description = String.Format(Messages.SUPP_PACK_UPLOADING_TO, sr.Name);
String result;
log.DebugFormat("Creating vdi of size {0} bytes on SR '{1}'", diskSize, sr.Name);
VDI vdi = NewVDI(sr);
XenRef<VDI> vdiRef = null;
try
{
vdiRef = VDI.create(Session, vdi);
}
catch (Exception ex)
{
log.ErrorFormat("{0} {1}", "Failed to create VDI", ex.Message);
throw;
}
log.DebugFormat("Uploading file '{0}' to VDI '{1}' on SR '{2}'", suppPackFilePath, vdi.Name, sr.Name);
Host localStorageHost = sr.GetStorageHost();
string hostUrl;
if (localStorageHost == null)
{
Uri uri = new Uri(Session.Url);
hostUrl = uri.Host;
}
else
{
log.DebugFormat("SR is not shared -- redirecting to {0}", localStorageHost.address);
hostUrl = localStorageHost.address;
}
log.DebugFormat("Using {0} for import", hostUrl);
try
{
HTTP.UpdateProgressDelegate progressDelegate = delegate(int percent)
{
var actionPercent = (int)(((totalUploaded * 100) + percent) / totalCount);
Tick(actionPercent, Description);
};
Session session = NewSession();
RelatedTask = Task.create(Session, "uploadTask", hostUrl);
result = HTTPHelper.Put(progressDelegate, GetCancelling, true, Connection, RelatedTask, ref session, suppPackFilePath, hostUrl,
(HTTP_actions.put_sss)HTTP_actions.put_import_raw_vdi,
session.uuid, vdiRef.opaque_ref);
}
catch (Exception ex)
{
log.ErrorFormat("{0} {1}", "Failed to import a virtual disk via HTTP.", ex.Message);
if (vdiRef != null)
RemoveVDI(Session, vdiRef);
throw;
}
finally
{
Task.destroy(Session, RelatedTask);
RelatedTask = null;
}
if (localStorageHost != null)
VdiRefs.Add(localStorageHost, vdiRef);
else // shared SR
foreach (var server in servers)
VdiRefs.Add(server, vdiRef);
totalUploaded++;
Description = String.Format(Messages.SUPP_PACK_UPLOADED, sr.Name);
return result;
}
示例3: UploadSupplementalPack
private string UploadSupplementalPack(SR sr)
{
this.Description = String.Format(Messages.SUPP_PACK_UPLOADING_TO, sr.Name);
String result;
log.DebugFormat("Creating vdi of size {0} bytes on SR '{1}'", diskSize, sr.Name);
VDI vdi = NewVDI(sr);
XenRef<VDI> vdiRef = null;
try
{
vdiRef = VDI.create(Session, vdi);
}
catch (Exception ex)
{
log.ErrorFormat("{0} {1}", "Failed to create VDI", ex.Message);
throw;
}
log.DebugFormat("Uploading file '{0}' to VDI '{1}' on SR '{2}'", suppPackFilePath, vdi.Name, sr.Name);
Host localStorageHost = sr.GetStorageHost();
string hostUrl;
if (localStorageHost == null)
{
Uri uri = new Uri(Session.Url);
hostUrl = uri.Host;
}
else
{
log.DebugFormat("SR is not shared -- redirecting to {0}", localStorageHost.address);
hostUrl = localStorageHost.address;
}
log.DebugFormat("Using {0} for import", hostUrl);
try
{
HTTP.UpdateProgressDelegate progressDelegate = delegate(int percent)
{
var actionPercent = (int)(((totalUploaded * 100) + percent) / totalCount);
Tick(actionPercent, Description);
};
Session session = NewSession();
RelatedTask = Task.create(Session, "uploadTask", hostUrl);
result = HTTPHelper.Put(progressDelegate, GetCancelling, true, Connection, RelatedTask, ref session, suppPackFilePath, hostUrl,
(HTTP_actions.put_sss)HTTP_actions.put_import_raw_vdi,
session.uuid, vdiRef.opaque_ref);
}
catch (Exception ex)
{
log.ErrorFormat("{0} {1}", "Failed to import a virtual disk over HTTP.", ex.Message);
if (vdiRef != null)
RemoveVDI(Session, vdiRef);
throw;
}
finally
{
Task.destroy(Session, RelatedTask);
RelatedTask = null;
}
if (localStorageHost != null)
VdiRefsToCleanUp.Add(localStorageHost, vdiRef);
else // shared SR
foreach (var server in servers)
VdiRefsToCleanUp.Add(server, vdiRef);
//introduce ISO for Ely and higher
if (Helpers.ElyOrGreater(Connection))
{
try
{
var poolUpdateRef = Pool_update.introduce(Connection.Session, vdiRef);
poolUpdate = Connection.WaitForCache(poolUpdateRef);
if (poolUpdate == null)
throw new Exception(Messages.UPDATE_ERROR_INTRODUCE); // This should not happen, because such case will result in a XAPI Failure. But this code has to be protected at this point.
VdiRefsToCleanUp.Clear();
}
catch (Failure ex)
{
if (ex.ErrorDescription != null && ex.ErrorDescription.Count > 1 && string.Equals("UPDATE_ALREADY_EXISTS", ex.ErrorDescription[0], StringComparison.InvariantCultureIgnoreCase))
{
string uuidFound = ex.ErrorDescription[1];
poolUpdate = Connection.Cache.Pool_updates.FirstOrDefault(pu => string.Equals(pu.uuid, uuidFound, System.StringComparison.InvariantCultureIgnoreCase));
//clean-up the VDI we've just created
try
{
RemoveVDI(Session, vdiRef);
//remove the vdi that have just been cleaned up
var remaining = VdiRefsToCleanUp.Where(kvp => kvp.Value != null && kvp.Value.opaque_ref != vdiRef.opaque_ref).ToList();
VdiRefsToCleanUp.Clear();
//.........这里部分代码省略.........