设为首页 收藏本站
查看: 1862|回复: 0

[经验分享] vsphere异常机制

[复制链接]

尚未签到

发表于 2015-10-10 07:23:41 | 显示全部楼层 |阅读模式
一、概览:
  Vsphere的异常机制由两部分构成,一部分是它的API文档中指明的Fault Type类型(如下图所示):
  
  几乎所有的在上图中显示的Fault Type,都有一个API文档中没有,但由JAX自动生成的FaultMsg异常类型。
  
  范例如下图所示:
  
  
  
  其中Fault Type是其对应的异常类的成员,如下图所示:
  
  所以我们所接受到的所有异常,其实都只能由FaultMsg对象来抛出。
  
  所有的Fault Type对象,都有一个共同的祖先:MethodFault类。
  
  Name
  Type
  Description
  dynamicProperty*
  DynamicProperty[]
  Set of dynamic properties. This property is optional because only the properties of an object that are unknown to a client will be part of this set. This property is not readonly just in case we want to send such properties from a client in the future.
  dynamicType*
  xsd:string
  Reserved.
  faultCause*
  LocalizedMethodFault
  Fault which is the cause of this fault.
  Since vSphere API 4.0
  faultMessage*
  LocalizableMessage[]
  Message which has details about the error Message can also contain a key to message catalogue which can be used to generate better localized messages.
  Since vSphere API 4.0
  
  
二、实例:
  我们可以执行的Task有两种,一种是以_Task后缀结尾的,另一种是没有_Task后缀结尾的。
  其中以_Task后缀结尾的Task都可以抛出一系列异常,而这一系列异常可能包含有更详细的子异常。
  
  以PowerOnVM_Task举例,API文档中指出它可以抛出如下异常:
  Faults
  Type
  Description
  DisallowedOperationOnFailoverHost
  Thrown if the host specified is a failover host. See ClusterFailoverHostAdmissionControlPolicy.
  FileFault
  Thrown if there is a problem accessing the virtual machine on the filesystem.
  InsufficientResourcesFault
  Thrown if this operation would violate a resource usage policy.
  InvalidPowerState
  Thrown if the power state is poweredOn.
  InvalidState
  Thrown if the host is in maintenance mode or if the virtual machine's configuration information is not available.
  NotEnoughLicenses
  Thrown if there are not enough licenses to power on this virtual machine.
  NotSupported
  Thrown if the virtual machine is marked as a template.
  RuntimeFault
  Thrown if any type of runtime fault is thrown that is not covered by the other faults; for example, a communication error.
  TaskInProgress
  Thrown if the virtual machine is busy.
  VmConfigFault
  Thrown if a configuration issue prevents the power-on. Typically, a more specific fault, such as UnsupportedVmxLocation, is thrown.
  其中的FileFault类又被如下类所继承:
Fault - FileFault
  Extended by
  CannotAccessFile, CannotCreateFile, CannotDeleteFile, DirectoryNotEmpty, FileAlreadyExists, FileLocked, FileNameTooLong, FileNotFound, FileNotWritable, FileTooLarge, IncorrectFileType, NetworkCopyFault, NoDiskSpace, NotADirectory, NotAFile, TooManyConcurrentNativeClones, TooManyNativeCloneLevels, TooManyNativeClonesOnFile
  又被如下Task抛出:
  Thrown by
  ChangeFileAttributesInGuest, ChangeOwner, CloneVApp_Task, CloneVM_Task, ConsolidateVMDisks_Task, CopyDatastoreFile_Task, CopyVirtualDisk_Task, CreateChildVM_Task, CreateDescriptor, CreateImportSpec, CreateScreenshot_Task, CreateSecondaryVM_Task, CreateSnapshot_Task, CreateTemporaryDirectoryInGuest, CreateTemporaryFileInGuest, CreateVirtualDisk_Task, CreateVM_Task, DefragmentAllDisks, DefragmentVirtualDisk_Task, DeleteDatastoreFile_Task, DeleteDirectory, DeleteDirectoryInGuest, DeleteFile, DeleteFileInGuest, DeleteVirtualDisk_Task, EagerZeroVirtualDisk_Task, EstimateStorageForConsolidateSnapshots_Task, ExportSnapshot, ExportVApp, ExportVm, ExtendVirtualDisk_Task, ImportVApp, InflateVirtualDisk_Task, InitiateFileTransferFromGuest, InitiateFileTransferToGuest, ListFilesInGuest, MakeDirectory, MakeDirectoryInGuest, MarkAsTemplate, MarkAsVirtualMachine, MigrateVM_Task, MoveDatastoreFile_Task, MoveDirectoryInGuest, MoveFileInGuest, MoveVirtualDisk_Task, ParseDescriptor, PowerOnVApp_Task, PowerOnVM_Task, QueryChangedDiskAreas, QueryVirtualDiskFragmentation, QueryVirtualDiskGeometry, QueryVirtualDiskUuid, ReconfigVM_Task, RegisterChildVM_Task, RegisterVM_Task, reloadVirtualMachineFromPath_Task, RelocateVM_Task, RestoreFirmwareConfiguration, RevertToSnapshot_Task, SearchDatastore_Task, SearchDatastoreSubFolders_Task, SetVirtualDiskUuid, ShrinkVirtualDisk_Task, StartProgramInGuest, StartRecording_Task, StartReplaying_Task, StopRecording_Task, StopReplaying_Task, UpdateVAppConfig, ValidateHost, ZeroFillVirtualDisk_Task
  我们可以看到里面明确将Task分为两类,
  一类以_Task后缀结尾,这一类Task抛出的异常,我们不仅可以在Client中监控到:
  
  

  也可以在控制台中输出:
  javax.xml.ws.soap.SOAPFaultException: 指定的参数错误。
  
  
  而第二个任务,则只能在控制台中输出,不能在Client中监测到。但是否被记入Vcenter的数据库,目前尚不清楚。
  
  
  对于实际的后台代码编写,建议对于异常的捕获,只用做到子节点这一级别。如果的确是对详细的报错信息有需求,再做到孙子节点这一级别也可以。
  
  
  注意:
  Client对于异常的捕获,是有优先级的,例如:若同时出现任务重名、参数错误两种异常,则优先输出参数错误的异常。
  

  csdn不能直接复制图片,一张张粘贴工作量太多,我醉了。不传图片了。
  
         版权声明:本文为博主原创文章,未经博主允许不得转载。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.iyunv.com/thread-124823-1-1.html 上篇帖子: vSphere 4系列之四:主机和虚拟机管理 下篇帖子: VMware vSphere 5.1 学习系列之二:安装 Openfiler 存储
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表