public static void main(String[] args) throws Exception { ServiceInstance si = new ServiceInstance(new URL("https://8.8.8.8/sdk"), "administrator", "vmware", true); LicenseManager lm = si.getLicenseManager(); LicenseAssignmentManager lam = lm.getLicenseAssignmentManager(); LicenseAssignmentManagerLicenseAssignment[] las = lam.queryAssignedLicenses(null); String newLic = "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX"; String oldLic = "YYYYY-YYYYY-YYYYY-YYYYY-YYYYY"; List<LicEntity> entities = new ArrayList<LicEntity>(); for(LicenseAssignmentManagerLicenseAssignment la : las) { LicenseManagerLicenseInfo licInfo = la.getAssignedLicense(); if(oldLic.equals(licInfo.getLicenseKey())) { entities.add(new LicEntity(la.getEntityId(), la.getEntityDisplayName())); System.out.println("entityId:" + la.getEntityId()); } } lm.addLicense(newLic, null); for(LicEntity e : entities) { lam.updateAssignedLicense(e.entityId, newLic, e.displayName); } lm.removeLicense(oldLic); }
public LicenseAssignmentManagerLicenseAssignment[] queryAssignedLicenses(String entityId) throws RuntimeFault, RemoteException { return getVimService().queryAssignedLicenses(getMOR(), entityId); }
public LicenseAssignmentManagerLicenseAssignment getAssignedLicenseToHost(ManagedObjectReference hostMor) throws Exception { List<LicenseAssignmentManagerLicenseAssignment> licenses = _context.getVimClient().getService().queryAssignedLicenses(_mor, hostMor.getValue()); return licenses.get(0); }
public LicenseManagerLicenseInfo getHostLicenseInfo(ManagedObjectReference hostMor) throws Exception { // Retrieve license assigned to specified host LicenseAssignmentManagerLicenseAssignment license = getAssignedLicenseToHost(hostMor); return license.getAssignedLicense(); }