本文整理汇总了Java中com.vmware.vim25.VimPortType类的典型用法代码示例。如果您正苦于以下问题:Java VimPortType类的具体用法?Java VimPortType怎么用?Java VimPortType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VimPortType类属于com.vmware.vim25包,在下文中一共展示了VimPortType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: deleteManagedEntity
import com.vmware.vim25.VimPortType; //导入依赖的package包/类
/**
* Deletes a managed object and waits for the delete operation to complete
*
* @param vimPort
* @param serviceContent
* @param mor
*/
public static boolean deleteManagedEntity(VimPortType vimPort,
ServiceContent serviceContent, ManagedObjectReference mor) {
WaitForValues waitForValues = new WaitForValues(vimPort,
serviceContent);
System.out.println("Deleting : [" + mor.getValue() + "]");
try {
ManagedObjectReference taskmor = vimPort.destroyTask(mor);
if (waitForValues.getTaskResultAfterDone(taskmor)) {
System.out.println("Successful delete of Managed Entity - ["
+ mor.getValue() + "]" + " and Entity Type - ["
+ mor.getType() + "]");
return true;
} else {
System.out
.println("Unable to delete : [" + mor.getValue() + "]");
return false;
}
} catch (Exception e) {
System.out.println("Unable to delete : [" + mor.getValue() + "]");
System.out.println("Reason :" + e.getLocalizedMessage());
return false;
}
}
开发者ID:vmware,项目名称:vsphere-automation-sdk-java,代码行数:31,代码来源:VimUtil.java
示例2: createSnapshot
import com.vmware.vim25.VimPortType; //导入依赖的package包/类
public static boolean createSnapshot(VimPortType vimPort,
ServiceContent serviceContent, ManagedObjectReference vmMor,
String snapshotname, String description) {
WaitForValues waitForValues = new WaitForValues(vimPort,
serviceContent);
System.out.println("Taking snapshot : [" + snapshotname + "]");
try {
ManagedObjectReference taskMor = vimPort.createSnapshotTask(vmMor,
snapshotname, description, false, false);
if (waitForValues.getTaskResultAfterDone(taskMor)) {
System.out.println("Snapshot - [" + snapshotname
+ "] Creation Successful");
return true;
} else {
System.out.println(
"Snapshot - [" + snapshotname + "] Creation Failed");
return false;
}
} catch (Exception e) {
System.out.println(
"Snapshot - [" + snapshotname + "] Creation Failed");
System.out.println("Reason :" + e.getLocalizedMessage());
return false;
}
}
开发者ID:vmware,项目名称:vsphere-automation-sdk-java,代码行数:26,代码来源:VimUtil.java
示例3: setTimeout
import com.vmware.vim25.VimPortType; //导入依赖的package包/类
/**
* Sets the timeout for server connections.
*
* @param timeout the timeout to be used for connecting
* @return true, if the operation was successful
*/
public boolean setTimeout(int timeout) {
if (serviceInstance != null) {
ServerConnection serverConnection = serviceInstance.getServerConnection();
if (serverConnection != null) {
VimPortType vimService = serverConnection.getVimService();
if (vimService != null) {
WSClient wsClient = vimService.getWsc();
if (wsClient != null) {
wsClient.setConnectTimeout(timeout);
wsClient.setReadTimeout(timeout);
return true;
}
}
}
}
return false;
}
开发者ID:opennms-forge,项目名称:vmwareConDiag,代码行数:24,代码来源:ViJavaConnectTest.java
示例4: setTimeout
import com.vmware.vim25.VimPortType; //导入依赖的package包/类
/**
* Sets the timeout for server connections.
*
* @param timeout the timeout to be used for connecting
* @return true, if the operation was successful
*/
public boolean setTimeout(int timeout) {
if (m_serviceInstance != null) {
ServerConnection serverConnection = m_serviceInstance.getServerConnection();
if (serverConnection != null) {
VimPortType vimService = serverConnection.getVimService();
if (vimService != null) {
WSClient wsClient = vimService.getWsc();
if (wsClient != null) {
wsClient.setConnectTimeout(timeout);
wsClient.setReadTimeout(timeout);
return true;
}
}
}
}
return false;
}
开发者ID:qoswork,项目名称:opennmszh,代码行数:24,代码来源:VmwareViJavaAccess.java
示例5: getTaskInfo
import com.vmware.vim25.VimPortType; //导入依赖的package包/类
protected TaskInfo getTaskInfo(VMwareClient vmw,
VMPropertyHandler paramHandler) throws Exception {
String instanceId = paramHandler.getInstanceName();
String taskKey = paramHandler
.getServiceSetting(VMPropertyHandler.TASK_KEY);
logger.debug("VM: " + instanceId + " taskId: " + taskKey);
if (taskKey == null || "".equals(taskKey)) {
return null;
}
VimPortType service = vmw.getConnection().getService();
ManagedObjectReference taskManager = vmw.getConnection()
.getServiceContent().getTaskManager();
ManagedObjectReference taskHistoryCollector = service
.createCollectorForTasks(taskManager, new TaskFilterSpec());
try {
service.resetCollector(taskHistoryCollector);
service.readNextTasks(taskHistoryCollector, 100);
List<TaskInfo> taskList = vmw.getConnection().getService()
.readPreviousTasks(taskHistoryCollector, 100);
if (taskList != null) {
for (TaskInfo taskInfo : taskList) {
if (taskInfo != null && taskKey.equals(taskInfo.getKey())) {
logTaskInfo(taskInfo);
return taskInfo;
}
}
}
logger.error("Task not found. VM: " + instanceId + " taskId: "
+ taskKey);
return null;
} finally {
service.destroyCollector(taskHistoryCollector);
}
}
开发者ID:servicecatalog,项目名称:oscm,代码行数:39,代码来源:Actions.java
示例6: reconfigureVirtualMachine
import com.vmware.vim25.VimPortType; //导入依赖的package包/类
/**
* Reconfigures VMware instance. Memory, CPU, disk space and network
* adapter. The VM has been created and must be stopped to reconfigure the
* hardware.
*/
public TaskInfo reconfigureVirtualMachine(VMPropertyHandler paramHandler)
throws Exception {
LOG.debug("instanceName: " + instanceName);
VimPortType service = vmw.getConnection().getService();
VirtualMachineConfigSpec vmConfigSpec = new VirtualMachineConfigSpec();
vmConfigSpec
.setMemoryMB(Long.valueOf(paramHandler.getConfigMemoryMB()));
vmConfigSpec.setNumCPUs(Integer.valueOf(paramHandler.getConfigCPUs()));
String reqUser = paramHandler
.getServiceSetting(VMPropertyHandler.REQUESTING_USER);
String comment = Messages.get(paramHandler.getLocale(), "vm_comment",
new Object[] { paramHandler.getSettings().getOrganizationName(),
paramHandler.getSettings().getSubscriptionId(),
reqUser });
String annotation = vmConfigSpec.getAnnotation();
comment = updateComment(comment, annotation);
vmConfigSpec.setAnnotation(comment);
DiskManager diskManager = new DiskManager(vmw, paramHandler);
diskManager.reconfigureDisks(vmConfigSpec, vmInstance);
NetworkManager.configureNetworkAdapter(vmw, vmConfigSpec, paramHandler,
vmInstance);
LOG.debug("Call vSphere API: reconfigVMTask()");
ManagedObjectReference reconfigureTask = service
.reconfigVMTask(vmInstance, vmConfigSpec);
return (TaskInfo) vmw.getServiceUtil()
.getDynamicProperty(reconfigureTask, "info");
}
开发者ID:servicecatalog,项目名称:oscm,代码行数:41,代码来源:VM.java
示例7: updateCommentField
import com.vmware.vim25.VimPortType; //导入依赖的package包/类
public TaskInfo updateCommentField(String comment) throws Exception {
LOG.debug("instanceName: " + instanceName + " comment: " + comment);
VimPortType service = vmw.getConnection().getService();
VirtualMachineConfigSpec vmConfigSpec = new VirtualMachineConfigSpec();
String annotation = vmConfigSpec.getAnnotation();
comment = updateComment(comment, annotation);
vmConfigSpec.setAnnotation(comment);
LOG.debug("Call vSphere API: reconfigVMTask()");
ManagedObjectReference reconfigureTask = service
.reconfigVMTask(vmInstance, vmConfigSpec);
return (TaskInfo) vmw.getServiceUtil()
.getDynamicProperty(reconfigureTask, "info");
}
开发者ID:servicecatalog,项目名称:oscm,代码行数:15,代码来源:VM.java
示例8: powerOffVM
import com.vmware.vim25.VimPortType; //导入依赖的package包/类
/**
* Power off virtual machine
*/
public static void powerOffVM(final Connection connection, final VimPortType vimPort,
final ManagedObjectReference vm) throws Exception {
ManagedObjectReference powerTask = vimPort.powerOffVMTask(vm);
TaskInfo info = VimUtils.waitTaskEnd(connection, powerTask);
if (info.getState() == TaskInfoState.ERROR) {
VimUtils.rethrow(info.getError());
}
}
开发者ID:vmware,项目名称:photon-model,代码行数:12,代码来源:ClientUtils.java
示例9: powerOnVM
import com.vmware.vim25.VimPortType; //导入依赖的package包/类
/**
* Power on virtual machine
*/
public static void powerOnVM(final Connection connection, final VimPortType vimPort,
final ManagedObjectReference vm) throws Exception {
ManagedObjectReference powerTask = vimPort.powerOnVMTask(vm, null);
TaskInfo info = VimUtils.waitTaskEnd(connection, powerTask);
if (info.getState() == TaskInfoState.ERROR) {
VimUtils.rethrow(info.getError());
}
}
开发者ID:vmware,项目名称:photon-model,代码行数:12,代码来源:ClientUtils.java
示例10: powerOffVm
import com.vmware.vim25.VimPortType; //导入依赖的package包/类
private static void powerOffVm(Connection connection, VimPortType vimPort,
ManagedObjectReference vm) {
try {
powerOffVM(connection, vimPort, vm);
} catch (Exception e) {
// Ignore the error message. Don't log. Attempt with the rest of the flow.
}
}
开发者ID:vmware,项目名称:photon-model,代码行数:9,代码来源:ClientUtils.java
示例11: getServiceContent
import com.vmware.vim25.VimPortType; //导入依赖的package包/类
/**
* Get access to the service content
*
* @param vimPortType
* @return {@link ServiceContent}
* @throws RuntimeFaultFaultMsg
*/
public static ServiceContent getServiceContent(VimPortType vimPortType)
throws RuntimeFaultFaultMsg {
// get the service content
ManagedObjectReference serviceInstance = new ManagedObjectReference();
serviceInstance.setType("ServiceInstance");
serviceInstance.setValue("ServiceInstance");
return vimPortType.retrieveServiceContent(serviceInstance);
}
开发者ID:vmware,项目名称:vsphere-automation-sdk-java,代码行数:16,代码来源:VimUtil.java
示例12: retrievePropertiesAllObjects
import com.vmware.vim25.VimPortType; //导入依赖的package包/类
/**
* Uses the new RetrievePropertiesEx method to emulate the now deprecated
* RetrieveProperties method.
*
* @param listpfs
* @return list of object content
* @throws Exception
*/
public static List<ObjectContent> retrievePropertiesAllObjects(
VimPortType vimPort, ManagedObjectReference propCollectorRef,
List<PropertyFilterSpec> listpfs)
throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
RetrieveOptions propObjectRetrieveOpts = new RetrieveOptions();
List<ObjectContent> listobjcontent = new ArrayList<ObjectContent>();
RetrieveResult rslts = vimPort.retrievePropertiesEx(propCollectorRef,
listpfs, propObjectRetrieveOpts);
if (rslts != null && rslts.getObjects() != null
&& !rslts.getObjects().isEmpty()) {
listobjcontent.addAll(rslts.getObjects());
}
String token = null;
if (rslts != null && rslts.getToken() != null) {
token = rslts.getToken();
}
while (token != null && !token.isEmpty()) {
rslts = vimPort.continueRetrievePropertiesEx(propCollectorRef,
token);
token = null;
if (rslts != null) {
token = rslts.getToken();
if (rslts.getObjects() != null
&& !rslts.getObjects().isEmpty()) {
listobjcontent.addAll(rslts.getObjects());
}
}
}
return listobjcontent;
}
开发者ID:vmware,项目名称:vsphere-automation-sdk-java,代码行数:41,代码来源:VimUtil.java
示例13: getProperties
import com.vmware.vim25.VimPortType; //导入依赖的package包/类
/**
* Get the required properties of the specified object.
*
* @param vimPort
* @param serviceContent
* @param moRef
* @param type
* @param properties
* @return
* @throws RuntimeFaultFaultMsg
* @throws InvalidPropertyFaultMsg
*/
public static List<DynamicProperty> getProperties(VimPortType vimPort,
ServiceContent serviceContent, ManagedObjectReference moRef,
String type, List<String> properties)
throws RuntimeFaultFaultMsg, InvalidPropertyFaultMsg {
// Create Property Spec
PropertySpec propertySpec = new PropertySpec();
propertySpec.setAll(false);
propertySpec.setType(type);
propertySpec.getPathSet().addAll(properties);
// Now create Object Spec
ObjectSpec objectSpec = new ObjectSpec();
objectSpec.setObj(moRef);
objectSpec.setSkip(false);
// Create PropertyFilterSpec using the PropertySpec and ObjectPec
// created above.
PropertyFilterSpec propertyFilterSpec = new PropertyFilterSpec();
propertyFilterSpec.getPropSet().add(propertySpec);
propertyFilterSpec.getObjectSet().add(objectSpec);
List<PropertyFilterSpec> listpfs = new ArrayList<PropertyFilterSpec>(1);
listpfs.add(propertyFilterSpec);
List<ObjectContent> listobjcontent = VimUtil
.retrievePropertiesAllObjects(vimPort,
serviceContent.getPropertyCollector(), listpfs);
assert listobjcontent != null && listobjcontent.size() > 0;
ObjectContent contentObj = listobjcontent.get(0);
List<DynamicProperty> objList = contentObj.getPropSet();
return objList;
}
开发者ID:vmware,项目名称:vsphere-automation-sdk-java,代码行数:44,代码来源:VimUtil.java
示例14: KeepAlive
import com.vmware.vim25.VimPortType; //导入依赖的package包/类
/**
* builds an instance of this object
* @param vimPort
* @param serviceInstanceReference
* @param interval
*/
public KeepAlive(final VimPortType vimPort, final ManagedObjectReference serviceInstanceReference, final Long interval) {
this.vimPort = vimPort;
this.serviceInstanceReference = serviceInstanceReference;
this.interval = interval;
this.running = Boolean.TRUE;
}
开发者ID:jdgwartney,项目名称:vsphere-ws,代码行数:13,代码来源:KeepAlive.java
示例15: byName
import com.vmware.vim25.VimPortType; //导入依赖的package包/类
/**
* given a hostname or IP address, returns the managed object ref for that host using
* the connection fed to the constructor.
* <p/>
*
* @param hostname
* @return the matching managed object reference or null
*/
public ManagedObjectReference byName(String hostname) {
ManagedObjectReference host = null;
VimPortType vimPort = connection.getVimPort();
ManagedObjectReference searchIndex = connection.getServiceContent().getSearchIndex();
try {
if (isIpAddress(hostname)) {
final java.net.InetAddress inetAddress = address(hostname);
final String ipAddress = ipAddress(inetAddress);
if ("".equals(ipAddress)) {
throw new GetHostRuntimeFault(String.format(
"could not properly verify '%s' as an IP address", hostname
));
}
// find by IP uses a subtly different method call, assuming you can resolve the IP
// you could just use this method all the time... but you can't always reach a host
// from your remote execution context ... and you may have the name.
host = vimPort.findByIp(searchIndex, null, ipAddress, false);
} else {
// a host name could be anything in this scenario since we are talking about
// a name that could potentially be an alias not actually reachable in our
// local command-line context, we'll give it a shot and see if we find anything...
host = vimPort.findByDnsName(searchIndex, null, hostname, false);
}
} catch (RuntimeFaultFaultMsg runtimeFaultFaultMsg) {
throw new GetHostRuntimeFault(runtimeFaultFaultMsg);
}
return host;
}
开发者ID:jdgwartney,项目名称:vsphere-ws,代码行数:38,代码来源:GetHost.java
示例16: vSphereLocationSupplierTest
import com.vmware.vim25.VimPortType; //导入依赖的package包/类
@Test
public void vSphereLocationSupplierTest() throws IOException {
ServerConnection serverConnection = PowerMock.createMock(ServerConnection.class);
WSClient wsClient = PowerMock.createMock(WSClient.class);
ManagedObjectReference managedObjectReference = PowerMock.createMock(ManagedObjectReference.class);
ServiceInstance serviceInstance = PowerMock.createMock(ServiceInstance.class);
CreateAndConnectVSphereClient supplier = PowerMock.createMock(CreateAndConnectVSphereClient.class);
VSphereServiceInstance vSphereServiceInstance = PowerMock.createMock(VSphereServiceInstance.class);
Folder rootFolder = PowerMock.createMock(Folder.class);
expect(supplier.get()).andReturn(vSphereServiceInstance);
expect(vSphereServiceInstance.getInstance()).andReturn(serviceInstance);
expect(serviceInstance.getRootFolder()).andReturn(rootFolder);
expect(rootFolder.getServerConnection()).andReturn(serverConnection).anyTimes();
expect(rootFolder.getMOR()).andReturn(managedObjectReference);
expect(serverConnection.getServiceInstance()).andReturn(serviceInstance).anyTimes();
expect(serverConnection.getVimService()).andReturn(new VimPortType(wsClient)).anyTimes();
AboutInfo aboutInfo = new AboutInfo();
aboutInfo.setApiVersion("5.1");
expect(serviceInstance.getPropertyCollector()).andReturn(new PropertyCollector(serverConnection, managedObjectReference));
expect(serviceInstance.getAboutInfo()).andReturn(aboutInfo);
vSphereServiceInstance.close();
replay(supplier, vSphereServiceInstance, serviceInstance, rootFolder, serverConnection);
VSphereLocationSupplier vSphereLocationSupplier = new VSphereLocationSupplier(supplier);
Set<? extends Location> location = vSphereLocationSupplier.get();
Assert.assertEquals(1, location.size());
for (Location l : location) {
Assert.assertEquals("default", l.getId());
}
verify(supplier, vSphereServiceInstance, serviceInstance, rootFolder, serverConnection);
}
开发者ID:igreenfield,项目名称:jcloud-vsphere,代码行数:40,代码来源:VSphereLocationSupplierTest.java
示例17: retrievePropertiesAllObjects
import com.vmware.vim25.VimPortType; //导入依赖的package包/类
/**
* Uses the new RetrievePropertiesEx method to emulate the now deprecated
* RetrieveProperties method
*
* @param propertyFilterSpecList
* @return list of object content
* @throws Exception
*/
private static List<ObjectContent> retrievePropertiesAllObjects(ConnectionResources connectionResources,
List<PropertyFilterSpec> propertyFilterSpecList)
throws RuntimeFaultFaultMsg, InvalidPropertyFaultMsg {
VimPortType vimPort = connectionResources.getVimPortType();
ManagedObjectReference serviceInstance = connectionResources.getServiceInstance();
ServiceContent serviceContent = vimPort.retrieveServiceContent(serviceInstance);
ManagedObjectReference propertyCollectorReference = serviceContent.getPropertyCollector();
RetrieveOptions propertyObjectRetrieveOptions = new RetrieveOptions();
List<ObjectContent> objectContentList = new ArrayList<>();
RetrieveResult results = vimPort.retrievePropertiesEx(propertyCollectorReference,
propertyFilterSpecList,
propertyObjectRetrieveOptions);
if (results != null && results.getObjects() != null && !results.getObjects().isEmpty()) {
objectContentList.addAll(results.getObjects());
}
String token = null;
if (results != null && results.getToken() != null) {
token = results.getToken();
}
while (token != null && !token.isEmpty()) {
results = vimPort.continueRetrievePropertiesEx(propertyCollectorReference, token);
token = null;
if (results != null) {
token = results.getToken();
if (results.getObjects() != null && !results.getObjects().isEmpty()) {
objectContentList.addAll(results.getObjects());
}
}
}
return objectContentList;
}
开发者ID:CloudSlang,项目名称:cs-actions,代码行数:46,代码来源:GetObjectProperties.java
示例18: ServiceConnection
import com.vmware.vim25.VimPortType; //导入依赖的package包/类
public ServiceConnection(VimPortType service, ServiceContent content) {
this.service = service;
this.content = content;
}
开发者ID:servicecatalog,项目名称:oscm,代码行数:5,代码来源:ServiceConnection.java
示例19: connect
import com.vmware.vim25.VimPortType; //导入依赖的package包/类
/**
* Establish a connection to the vCenter.
*/
public void connect() throws Exception {
// FIXME what to do?
HostnameVerifier hv = new HostnameVerifier() {
@Override
public boolean verify(String urlHostName, SSLSession session) {
return true;
}
};
int numFailedLogins = 0;
boolean repeatLogin = true;
while (repeatLogin) {
try {
HttpsURLConnection.setDefaultHostnameVerifier(hv);
VimService vimService = new VimService();
VimPortType vimPort = vimService.getVimPort();
Map<String, Object> ctxt = ((BindingProvider) vimPort)
.getRequestContext();
ctxt.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);
ctxt.put(BindingProvider.SESSION_MAINTAIN_PROPERTY,
Boolean.TRUE);
ManagedObjectReference morSvcInstance = new ManagedObjectReference();
morSvcInstance.setType("ServiceInstance");
morSvcInstance.setValue("ServiceInstance");
ServiceContent serviceContent = vimPort
.retrieveServiceContent(morSvcInstance);
vimPort.login(serviceContent.getSessionManager(), user,
password, null);
connection = new ServiceConnection(vimPort, serviceContent);
LOG.debug("Established connection to vSphere. URL: " + url
+ ", UserId: " + user);
repeatLogin = false;
} catch (Exception e) {
LOG.error("Failed to establish connection to vSphere. URL: "
+ url + ", UserId: " + user, e);
if (numFailedLogins > 2) {
throw e;
}
numFailedLogins++;
repeatLogin = true;
try {
Thread.sleep(3000);
} catch (@SuppressWarnings("unused") InterruptedException ex) {
Thread.currentThread().interrupt();
}
}
}
}
开发者ID:servicecatalog,项目名称:oscm,代码行数:57,代码来源:VMwareClient.java
示例20: getService
import com.vmware.vim25.VimPortType; //导入依赖的package包/类
public VimPortType getService() {
return getConnection().getService();
}
开发者ID:servicecatalog,项目名称:oscm,代码行数:4,代码来源:VMwareClient.java
注:本文中的com.vmware.vim25.VimPortType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论