本文整理汇总了Java中org.osc.sdk.manager.element.ManagerDeviceMemberElement类的典型用法代码示例。如果您正苦于以下问题:Java ManagerDeviceMemberElement类的具体用法?Java ManagerDeviceMemberElement怎么用?Java ManagerDeviceMemberElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ManagerDeviceMemberElement类属于org.osc.sdk.manager.element包,在下文中一共展示了ManagerDeviceMemberElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteMemberDevice
import org.osc.sdk.manager.element.ManagerDeviceMemberElement; //导入依赖的package包/类
private static boolean deleteMemberDevice(ManagerDeviceApi mgrApi, String deviceId) {
try {
mgrApi.deleteDeviceMember(deviceId);
return true;
} catch (Exception ex) {
try {
ManagerDeviceMemberElement device = mgrApi.getDeviceMemberById(deviceId);
if (device != null) {
log.error("Fail to delete member device: " + deviceId, ex);
return false;
}
} catch (Exception e) {
log.info("Failed to delete device member id '" + deviceId + "') from MC. Assume already deleted.");
}
}
return true;
}
示例2: updateDeviceMember
import org.osc.sdk.manager.element.ManagerDeviceMemberElement; //导入依赖的package包/类
@Override
public String updateDeviceMember(ManagerDeviceMemberElement deviceElement, String name, String vserverIpAddress,
String contactIpAddress, String ipAddress, String gateway, String prefixLength) throws Exception {
DeviceMemberEntity deviceMember = new DeviceMemberEntity();
deviceMember.setId(Long.parseLong(deviceElement.getId()));
deviceMember.setName(name);
setDefaultMemberState(deviceMember);
updateMember(deviceMember, vserverIpAddress, contactIpAddress, ipAddress, gateway, prefixLength);
return updateDeviceMember(deviceMember, Long.parseLong(this.vs.getMgrId()));
}
示例3: findDeviceMemberByName
import org.osc.sdk.manager.element.ManagerDeviceMemberElement; //导入依赖的package包/类
@Override
public ManagerDeviceMemberElement findDeviceMemberByName(final String name) throws Exception {
return this.txControl.supports(() -> {
DeviceMemberEntity result = getDeviceMember(Long.parseLong(IsmDeviceApi.this.vs.getMgrId()), null,
name);
return result;
});
}
示例4: listDeviceMembers
import org.osc.sdk.manager.element.ManagerDeviceMemberElement; //导入依赖的package包/类
public List<? extends ManagerDeviceMemberElement> listDeviceMembers(Long deviceId) throws Exception {
return this.txControl.supports(() -> {
CriteriaBuilder criteriaBuilder = IsmDeviceApi.this.em.getCriteriaBuilder();
CriteriaQuery<DeviceMemberEntity> query = criteriaBuilder.createQuery(DeviceMemberEntity.class);
Root<DeviceMemberEntity> r = query.from(DeviceMemberEntity.class);
query.select(r)
.where(criteriaBuilder.and(criteriaBuilder.equal(r.get("device").get("id"), deviceId)));
return IsmDeviceApi.this.em.createQuery(query).getResultList();
});
}
示例5: createMemberDevice
import org.osc.sdk.manager.element.ManagerDeviceMemberElement; //导入依赖的package包/类
public void createMemberDevice(EntityManager em, DistributedApplianceInstance dai, ManagerDeviceApi mgrApi)
throws Exception {
try {
String mgrDeviceId = mgrApi.createDeviceMember(dai.getName(), dai.getHostName(), dai.getIpAddress(),
dai.getMgmtIpAddress(), dai.getMgmtGateway(), dai.getMgmtSubnetPrefixLength());
dai.setMgrDeviceId(mgrDeviceId);
log.info("Create new member device (" + mgrDeviceId + ") successfully created.");
updateApplianceConfigIfNeeded(dai, mgrApi);
OSCEntityManager.update(em, dai, this.txBroadcastUtil);
} catch (Exception e) {
log.info("Failed to locate device in Manager.");
ManagerDeviceMemberElement deviceElement = mgrApi.findDeviceMemberByName(dai.getName());
if (deviceElement != null) {
log.info("Found existing device (" + deviceElement.getId() + ").");
String updatedDeviceId = mgrApi.updateDeviceMember(deviceElement, dai.getName(), dai.getHostName(), dai.getIpAddress(),
dai.getMgmtIpAddress(), dai.getMgmtGateway(), dai.getMgmtSubnetPrefixLength());
dai.setMgrDeviceId(updatedDeviceId);
updateApplianceConfigIfNeeded(dai, mgrApi);
OSCEntityManager.update(em, dai, this.txBroadcastUtil);
} else {
throw e;
}
}
}
示例6: executeTransaction
import org.osc.sdk.manager.element.ManagerDeviceMemberElement; //导入依赖的package包/类
@Override
public void executeTransaction(EntityManager em) throws Exception {
try (ManagerDeviceApi mgrApi = this.apiFactoryService.createManagerDeviceApi(this.vs)) {
for (ManagerDeviceMemberElement mgrDeviceMember : mgrApi.listDeviceMembers()) {
for (DistributedApplianceInstance dai : this.vs.getDistributedApplianceInstances()) {
if (dai.getName().equals(mgrDeviceMember.getName())
&& !mgrDeviceMember.getId().equals(dai.getMgrDeviceId())) {
dai.setMgrDeviceId(mgrDeviceMember.getId());
OSCEntityManager.update(em, dai, this.txBroadcastUtil);
}
}
}
}
}
示例7: create
import org.osc.sdk.manager.element.ManagerDeviceMemberElement; //导入依赖的package包/类
public MgrDeleteMemberDeviceTask create(VirtualSystem vs, ManagerDeviceMemberElement device) {
MgrDeleteMemberDeviceTask task = new MgrDeleteMemberDeviceTask();
task.apiFactoryService = this.apiFactoryService;
task.vs = vs;
task.device = device;
task.deviceName = device.getName();
task.dbConnectionManager = this.dbConnectionManager;
task.txBroadcastUtil = this.txBroadcastUtil;
return task;
}
示例8: testInitialize
import org.osc.sdk.manager.element.ManagerDeviceMemberElement; //导入依赖的package包/类
@Before
public void testInitialize() throws Exception {
MockitoAnnotations.initMocks(this);
this.em = InMemDB.getEntityManagerFactory().createEntityManager();
populateDatabase();
ManagerDeviceApi mgrDeviceGroupSupportedApi = mock(ManagerDeviceApi.class);
when(mgrDeviceGroupSupportedApi.isDeviceGroupSupported()).thenReturn(true);
ManagerDeviceApi mgrDeviceNoDaiApi = mock(ManagerDeviceApi.class);
when(mgrDeviceNoDaiApi.isDeviceGroupSupported()).thenReturn(true);
ManagerDeviceApi mgrDeviceGroupNotSupportedApi = mock(ManagerDeviceApi.class);
when(mgrDeviceGroupNotSupportedApi.isDeviceGroupSupported()).thenReturn(false);
Mockito.<List<? extends ManagerDeviceMemberElement>>when(mgrDeviceNoDaiApi.listDeviceMembers())
.thenReturn(Arrays.asList(MGR_DEVICE_MEMBER_ELEMENT_NO_DAI));
Mockito.<List<? extends ManagerDeviceMemberElement>>when(mgrDeviceGroupSupportedApi.listDeviceMembers())
.thenReturn(Arrays.asList(MGR_DEVICE_MEMBER_ELEMENT_WITH_DAI));
this.apiFactoryService = mock(ApiFactoryService.class);
when(this.apiFactoryService.createManagerDeviceApi(MANAGER_ID_PRESENT_NO_DAI_DEVICE_VS))
.thenReturn(mgrDeviceNoDaiApi);
when(this.apiFactoryService.createManagerDeviceApi(MANAGER_ID_NOT_PRESENT_VS))
.thenReturn(mgrDeviceGroupSupportedApi);
when(this.apiFactoryService.createManagerDeviceApi(MANAGER_DEVICE_ID_PRESENT_VS))
.thenReturn(mgrDeviceGroupSupportedApi);
when(this.apiFactoryService.createManagerDeviceApi(DAI_IP_PRESENT_VS))
.thenReturn(mgrDeviceGroupSupportedApi);
when(this.apiFactoryService.createManagerDeviceApi(MANAGER_DEVICE_ID_AND_DAI_IP_NOT_PRESENT_VS))
.thenReturn(mgrDeviceGroupSupportedApi);
when(this.apiFactoryService.createManagerDeviceApi(DEVICE_GROUP_NOT_SUPPORTED_VS))
.thenReturn(mgrDeviceGroupNotSupportedApi);
when(this.apiFactoryService.createManagerDeviceApi(MANAGER_ID_AND_DAI_DEVICE_PRESENT_VS))
.thenReturn(mgrDeviceGroupSupportedApi);
}
示例9: getDeviceMemberById
import org.osc.sdk.manager.element.ManagerDeviceMemberElement; //导入依赖的package包/类
@Override
public ManagerDeviceMemberElement getDeviceMemberById(final String id) throws Exception {
return getDeviceMemberById(Long.parseLong(this.vs.getMgrId()), Long.parseLong(id));
}
示例10: createManagerDeviceMember
import org.osc.sdk.manager.element.ManagerDeviceMemberElement; //导入依赖的package包/类
private static ManagerDeviceMemberElement createManagerDeviceMember(String name) {
ManagerDeviceMemberElement managerDeviceMember = Mockito.mock(ManagerDeviceMemberElement.class);
Mockito.doReturn(name).when(managerDeviceMember).getName();
return managerDeviceMember;
}
示例11: start
import org.osc.sdk.manager.element.ManagerDeviceMemberElement; //导入依赖的package包/类
@Before
public void start() throws Exception {
VSElement vs = new VSElement(1L, VSS_TEST);
VirtualSystemElement vse = vs;
String deviceId;
ManagerDeviceApi managerDeviceApi = this.api.createManagerDeviceApi(null, vse);
deviceId = managerDeviceApi.createVSSDevice();
assertNotNull(deviceId);
vs.setMgrId(Long.parseLong(deviceId));
managerDeviceApi = this.api.createManagerDeviceApi(null, vs);
assertEquals(1, managerDeviceApi.listDevices().size());
assertNotNull(managerDeviceApi.createDeviceMember(DEVICE_MEMBER_TEST, null, null, null, null, null));
ManagerDeviceMemberElement member = managerDeviceApi.findDeviceMemberByName(DEVICE_MEMBER_TEST);
managerDeviceApi.deleteDeviceMember(member.getId());
managerDeviceApi.deleteVSSDevice();
assertEquals(Collections.emptyList(), managerDeviceApi.listDevices());
}
示例12: updateDeviceMember
import org.osc.sdk.manager.element.ManagerDeviceMemberElement; //导入依赖的package包/类
/**
* Updates a device member using the context of the current virtual system.
*
* @param deviceElement the device member being updated
* @param name the new unique name of the device provided by OSC
* @param deviceHostName the name or IP address of the hypervisor hosting this device
* @param ipAddress the device immutable and unique IPv4 address
* @param mgmtIPAddress the device management IP address
* @param gateway the device gateway IP address
* @param prefixLength the device subnet prefix length
* @return the identifier of the updated device
*
* @throws Exception upon failure
*/
String updateDeviceMember(ManagerDeviceMemberElement deviceElement, String name,
String deviceHostName, String ipAddress, String mgmtIPAddress, String gateway, String prefixLength)
throws Exception;
示例13: getDeviceMemberById
import org.osc.sdk.manager.element.ManagerDeviceMemberElement; //导入依赖的package包/类
/**
* Retrieves the device member given its identifier and the context of the current virtual system.
*
* @param id the identifier of the targeted device member
* @return The device member, null if not found
* @throws Exception upon failure
*/
ManagerDeviceMemberElement getDeviceMemberById(String id) throws Exception;
示例14: findDeviceMemberByName
import org.osc.sdk.manager.element.ManagerDeviceMemberElement; //导入依赖的package包/类
/**
* Retrieves the device member given its name and the context of the current virtual system.
*
* @param name the name of the targeted device member
* @return The device member, null if not found
* @throws Exception upon failure
*/
ManagerDeviceMemberElement findDeviceMemberByName(String name) throws Exception;
示例15: listDeviceMembers
import org.osc.sdk.manager.element.ManagerDeviceMemberElement; //导入依赖的package包/类
/**
* Retrieves the list of all device members for the current virtual system.
*
* @return the collection of all device members for the current virtual system
* @throws Exception upon failure
*/
List<? extends ManagerDeviceMemberElement> listDeviceMembers() throws Exception;