当前位置: 首页>>代码示例>>Java>>正文


Java ServiceInstance类代码示例

本文整理汇总了Java中com.vmware.vim25.mo.ServiceInstance的典型用法代码示例。如果您正苦于以下问题:Java ServiceInstance类的具体用法?Java ServiceInstance怎么用?Java ServiceInstance使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ServiceInstance类属于com.vmware.vim25.mo包,在下文中一共展示了ServiceInstance类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: migrateVM

import com.vmware.vim25.mo.ServiceInstance; //导入依赖的package包/类
private static boolean migrateVM(String targetVMName, String newHostName,
    boolean tryAnotherVM, boolean tryAnotherHost) throws Exception {
  ServiceInstance si = new ServiceInstance(new URL(url), username, password,
      true);

  try {
    Folder rootFolder = si.getRootFolder();
    HostSystem newHost = (HostSystem)new InventoryNavigator(rootFolder)
        .searchManagedEntity("HostSystem", newHostName);
    
    return migrateVM(si, rootFolder, newHost, targetVMName, newHostName,
        tryAnotherVM, tryAnotherHost);
  } finally {
    si.getServerConnection().logout();
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:17,代码来源:VIJavaUtil.java

示例2: doMigrateVM

import com.vmware.vim25.mo.ServiceInstance; //导入依赖的package包/类
private static synchronized boolean doMigrateVM(String targetVMName,
    String newHostName) throws Exception {
  ServiceInstance si = new ServiceInstance(new URL(url), username, password,
      true);
  try {
    Folder rootFolder = si.getRootFolder();
    InventoryNavigator in = new InventoryNavigator(rootFolder);
    HostSystem newHost = (HostSystem)in.searchManagedEntity("HostSystem",
        newHostName);
    if (newHost == null) {
      throw new TestException("Could not find host " + newHostName + " as a target host for vMotion.");
    }

    return migrateVM(si, rootFolder, newHost, targetVMName, newHostName);

  } finally {
    si.getServerConnection().logout();
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:20,代码来源:VIJavaUtil.java

示例3: HydraTask_migrateNetDownVM

import com.vmware.vim25.mo.ServiceInstance; //导入依赖的package包/类
public static void HydraTask_migrateNetDownVM() throws Exception {
  SharedMap sMap = VMotionBB.getBB().getSharedMap();

  Boolean bool = (Boolean)sMap.get("connectionDropped");
  if (bool == null || !bool) {
    return;
  }

  initializeParams();
  if (!validateParams()) {
    return;
  }

  ServiceInstance si = new ServiceInstance(new URL(url), username, password,
      true);

  try {
    Folder rootFolder = si.getRootFolder();
    HostSystem newHost = (HostSystem)new InventoryNavigator(rootFolder)
        .searchManagedEntity("HostSystem", hostNames[0]);
    migrateVM(si, rootFolder, newHost, vmNames[0], hostNames[0], false, false);
  } finally {
    si.getServerConnection().logout();
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:26,代码来源:VIJavaUtil.java

示例4: main

import com.vmware.vim25.mo.ServiceInstance; //导入依赖的package包/类
public static void main(String[] args) throws Exception
{
    CommandLineParser clp = new CommandLineParser(new OptionSpec[]{}, args);
   	String urlStr = clp.get_option("url");
 	    String username = clp.get_option("username");
    String password = clp.get_option("password");

	ServiceInstance si = new ServiceInstance(new URL(urlStr), username, password, true);

	String sessionStr = si.getServerConnection().getSessionStr();
	
	System.out.println("sessionStr=" + sessionStr);

	Thread.sleep(30*60*1000);
	
	si.getServerConnection().logout();
}
 
开发者ID:Juniper,项目名称:vijava,代码行数:18,代码来源:SessionProducer.java

示例5: main

import com.vmware.vim25.mo.ServiceInstance; //导入依赖的package包/类
public static void main(String[] args) throws Exception
{
  if(args.length != 3)
  {
    System.out.println("Usage: java PrintAlarmManager " 
      + "<url> <username> <password>");
    return;
  }

  ServiceInstance si = new ServiceInstance(
    new URL(args[0]), args[1], args[2], true);
   
  AlarmManager alarmMgr = si.getAlarmManager();

  System.out.println("Alarm expressions:");
  AlarmExpression[] defaultExps = alarmMgr.getDefaultExpression();
  printAlarmExpressions(defaultExps);

  System.out.println("\n\nAlarm descriptions:");
  AlarmDescription ad = alarmMgr.getDescription();
  printAlarmDescription(ad);
  
  si.getServerConnection().logout();
}
 
开发者ID:Juniper,项目名称:vijava,代码行数:25,代码来源:PrintAlarmManager.java

示例6: isMachineRunning

import com.vmware.vim25.mo.ServiceInstance; //导入依赖的package包/类
@Override
public boolean isMachineRunning( TargetHandlerParameters parameters, String machineId )
throws TargetException {

	boolean result;
	try {
		final ServiceInstance vmwareServiceInstance = getServiceInstance( parameters.getTargetProperties());
		VirtualMachine vm = getVirtualMachine( vmwareServiceInstance, machineId );
		result = vm != null;

	} catch( Exception e ) {
		throw new TargetException( e );
	}

	return result;
}
 
开发者ID:roboconf,项目名称:roboconf-platform,代码行数:17,代码来源:VmwareIaasHandler.java

示例7: retrievePublicIpAddress

import com.vmware.vim25.mo.ServiceInstance; //导入依赖的package包/类
@Override
public String retrievePublicIpAddress( TargetHandlerParameters parameters, String machineId )
throws TargetException {

	String result = null;
	try {
		ServiceInstance vmwareServiceInstance = VmwareIaasHandler.getServiceInstance( parameters.getTargetProperties());
		String rootInstanceName = InstanceHelpers.findRootInstancePath( parameters.getScopedInstancePath());
		VirtualMachine vm = VmwareIaasHandler.getVirtualMachine( vmwareServiceInstance, rootInstanceName );
		if( vm != null )
			result = vm.getGuest().getIpAddress();

	} catch( Exception e ) {
		throw new TargetException( e );
	}

	return result;
}
 
开发者ID:roboconf,项目名称:roboconf-platform,代码行数:19,代码来源:VmwareIaasHandler.java

示例8: HypervisorManagerVMware

import com.vmware.vim25.mo.ServiceInstance; //导入依赖的package包/类
public HypervisorManagerVMware(String address, String user, String password) throws Exception {
	if(!NetworkManager.isValidAddress(address)) {
		throw new Exception("invalid network address");
	}
	
	StringBuilder _sb = new StringBuilder();
	_sb.append("https://");
	_sb.append(address);
	_sb.append("/sdk/VimService");
	this._url = _sb.toString();
	this._address = address;
	this._user = user;
	this._password = password;
	try {
		trustAllHttpsCertificates();
		logger.info("Vmware: connected at first attempt");
	} catch (SSLHandshakeException sslEx) {
		trustAllHttpsCertificatesWithoutKeys();
		logger.info("Vmware: connected at second attempt");
	}
	new ServiceInstance(new URL(this._url), this._user, this._password, true);
}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:23,代码来源:HypervisorManagerVMware.java

示例9: connect

import com.vmware.vim25.mo.ServiceInstance; //导入依赖的package包/类
private void connect() {

        if (configuration != null && configuration.getConfigYml() != null) {
            Map<String, ?> config = configuration.getConfigYml();
            String host = (String) config.get("host");
            String username = (String) config.get("username");
            String password = getPassword(config);

            String url = "https://" + host + "/sdk";
            try {
                ServiceInstance serviceInstance = new ServiceInstance(new URL(url), username, password, true);
                rootFolder = serviceInstance.getRootFolder();
            } catch (Exception e) {
                logger.error("Unable to connect to the host [" + host + "]", e);
                throw new RuntimeException("Unable to connect to the host [" + host + "]", e);
            }
            logger.info("Connection to: " + url + " Successful");
        }
    }
 
开发者ID:Appdynamics,项目名称:vmware-vsphere-monitoring-extension,代码行数:20,代码来源:VMWareMonitor.java

示例10: inventoryNavigator

import com.vmware.vim25.mo.ServiceInstance; //导入依赖的package包/类
@Bean
@ConditionalOnProperty("vsphere.host")
InventoryNavigator inventoryNavigator(@Value("${vsphere.host}") String host,
        @Value("${vsphere.username}") String username,
        @Value("${vsphere.password}") String password) throws MalformedURLException,
        RemoteException {
    URL url = new URL(String.format("https://%s/sdk", host));
    ServiceInstance serviceInstance = new ServiceInstance(url, username, password, true);
    return new InventoryNavigator(serviceInstance.getRootFolder());
}
 
开发者ID:newrelic,项目名称:newrelic-pcf-drain,代码行数:11,代码来源:MonitoringConfiguration.java

示例11: dummyVMotion

import com.vmware.vim25.mo.ServiceInstance; //导入依赖的package包/类
private static void dummyVMotion(ServiceInstance si, Folder rootFolder,
    HostSystem newHost, String targetVMName, String newHostName) {
  log("Selected host [vm] for vMotion: " + newHostName + " [" + targetVMName
      + "]");
  try {Thread.sleep(120000);} catch(InterruptedException ir) {}
  log("vMotion of " + targetVMName + " to " + newHostName
      + " completed");
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:9,代码来源:VMotionTrigger.java

示例12: migrateVM

import com.vmware.vim25.mo.ServiceInstance; //导入依赖的package包/类
private static boolean migrateVM(ServiceInstance si, Folder rootFolder,
    HostSystem newHost, String targetVMName, String newHostName)
    throws Exception {

  log("Selected host [vm] for vMotion: " + newHostName + " [" + targetVMName
      + "]");
  VirtualMachine vm = (VirtualMachine)new InventoryNavigator(rootFolder)
      .searchManagedEntity("VirtualMachine", targetVMName);
  if (vm == null) {
    log(WARNING, "Could not resolve VM " + targetVMName + ", vMotion of this VM cannot be performed.");
    return false;
  }

  ComputeResource cr = (ComputeResource)newHost.getParent();

  String[] checks = new String[] { "cpu", "software" };
  HostVMotionCompatibility[] vmcs = si.queryVMotionCompatibility(vm,
      new HostSystem[] { newHost }, checks);

  String[] comps = vmcs[0].getCompatibility();
  if (checks.length != comps.length) {
    log(WARNING, "CPU/software NOT compatible, vMotion failed.");
    return false;
  }

  long start = System.currentTimeMillis();
  Task task = vm.migrateVM_Task(cr.getResourcePool(), newHost,
      VirtualMachineMovePriority.highPriority,
      VirtualMachinePowerState.poweredOn);
  if (task.waitForMe() == Task.SUCCESS) {
    long end = System.currentTimeMillis();
    log("vMotion of " + targetVMName + " to " + newHostName
        + " completed in " + (end - start) + "ms. Task result: "
        + task.getTaskInfo().getResult());
    return true;
  } else {
    TaskInfo info = task.getTaskInfo();
    log(WARNING, "vMotion of " + targetVMName + " to " + newHostName
        + " failed. Error details: " + info.getError().getFault());
    return false;
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:43,代码来源:VMotionTrigger.java

示例13: validateVMNotOnHost

import com.vmware.vim25.mo.ServiceInstance; //导入依赖的package包/类
private static boolean validateVMNotOnHost(ServiceInstance si,
    Folder rootFolder, HostSystem newHost, String vmName, String hostName)
    throws Exception {
  VirtualMachine[] vms = newHost.getVms();
  for (VirtualMachine vmac : vms) {
    if (vmac.getName().equals(vmName)) {
      Log.getLogWriter().info(
          vmName + " is already running on target host " + hostName
              + ". Selecting another pair...");
      return false;
    }
  }
  return true;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:15,代码来源:VIJavaUtil.java

示例14: main

import com.vmware.vim25.mo.ServiceInstance; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    ServiceInstance si = new ServiceInstance(new URL(
            "https://10.120.30.40/sdk"), "[email protected]",
            "Administrator!23", true);
    // Get the rootFolder
    Folder rootFolder = si.getRootFolder();

    // Get all the hosts in the vCenter server
    ManagedEntity[] hosts = new InventoryNavigator(rootFolder)
            .searchManagedEntities("HostSystem");

    if (hosts == null) {
        System.out.println("Host not found on vCenter");
        si.getServerConnection().logout();
        return;
    }

    // Map to store the datastore name as key and its UUID as the value
    Map< String , String> vmfsdatastoreUUIDs = new HashMap< String , String>();

    // Map to store host as key and all of its datastores as the value
    Map< ManagedEntity , Datastore[]> hostDatastores = new HashMap< ManagedEntity , Datastore[]>();
    for (ManagedEntity hostSystem : hosts) {
        HostDatastoreBrowser hdb = ((HostSystem) hostSystem)
                .getDatastoreBrowser();
        Datastore[] ds = hdb.getDatastores();
        hostDatastores.put(hostSystem, ds);
    }

    System.out.println("Hosts and all of its associated datastores");
    for (Map.Entry < ManagedEntity , Datastore[]> datastores : hostDatastores
            .entrySet()) {
        System.out.println("");
        System.out.print("[" + datastores.getKey().getName() + "::");
        for (Datastore datastore : datastores.getValue()) {
            System.out.print(datastore.getName() + ",");
            DatastoreInfo dsinfo = datastore.getInfo();
            if (dsinfo instanceof VmfsDatastoreInfo) {
                VmfsDatastoreInfo vdinfo = (VmfsDatastoreInfo) dsinfo;
                vmfsdatastoreUUIDs.put(datastore.getName(), vdinfo
                        .getVmfs().getUuid());
            }

        }
        System.out.print("]");
    }
    System.out.println(" ");
    System.out.println("Datastore and its UUID");
    for (Map.Entry< String , String> dsuuid : vmfsdatastoreUUIDs.entrySet()) {
        System.out.println("[" + dsuuid.getKey() + "::" + dsuuid.getValue()
                + "]");
    }
    si.getServerConnection().logout();

}
 
开发者ID:vThinkBeyondVM,项目名称:vThinkBVM-scripts,代码行数:56,代码来源:findVMFSUUIDs.java

示例15: CreateAndConnectVSphereClient

import com.vmware.vim25.mo.ServiceInstance; //导入依赖的package包/类
@Inject
public CreateAndConnectVSphereClient(Function<Supplier<NodeMetadata>, ServiceInstance> providerContextToCloud,
                                     Factory runScriptOnNodeFactory,
                                     @Provider Supplier<URI> providerSupplier,
                                     @Provider Supplier<Credentials> credentials) {

   this.credentials = checkNotNull(credentials, "credentials is needed");
   this.providerSupplier = checkNotNull(providerSupplier, "endpoint to vSphere node or vCenter server is needed");
}
 
开发者ID:igreenfield,项目名称:jcloud-vsphere,代码行数:10,代码来源:CreateAndConnectVSphereClient.java


注:本文中的com.vmware.vim25.mo.ServiceInstance类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。