def cluster_parameters_for(config, container_settings, volumes): return models.ClusterCreateParameters( virtual_machine_configuration=models.VirtualMachineConfiguration( image_reference=models.ImageReference(offer='UbuntuServer', publisher='Canonical', sku='16.04-LTS', version='16.04.201708151')), location=config.location, vm_size=config.vm_type, user_account_settings=models.UserAccountSettings( admin_user_name=config.admin_user['name'], admin_user_password=config.admin_user['password']), scale_settings=models.ScaleSettings(manual=models.ManualScaleSettings( target_node_count=config.node_count)), node_setup=models.NodeSetup(mount_volumes=volumes))
def _get_image_reference(image, custom_image): """Returns image reference for the given image and custom image. :param str image or None: image alias or full spec. :param str custom_image or None: resource id of the custom image. :raise CLIError: if the image with given alias was not found. """ if custom_image and not image: raise CLIError('You need to specify --image argument with information about the custom image') if custom_image and not is_valid_resource_id(custom_image): raise CLIError('Ill-formed custom image resource id') if ':' in image: # full image specification is provided try: publisher, offer, sku, version = image.split(':') if not publisher: raise CLIError('Image publisher must be provided in --image argument') if not offer: raise CLIError('Image offer must be provided in --image argument') if not sku: raise CLIError('Image sku must be provided in --image argument') return models.ImageReference( publisher=publisher, offer=offer, sku=sku, version=version or None, virtual_machine_image_id=custom_image ) except ValueError: raise CLIError('--image must have format "publisher:offer:sku:version" or "publisher:offer:sku:"') # image alias is used reference = None for alias, value in SUPPORTED_IMAGE_ALIASES.items(): if alias.lower() == image.lower(): reference = value if not reference: raise CLIError('Unsupported image alias "{0}", supported aliases are {1}'.format( image, ', '.join(SUPPORTED_IMAGE_ALIASES.keys()))) result = copy.deepcopy(reference) result.virtual_machine_image_id = custom_image return result
AUTO_STORAGE_ACCOUNT_PREFIX = 'bai' AUTO_STORAGE_CONTAINER_PATH = 'autobfs' AUTO_STORAGE_SHARE_PATH = 'autoafs' # Placeholders which customer may use in his config file for cluster creation. AZURE_BATCHAI_STORAGE_KEY_PLACEHOLDER = '<{0}>'.format(AZURE_BATCHAI_STORAGE_KEY) AZURE_BATCHAI_STORAGE_ACCOUNT_PLACEHOLDER = '<{0}>'.format(AZURE_BATCHAI_STORAGE_ACCOUNT) # Default expiration time for file download URLs. DEFAULT_URL_EXPIRY_MIN = 60 # Supported images. SUPPORTED_IMAGE_ALIASES = { "UbuntuLTS": models.ImageReference( publisher='Canonical', offer='UbuntuServer', sku='16.04-LTS' ), "UbuntuDSVM": models.ImageReference( publisher='microsoft-ads', offer='linux-data-science-vm-ubuntu', sku='linuxdsvmubuntu' ) } # Type of entries reported by list startup files. LogFile = collections.namedtuple('LogFile', 'name download_url is_directory size') logger = get_logger(__name__)