mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-25 14:20:22 -07:00
network models
This commit is contained in:
parent
7d77ce6866
commit
11c5d7b670
9 changed files with 71 additions and 85 deletions
|
@ -113,8 +113,6 @@ try:
|
|||
from msrestazure.azure_exceptions import CloudError
|
||||
from msrestazure.tools import resource_id, is_valid_resource_id
|
||||
from msrestazure import azure_cloud
|
||||
from azure.mgmt.network.models import PublicIPAddress, NetworkSecurityGroup, SecurityRule, NetworkInterface, \
|
||||
NetworkInterfaceIPConfiguration, Subnet
|
||||
from azure.common.credentials import ServicePrincipalCredentials, UserPassCredentials
|
||||
from azure.mgmt.network.version import VERSION as network_client_version
|
||||
from azure.mgmt.storage.version import VERSION as storage_client_version
|
||||
|
@ -638,7 +636,7 @@ class AzureRMModuleBase(object):
|
|||
self.check_provisioning_state(pip)
|
||||
return pip
|
||||
|
||||
params = PublicIPAddress(
|
||||
params = self.network_models.PublicIPAddress(
|
||||
location=location,
|
||||
public_ip_allocation_method=allocation_method,
|
||||
)
|
||||
|
@ -678,7 +676,7 @@ class AzureRMModuleBase(object):
|
|||
self.check_provisioning_state(group)
|
||||
return group
|
||||
|
||||
parameters = NetworkSecurityGroup()
|
||||
parameters = self.network_models.NetworkSecurityGroup()
|
||||
parameters.location = location
|
||||
|
||||
if not open_ports:
|
||||
|
@ -686,16 +684,16 @@ class AzureRMModuleBase(object):
|
|||
if os_type == 'Linux':
|
||||
# add an inbound SSH rule
|
||||
parameters.security_rules = [
|
||||
SecurityRule('Tcp', '*', '*', 'Allow', 'Inbound', description='Allow SSH Access',
|
||||
self.network_models.SecurityRule('Tcp', '*', '*', 'Allow', 'Inbound', description='Allow SSH Access',
|
||||
source_port_range='*', destination_port_range='22', priority=100, name='SSH')
|
||||
]
|
||||
parameters.location = location
|
||||
else:
|
||||
# for windows add inbound RDP and WinRM rules
|
||||
parameters.security_rules = [
|
||||
SecurityRule('Tcp', '*', '*', 'Allow', 'Inbound', description='Allow RDP port 3389',
|
||||
self.network_models.SecurityRule('Tcp', '*', '*', 'Allow', 'Inbound', description='Allow RDP port 3389',
|
||||
source_port_range='*', destination_port_range='3389', priority=100, name='RDP01'),
|
||||
SecurityRule('Tcp', '*', '*', 'Allow', 'Inbound', description='Allow WinRM HTTPS port 5986',
|
||||
self.network_models.SecurityRule('Tcp', '*', '*', 'Allow', 'Inbound', description='Allow WinRM HTTPS port 5986',
|
||||
source_port_range='*', destination_port_range='5986', priority=101, name='WinRM01'),
|
||||
]
|
||||
else:
|
||||
|
@ -706,7 +704,7 @@ class AzureRMModuleBase(object):
|
|||
priority += 1
|
||||
rule_name = "Rule_{0}".format(priority)
|
||||
parameters.security_rules.append(
|
||||
SecurityRule('Tcp', '*', '*', 'Allow', 'Inbound', source_port_range='*',
|
||||
self.network_models.SecurityRule('Tcp', '*', '*', 'Allow', 'Inbound', source_port_range='*',
|
||||
destination_port_range=str(port), priority=priority, name=rule_name)
|
||||
)
|
||||
|
||||
|
@ -767,6 +765,11 @@ class AzureRMModuleBase(object):
|
|||
api_version='2017-06-01')
|
||||
return self._network_client
|
||||
|
||||
@property
|
||||
def network_models(self):
|
||||
self.log("Getting network models...")
|
||||
return NetworkManagementClient.models("2017-06-01")
|
||||
|
||||
@property
|
||||
def rm_client(self):
|
||||
self.log('Getting resource manager client')
|
||||
|
@ -776,6 +779,11 @@ class AzureRMModuleBase(object):
|
|||
api_version='2017-05-10')
|
||||
return self._resource_client
|
||||
|
||||
@property
|
||||
def rm_models(self):
|
||||
self.log("Getting resource manager models")
|
||||
return ResourceManagementClient.models("2017-05-10")
|
||||
|
||||
@property
|
||||
def compute_client(self):
|
||||
self.log('Getting compute client')
|
||||
|
@ -785,6 +793,11 @@ class AzureRMModuleBase(object):
|
|||
api_version='2017-03-30')
|
||||
return self._compute_client
|
||||
|
||||
@property
|
||||
def compute_models(self):
|
||||
self.log("Getting compute models")
|
||||
return ComputeManagementClient.models("2017-03-30")
|
||||
|
||||
@property
|
||||
def dns_client(self):
|
||||
self.log('Getting dns client')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue