Beispiel #1
0
 def test_get_lun_with_host_access(self):
     unity = UnitySystem('10.109.22.101', 'admin', 'Password123!')
     lun = unity.get_lun(_id='sv_567')
     assert_that(lun.host_access, instance_of(UnityBlockHostAccessList))
     access = lun.host_access[0]
     assert_that(access.access_mask, equal_to(HostLUNAccessEnum.PRODUCTION))
     assert_that(access.host, instance_of(UnityHost))
     assert_that(access.host.id, equal_to('Host_1'))
Beispiel #2
0
    def test_lun_perf_disabled_exception(self):
        unity = UnitySystem('10.244.223.61', 'a', 'a')
        unity.disable_perf_stats()

        def f():
            return unity.get_lun(_id='sv_2').read_iops

        assert_that(f, raises(UnityPerfMonNotEnabledError, 'not enabled'))
Beispiel #3
0
 def test_get_lun_with_host_access(self):
     unity = UnitySystem('10.109.22.101', 'admin', 'Password123!')
     lun = unity.get_lun(_id='sv_567')
     assert_that(lun.host_access, instance_of(UnityBlockHostAccessList))
     access = lun.host_access[0]
     assert_that(access.access_mask, equal_to(HostLUNAccessEnum.PRODUCTION))
     assert_that(access.host, instance_of(UnityHost))
     assert_that(access.host.id, equal_to('Host_1'))
Beispiel #4
0
class UnityLunEnablePerfStatsTest(TestCase):
    @patch_rest
    def setUp(self):
        self.unity = UnitySystem('10.244.223.61', 'a', 'a')
        self.unity.enable_perf_stats(1, [UnityDisk])

    @patch_rest
    def tearDown(self):
        self.unity.disable_perf_stats()

    @patch_rest
    def test_lun_perf_not_enabled_exception(self):
        disk = self.unity.get_disk(_id='dae_0_1_disk_0')
        assert_that(disk.read_iops, is_nan())

        def f():
            return self.unity.get_lun(_id='sv_2').read_iops

        assert_that(f, raises(UnityPerfMonNotEnabledError, 'not enabled'))

    @patch_rest
    def test_lun_properties_perf_not_enabled(self):
        lun = self.unity.get_lun(_id='sv_2')
        assert_that(lun.property_names, is_not(has_item('read_iops')))
        disk = self.unity.get_disk(_id='dae_0_1_disk_0')
        assert_that(disk.property_names(), has_item('read_iops'))

    @patch_rest
    def test_nested_properties(self):
        lun = self.unity.get_lun(_id='sv_12')
        assert_that(lun.pool.raid_type, equal_to(RaidTypeEnum.RAID10))
        assert_that(lun.pool.is_fast_cache_enabled, equal_to(False))
        assert_that(lun.host_access[0].host.name,
                    equal_to('Virtual_Machine_12'))
Beispiel #5
0
class UnityLunEnablePerfStatsTest(TestCase):
    @patch_rest
    def setUp(self):
        self.unity = UnitySystem('10.244.223.61', 'a', 'a')
        self.unity.enable_perf_stats(1, [UnityDisk])

    @patch_rest
    def tearDown(self):
        self.unity.disable_perf_stats()

    @patch_rest
    def test_lun_perf_not_enabled_exception(self):
        disk = self.unity.get_disk(_id='dae_0_1_disk_0')
        assert_that(disk.read_iops, is_nan())

        def f():
            return self.unity.get_lun(_id='sv_2').read_iops

        assert_that(f, raises(UnityPerfMonNotEnabledError, 'not enabled'))

    @patch_rest
    def test_lun_properties_perf_not_enabled(self):
        lun = self.unity.get_lun(_id='sv_2')
        assert_that(lun.property_names, is_not(has_item('read_iops')))
        disk = self.unity.get_disk(_id='dae_0_1_disk_0')
        assert_that(disk.property_names(), has_item('read_iops'))
Beispiel #6
0
class UnityLunEnablePerfStatsTest(TestCase):
    @patch_rest
    def setUp(self):
        self.unity = UnitySystem('10.244.223.61', 'a', 'a')
        self.unity.enable_perf_stats(1, [UnityDisk])

    @patch_rest
    def tearDown(self):
        self.unity.disable_perf_stats()

    @patch_rest
    def test_lun_perf_not_enabled_exception(self):
        disk = self.unity.get_disk(_id='dae_0_1_disk_0')
        assert_that(disk.read_iops, is_nan())

        def f():
            return self.unity.get_lun(_id='sv_2').read_iops

        assert_that(f, raises(UnityPerfMonNotEnabledError, 'not enabled'))

    @patch_rest
    def test_lun_properties_perf_not_enabled(self):
        lun = self.unity.get_lun(_id='sv_2')
        assert_that(lun.property_names, is_not(has_item('read_iops')))
        disk = self.unity.get_disk(_id='dae_0_1_disk_0')
        assert_that(disk.property_names(), has_item('read_iops'))

    @patch_rest
    def test_nested_properties(self):
        lun = self.unity.get_lun(_id='sv_12')
        assert_that(lun.pool.raid_type, equal_to(RaidTypeEnum.RAID10))
        assert_that(lun.pool.is_fast_cache_enabled, equal_to(False))
        assert_that(lun.host_access[0].host.name,
                    equal_to('Virtual_Machine_12'))

    @patch_rest
    def test_create_snap_of_member_snap_not_support(self):
        lun = UnityLun(cli=t_rest(), _id='sv_58')
        assert_that(
            calling(lun.create_snap).with_args(name='not-support'),
            raises(UnityCGMemberActionNotSupportError))

    @patch_rest
    def test_thinclone_of_member_snap_not_support(self):
        lun = UnityLun(cli=t_rest(version='4.3'), _id='sv_58')
        assert_that(
            calling(lun.thin_clone).with_args('not-support'),
            raises(UnityCGMemberActionNotSupportError))

    @patch_rest
    def test_thinclone_of_thick_lun_not_allowed(self):
        lun = UnityLun(cli=t_rest(version='4.3'), _id='sv_59')
        assert_that(
            calling(lun.thin_clone).with_args('not-allowed'),
            raises(UnityThinCloneNotAllowedError))
Beispiel #7
0
def get_unity_unisphere_connection(module_params):
    if HAS_UNITY_SDK:
        conn = UnitySystem(host=module_params['unispherehost'],
                           port=module_params['port'],
                           verify=module_params['verifycert'],
                           username=module_params['username'],
                           password=module_params['password'])
        return conn
Beispiel #8
0
def index():
    data = ''
    if request.method == "POST":

        info = request.form.to_dict()
        # array = ip address of Unity array from inputbox
        ip = info['ip']
        username = info['username']
        password = info['password']

        unity = UnitySystem(ip, username, password)
        hosts = unity.get_host()

        data = dict(
            array_name=unity.name,
            array_OE=unity.system_version,
            host_list=hosts
        )
        for host in data['host_list']:
            print(host.name)

        #user = f'Connected to {unity.name} (OE: {unity.system_version})'

    return render_template("index.html", data=data)
Beispiel #9
0
import sys
import re
from storops import UnitySystem
import json

array_ip = ''
array_user = '******'
array_pass = '******'

unity = UnitySystem(array_ip, array_user, array_pass)
luns = unity.get_lun()
for lun in luns:
    lun_id = lun.id
    lun_name = lun.name
    lun_wwn = lun.wwn
    lun_size = lun.size_total / 1024 / 1024 / 1024
    print('Lun ID: {}'.format(lun_id))
    print('Lun Name: {}'.format(lun_name))
    print('Lun Size (GB): {}'.format(lun_size))
    print('Lun WWN: {}'.format(lun.wwn))
    lun_pool = lun.pool.id
    print('Lun Pool: {}'.format(lun_pool))
    print()
Beispiel #10
0
from requests.packages.urllib3.exceptions import InsecureRequestWarning

requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

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! ***')
Beispiel #11
0
import sys
import re
from storops import UnitySystem
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)


array_ip = 'ip_address'
array_user = '******'
array_pass = '******'
account_num = ''
array_num = ''

unity = UnitySystem(array_ip, array_user, array_pass)
input_file_name = sys.argv[1]
with open(input_file_name, 'r') as input_file:
    server_re = re.compile(r'(###)( )([0-9]{6})')
    ip_re = re.compile(r'(\$\$\$)( )(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})')
    wwn_re = re.compile(
        r'(fc    )(\b\S{2}\:\S{2}\:\S{2}\:\S{2}\:\S{2}\:\S{2}\:\S{2}\:\S{2}\b)')
    input_file = input_file.read()
    server_list = server_re.findall(input_file)
    ip_list = ip_re.findall(input_file)
    wwn_list = wwn_re.findall(input_file)
    counter = 0
    for server, ip in zip(server_list, ip_list):
        server_name = '{}-{}'.format(account_num, server[2])
        host = unity.create_host(server_name, os='VMware ESXi')
        host.add_initiator('20:00{0}:{1}'.format(
            wwn_list[counter + 1][1][5:], wwn_list[counter + 1][1]))
Beispiel #12
0
def t_unity():
    unity = UnitySystem('10.244.223.61', 'admin', 'Password123!')
    log.debug('initialize unity system: {}'.format(unity))
    return unity
Beispiel #13
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)}")
import sys
import re
from storops import UnitySystem
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

array_ip = 'ip_Address'
array_user = ''
array_pass = ''
account_num = ''
array_num = ''
host_type = 'VMware ESXi'

unity = UnitySystem(array_ip, array_user, array_pass)
input_file_name = sys.argv[1]
with open(input_file_name, 'r') as input_file:
    server_re = re.compile(r'(###)( )([0-9]{6})')
    ip_re = re.compile(r'(\$\$\$)( )(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})')
    wwn_re = re.compile(
        r'(Port WWN       : )(\b\S{2}\:\S{2}\:\S{2}\:\S{2}\:\S{2}\:\S{2}\:\S{2}\:\S{2}\b)'
    )
    input_file = input_file.read()
    server_list = server_re.findall(input_file)
    ip_list = ip_re.findall(input_file)
    wwn_list = wwn_re.findall(input_file)
    counter = 0
    for server, ip in zip(server_list, ip_list):
        server_name = '{}-{}'.format(account_num, server[2])
        host = unity.create_host(server_name, os=host_type)
        host.add_initiator('20{0}:{1}'.format(wwn_list[counter + 0][1][2:],
Beispiel #15
0
import sys
import re
from storops import UnitySystem
import json
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

array_ip = 'ip'
array_user = '******'
array_pass = '******'

with open(array_ip + '.json', 'w') as file:
    unity = UnitySystem(array_ip, array_user, array_pass)
    # file.writelines(unity.get_sp().json(indent=4))
    # file.writelines(unity.get_dpe().json(indent=4))
    # file.writelines(unity.get_dae().json(indent=4))
    # file.writelines(unity.get_disk().json(indent=4))
    # file.writelines(unity.get_ssd().json(indent=4))
    # file.writelines(unity.get_battery().json(indent=4))
    # file.writelines(unity.get_power_supply().json(indent=4))
    # file.writelines(unity.get_sas_port().json(indent=4))
    # file.writelines(unity.get_ethernet_port().json(indent=4))
    # file.writelines(unity.get_ip_port().json(indent=4))
    # file.writelines(unity.get_lcc().json(indent=4))
    # file.writelines(unity.get_io_module().json(indent=4))
    # file.writelines(unity.get_sas_port().json(indent=4))
    # file.writelines(unity.get_fan().json(indent=4))
    # file.writelines(unity.get_memory_module().json(indent=4))
    # file.writelines(unity.get_license().json(indent=4))
    # file.writelines(unity.get_capability_profile().json(indent=4))
Beispiel #16
0
 def setUp(self):
     self.unity = UnitySystem('10.244.223.61', 'a', 'a')
     self.unity.enable_perf_stats(1, [UnityDisk])
import sys
import re
from storops import UnitySystem
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

array_user = '******'
array_pass = '******'

#input_file_name = sys.argv[1]
input_file_name = 'unity_list.txt'
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))
                filesystems = unity.get_filesystem()
                for fs in filesystems:
                    print(fs)
            except (Exception):
                print(Exception.message)
                continue