コード例 #1
0
array_user = '******'
array_pass = '******'

input_file_name = sys.argv[1]
with open(input_file_name, 'r') as input_file:
    for ip in input_file.readlines():
        with open(input_file_name[:-4] + '_out' + '.txt', 'a') as file:
            print(ip)
            file.write(ip + '\n')
            array_ip = ip[:-1]
            try:
                unity = UnitySystem(array_ip, array_user, array_pass)
                print('Array: {}'.format(unity.name))
                file.write('Array: {}\n'.format(unity.name))
                pools = unity.get_pool()
                for pool in pools:
                    print('\tPool: {}'.format(pool.name))
                    file.write('\tPool: {}\n'.format(pool.name))
                    allocated = pool.size_used / pool.size_total
                    subscribed = pool.size_subscribed / pool.size_total
                    print('\tAllocated: {:.2f}'.format(allocated * 100))
                    file.write('\tAllocated: {:.2f}\n'.format(allocated * 100))
                    print('\tSubscribed: {:.2f}'.format(subscribed * 100))
                    file.write('\tSubscribed: {:.2f}\n'.format(subscribed *
                                                               100))
                    if subscribed * 100 > 100:
                        print('\t*** Oversubscribed! ***')
                        file.write('\t*** Oversubscribed! ***\n')
                    print()
                    file.write('\n')
コード例 #2
0
import os
import urllib3

from storops import UnitySystem  # https://github.com/emc-openstack/storops
from hurry.filesize import size

# Load the config from environment variables
SAN_IP = os.environ["UNITY_SAN_IP"]
USER = os.environ["UNITY_USER"]
PASSWORD = os.environ["UNITY_PASSWORD"]

# Squelch HTTPS warnings
urllib3.disable_warnings()

# Connect to Unity
unity = UnitySystem(SAN_IP, USER, PASSWORD)

# Collect some basic information - List the storage pools
print("Listing Pools:")
pools = unity.get_pool()
for pool in pools.list:
    print(f"   {pool.name}")

# Show usage details of a specific pool
print("Usage in pool1:")
pool1 = unity.get_pool(name="pool1")
print(f"   Used: {size(pool1.size_used)}")
print(f"   Free: {size(pool1.size_free)}")
print(f"   Total: {size(pool1.size_total)}")