Exemplo n.º 1
0
  def __init__(self, spec):
    super(AzureNetwork, self).__init__(spec)
    self.resource_group = GetResourceGroup()
    self.location = util.GetLocationFromZone(self.zone)
    # With dedicated hosting and/or an availability zone, an availability set
    # cannot be created
    if (FLAGS.dedicated_hosts or util.GetAvailabilityZoneFromZone(self.zone) or
        not FLAGS.azure_availability_set):
      self.avail_set = None
    else:
      avail_set_name = '%s-%s' % (self.resource_group.name, self.zone)
      self.avail_set = AzureAvailSet(avail_set_name, self.location)
    # Storage account names can't include separator characters :(.
    storage_account_prefix = 'pkb%s' % FLAGS.run_uri

    # Storage account names must be 3-24 characters long and use
    # numbers and lower-case letters only, which leads us to this
    # awful naming scheme.
    suffix = 'storage%d' % AzureStorageAccount.total_storage_accounts
    self.storage_account = AzureStorageAccount(
        FLAGS.azure_storage_type, self.location,
        storage_account_prefix[:24 - len(suffix)] + suffix)
    prefix = '%s-%s' % (self.resource_group.name, self.zone)
    self.vnet = AzureVirtualNetwork(self.location, prefix + '-vnet')
    self.subnet = AzureSubnet(self.vnet, self.vnet.name + '-subnet')
    self.nsg = AzureNetworkSecurityGroup(self.location, self.subnet,
                                         self.subnet.name + '-nsg')
 def __init__(self, registry_spec):
   super(AzureContainerRegistry, self).__init__(registry_spec)
   self.location = util.GetLocationFromZone(self.zone)
   self.resource_group = azure_network.GetResourceGroup(self.location)
   self.login_server = None
   self.sku = 'Basic'
   self._deleted = False
   self.acr_id = None
   self.service_principal = service_principal.ServicePrincipal.GetInstance()
  def __init__(self, spec):
    super(AzureNetwork, self).__init__(spec)
    self.resource_group = GetResourceGroup()
    self.location = util.GetLocationFromZone(self.zone)
    self.availability_zone = util.GetAvailabilityZoneFromZone(self.zone)

    placement_group_spec = azure_placement_group.AzurePlacementGroupSpec(
        'AzurePlacementGroupSpec',
        flag_values=FLAGS,
        zone=self.zone,
        resource_group=self.resource_group.name)

    is_dedicated_host = bool(FLAGS.dedicated_hosts)
    in_availability_zone = bool(self.availability_zone)
    cluster_placement_group = (
        FLAGS.placement_group_style == placement_group.PLACEMENT_GROUP_CLUSTER)
    spread_placement_group = (
        FLAGS.placement_group_style == placement_group.PLACEMENT_GROUP_SPREAD)

    if cluster_placement_group and IsProximityPlacementGroupCompatible(
        self.location):
      self.placement_group = azure_placement_group.AzureProximityGroup(
          placement_group_spec)
    # With dedicated hosting and/or an availability zone, an availability set
    # cannot be created
    elif spread_placement_group and not (is_dedicated_host or
                                         in_availability_zone):
      self.placement_group = azure_placement_group.AzureAvailSet(
          placement_group_spec)
    else:
      self.placement_group = None

    # Storage account names can't include separator characters :(.
    storage_account_prefix = 'pkb%s' % FLAGS.run_uri

    # Storage account names must be 3-24 characters long and use
    # numbers and lower-case letters only, which leads us to this
    # awful naming scheme.
    suffix = 'storage%d' % AzureStorageAccount.total_storage_accounts
    self.storage_account = AzureStorageAccount(
        FLAGS.azure_storage_type, self.location,
        storage_account_prefix[:24 - len(suffix)] + suffix)

    # Length restriction from https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/resource-name-rules#microsoftnetwork  pylint: disable=line-too-long
    prefix = '%s-%s' % (self.resource_group.name, self.location)
    vnet_name = prefix + '-vnet'
    if len(vnet_name) > 64:
      vnet_name = prefix[:59] + '-vnet'
    self.vnet = AzureVirtualNetwork.GetForLocation(spec, self.location,
                                                   vnet_name)
    subnet_name = self.vnet.name
    if self.availability_zone:
      subnet_name += '-' + self.availability_zone
    subnet_name += '-subnet'
    self.subnet = AzureSubnet(self.vnet, subnet_name)
    self.nsg = AzureNetworkSecurityGroup(self.location, self.subnet,
                                         self.subnet.name + '-nsg')
Exemplo n.º 4
0
    def __init__(self, relational_db_spec):
        super(AzureRelationalDb, self).__init__(relational_db_spec)
        self.instance_id = 'pkb-db-instance-' + FLAGS.run_uri
        if util.IsZone(self.spec.db_spec.zone):
            raise errors.Config.InvalidValue(
                'Availability zones are currently not supported by Azure DBs')
        self.location = util.GetLocationFromZone(self.spec.db_spec.zone)
        self.resource_group = azure_network.GetResourceGroup(self.location)

        self.unmanaged_db_exists = None if self.is_managed_db else False
  def __init__(self, disk_spec, zone):
    super(AzureSmbService, self).__init__(disk_spec, zone)
    self.name = 'azure-smb-fs-%s' % FLAGS.run_uri
    self.location = util.GetLocationFromZone(self.zone)
    self.resource_group = azure_network.GetResourceGroup(self.location)

    # set during _Create()
    self.connection_args: List[str] = None
    self.storage_account_key: str = None
    self.storage_account_name: str = None
Exemplo n.º 6
0
  def __init__(self, azure_placement_group_spec):
    """Init method for AzurePlacementGroup.

    Args:
      azure_placement_group_spec: Object containing the
        information needed to create an AzurePlacementGroup.
    """
    super(AzurePlacementGroup, self).__init__(azure_placement_group_spec)
    self.resource_group = azure_placement_group_spec.resource_group
    self.name = '%s-%s' % (self.resource_group, self.zone)
    self.location = util.GetLocationFromZone(self.zone)
    self.strategy = azure_placement_group_spec.placement_group_style
 def __init__(self, spec):
   """Initializes the cluster."""
   super(AksCluster, self).__init__(spec)
   if util.IsZone(spec.vm_spec.zone):
     raise errors.Config.InvalidValue(
         'Availability zones are currently not supported by Aks Cluster')
   self.location = util.GetLocationFromZone(self.zone)
   self.resource_group = azure_network.GetResourceGroup(self.location)
   self.name = 'pkbcluster%s' % FLAGS.run_uri
   # TODO(pclay): replace with built in service principal once I figure out how
   # to make it work with ACR
   self.service_principal = service_principal.ServicePrincipal.GetInstance()
   self._deleted = False
    def __init__(self, vm_spec):
        """Initialize an Azure virtual machine.

    Args:
      vm_spec: virtual_machine.BaseVmSpec object of the vm.
    """
        super(AzureVirtualMachine, self).__init__(vm_spec)

        # PKB zone can be either a location or a location with an availability zone.
        # Format for Azure availability zone support is "location-availability_zone"
        # Example: eastus2-1 is Azure location eastus2 with availability zone 1.

        self.location = util.GetLocationFromZone(self.zone)
        self.availability_zone = util.GetAvailabilityZoneFromZone(self.zone)
        self.use_dedicated_host = vm_spec.use_dedicated_host
        # TODO(buggay): implement num_vms_per_host functionality
        self.num_vms_per_host = vm_spec.num_vms_per_host
        if self.num_vms_per_host:
            raise NotImplementedError(
                'Num vms per host for Azure is not supported.')
        self.network = azure_network.AzureNetwork.GetNetwork(self)
        self.firewall = azure_network.AzureFirewall.GetFirewall()
        self.max_local_disks = NUM_LOCAL_VOLUMES.get(self.machine_type) or 1
        self._lun_counter = itertools.count()
        self._deleted = False

        self.resource_group = azure_network.GetResourceGroup()
        self.public_ip = AzurePublicIPAddress(self.location,
                                              self.availability_zone,
                                              self.name + '-public-ip')
        self.nic = AzureNIC(self.network.subnet, self.name + '-nic',
                            self.public_ip.name,
                            vm_spec.accelerated_networking)
        self.storage_account = self.network.storage_account
        self.image = vm_spec.image or self.IMAGE_URN
        self.host = None
        if self.use_dedicated_host:
            self.host_series_sku = _GetSkuType(self.machine_type)
            self.host_list = None

        disk_spec = disk.BaseDiskSpec('azure_os_disk')
        disk_spec.disk_type = (vm_spec.boot_disk_type
                               or self.storage_account.storage_type)
        if vm_spec.boot_disk_size:
            disk_spec.disk_size = vm_spec.boot_disk_size
        self.os_disk = azure_disk.AzureDisk(disk_spec,
                                            self.name,
                                            self.machine_type,
                                            self.storage_account,
                                            None,
                                            is_image=True)
Exemplo n.º 9
0
 def __init__(self,
              name,
              zone=None,
              use_existing=False,
              timeout_minutes=None,
              raise_on_create_failure=True):
     super(AzureResourceGroup, self).__init__()
     self.name = name
     self.use_existing = use_existing
     self.timeout_minutes = timeout_minutes
     self.raise_on_create_failure = raise_on_create_failure
     # A resource group's location doesn't affect the location of
     # actual resources, but we need to choose *some* location for every
     # benchmark, even if the user doesn't specify one.
     self.location = util.GetLocationFromZone(
         FLAGS.zones[0] if FLAGS.zones else zone or DEFAULT_LOCATION)
     # Whenever an Azure CLI command needs a resource group, it's
     # always specified the same way.
     self.args = ['--resource-group', self.name]
Exemplo n.º 10
0
 def __init__(self, disk_spec, zone):
   super(AzureSmbService, self).__init__(disk_spec, zone)
   self.name = 'azure-smb-fs-%s' % FLAGS.run_uri
   self.location = util.GetLocationFromZone(self.zone)
   self.resource_group = azure_network.GetResourceGroup(self.location)
Exemplo n.º 11
0
 def __init__(self, cluster_spec):
     super(AciCluster, self).__init__(cluster_spec)
     self.location = util.GetLocationFromZone(self.zone)
     self.resource_group = azure_network.GetResourceGroup(self.location)
 def test_get_location_from_zone_invalid_zone(self):
     valid_location = 'eastus2-1a'
     with self.assertRaises(ValueError):
         util.GetLocationFromZone(valid_location)
 def test_get_location_from_zone_valid_zone(self):
     valid_zone = 'eastus2-1'
     self.assertEqual(self.expected_location,
                      util.GetLocationFromZone(valid_zone))