org.ovirt.engine.core.common.businessentities.network.Network类的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(13.2k)|赞(0)|评价(0)|浏览(125)

本文整理了Java中org.ovirt.engine.core.common.businessentities.network.Network类的一些代码示例,展示了Network类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Network类的具体详情如下:
包路径:org.ovirt.engine.core.common.businessentities.network.Network
类名称:Network

Network介绍

暂无

代码示例

代码示例来源:origin: oVirt/ovirt-engine

private static Network cloneNetwork(Network instance) {
  Network obj = new Network();
  obj.setAddr(instance.getAddr());
  obj.setDescription(instance.getDescription());
  obj.setComment(instance.getComment());
  obj.setId(instance.getId());
  obj.setName(instance.getName());
  obj.setVdsmName(instance.getVdsmName());
  obj.setSubnet(instance.getSubnet());
  obj.setGateway(instance.getGateway());
  obj.setType(instance.getType());
  obj.setVlanId(instance.getVlanId());
  obj.setStp(instance.getStp());
  obj.setDataCenterId(instance.getDataCenterId());
  obj.setMtu(instance.getMtu());
  obj.setVmNetwork(instance.isVmNetwork());
  if (instance.getCluster() !=null){
    obj.setCluster(cloneNetworkCluster(instance.getCluster()));
  }
  if (instance.getProvidedBy() != null) {
    obj.setProvidedBy(cloneProviderNetwork(instance.getProvidedBy()));
  }
  return obj;
}

代码示例来源:origin: oVirt/ovirt-engine

private Guid getDnsResolverConfigurationId(Network network) {
  DnsResolverConfiguration dnsResolverConfiguration = network.getDnsResolverConfiguration();
  if (dnsResolverConfiguration == null) {
    return null;
  }
  return dnsResolverConfiguration.getId();
}

代码示例来源:origin: oVirt/ovirt-engine

public Network(String addr, String description, Guid id, String name, String vdsmName, String subnet, String gateway,
    Integer type, Integer vlan_id, boolean stp, int mtu, boolean vmNetwork) {
  this();
  this.addr = addr;
  this.setDescription(description);
  this.id = id;
  this.setName(name);
  this.vdsmName = vdsmName;
  this.subnet = subnet;
  this.gateway = gateway;
  this.type = type;
  this.vlanId = vlan_id;
  this.stp = stp;
  this.mtu = mtu;
  this.vmNetwork = vmNetwork;
  this.comment = "";
}

代码示例来源:origin: oVirt/ovirt-engine

public static void setNetworkVdsmName(Network network) {
  String networkName = network.getName();
  if (VALID_VDS_NAME_PATTERN.matcher(networkName).matches()) {
    network.setVdsmName(networkName);
  } else {
    network.setVdsmName("on" + network.getId().toString()
        .replaceAll("[^a-zA-Z0-9]+", "")
        .substring(0, BusinessEntitiesDefinitions.HOST_NIC_NAME_LENGTH - 2));
  }
}

代码示例来源:origin: oVirt/ovirt-engine

@Override
public String toString() {
  return ToStringBuilder.forInstance(this)
      .append("id", getId())
      .append("description", getDescription())
      .append("comment", getComment())
      .append("vdsmName", getVdsmName())
      .append("subnet", getSubnet())
      .append("gateway", getGateway())
      .append("type", getType())
      .append("vlanId", getVlanId())
      .append("stp", getStp())
      .append("dataCenterId", getDataCenterId())
      .append("mtu", getMtu())
      .append("vmNetwork", isVmNetwork())
      .append("cluster", getCluster())
      .append("providedBy", getProvidedBy())
      .append("label", getLabel())
      .append("qosId", getQosId())
      .append("dnsResolverConfiguration", dnsResolverConfiguration)
      .build();
}

代码示例来源:origin: oVirt/ovirt-engine

@Mapping(from = org.ovirt.engine.core.common.businessentities.network.Network.class, to = Network.class)
public static Network map(org.ovirt.engine.core.common.businessentities.network.Network entity, Network template) {
  Network model = template != null ? template : new Network();
  model.setId(entity.getId().toString());
  model.setName(entity.getName());
  model.setDescription(entity.getDescription());
  model.setComment(entity.getComment());
  if (entity.getDataCenterId() != null) {
    DataCenter dataCenter = new DataCenter();
    dataCenter.setId(entity.getDataCenterId().toString());
    model.setDataCenter(dataCenter);
  if (entity.getAddr() != null ||
    entity.getSubnet() != null ||
    entity.getGateway() != null) {
    model.setIp(new Ip());
    model.getIp().setAddress(entity.getAddr());
    model.getIp().setNetmask(entity.getSubnet());
    model.getIp().setGateway(entity.getGateway());
  if (entity.getVlanId() != null) {
    model.setVlan(new Vlan());
    model.getVlan().setId(entity.getVlanId());
  model.setStp(entity.getStp());
  model.setMtu(entity.getMtu());
  if (entity.isVmNetwork()) {
    model.getUsages().getUsages().add(NetworkUsage.VM);

代码示例来源:origin: oVirt/ovirt-engine

@Mapping(from = Network.class, to = org.ovirt.engine.core.common.businessentities.network.Network.class)
public static org.ovirt.engine.core.common.businessentities.network.Network map(Network model, org.ovirt.engine.core.common.businessentities.network.Network template) {
  org.ovirt.engine.core.common.businessentities.network.Network entity = template != null ? template : new org.ovirt.engine.core.common.businessentities.network.Network();
  entity.setCluster(template != null && template.getCluster() != null ? template.getCluster() : new NetworkCluster());
  if (model.isSetId()) {
    entity.setId(GuidUtils.asGuid(model.getId()));
    entity.setName(model.getName());
    entity.setDescription(model.getDescription());
    entity.setComment(model.getComment());
    entity.setDataCenterId(GuidUtils.asGuid(model.getDataCenter().getId()));
      entity.setAddr(model.getIp().getAddress());
      entity.setSubnet(model.getIp().getNetmask());
      entity.setGateway(model.getIp().getGateway());
    entity.setVlanId(model.getVlan().getId());
    entity.setStp(model.isStp());
    entity.getCluster().setDisplay(model.isDisplay());
    entity.getCluster().setDisplay(networkUsages.contains(NetworkUsage.DISPLAY));
    entity.getCluster().setMigration(networkUsages.contains(NetworkUsage.MIGRATION));
    entity.getCluster().setManagement(networkUsages.contains(NetworkUsage.MANAGEMENT));

代码示例来源:origin: oVirt/ovirt-engine

@Override
public T mapRow(ResultSet rs, int rowNum) throws SQLException {
  T entity = createNetworkEntity();
  entity.setId(getGuidDefaultEmpty(rs, "id"));
  entity.setName(rs.getString("name"));
  entity.setVdsmName(rs.getString("vdsm_name"));
  entity.setDescription(rs.getString("description"));
  entity.setComment(rs.getString("free_text_comment"));
  entity.setType((Integer) rs.getObject("type"));
  entity.setAddr(rs.getString("addr"));
  entity.setSubnet(rs.getString("subnet"));
  entity.setGateway(rs.getString("gateway"));
  entity.setVlanId((Integer) rs.getObject("vlan_id"));
  entity.setStp(rs.getBoolean("stp"));
  entity.setDataCenterId(getGuidDefaultEmpty(rs, "storage_pool_id"));
  entity.setMtu(rs.getInt("mtu"));
  entity.setVmNetwork(rs.getBoolean("vm_network"));
  Guid providerId = getGuid(rs, "provider_network_provider_id");
  if (providerId != null) {
    entity.setProvidedBy(new ProviderNetwork(
        providerId,
        rs.getString("provider_network_external_id"),
        getGuid(rs, "provider_physical_network_id")));
  }
  entity.setQosId(getGuid(rs, "qos_id"));
  entity.setLabel(rs.getString("label"));
  Guid dnsResolverConfigurationId = getGuid(rs, "dns_resolver_configuration_id");
  entity.setDnsResolverConfiguration(dnsResolverConfigurationDao.get(dnsResolverConfigurationId));
  return entity;
}

代码示例来源:origin: oVirt/ovirt-engine

private void updateProperties() {
  Network extendedNetwork = getEntity();
  setName(extendedNetwork.getName());
  setId(extendedNetwork.getId());
  setDescription(extendedNetwork.getDescription());
  setVmNetwork(extendedNetwork.isVmNetwork());
  setVlan(extendedNetwork.getVlanId());
  setMtu(extendedNetwork.getMtu());
  setVdsmName(extendedNetwork.getVdsmName());
  if (extendedNetwork.isExternal()) {
    setExternalId(extendedNetwork.getProvidedBy().getExternalId());
  } else {
    setExternalId(null);
  }
}

代码示例来源:origin: oVirt/ovirt-engine

public void flush() {
  network.setDataCenterId(getSelectedDc().getId());
  network.setName(getName().getEntity());
  network.setStp(getIsStpEnabled().getEntity());
  network.setDescription(getDescription().getEntity());
  network.setComment(getComment().getEntity());
  network.setVmNetwork(getIsVmNetwork().getEntity());
  String label = getNetworkLabel().getSelectedItem();
  network.setLabel(StringHelper.isNotNullOrEmpty(label) ? label : null);
  network.setDefaultMtu();
  if (getMtu().getIsChangable()) {
    network.setMtu(Integer.parseInt(getMtu().getEntity().toString()));
  }
  network.setDnsResolverConfiguration(getDnsConfigurationModel().flush());
  network.setVlanId(null);
  if (getHasVLanTag().getEntity() && !getExternal().getEntity()) {
    network.setVlanId(Integer.parseInt(getVLanTag().getEntity().toString()));
  }
  for (VnicProfileModel profileModel : getProfiles().getItems()) {
    profileModel.flush();
  }
  if (getQos().getIsChangable()) {
    HostNetworkQos qos = getQos().getSelectedItem();
    network.setQosId(qos == EMPTY_HOST_NETWORK_QOS ? null : qos.getId());
  }
}

代码示例来源:origin: oVirt/ovirt-engine

private void init() {
  setTitle(ConstantsManager.getInstance().getConstants().editLogicalNetworkTitle());
  setHelpTag(HelpTag.edit_logical_network);
  setHashName("edit_logical_network"); //$NON-NLS-1$
  getName().setEntity(getNetwork().getName());
  getDescription().setEntity(getNetwork().getDescription());
  getComment().setEntity(getNetwork().getComment());
  getIsStpEnabled().setEntity(getNetwork().getStp());
  getConnectedToPhysicalNetwork().setEntity(isConnectedToPhysicalNetwork());
  initMtu();
  initIsVm();
  getExternal().setEntity(getNetwork().isExternal());
  getExternal().setIsChangeable(false);
  if (isConnectedToPhysicalNetwork()) {
    if (getNetwork().getProvidedBy().isSetPhysicalNetworkId()) {
      getUsePhysicalNetworkFromDatacenter().setEntity(true);
    }
  } else {
    getNetworkLabel().setSelectedItem(getNetwork().getLabel());
    getHasVLanTag().setEntity(getNetwork().getVlanId() != null);
    getVLanTag().setEntity(getNetwork().getVlanId());
  }
  toggleProfilesAvailability();
}

代码示例来源:origin: oVirt/ovirt-engine

@Override
protected org.ovirt.engine.core.common.businessentities.network.Network getEntity(int index) {
  org.ovirt.engine.core.common.businessentities.network.Network network = new org.ovirt.engine.core.common.businessentities.network.Network();
  NetworkCluster networkCluster = new NetworkCluster();
  networkCluster.setDisplay(false);
  networkCluster.setMigration(false);
  networkCluster.setRequired(false);
  networkCluster.setDefaultRoute(false);
  network.setCluster(networkCluster);
  network.setId(GUIDS[index]);
  network.setName(NAMES[index]);
  network.setDescription(DESCRIPTIONS[index]);
  network.setDataCenterId(GUIDS[1]);
  return network;
}

代码示例来源:origin: oVirt/ovirt-engine

@Override
public Response doImport(Action action) {
  validateParameters(action, "dataCenter.id|name");
  Guid dataCenterId = getDataCenterId(action);
  ProviderNetwork providerNetwork = new ProviderNetwork(new Guid(providerId), id);
  Network network = new Network();
  network.setProvidedBy(providerNetwork);
  network.setDataCenterId(dataCenterId);
  network.setName(getNetwork().getName());
  AddNetworkStoragePoolParameters parameters = new AddNetworkStoragePoolParameters(dataCenterId, network);
  return doAction(ActionType.AddNetwork, parameters, action);
}

代码示例来源:origin: oVirt/ovirt-engine

@BeforeEach
@Override
public void setUp() throws Exception {
  super.setUp();
  newNet = new Network();
  newNet.setName("newnet1");
  newNet.setVdsmName("newnet1");
  newNet.setDescription("New network");
  newNet.setDataCenterId(FixturesTool.DATA_CENTER);
}

代码示例来源:origin: oVirt/ovirt-engine

private Network createNetwork(String networkA) {
  Network result = new Network();
  result.setId(Guid.newGuid());
  result.setName(networkA);
  return result;
}

代码示例来源:origin: oVirt/ovirt-engine

static org.ovirt.engine.core.common.businessentities.network.Network setUpEntityExpectations(org.ovirt.engine.core.common.businessentities.network.Network entity, int index) {
  when(entity.getId()).thenReturn(GUIDS[index]);
  when(entity.getName()).thenReturn(NAMES[index]);
  when(entity.getDescription()).thenReturn(DESCRIPTIONS[index]);
  when(entity.getDataCenterId()).thenReturn(GUIDS[1]);
  return entity;
}

代码示例来源:origin: oVirt/ovirt-engine

@Override
protected Network getEntity(int index) {
  Network network = mock(Network.class);
  when(network.getId()).thenReturn(GUIDS[index]);
  when(network.getName()).thenReturn(NAMES[index]);
  ProviderNetwork providedBy = new ProviderNetwork();
  providedBy.setProviderId(GUIDS[0]);
  providedBy.setExternalId(string2hex(NAMES[index]));
  when(network.getProvidedBy()).thenReturn(providedBy);
  return network;
}

代码示例来源:origin: oVirt/ovirt-engine

private LogicalNetworkModel createUnmanagedNetworkModel(String networkName, VdsNetworkInterface nic) {
  Network unmanagedNetwork = new Network();
  unmanagedNetwork.setName(networkName);
  unmanagedNetwork.setVlanId(nic.getVlanId());
  unmanagedNetwork.setMtu(nic.getMtu());
  unmanagedNetwork.setVmNetwork(nic.isBridged());
  LogicalNetworkModel networkModel = new LogicalNetworkModel(unmanagedNetwork, null, this);
  return networkModel;
}

代码示例来源:origin: oVirt/ovirt-engine

private Map<String, Guid> mapNetworkNamesToNetworkIds() {
  List<org.ovirt.engine.core.common.businessentities.network.Network> clusterNetworks = getClusterNetworks();
  Map<String, Guid> networkIdByName = new HashMap<>();
  for(org.ovirt.engine.core.common.businessentities.network.Network nwk : clusterNetworks) {
    networkIdByName.put(nwk.getName(), nwk.getId());
  }
  return networkIdByName;
}

代码示例来源:origin: oVirt/ovirt-engine

public org.ovirt.engine.core.common.businessentities.network.Network lookupNetwork(Guid id, String name, String dataCenterId) {
  for (org.ovirt.engine.core.common.businessentities.network.Network entity : getBackendCollection(queryType, getQueryParameters())) {
    if ((id != null && id.equals(entity.getId())) ||
      (name != null && name.equals(entity.getName()))
      && (entity.getDataCenterId()!=null) && entity.getDataCenterId().toString().equals(dataCenterId)) {
      return entity;
    }
  }
  return null;
}

相关文章