本文整理汇总了Java中com.microsoft.azure.management.network.NetworkInterface类的典型用法代码示例。如果您正苦于以下问题:Java NetworkInterface类的具体用法?Java NetworkInterface怎么用?Java NetworkInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NetworkInterface类属于com.microsoft.azure.management.network包,在下文中一共展示了NetworkInterface类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: withNewPrimaryPublicIPAddress
import com.microsoft.azure.management.network.NetworkInterface; //导入依赖的package包/类
@Override
public VirtualMachineImpl withNewPrimaryPublicIPAddress(String leafDnsLabel) {
PublicIPAddress.DefinitionStages.WithGroup definitionWithGroup = this.networkManager.publicIPAddresses()
.define(this.namer.randomName("pip", 15))
.withRegion(this.regionName());
PublicIPAddress.DefinitionStages.WithCreate definitionAfterGroup;
if (this.creatableGroup != null) {
definitionAfterGroup = definitionWithGroup.withNewResourceGroup(this.creatableGroup);
} else {
definitionAfterGroup = definitionWithGroup.withExistingResourceGroup(this.resourceGroupName());
}
this.implicitPipCreatable = definitionAfterGroup.withLeafDomainLabel(leafDnsLabel);
// Create NIC with creatable PIP
//
Creatable<NetworkInterface> nicCreatable = this.nicDefinitionWithCreate
.withNewPrimaryPublicIPAddress(this.implicitPipCreatable);
this.creatablePrimaryNetworkInterfaceKey = this.addDependency(nicCreatable);
return this;
}
开发者ID:Azure,项目名称:azure-libraries-for-java,代码行数:20,代码来源:VirtualMachineImpl.java
示例2: deleteByResourceGroupAsync
import com.microsoft.azure.management.network.NetworkInterface; //导入依赖的package包/类
@Override
public Completable deleteByResourceGroupAsync(String groupName, String name) {
// Clear NIC references if any
NetworkSecurityGroupImpl nsg = (NetworkSecurityGroupImpl) getByResourceGroup(groupName, name);
if (nsg != null) {
Set<String> nicIds = nsg.networkInterfaceIds();
if (nicIds != null) {
for (String nicRef : nsg.networkInterfaceIds()) {
NetworkInterface nic = this.manager().networkInterfaces().getById(nicRef);
if (nic == null) {
continue;
} else if (!nsg.id().equalsIgnoreCase(nic.networkSecurityGroupId())) {
continue;
} else {
nic.update().withoutNetworkSecurityGroup().apply();
}
}
}
}
return this.deleteInnerAsync(groupName, name);
}
开发者ID:Azure,项目名称:azure-libraries-for-java,代码行数:23,代码来源:NetworkSecurityGroupsImpl.java
示例3: getVirtualMachineIds
import com.microsoft.azure.management.network.NetworkInterface; //导入依赖的package包/类
@Override
public Set<String> getVirtualMachineIds() {
Set<String> vmIds = new HashSet<>();
Map<String, String> nicConfigs = this.backendNicIPConfigurationNames();
if (nicConfigs != null) {
for (String nicId : nicConfigs.keySet()) {
try {
NetworkInterface nic = this.parent().manager().networkInterfaces().getById(nicId);
if (nic == null || nic.virtualMachineId() == null) {
continue;
} else {
vmIds.add(nic.virtualMachineId());
}
} catch (CloudException | IllegalArgumentException e) {
continue;
}
}
}
return vmIds;
}
开发者ID:Azure,项目名称:azure-libraries-for-java,代码行数:22,代码来源:LoadBalancerBackendImpl.java
示例4: getNetworkInterfaceIPConfiguration
import com.microsoft.azure.management.network.NetworkInterface; //导入依赖的package包/类
@Override
public NicIPConfiguration getNetworkInterfaceIPConfiguration() {
if (this.inner().ipConfiguration() == null) {
return null;
}
String nicIPConfigId = this.inner().ipConfiguration().id();
if (nicIPConfigId == null) {
return null;
}
String nicIPConfigName = ResourceUtils.nameFromResourceId(nicIPConfigId);
String nicId = ResourceUtils.parentResourceIdFromResourceId(nicIPConfigId);
NetworkInterface nic = this.parent().parent().parent().manager().networkInterfaces().getById(nicId);
if (nic == null) {
return null;
} else {
return nic.ipConfigurations().get(nicIPConfigName);
}
}
开发者ID:Azure,项目名称:azure-libraries-for-java,代码行数:20,代码来源:ApplicationGatewayBackendServerHealthImpl.java
示例5: renderVmDefinition
import com.microsoft.azure.management.network.NetworkInterface; //导入依赖的package包/类
/**
* Creates a VM definition from a given {@link VmSpec} and with a given
* network interface.
*
* @param vmSpec
* @param vmNetworkInterface
* @return
*/
public Creatable<VirtualMachine> renderVmDefinition(VmSpec vmSpec, NetworkInterface vmNetworkInterface) {
String vmName = vmSpec.getVmName();
Azure api = ApiUtils.acquireApiClient(this.apiAccess);
WithOS rawVmDef = api.virtualMachines().define(vmName) //
.withRegion(this.region) //
.withExistingResourceGroup(this.resourceGroup) //
.withExistingPrimaryNetworkInterface(vmNetworkInterface);
if (vmSpec.getLinuxSettings().isPresent()) {
return linuxVmDefinition(vmSpec, rawVmDef);
} else {
return windowsVmDefinition(vmSpec, rawVmDef);
}
}
开发者ID:elastisys,项目名称:scale.cloudpool,代码行数:24,代码来源:VmLauncher.java
示例6: doRequest
import com.microsoft.azure.management.network.NetworkInterface; //导入依赖的package包/类
@Override
public NetworkInterface doRequest(Azure api) throws NotFoundException, AzureException {
LOG.debug("creating network interface {} ...", this.nicName);
String networkName = this.networkSettings.getVirtualNetwork();
Network network = new GetNetworkRequest(apiAccess(), this.resourceGroup, networkName).call();
if (!network.subnets().keySet().contains(this.networkSettings.getSubnetName())) {
throw new NotFoundException(String.format("virtual network '%s' does not have a subnet named '%s'",
this.networkSettings.getVirtualNetwork(), this.networkSettings.getSubnetName()));
}
NetworkInterface networkInterface;
try {
WithCreate nicDef = nicDefinition(api, network);
networkInterface = nicDef.create();
} catch (Exception e) {
throw new AzureException("failed to create network interface card: " + e.getMessage(), e);
}
return networkInterface;
}
开发者ID:elastisys,项目名称:scale.cloudpool,代码行数:23,代码来源:CreateNetworkInterfaceRequest.java
示例7: primaryNicMock
import com.microsoft.azure.management.network.NetworkInterface; //导入依赖的package包/类
private NetworkInterface primaryNicMock() {
NetworkInterface nicMock = mock(NetworkInterface.class);
when(nicMock.primaryPrivateIP()).thenReturn(this.privateIp);
NicIPConfiguration primaryIpConfigMock = mock(NicIPConfiguration.class);
when(nicMock.primaryIPConfiguration()).thenReturn(primaryIpConfigMock);
if (this.publicIp != null) {
PublicIPAddress publicIpAddrMock = mock(PublicIPAddress.class);
when(primaryIpConfigMock.getPublicIPAddress()).thenReturn(publicIpAddrMock);
when(publicIpAddrMock.ipAddress()).thenReturn(this.publicIp);
}
return nicMock;
}
开发者ID:elastisys,项目名称:scale.cloudpool,代码行数:17,代码来源:VmMockBuilder.java
示例8: print
import com.microsoft.azure.management.network.NetworkInterface; //导入依赖的package包/类
/**
* Print network interface.
*
* @param resource a network interface
*/
public static void print(NetworkInterface resource) {
StringBuilder info = new StringBuilder();
info.append("NetworkInterface: ").append(resource.id())
.append("Name: ").append(resource.name())
.append("\n\tResource group: ").append(resource.resourceGroupName())
.append("\n\tRegion: ").append(resource.region())
.append("\n\tTags: ").append(resource.tags())
.append("\n\tInternal DNS name label: ").append(resource.internalDnsNameLabel())
.append("\n\tInternal FQDN: ").append(resource.internalFqdn())
.append("\n\tInternal domain name suffix: ").append(resource.internalDomainNameSuffix())
.append("\n\tNetwork security group: ").append(resource.networkSecurityGroupId())
.append("\n\tApplied DNS servers: ").append(resource.appliedDnsServers().toString())
.append("\n\tDNS server IPs: ");
// Output dns servers
for (String dnsServerIp : resource.dnsServers()) {
info.append("\n\t\t").append(dnsServerIp);
}
info.append("\n\tIP forwarding enabled? ").append(resource.isIPForwardingEnabled())
.append("\n\tAccelerated networking enabled? ").append(resource.isAcceleratedNetworkingEnabled())
.append("\n\tMAC Address:").append(resource.macAddress())
.append("\n\tPrivate IP:").append(resource.primaryPrivateIP())
.append("\n\tPrivate allocation method:").append(resource.primaryPrivateIPAllocationMethod())
.append("\n\tPrimary virtual network ID: ").append(resource.primaryIPConfiguration().networkId())
.append("\n\tPrimary subnet name:").append(resource.primaryIPConfiguration().subnetName());
System.out.println(info.toString());
}
开发者ID:Azure-Samples,项目名称:acr-java-manage-azure-container-registry,代码行数:35,代码来源:Utils.java
示例9: withExistingPrimaryPublicIPAddress
import com.microsoft.azure.management.network.NetworkInterface; //导入依赖的package包/类
@Override
public VirtualMachineImpl withExistingPrimaryPublicIPAddress(PublicIPAddress publicIPAddress) {
Creatable<NetworkInterface> nicCreatable = this.nicDefinitionWithCreate
.withExistingPrimaryPublicIPAddress(publicIPAddress);
this.creatablePrimaryNetworkInterfaceKey = this.addDependency(nicCreatable);
return this;
}
开发者ID:Azure,项目名称:azure-libraries-for-java,代码行数:8,代码来源:VirtualMachineImpl.java
示例10: prepareNetworkInterface
import com.microsoft.azure.management.network.NetworkInterface; //导入依赖的package包/类
private NetworkInterface.DefinitionStages.WithPrimaryPublicIPAddress prepareNetworkInterface(String name) {
NetworkInterface.DefinitionStages.WithGroup definitionWithGroup = this.networkManager
.networkInterfaces()
.define(name)
.withRegion(this.regionName());
NetworkInterface.DefinitionStages.WithPrimaryNetwork definitionWithNetwork;
if (this.creatableGroup != null) {
definitionWithNetwork = definitionWithGroup.withNewResourceGroup(this.creatableGroup);
} else {
definitionWithNetwork = definitionWithGroup.withExistingResourceGroup(this.resourceGroupName());
}
return definitionWithNetwork
.withNewPrimaryNetwork("vnet" + name)
.withPrimaryPrivateIPAddressDynamic();
}
开发者ID:Azure,项目名称:azure-libraries-for-java,代码行数:16,代码来源:VirtualMachineImpl.java
示例11: preparePrimaryNetworkInterface
import com.microsoft.azure.management.network.NetworkInterface; //导入依赖的package包/类
private NetworkInterface.DefinitionStages.WithPrimaryNetwork preparePrimaryNetworkInterface(String name) {
NetworkInterface.DefinitionStages.WithGroup definitionWithGroup = this.networkManager.networkInterfaces()
.define(name)
.withRegion(this.regionName());
NetworkInterface.DefinitionStages.WithPrimaryNetwork definitionAfterGroup;
if (this.creatableGroup != null) {
definitionAfterGroup = definitionWithGroup.withNewResourceGroup(this.creatableGroup);
} else {
definitionAfterGroup = definitionWithGroup.withExistingResourceGroup(this.resourceGroupName());
}
return definitionAfterGroup;
}
开发者ID:Azure,项目名称:azure-libraries-for-java,代码行数:13,代码来源:VirtualMachineImpl.java
示例12: printPIP
import com.microsoft.azure.management.network.NetworkInterface; //导入依赖的package包/类
public static void printPIP(PublicIPAddress resource) {
StringBuilder info = new StringBuilder().append("Public IP Address: ").append(resource.id())
.append("\n\tName: ").append(resource.name())
.append("\n\tResource group: ").append(resource.resourceGroupName())
.append("\n\tRegion: ").append(resource.region())
.append("\n\tTags: ").append(resource.tags())
.append("\n\tIP Address: ").append(resource.ipAddress())
.append("\n\tLeaf domain label: ").append(resource.leafDomainLabel())
.append("\n\tFQDN: ").append(resource.fqdn())
.append("\n\tReverse FQDN: ").append(resource.reverseFqdn())
.append("\n\tIdle timeout (minutes): ").append(resource.idleTimeoutInMinutes())
.append("\n\tIP allocation method: ").append(resource.ipAllocationMethod().toString())
.append("\n\tIP version: ").append(resource.version().toString());
// Show the associated load balancer if any
info.append("\n\tLoad balancer association: ");
if (resource.hasAssignedLoadBalancer()) {
final LoadBalancerPublicFrontend frontend = resource.getAssignedLoadBalancerFrontend();
final LoadBalancer lb = frontend.parent();
info.append("\n\t\tLoad balancer ID: ").append(lb.id())
.append("\n\t\tFrontend name: ").append(frontend.name());
} else {
info.append("(None)");
}
// Show the associated NIC if any
info.append("\n\tNetwork interface association: ");
if (resource.hasAssignedNetworkInterface()) {
final NicIPConfiguration nicIp = resource.getAssignedNetworkInterfaceIPConfiguration();
final NetworkInterface nic = nicIp.parent();
info.append("\n\t\tNetwork interface ID: ").append(nic.id())
.append("\n\t\tIP config name: ").append(nicIp.name());
} else {
info.append("(None)");
}
System.out.println(info.toString());
}
开发者ID:Azure,项目名称:azure-libraries-for-java,代码行数:39,代码来源:TestPublicIPAddress.java
示例13: updateResource
import com.microsoft.azure.management.network.NetworkInterface; //导入依赖的package包/类
@Override
public NetworkInterface updateResource(NetworkInterface resource) throws Exception {
resource = resource.update()
.withoutIPForwarding()
.withoutAcceleratedNetworking()
.withSubnet("subnet2")
.updateIPConfiguration("primary") // Updating the primary IP configuration
.withPrivateIPAddressDynamic() // Equivalent to ..update().withPrimaryPrivateIPAddressDynamic()
.withoutPublicIPAddress() // Equivalent to ..update().withoutPrimaryPublicIPAddress()
.parent()
.withTag("tag1", "value1")
.withTag("tag2", "value2")
.apply();
// Verifications
Assert.assertFalse(resource.isAcceleratedNetworkingEnabled());
Assert.assertFalse(resource.isIPForwardingEnabled());
NicIPConfiguration primaryIpConfig = resource.primaryIPConfiguration();
Assert.assertNotNull(primaryIpConfig);
Assert.assertTrue(primaryIpConfig.isPrimary());
Assert.assertTrue("subnet2".equalsIgnoreCase(primaryIpConfig.subnetName()));
Assert.assertNull(primaryIpConfig.publicIPAddressId());
Assert.assertTrue(resource.tags().containsKey("tag1"));
Assert.assertEquals(1, resource.ipConfigurations().size());
return resource;
}
开发者ID:Azure,项目名称:azure-libraries-for-java,代码行数:28,代码来源:TestNetworkInterface.java
示例14: getAssignedNetworkInterfaceIPConfiguration
import com.microsoft.azure.management.network.NetworkInterface; //导入依赖的package包/类
@Override
public NicIPConfiguration getAssignedNetworkInterfaceIPConfiguration() {
if (this.hasAssignedNetworkInterface()) {
final String refId = this.inner().ipConfiguration().id();
final String parentId = ResourceUtils.parentResourceIdFromResourceId(refId);
final NetworkInterface nic = this.myManager.networkInterfaces().getById(parentId);
final String childName = ResourceUtils.nameFromResourceId(refId);
return nic.ipConfigurations().get(childName);
} else {
return null;
}
}
开发者ID:Azure,项目名称:azure-libraries-for-java,代码行数:13,代码来源:PublicIPAddressImpl.java
示例15: listNetworkInterfaceIPConfigurations
import com.microsoft.azure.management.network.NetworkInterface; //导入依赖的package包/类
@Override
public Collection<NicIPConfiguration> listNetworkInterfaceIPConfigurations() {
Collection<NicIPConfiguration> ipConfigs = new ArrayList<>();
Map<String, NetworkInterface> nics = new TreeMap<>();
List<IPConfigurationInner> ipConfigRefs = this.inner().ipConfigurations();
if (ipConfigRefs == null) {
return ipConfigs;
}
for (IPConfigurationInner ipConfigRef : ipConfigRefs) {
String nicID = ResourceUtils.parentResourceIdFromResourceId(ipConfigRef.id());
String ipConfigName = ResourceUtils.nameFromResourceId(ipConfigRef.id());
// Check if NIC already cached
NetworkInterface nic = nics.get(nicID.toLowerCase());
if (nic == null) {
// NIC not previously found, so ask Azure for it
nic = this.parent().manager().networkInterfaces().getById(nicID);
}
if (nic == null) {
// NIC doesn't exist so ignore this bad reference
continue;
}
// Cache the NIC
nics.put(nic.id().toLowerCase(), nic);
// Get the IP config
NicIPConfiguration ipConfig = nic.ipConfigurations().get(ipConfigName);
if (ipConfig == null) {
// IP config not found, so ignore this bad reference
continue;
}
ipConfigs.add(ipConfig);
}
return Collections.unmodifiableCollection(ipConfigs);
}
开发者ID:Azure,项目名称:azure-libraries-for-java,代码行数:40,代码来源:SubnetImpl.java
示例16: afterCreating
import com.microsoft.azure.management.network.NetworkInterface; //导入依赖的package包/类
@Override
protected void afterCreating() {
if (this.nicsInBackends != null) {
List<Exception> nicExceptions = new ArrayList<>();
// Update the NICs to point to the backend pool
for (Entry<String, String> nicInBackend : this.nicsInBackends.entrySet()) {
String nicId = nicInBackend.getKey();
String backendName = nicInBackend.getValue();
try {
NetworkInterface nic = this.manager().networkInterfaces().getById(nicId);
NicIPConfiguration nicIP = nic.primaryIPConfiguration();
nic.update()
.updateIPConfiguration(nicIP.name())
.withExistingLoadBalancerBackend(this, backendName)
.parent()
.apply();
} catch (Exception e) {
nicExceptions.add(e);
}
}
if (!nicExceptions.isEmpty()) {
throw new CompositeException(nicExceptions);
}
this.nicsInBackends.clear();
this.refresh();
}
}
开发者ID:Azure,项目名称:azure-libraries-for-java,代码行数:31,代码来源:LoadBalancerImpl.java
示例17: refreshAsync
import com.microsoft.azure.management.network.NetworkInterface; //导入依赖的package包/类
@Override
public Observable<NetworkInterface> refreshAsync() {
return super.refreshAsync().map(new Func1<NetworkInterface, NetworkInterface>() {
@Override
public NetworkInterface call(NetworkInterface networkInterface) {
NetworkInterfaceImpl impl = (NetworkInterfaceImpl) networkInterface;
impl.clearCachedRelatedResources();
impl.initializeChildrenFromInner();
return impl;
}
});
}
开发者ID:Azure,项目名称:azure-libraries-for-java,代码行数:13,代码来源:NetworkInterfaceImpl.java
示例18: createNetworkInterface
import com.microsoft.azure.management.network.NetworkInterface; //导入依赖的package包/类
/**
* Creates a network interface for the given VM, possibly with associated
* security groups and public IP.
*
* @param vmSpec
* A VM to be created.
* @return
*/
private NetworkInterface createNetworkInterface(VmSpec vmSpec) throws NotFoundException, AzureException {
// create a network interface for VM (possibly with security groups
// and public IP)
String vmName = vmSpec.getVmName();
LOG.debug("creating network interface {} for VM ...", vmName);
NetworkInterface networkInterface = new CreateNetworkInterfaceRequest(this.apiAccess, this.resourceGroup,
this.region, vmName, vmSpec.getNetwork()).call();
return networkInterface;
}
开发者ID:elastisys,项目名称:scale.cloudpool,代码行数:18,代码来源:VmLauncher.java
示例19: cleanupNetworkInterfaces
import com.microsoft.azure.management.network.NetworkInterface; //导入依赖的package包/类
/**
* Removes a collection of network interfaces (together with any associated
* public IPs).
*
* @param networkInterfaces
*/
private void cleanupNetworkInterfaces(Collection<NetworkInterface> networkInterfaces) {
for (NetworkInterface networkInterface : networkInterfaces) {
try {
LOG.info("cleaning up network interface {} ...", networkInterface.id());
new DeleteNetworkInterfaceRequest(this.apiAccess, networkInterface.id()).call();
} catch (Exception e) {
LOG.warn("failed to clean up network interface {}: {}", networkInterface.id(), e.getMessage(), e);
}
}
}
开发者ID:elastisys,项目名称:scale.cloudpool,代码行数:17,代码来源:VmLauncher.java
示例20: doRequest
import com.microsoft.azure.management.network.NetworkInterface; //导入依赖的package包/类
@Override
public NetworkInterface doRequest(Azure api) throws NotFoundException, AzureException {
NetworkInterface nic;
try {
nic = api.networkInterfaces().getById(this.networkInterfaceId);
} catch (Exception e) {
throw new AzureException("failed to get network interface: " + e.getMessage(), e);
}
return Optional.ofNullable(nic).orElseThrow(() -> notFoundError());
}
开发者ID:elastisys,项目名称:scale.cloudpool,代码行数:12,代码来源:GetNetworkInterfaceRequest.java
注:本文中的com.microsoft.azure.management.network.NetworkInterface类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论