• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Datastore类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: forwardMetricsToInsights

import com.vmware.vim25.mo.Datastore; //导入依赖的package包/类
@Scheduled(fixedRateString = "${collection.interval:30000}")
public void forwardMetricsToInsights() throws InvalidProperty, RuntimeFault, RemoteException {
    long start = startTiming();
    int datastoreCount = 0;
    for (String name : datastores) {
        Datastore datastore = (Datastore) inventoryNavigator.searchManagedEntity("Datastore",
                name);
        if (datastore != null) {
            Map<String, Object> attributes = Maps.newHashMap();
            attributes.put("platform_instance", cfInstanceName);
            attributes.put("type", "datastore");
            attributes.put("name", name);
            attributes.put("capacity", bytesToGb(datastore.getSummary().getCapacity()));
            attributes.put("free_space", bytesToGb(datastore.getSummary().getFreeSpace()));
            attributes.put("uncommitted", bytesToGb(datastore.getSummary().getUncommitted()));
            insights.recordCustomEvent("cf_iaas_metrics", attributes);
            datastoreCount++;
        } else {
            LOG.error("Unable to find datastore {}", name);
        }
    }
    endTiming(start, datastoreCount);
}
 
开发者ID:newrelic,项目名称:newrelic-pcf-drain,代码行数:24,代码来源:VSphereMetricsForwarder.java


示例2: getFreeDatastoreName

import com.vmware.vim25.mo.Datastore; //导入依赖的package包/类
static String getFreeDatastoreName(VirtualMachine vm, 
    int size) throws Exception
{
  String dsName = null;
  Datastore[] datastores = vm.getDatastores();
  for(int i=0; i<datastores.length; i++) 
  {
    DatastoreSummary ds = datastores[i].getSummary(); 
    if(ds.getFreeSpace() > size) 
    {
      dsName = ds.getName();
      break;           
    }
  }
  return dsName;
}
 
开发者ID:Juniper,项目名称:vijava,代码行数:17,代码来源:VmDiskOp.java


示例3: main

import com.vmware.vim25.mo.Datastore; //导入依赖的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


示例4: MasterToVirtualMachineCloneSpec

import com.vmware.vim25.mo.Datastore; //导入依赖的package包/类
@Inject
public MasterToVirtualMachineCloneSpec(ResourcePool resourcePool, Datastore datastore, String cloningStrategy, String linuxName, boolean postConfiguration) {
   this.resourcePool = resourcePool;
   this.datastore = datastore;
   this.cloningStrategy = cloningStrategy;
   this.linuxName = linuxName;
   this.postConfiguration = postConfiguration;
}
 
开发者ID:igreenfield,项目名称:jcloud-vsphere,代码行数:9,代码来源:MasterToVirtualMachineCloneSpec.java


示例5: configureRelocateSpec

import com.vmware.vim25.mo.Datastore; //导入依赖的package包/类
private VirtualMachineRelocateSpec configureRelocateSpec(ResourcePool resourcePool, Datastore datastore, VirtualMachine master)
        throws Exception, InvalidProperty, RuntimeFault, RemoteException {
   VirtualMachineRelocateSpec rSpec = new VirtualMachineRelocateSpec();
   if (cloningStrategy.equals("linked")) {
      ArrayList<Integer> diskKeys = getIndependentVirtualDiskKeys(master);
      if (diskKeys.size() > 0) {
         Datastore[] dss = master.getDatastores();

         VirtualMachineRelocateSpecDiskLocator[] diskLocator = new VirtualMachineRelocateSpecDiskLocator[diskKeys.size()];
         int count = 0;
         for (Integer key : diskKeys) {
            diskLocator[count] = new VirtualMachineRelocateSpecDiskLocator();
            diskLocator[count].setDatastore(dss[0].getMOR());
            diskLocator[count]
                    .setDiskMoveType(VirtualMachineRelocateDiskMoveOptions.moveAllDiskBackingsAndDisallowSharing
                            .toString());
            diskLocator[count].setDiskId(key);
            count = count + 1;
         }
         rSpec.setDiskMoveType(VirtualMachineRelocateDiskMoveOptions.createNewChildDiskBacking.toString());
         rSpec.setDisk(diskLocator);
      } else {
         rSpec.setDiskMoveType(VirtualMachineRelocateDiskMoveOptions.createNewChildDiskBacking.toString());
      }
   } else if (cloningStrategy.equals("full")) {
      rSpec.setDatastore(datastore.getMOR());
      rSpec.setPool(resourcePool.getMOR());
      //rSpec.setHost();
   } else
      throw new Exception(String.format("Cloning strategy %s not supported", cloningStrategy));
   return rSpec;
}
 
开发者ID:igreenfield,项目名称:jcloud-vsphere,代码行数:33,代码来源:MasterToVirtualMachineCloneSpec.java


示例6: getDatastore

import com.vmware.vim25.mo.Datastore; //导入依赖的package包/类
public Datastore getDatastore() {
   Datastore datastore = null;
   long freeSpace = 0;
   try {
      for (Datastore d : host.getDatastores()) {
         if (d.getSummary().getFreeSpace() > freeSpace) {
            freeSpace = d.getSummary().getFreeSpace();
            datastore = d;
         }
      }
   } catch (Throwable e) {
      Throwables.propagate(e);
   }
   return datastore;
}
 
开发者ID:igreenfield,项目名称:jcloud-vsphere,代码行数:16,代码来源:VSphereHost.java


示例7: createCloneSpec

import com.vmware.vim25.mo.Datastore; //导入依赖的package包/类
protected VirtualMachineCloneSpec createCloneSpec(String computeResourceName, String resourcePoolName,
        String datastoreName) {
    VirtualMachineRelocateSpec relocateSpec = new VirtualMachineRelocateSpec();

    // ComputeResource
    ComputeResource computeResource = vmwareClient.search(ComputeResource.class, computeResourceName);
    if (computeResource == null) {
        // ComputeResourceが見つからない場合
        throw new AutoException("EPROCESS-000503", computeResourceName);
    }

    // ResourcePool
    if (StringUtils.isEmpty(resourcePoolName)) {
        resourcePoolName = "Resources";
    }
    ResourcePool resourcePool = vmwareClient.search(computeResource, ResourcePool.class, resourcePoolName);
    if (resourcePool == null) {
        // ResourcePoolが見つからない場合
        throw new AutoException("EPROCESS-000504", resourcePoolName);
    }
    relocateSpec.setPool(resourcePool.getMOR());

    // Datastore
    if (StringUtils.isNotEmpty(datastoreName)) {
        // データストアが指定されている場合
        Datastore datastore = vmwareClient.search(Datastore.class, datastoreName);
        if (datastore == null) {
            // データストアが見つからない場合
            throw new AutoException("EPROCESS-000505", datastoreName);
        }
        relocateSpec.setDatastore(datastore.getMOR());
    }

    VirtualMachineCloneSpec cloneSpec = new VirtualMachineCloneSpec();
    cloneSpec.setLocation(relocateSpec);
    cloneSpec.setPowerOn(false);
    cloneSpec.setTemplate(false);

    return cloneSpec;
}
 
开发者ID:primecloud-controller-org,项目名称:primecloud-controller,代码行数:41,代码来源:VmwareProcessClient.java


示例8: deleteDisk

import com.vmware.vim25.mo.Datastore; //导入依赖的package包/类
public void deleteDisk(String datastoreName, String fileName) {
    // Datacenter
    ManagedEntity datacenter = vmwareClient.getRootEntity();

    // Datastore
    Datastore datastore = vmwareClient.search(Datastore.class, datastoreName);
    if (datastore == null) {
        // データストアが見つからない場合
        throw new AutoException("EPROCESS-000505", datastoreName);
    }

    // ディスクの削除
    FileManager fileManager = vmwareClient.getServiceInstance().getFileManager();
    if (fileManager == null) {
        // fileManagerが利用できない場合
        throw new AutoException("EPROCESS-000533");
    }

    try {
        // ディスク削除
        fileManager.deleteDatastoreFile_Task(fileName, (Datacenter) datacenter);
        // ディスク削除後にごみができ、再度アタッチするとエラーになるので削除
        String flatname;
        flatname = fileName.substring(0, fileName.length() - 5) + "-flat.vmdk";
        fileManager.deleteDatastoreFile_Task(flatname, (Datacenter) datacenter);
    } catch (RemoteException e) {
        throw new AutoException("EPROCESS-000522", e, fileName);
    }

    if (log.isInfoEnabled()) {
        log.info(MessageUtils.getMessage("IPROCESS-100455", fileName));
    }
}
 
开发者ID:primecloud-controller-org,项目名称:primecloud-controller,代码行数:34,代码来源:VmwareProcessClient.java


示例9: selectDatastore

import com.vmware.vim25.mo.Datastore; //导入依赖的package包/类
protected String selectDatastore(VmwareProcessClient vmwareProcessClient, VmwareInstance vmwareInstance) {
    // データストアフォルダ内のデータストアのうち、アクセス可能で空き容量が最も大きいものを用いる
    Datastore datastore = null;
    long freeSpace = 0L;

    // ComputeResourceごとのフォルダがあれば、その中のデータストアを用いる
    String datastoreFolderName = vmwareInstance.getComputeResource() + "-storage";
    Folder datastoreFolder = vmwareProcessClient.getVmwareClient().search(Folder.class, datastoreFolderName);
    if (datastoreFolder == null) {
        // ComputeResourceごとのフォルダがなければ、"storage"フォルダの中のデータストアを用いる
        datastoreFolder = vmwareProcessClient.getVmwareClient().search(Folder.class, "storage");
    }

    if (datastoreFolder != null) {
        ManagedEntity[] entities = vmwareProcessClient.getVmwareClient().searchByType(datastoreFolder,
                Datastore.class);
        for (ManagedEntity entity : entities) {
            Datastore datastore2 = Datastore.class.cast(entity);
            DatastoreSummary summary2 = datastore2.getSummary();

            if (summary2.isAccessible() && freeSpace < summary2.getFreeSpace()) {
                datastore = datastore2;
                freeSpace = summary2.getFreeSpace();
            }
        }
    }

    if (datastore == null) {
        // 利用可能なデータストアがない場合
        throw new AutoException("EPROCESS-000528", vmwareInstance.getComputeResource());
    }

    return datastore.getName();
}
 
开发者ID:primecloud-controller-org,项目名称:primecloud-controller,代码行数:35,代码来源:VmwareMachineProcess.java


示例10: existsNFSStore

import com.vmware.vim25.mo.Datastore; //导入依赖的package包/类
public boolean existsNFSStore(String name, String host, String address, String path) throws Exception {
	if(address == null || path == null || address.isEmpty() || path.isEmpty()) {
		return false;
	}
	ServiceInstance si = new ServiceInstance(new URL(this._url), this._user, this._password, true);
	if(host == null || host.isEmpty()) {
		si.getServerConnection().logout();
		throw new Exception("invalid host name");
	}
	try {
		HostSystem _host = (HostSystem) new InventoryNavigator(si.getRootFolder()).searchManagedEntity("HostSystem", host);
		if(_host == null) {
			si.getServerConnection().logout();
			throw new Exception("host system not found");
		}
		
		HostDatastoreSystem _hds = _host.getHostDatastoreSystem();
		for(Datastore _ds : _hds.getDatastores()) {
			DatastoreInfo _info = _ds.getInfo();
			if(_info instanceof NasDatastoreInfo) {
				NasDatastoreInfo _nasinfo = (NasDatastoreInfo) _info;
				if(name.equalsIgnoreCase(_nasinfo.getNas().getName())) {
					return true;
				} else if(address.equalsIgnoreCase(_nasinfo.getNas().getRemoteHost()) &&
						path.equalsIgnoreCase(_nasinfo.getNas().getRemotePath())) {
					return true;
				}
			}
		}
	} catch(Exception _ex) {
	} finally {
		si.getServerConnection().logout();
	}
	return false;
}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:36,代码来源:HypervisorManagerVMware.java


示例11: attachDisk

import com.vmware.vim25.mo.Datastore; //导入依赖的package包/类
/**
 * TODO: メソッドコメントを記述
 *
 * @param vmwareProcessClient
 * @param instanceNo
 * @param diskNo
 */
public void attachDisk(VmwareProcessClient vmwareProcessClient, Long instanceNo, Long diskNo) {
    VmwareDisk vmwareDisk = vmwareDiskDao.read(diskNo);

    if (BooleanUtils.isTrue(vmwareDisk.getAttached())) {
        // ディスクがアタッチ済みの場合はスキップ
        return;
    }

    VmwareInstance vmwareInstance = vmwareInstanceDao.read(instanceNo);

    //イベントログ出力
    Component component = componentDao.read(vmwareDisk.getComponentNo());
    Instance instance = instanceDao.read(instanceNo);
    Platform platform = platformDao.read(vmwareProcessClient.getPlatformNo());
    if (StringUtils.isEmpty(vmwareDisk.getFileName())) {
        processLogger.debug(component, instance, "VmwareDiskCreate", new Object[] { platform.getPlatformName() });
    } else {
        processLogger.debug(component, instance, "VmwareDiskAttach", new Object[] { platform.getPlatformName(),
                vmwareDisk.getFileName() });
    }

    // ディスクのアタッチ
    VirtualDisk disk = vmwareProcessClient.attachDisk(vmwareInstance.getMachineName(), vmwareDisk.getScsiId(),
            vmwareDisk.getSize(), vmwareDisk.getFileName());

    // ディスク情報の取得
    VirtualDeviceFileBackingInfo backingInfo = VirtualDeviceFileBackingInfo.class.cast(disk.getBacking());
    Datastore datastore = new Datastore(vmwareProcessClient.getVmwareClient().getServiceInstance()
            .getServerConnection(), backingInfo.getDatastore());

    //イベントログ出力
    if (StringUtils.isEmpty(vmwareDisk.getFileName())) {
        processLogger.debug(component, instance, "VmwareDiskCreateFinish",
                new Object[] { platform.getPlatformName(), backingInfo.getFileName(), vmwareDisk.getSize() });
    } else {
        processLogger.debug(component, instance, "VmwareDiskAttachFinish",
                new Object[] { platform.getPlatformName(), vmwareDisk.getFileName(), vmwareDisk.getSize() });
    }

    // データベース更新
    vmwareDisk = vmwareDiskDao.read(diskNo);
    vmwareDisk.setAttached(true);
    vmwareDisk.setDatastore(datastore.getName());
    vmwareDisk.setFileName(backingInfo.getFileName());
    vmwareDiskDao.update(vmwareDisk);
}
 
开发者ID:primecloud-controller-org,项目名称:primecloud-controller,代码行数:54,代码来源:VmwareDiskProcess.java


示例12: getVirtualMachine

import com.vmware.vim25.mo.Datastore; //导入依赖的package包/类
public Map<String, String> getVirtualMachine(String name) throws Exception {
	if(name == null || name.isEmpty()) {
		throw new Exception("invalid virtual machine name");
	}
	
	Map<String,String> _machine = new HashMap<String, String>();
	ServiceInstance si = new ServiceInstance(new URL(this._url), this._user, this._password, true);
	try {
		Folder rootFolder = si.getRootFolder();
		VirtualMachine _vm = (VirtualMachine) new InventoryNavigator(rootFolder).searchManagedEntity("VirtualMachine", name);
		if(_vm == null) {
			throw new Exception("virtual machine not found");
		}
		
		StringBuilder _sb = new StringBuilder();
    	_machine.put("name", _vm.getName());
    	for(Datastore _ds : _vm.getDatastores()) {
    		if(_sb.length() > 0) {
    			_sb.append(":");
    		}
    		_sb.append(_ds.getName());
    	}
    	_machine.put("datastore", _sb.toString());
    	_sb = new StringBuilder();
    	for(Network _nw : _vm.getNetworks()) {
    		if(_sb.length() > 0) {
    			_sb.append(":");
    		}
    		_sb.append(_nw.getName());
    	}
    	_machine.put("network", _sb.toString());
    	_sb = new StringBuilder();
    	VirtualMachineSnapshotTree[] _stree = _vm.getSnapshot().getRootSnapshotList();
	    if(_stree != null) {
	    	for(VirtualMachineSnapshotTree _st : _stree) {
	    		if(_sb.length() > 0) {
	    			_sb.append(":");
	    		}
	    		_sb.append(_st.getName());
	    	}
	    	_machine.put("snapshot", _sb.toString());
	    } else {
	    	_machine.put("snapshot", "");
	    }
    	
	} catch(Exception _ex) {
		throw new Exception("hypervisor error - " + _ex.getMessage());
	} finally {
		si.getServerConnection().logout();
	}
	return _machine;
}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:53,代码来源:HypervisorManagerVMware.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java XmlNamespace类代码示例发布时间:2022-05-23
下一篇:
Java TextFormat类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap