Git Product home page Git Product logo

netappfiles-python-pool-change-sdk-sample's Introduction

page_type languages products description
sample
python
azure
azure-netapp-files
This project demonstrates how to use python with NetApp Files SDK for Microsoft.NetApp resource provider to perform a pool change on a Volume.

Azure NetAppFiles Pool Change SDK Sample for Python

This project demonstrates how to use a Python sample application to perform a pool change on a Volume for the Microsoft.NetApp resource provider.

In this sample application we perform the following operations:

  • Creation
    • ANF Account
    • Source Capacity Pool in service level Premium
    • Destination Capacity Pool in service level Standard
    • Volume in the Source capacity pool
  • Updates
    • Perform pool change - move Volume from Premium tier capacity pool to Standard tier capacity Pool
  • Deletions (disabled by default)
    • Volume
    • Source Capacity Pool
    • Destination Capacity Pool
    • ANF Account

If you don't already have a Microsoft Azure subscription, you can get a FREE trial account here.

Prerequisites

  1. Python (code was built and tested using version 3.9.5)
  2. Azure Subscription.
  3. Subscription needs to have Azure NetApp Files resource provider registered. For more information, see Register for NetApp Resource Provider.
  4. Resource Group created
  5. Virtual Network with a delegated subnet to Microsoft.Netapp/volumes resource. For more information, please refer to Guidelines for Azure NetApp Files network planning
  6. For this sample Python console application to work we need to authenticate, and the chosen method for this sample is using service principals.
    1. Within an Azure Cloud Shell session, make sure you're logged on at the subscription where you want to be associated with the service principal by default:

      az account show

      If this is not the correct subscription, use:

      az account set -s <subscription name or id>  
    2. Create a service principal using Azure CLI

      az ad sp create-for-rbac --sdk-auth

      Note: this command will automatically assign RBAC contributor role to the service principal at subscription level, you can narrow down the scope to the specific resource group where your tests will create the resources.

    3. Copy the output content and paste it in a file called azureauth.json and secure it with file system permissions

    4. Set an environment variable pointing to the file path you just created, here is an example with Powershell and bash:

      Powershell

      [Environment]::SetEnvironmentVariable("AZURE_AUTH_LOCATION", "C:\sdksample\azureauth.json", "User")

      Bash

      export AZURE_AUTH_LOCATION=/sdksamples/azureauth.json

      Note: for other Azure Active Directory authentication methods for Python, please refer to these samples.

What is example.py doing?

This sample project is dedicated to demonstrate how to perform a pool change on a Volume in Azure NetApp Files for a NFS v4.1 enabled volume. Similar to other examples, the authentication method is based on a service principal. This project will first create an ANF Account and then two different capacity pools, source pool at service level Premium and destination pool at service level Standard. A single volume is created in the source pool and then updated for a pool change, moving it to the destination pool. Doing so will change the volume's service level from Premium to Standard. Finally, all created resources will be deleted via the cleanup process (as long as the appropriate variable, CLEANUP_RESOURCES, in example.py has been set to 'True').

Contents

File/folder Description
media\ Folder that contains a screenshot of a successful run.
src\ Sample source code folder.
src\example.py Sample main file that executes all operations.
src\sample_utils.py Sample file that contains authentication functions, all wait functions and other small functions.
src\resource_uri_utils.py Sample file that contains functions to work with URIs, e.g. get resource name from URI (get_anf_capacitypool).
src\requirements.txt Sample script required modules.

How to run the script

  1. Clone it locally
    git clone https://github.com/Azure-Samples/netappfiles-python-pool-change-sdk-sample.git
  2. Change folder to .\netappfiles-python-pool-change-sdk-sample\src
  3. Install any missing dependencies as needed
    pip install -r ./requirements.txt
    or upgrade dependencies if they already exist
    pip install --upgrade -r ./requirements.txt
  4. Make sure you have the azureauth.json and its environment variable with the path to it defined (as previously described at prerequisites)
  5. Edit file example.py and change the variables contents as appropriate (names are self-explanatory).
  6. Run the script
    python example.py

Sample output e2e execution

References

netappfiles-python-pool-change-sdk-sample's People

Contributors

adelghabboun avatar cfialkiewicz avatar haukurstefansson avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.