コード例 #1
0
ファイル: test_dns.py プロジェクト: svetaquali/ionosphere
    def test_private_dns(self):
        sandbox = '654321'
        vnet_name = '{}_vnet'.format(sandbox)
        dns_name = '{}.sandbox.com'.format(sandbox)

        template = ARMTemplate()

        vnet = VirtualNetwork(vnet_name, template=template)

        nic = NetworkInterface('testNic')

        dns = DnsZone(dns_name,
                      template=template,
                      registrationVirtualNetworks=[SubResource(id=vnet.ref())],
                      zoneType=ZoneType.Private.name,
                      dependsOn=vnet)

        dns_a = DnsZoneA(
            '/'.join([dns_name, 'app1']),
            template=template,
            TTL=3600,
            ARecords=[
                ARecord(
                    ipv4Address=
                    "[reference('crumbNIC').ipConfigurations[0].properties.privateIPAddress]"
                )
            ],
            dependsOn=dns)

        j = template.to_json()

        print(j)
コード例 #2
0
from compute import *

from base import ARMTemplate
from network import *

template = ARMTemplate()

vnet = VirtualNetwork("myvnet",
                      addressSpace=AddressSpace(addressPrefixes=['10.0.0.0/24']),
                      subnets=[Subnet('subnet1', addressPrefix='10.0.0.0/24')])

#region load balancer

# needs to be Static so it will be assigned a value immediately
lb_pub_ip = PublicIPAddress('lb_pub_ip', publicIPAllocationMethod='Static')

lb_ip_conf = FrontendIPConfiguration('lb_ip_conf',
                                     privateIPAllocationMethod='Dynamic',
                                     # subnet=SubResource(id=vnet.SubnetRef('subnet1')),
                                     publicIPAddress=SubResource(id=lb_pub_ip.ref()))

lb_rule = LoadBalancingRule('lbrule',
                            protocol='Tcp',
                            loadDistribution='SourceIP',
                            frontendPort=22,
                            backendPort=22,
                            frontendIPConfiguration=FrontendIPConfigurationRef(load_balancer='my_lb',
                                                                               ip_conf=lb_ip_conf),
                            probe=ProbeRef(load_balancer='my_lb', probe='testProbe'),
                            backendAddressPool=BackendAddressPoolRef(load_balancer='my_lb', backend_pool='lb_backend'))
コード例 #3
0
 def test_max_resources(self):
     template = ARMTemplate()
     for i in range(0, MAX_RESOURCES):
         template.add_resource(PublicIPAddress(str(i)))
     with self.assertRaises(ValueError):
         template.add_resource(PublicIPAddress("address"))
コード例 #4
0
import uuid
from compute import *
from base import ARMTemplate, ARMParameter
from network import *
from storage import StorageAccount, StorageAccountSku

template = ARMTemplate(customerUsageAttributionGuid='pid-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX')

vm_password_param = ARMParameter('vmPassword',
                                 template=template,
                                 type='secureString',
                                 description='The password for the VM access. User is "adminuser"')

vnet = VirtualNetwork("myvnet",
                      addressSpace=AddressSpace(addressPrefixes=['10.0.0.0/24']),
                      subnets=[Subnet('subnet1', addressPrefix='10.0.0.0/24')],
                      tags={'Key1': 'tag-key1', 'Key2': 'tag-key2', 'Key3': 'tag-key3'})

nsg = NetworkSecurityGroup("testvmNsg",
                           securityRules=[
                               SecurityRule('ssh',
                                            description='public ssh access',
                                            protocol='Tcp',
                                            destinationPortRange="22",
                                            destinationAddressPrefix="*",
                                            sourceAddressPrefix='Internet',
                                            sourcePortRange='*',
                                            access='Allow',
                                            direction='Inbound',
                                            priority=200
                                            )])
コード例 #5
0
 def test_max_parameters(self):
     template = ARMTemplate()
     for i in range(0, MAX_PARAMETERS):
         template.add_parameter(ARMParameter(str(i), type='string'))
     with self.assertRaises(ValueError):
         template.add_parameter(ARMParameter("parameter", type='string'))