Ejemplo n.º 1
0
def create_file_server(client, resource_group, file_server_name, json_file=None, vm_size=None, location=None,
                       user_name=None, ssh_key=None, password=None, disk_count=None, disk_size=None,
                       storage_sku='Premium_LRS', raw=False):
    if json_file:
        with open(json_file) as f:
            json_obj = json.load(f)
            parameters = _get_deserializer()('FileServerCreateParameters', json_obj)
    else:
        parameters = models.FileServerCreateParameters(None, None, None, None)

    parameters = _update_user_account_settings(parameters, user_name, ssh_key, password)
    if location:
        parameters.location = location
    if not parameters.location:
        raise CLIError('Please provide location for cluster creation.')
    if not parameters.data_disks:
        parameters.data_disks = models.DataDisks(None, None, None)
    if disk_size:
        parameters.data_disks.disk_size_in_gb = disk_size
    if not parameters.data_disks.disk_size_in_gb:
        raise CLIError('Please provide disk size in Gb.')
    if disk_count:
        parameters.data_disks.disk_count = disk_count
    if not parameters.data_disks.disk_count:
        raise CLIError('Please provide number of data disks (at least one disk is required).')
    if storage_sku:
        parameters.data_disks.storage_account_type = storage_sku
    if not parameters.data_disks.storage_account_type:
        raise CLIError('Please provide storage account type (storage sku).')
    if vm_size:
        parameters.vm_size = vm_size
    if not parameters.vm_size:
        raise CLIError('Please provide VM size.')
    return client.create(resource_group, file_server_name, parameters, raw=raw)
Ejemplo n.º 2
0
    def create_file_server(client,
                           location,
                           resource_group,
                           nfs_name,
                           subnet_id=None):
        """Creates NFS

        :param BatchAIManagementClient client: client instance.
        :param str location: location.
        :param str resource_group: resource group name.
        :param str nfs_name: file server name.
        :param models.ResourceId subnet_id: id of the subnet.
        :return models.FileServer: created file server.
        """
        client.workspaces.create(resource_group,
                                 Helpers.DEFAULT_WORKSPACE_NAME,
                                 location).result()
        return client.file_servers.create(
            resource_group, Helpers.DEFAULT_WORKSPACE_NAME, nfs_name,
            models.FileServerCreateParameters(
                vm_size='STANDARD_D1',
                ssh_configuration=models.SshConfiguration(
                    user_account_settings=models.UserAccountSettings(
                        admin_user_name=Helpers.ADMIN_USER_NAME,
                        admin_user_password=Helpers.ADMIN_USER_PASSWORD,
                    )),
                data_disks=models.DataDisks(
                    disk_size_in_gb=10,
                    disk_count=2,
                    storage_account_type='Standard_LRS'),
                subnet=subnet_id)).result()
Ejemplo n.º 3
0
def create_file_server(cmd, client, resource_group, file_server_name, json_file=None, vm_size=None, location=None,
                       user_name=None, ssh_key=None, password=None, generate_ssh_keys=None,
                       disk_count=None, disk_size=None, caching_type=None, storage_sku=None, subnet=None,
                       raw=False):
    if generate_ssh_keys:
        _generate_ssh_keys()
        if ssh_key is None:
            ssh_key = _get_default_ssh_public_key_location()
    _ensure_resource_not_exist(client, resource_group, file_server_name)
    if json_file:
        with open(json_file) as f:
            json_obj = json.load(f)
            params = _get_deserializer()('FileServerCreateParameters', json_obj)
    else:
        # noinspection PyTypeChecker
        params = models.FileServerCreateParameters()
    params = _update_user_account_settings(params, user_name, ssh_key, password)
    params.location = location or _get_resource_group_location(cmd.cli_ctx, resource_group)
    if not params.data_disks:
        # noinspection PyTypeChecker
        params.data_disks = models.DataDisks()
    if disk_size:
        params.data_disks.disk_size_in_gb = disk_size
    if not params.data_disks.disk_size_in_gb:
        raise CLIError('Please provide disk size in Gb.')
    if disk_count:
        params.data_disks.disk_count = disk_count
    if not params.data_disks.disk_count:
        raise CLIError('Please provide number of data disks (at least one disk is required).')
    if caching_type:
        params.data_disks.caching_type = caching_type
    if storage_sku:
        params.data_disks.storage_account_type = storage_sku
    if not params.data_disks.storage_account_type:
        raise CLIError('Please provide storage account type (storage sku).')
    if vm_size:
        params.vm_size = vm_size
    if not params.vm_size:
        raise CLIError('Please provide VM size.')
    if subnet:
        if not is_valid_resource_id(subnet):
            raise CLIError('Ill-formed subnet resource id')
        params.subnet = models.ResourceId(id=subnet)

    return client.create(resource_group, file_server_name, params, raw=raw)