# Copyright (c) 2015 Clinton Knight. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from lxml import etree CONNECTION_INFO = { 'hostname': 'hostname', 'transport_type': 'https', 'port': 443, 'username': 'admin', 'password': 'passw0rd' } NODE_NAME = 'fake_node' VSERVER_NAME = 'fake_vserver' VSERVER_NAME_2 = 'fake_vserver_2' ADMIN_VSERVER_NAME = 'fake_admin_vserver' NODE_VSERVER_NAME = 'fake_node_vserver' ROOT_VOLUME_AGGREGATE_NAME = 'fake_root_aggr' ROOT_VOLUME_NAME = 'fake_root_volume' SHARE_AGGREGATE_NAME = 'fake_aggr1' SHARE_AGGREGATE_NAMES = ('fake_aggr1', 'fake_aggr2') SHARE_AGGREGATE_RAID_TYPES = ('raid4', 'raid_dp') SHARE_AGGREGATE_DISK_TYPE = 'FCAL' SHARE_NAME = 'fake_share' SHARE_SIZE = '1000000000' SHARE_NAME_2 = 'fake_share_2' SNAPSHOT_NAME = 'fake_snapshot' CG_SNAPSHOT_ID = 'fake_cg_id' PARENT_SHARE_NAME = 'fake_parent_share' PARENT_SNAPSHOT_NAME = 'fake_parent_snapshot' MAX_FILES = 5000 LANGUAGE = 'fake_language' SNAPSHOT_POLICY_NAME = 'fake_snapshot_policy' EXPORT_POLICY_NAME = 'fake_export_policy' DELETED_EXPORT_POLICIES = { VSERVER_NAME: [ 'deleted_manila_fake_policy_1', 'deleted_manila_fake_policy_2', ], VSERVER_NAME_2: [ 'deleted_manila_fake_policy_3', ], } USER_NAME = 'fake_user' PORT = 'e0a' VLAN = '1001' VLAN_PORT = 'e0a-1001' IP_ADDRESS = '10.10.10.10' NETMASK = '255.255.255.0' NET_ALLOCATION_ID = 'fake_allocation_id' LIF_NAME_TEMPLATE = 'os_%(net_allocation_id)s' LIF_NAME = LIF_NAME_TEMPLATE % {'net_allocation_id': NET_ALLOCATION_ID} IPSPACE_NAME = 'fake_ipspace' BROADCAST_DOMAIN = 'fake_domain' MTU = 9000 IPSPACES = [{ 'uuid': 'fake_uuid', 'ipspace': IPSPACE_NAME, 'id': 'fake_id', 'broadcast-domains': ['OpenStack'], 'ports': [NODE_NAME + ':' + VLAN_PORT], 'vservers': [ IPSPACE_NAME, VSERVER_NAME, ] }] EMS_MESSAGE = { 'computer-name': 'fake_host', 'event-id': '0', 'event-source': 'fake driver', 'app-version': 'fake app version', 'category': 'fake category', 'event-description': 'fake description', 'log-level': '6', 'auto-support': 'false', } NO_RECORDS_RESPONSE = etree.XML(""" 0 """) PASSED_RESPONSE = etree.XML(""" """) VSERVER_GET_ITER_RESPONSE = etree.XML(""" %(fake_vserver)s 1 """ % {'fake_vserver': VSERVER_NAME}) VSERVER_GET_ROOT_VOLUME_NAME_RESPONSE = etree.XML(""" %(root_volume)s %(fake_vserver)s 1 """ % {'root_volume': ROOT_VOLUME_NAME, 'fake_vserver': VSERVER_NAME}) VSERVER_GET_IPSPACE_NAME_RESPONSE = etree.XML(""" %(ipspace)s %(fake_vserver)s 1 """ % {'ipspace': IPSPACE_NAME, 'fake_vserver': VSERVER_NAME}) VSERVER_GET_RESPONSE = etree.XML(""" %(aggr1)s %(aggr2)s 45678592 %(aggr1)s 6448431104 %(aggr2)s %(vserver)s """ % { 'vserver': VSERVER_NAME, 'aggr1': SHARE_AGGREGATE_NAMES[0], 'aggr2': SHARE_AGGREGATE_NAMES[1], }) VSERVER_DATA_LIST_RESPONSE = etree.XML(""" %(vserver)s data 1 """ % {'vserver': VSERVER_NAME}) VSERVER_AGGREGATES = { SHARE_AGGREGATE_NAMES[0]: { 'available': 45678592, }, SHARE_AGGREGATE_NAMES[1]: { 'available': 6448431104, }, } VSERVER_GET_RESPONSE_NO_AGGREGATES = etree.XML(""" %(vserver)s """ % {'vserver': VSERVER_NAME}) ONTAPI_VERSION_RESPONSE = etree.XML(""" 1 19 """) LICENSE_V2_LIST_INFO_RESPONSE = etree.XML(""" none Cluster Base License false cluster3 base 1-80-000008 license none NFS License false cluster3-01 nfs 1-81-0000000000000004082368507 license none CIFS License false cluster3-01 cifs 1-81-0000000000000004082368507 license none iSCSI License false cluster3-01 iscsi 1-81-0000000000000004082368507 license none FCP License false cluster3-01 fcp 1-81-0000000000000004082368507 license none SnapRestore License false cluster3-01 snaprestore 1-81-0000000000000004082368507 license none SnapMirror License false cluster3-01 snapmirror 1-81-0000000000000004082368507 license none FlexClone License false cluster3-01 flexclone 1-81-0000000000000004082368507 license none SnapVault License false cluster3-01 snapvault 1-81-0000000000000004082368507 license """) LICENSES = ( 'base', 'cifs', 'fcp', 'flexclone', 'iscsi', 'nfs', 'snapmirror', 'snaprestore', 'snapvault' ) VOLUME_COUNT_RESPONSE = etree.XML(""" vol0 cluster3-01 %(root_volume)s %(fake_vserver)s 2 """ % {'root_volume': ROOT_VOLUME_NAME, 'fake_vserver': VSERVER_NAME}) CIFS_SECURITY_SERVICE = { 'type': 'active_directory', 'password': 'fake_password', 'user': 'fake_user', 'domain': 'fake_domain', 'dns_ip': 'fake_dns_ip', } LDAP_SECURITY_SERVICE = { 'type': 'ldap', 'password': 'fake_password', 'server': 'fake_server', 'id': 'fake_id', } KERBEROS_SECURITY_SERVICE = { 'type': 'kerberos', 'password': 'fake_password', 'user': 'fake_user', 'server': 'fake_server', 'id': 'fake_id', 'domain': 'fake_domain', 'dns_ip': 'fake_dns_ip', } KERBEROS_SERVICE_PRINCIPAL_NAME = 'nfs/fake-vserver.fake_domain@FAKE_DOMAIN' INVALID_SECURITY_SERVICE = { 'type': 'fake', } SYSTEM_NODE_GET_ITER_RESPONSE = etree.XML(""" %s 1 """ % NODE_NAME) NET_PORT_GET_ITER_RESPONSE = etree.XML(""" full full auto true true true up 00:0c:29:fc:04:d9 1500 %(node_name)s full none 10 e0a physical data full full auto true true true up 00:0c:29:fc:04:e3 1500 %(node_name)s full none 100 e0b physical data full full auto true true true up 00:0c:29:fc:04:ed 1500 %(node_name)s full none 1000 e0c physical data full full auto true true true up 00:0c:29:fc:04:f7 1500 %(node_name)s full none 10000 e0d physical data 4 """ % {'node_name': NODE_NAME}) SPEED_SORTED_PORTS = ( {'node': NODE_NAME, 'port': 'e0d', 'speed': '10000'}, {'node': NODE_NAME, 'port': 'e0c', 'speed': '1000'}, {'node': NODE_NAME, 'port': 'e0b', 'speed': '100'}, {'node': NODE_NAME, 'port': 'e0a', 'speed': '10'}, ) PORT_NAMES = ('e0a', 'e0b', 'e0c', 'e0d') SPEED_SORTED_PORT_NAMES = ('e0d', 'e0c', 'e0b', 'e0a') UNSORTED_PORTS_ALL_SPEEDS = ( {'node': NODE_NAME, 'port': 'port6', 'speed': 'undef'}, {'node': NODE_NAME, 'port': 'port3', 'speed': '100'}, {'node': NODE_NAME, 'port': 'port1', 'speed': '10000'}, {'node': NODE_NAME, 'port': 'port4', 'speed': '10'}, {'node': NODE_NAME, 'port': 'port7'}, {'node': NODE_NAME, 'port': 'port2', 'speed': '1000'}, {'node': NODE_NAME, 'port': 'port5', 'speed': 'auto'}, ) SORTED_PORTS_ALL_SPEEDS = ( {'node': NODE_NAME, 'port': 'port1', 'speed': '10000'}, {'node': NODE_NAME, 'port': 'port2', 'speed': '1000'}, {'node': NODE_NAME, 'port': 'port3', 'speed': '100'}, {'node': NODE_NAME, 'port': 'port4', 'speed': '10'}, {'node': NODE_NAME, 'port': 'port5', 'speed': 'auto'}, {'node': NODE_NAME, 'port': 'port6', 'speed': 'undef'}, {'node': NODE_NAME, 'port': 'port7'}, ) NET_PORT_GET_ITER_BROADCAST_DOMAIN_RESPONSE = etree.XML(""" %(ipspace)s %(domain)s %(node)s %(port)s 1 """ % { 'domain': BROADCAST_DOMAIN, 'node': NODE_NAME, 'port': PORT, 'ipspace': IPSPACE_NAME, }) NET_PORT_GET_ITER_BROADCAST_DOMAIN_MISSING_RESPONSE = etree.XML(""" %(ipspace)s %(node)s %(port)s 1 """ % {'node': NODE_NAME, 'port': PORT, 'ipspace': IPSPACE_NAME}) NET_PORT_BROADCAST_DOMAIN_GET_ITER_RESPONSE = etree.XML(""" %(domain)s %(ipspace)s 1 """ % {'domain': BROADCAST_DOMAIN, 'ipspace': IPSPACE_NAME}) NET_IPSPACES_GET_ITER_RESPONSE = etree.XML(""" OpenStack fake_id %(ipspace)s %(node)s:%(port)s fake_uuid %(ipspace)s %(vserver)s 1 """ % { 'ipspace': IPSPACE_NAME, 'node': NODE_NAME, 'port': VLAN_PORT, 'vserver': VSERVER_NAME }) NET_INTERFACE_GET_ITER_RESPONSE = etree.XML("""
192.168.228.42
ipv4 up %(node)s e0c none none system-defined disabled mgmt %(node)s e0c cluster_mgmt true true d3230112-7524-11e4-8608-123478563412 false %(netmask)s 24 up cluster_mgmt c192.168.228.0/24 system_defined cluster3
192.168.228.43
ipv4 up %(node)s e0d none system-defined nextavail mgmt %(node)s e0d mgmt1 true true 0ccc57cc-7525-11e4-8608-123478563412 false %(netmask)s 24 up node_mgmt n192.168.228.0/24 system_defined cluster3-01
%(address)s
ipv4 up %(node)s %(vlan)s nfs cifs none system-defined nextavail data %(node)s %(vlan)s %(lif)s false true db4d91b6-95d9-11e4-8608-123478563412 false %(netmask)s 24 up data d10.0.0.0/24 system_defined %(vserver)s
3
""" % { 'lif': LIF_NAME, 'vserver': VSERVER_NAME, 'node': NODE_NAME, 'address': IP_ADDRESS, 'netmask': NETMASK, 'vlan': VLAN_PORT, }) LIF_NAMES = ('cluster_mgmt', 'mgmt1', LIF_NAME) NET_INTERFACE_GET_ITER_RESPONSE_NFS = etree.XML("""
%(address)s
ipv4 up %(node)s %(vlan)s nfs cifs none system-defined nextavail data %(node)s %(vlan)s %(lif)s false true db4d91b6-95d9-11e4-8608-123478563412 false %(netmask)s 24 up data d10.0.0.0/24 system_defined %(vserver)s
1
""" % { 'lif': LIF_NAME, 'vserver': VSERVER_NAME, 'node': NODE_NAME, 'address': IP_ADDRESS, 'netmask': NETMASK, 'vlan': VLAN_PORT, }) LIFS = ( {'address': '192.168.228.42', 'home-node': NODE_NAME, 'home-port': 'e0c', 'interface-name': 'cluster_mgmt', 'netmask': NETMASK, 'role': 'cluster_mgmt', 'vserver': 'cluster3' }, {'address': '192.168.228.43', 'home-node': NODE_NAME, 'home-port': 'e0d', 'interface-name': 'mgmt1', 'netmask': NETMASK, 'role': 'node_mgmt', 'vserver': 'cluster3-01' }, {'address': IP_ADDRESS, 'home-node': NODE_NAME, 'home-port': VLAN_PORT, 'interface-name': LIF_NAME, 'netmask': NETMASK, 'role': 'data', 'vserver': VSERVER_NAME, }, ) NFS_LIFS = [ {'address': IP_ADDRESS, 'home-node': NODE_NAME, 'home-port': VLAN_PORT, 'interface-name': LIF_NAME, 'netmask': NETMASK, 'role': 'data', 'vserver': VSERVER_NAME, }, ] NET_INTERFACE_GET_ONE_RESPONSE = etree.XML(""" %(lif)s %(vserver)s 1 """ % {'lif': LIF_NAME, 'vserver': VSERVER_NAME}) AGGR_GET_NAMES_RESPONSE = etree.XML(""" /%(aggr1)s/plex0 /%(aggr1)s/plex0/rg0 %(aggr1)s /%(aggr2)s/plex0 /%(aggr2)s/plex0/rg0 /%(aggr2)s/plex0/rg1 %(aggr2)s 2 """ % { 'aggr1': SHARE_AGGREGATE_NAMES[0], 'aggr2': SHARE_AGGREGATE_NAMES[1], }) AGGR_GET_SPACE_RESPONSE = etree.XML(""" /%(aggr1)s/plex0 /%(aggr1)s/plex0/rg0 45670400 943718400 898048000 %(aggr1)s /%(aggr2)s/plex0 /%(aggr2)s/plex0/rg0 /%(aggr2)s/plex0/rg1 4267659264 7549747200 3282087936 %(aggr2)s 2 """ % { 'aggr1': SHARE_AGGREGATE_NAMES[0], 'aggr2': SHARE_AGGREGATE_NAMES[1], }) AGGR_GET_NODE_RESPONSE = etree.XML(""" %(node)s %(aggr)s 1 """ % { 'aggr': SHARE_AGGREGATE_NAME, 'node': NODE_NAME }) AGGR_GET_ITER_RESPONSE = etree.XML(""" false 64_bit 1758646411 aggr 512 30384 96 30384 30384 30384 243191 96 0 4082368507 cluster3-01 4082368507 cluster3-01 off 0 active block 3 cfo true false true false false false unmirrored online 1 true false /%(aggr1)s/plex0 normal,active block false false false /%(aggr1)s/plex0/rg0 0 0 0 on 16 raid_dp, normal raid_dp online false 0 0 true true 0 0 0 0 0 0 0 0 0 245760 0 95 45670400 943718400 898048000 0 898048000 897802240 1 0 0 %(aggr1)s 15863632-ea49-49a8-9c88-2bd2d57c6d7a cluster3-01 unknown false 64_bit 706602229 aggr 528 31142 96 31142 31142 31142 1945584 96 0 4082368507 cluster3-01 4082368507 cluster3-01 off 0 active block 10 sfo false false true false false false unmirrored online 1 true false /%(aggr2)s/plex0 normal,active block false false false /%(aggr2)s/plex0/rg0 0 0 block false false false /%(aggr2)s/plex0/rg1 0 0 0 on 8 raid4, normal raid4 online false 0 0 true true 0 0 0 0 0 0 0 0 0 425984 0 15 6448431104 7549747200 1101316096 0 1101316096 1100890112 2 0 0 %(aggr2)s 2a741934-1aaf-42dd-93ca-aaf231be108a cluster3-01 not_striped 2 """ % { 'aggr1': SHARE_AGGREGATE_NAMES[0], 'aggr2': SHARE_AGGREGATE_NAMES[1], }) VOLUME_GET_NAME_RESPONSE = etree.XML(""" %(volume)s %(vserver)s 1 """ % {'volume': SHARE_NAME, 'vserver': VSERVER_NAME}) VOLUME_GET_VOLUME_PATH_RESPONSE = etree.XML(""" /%(volume)s """ % {'volume': SHARE_NAME}) VOLUME_GET_VOLUME_PATH_CIFS_RESPONSE = etree.XML(""" \\%(volume)s """ % {'volume': SHARE_NAME}) VOLUME_JUNCTION_PATH = '/' + SHARE_NAME VOLUME_JUNCTION_PATH_CIFS = '\\' + SHARE_NAME VOLUME_MODIFY_ITER_RESPONSE = etree.XML(""" 0 1 %(volume)s %(vserver)s """ % {'volume': SHARE_NAME, 'vserver': VSERVER_NAME}) VOLUME_MODIFY_ITER_ERROR_RESPONSE = etree.XML(""" 160 Unable to set volume attribute "size" %(volume)s %(vserver)s 1 0 """ % {'volume': SHARE_NAME, 'vserver': VSERVER_NAME}) SNAPSHOT_GET_ITER_NOT_BUSY_RESPONSE = etree.XML(""" false %(snap)s %(volume)s %(vserver)s 1 """ % {'snap': SNAPSHOT_NAME, 'volume': SHARE_NAME, 'vserver': VSERVER_NAME}) SNAPSHOT_GET_ITER_BUSY_RESPONSE = etree.XML(""" true %(snap)s %(volume)s %(vserver)s volume clone 1 """ % {'snap': SNAPSHOT_NAME, 'volume': SHARE_NAME, 'vserver': VSERVER_NAME}) SNAPSHOT_GET_ITER_NOT_UNIQUE_RESPONSE = etree.XML(""" false %(snap)s %(volume)s %(vserver)s false %(snap)s %(root_volume)s %(admin_vserver)s 1 """ % { 'snap': SNAPSHOT_NAME, 'volume': SHARE_NAME, 'vserver': VSERVER_NAME, 'root_volume': ROOT_VOLUME_NAME, 'admin_vserver': ADMIN_VSERVER_NAME, }) SNAPSHOT_GET_ITER_UNAVAILABLE_RESPONSE = etree.XML(""" 0 13023 %(volume)s Unable to get information for Snapshot copies of volume \ "%(volume)s" on Vserver "%(vserver)s". Reason: Volume not online. %(vserver)s """ % {'volume': SHARE_NAME, 'vserver': VSERVER_NAME}) SNAPSHOT_GET_ITER_OTHER_ERROR_RESPONSE = etree.XML(""" 0 99999 %(volume)s Unable to get information for Snapshot copies of volume \ "%(volume)s" on Vserver "%(vserver)s". %(vserver)s """ % {'volume': SHARE_NAME, 'vserver': VSERVER_NAME}) SNAPSHOT_MULTIDELETE_ERROR_RESPONSE = etree.XML(""" 13021 %(volume)s No such snapshot. """ % {'volume': SHARE_NAME}) NFS_EXPORT_RULES = ('10.10.10.10', '10.10.10.20') NFS_EXPORTFS_LIST_RULES_2_NO_RULES_RESPONSE = etree.XML(""" """) NFS_EXPORTFS_LIST_RULES_2_RESPONSE = etree.XML(""" %(path)s 65534 false %(host1)s %(host2)s %(host1)s %(host2)s %(host1)s %(host2)s sys """ % { 'path': VOLUME_JUNCTION_PATH, 'host1': NFS_EXPORT_RULES[0], 'host2': NFS_EXPORT_RULES[1], }) AGGR_GET_RAID_TYPE_RESPONSE = etree.XML(""" /%(aggr1)s/plex0 /%(aggr1)s/plex0/rg0 %(raid_type1)s %(aggr1)s /%(aggr2)s/plex0 /%(aggr2)s/plex0/rg0 /%(aggr2)s/plex0/rg1 %(raid_type2)s %(aggr2)s 2 """ % { 'aggr1': SHARE_AGGREGATE_NAMES[0], 'aggr2': SHARE_AGGREGATE_NAMES[1], 'raid_type1': SHARE_AGGREGATE_RAID_TYPES[0], 'raid_type2': SHARE_AGGREGATE_RAID_TYPES[1] }) STORAGE_DISK_GET_ITER_RESPONSE = etree.XML(""" cluster3-01:v5.19 %s 1 """ % SHARE_AGGREGATE_DISK_TYPE) GET_AGGREGATE_FOR_VOLUME_RESPONSE = etree.XML(""" %(aggr)s %(share)s os_aa666789-5576-4835-87b7-868069856459 1 """ % { 'aggr': SHARE_AGGREGATE_NAME, 'share': SHARE_NAME }) EXPORT_RULE_GET_ITER_RESPONSE = etree.XML(""" %(rule)s %(policy)s 3 manila_svm %(rule)s %(policy)s 1 manila_svm 2 """ % {'policy': EXPORT_POLICY_NAME, 'rule': IP_ADDRESS}) VOLUME_GET_EXPORT_POLICY_RESPONSE = etree.XML(""" %(policy)s %(volume)s manila_svm 1 """ % {'policy': EXPORT_POLICY_NAME, 'volume': SHARE_NAME}) DELETED_EXPORT_POLICY_GET_ITER_RESPONSE = etree.XML(""" %(policy1)s %(vserver)s %(policy2)s %(vserver)s %(policy3)s %(vserver2)s 2 """ % { 'vserver': VSERVER_NAME, 'vserver2': VSERVER_NAME_2, 'policy1': DELETED_EXPORT_POLICIES[VSERVER_NAME][0], 'policy2': DELETED_EXPORT_POLICIES[VSERVER_NAME][1], 'policy3': DELETED_EXPORT_POLICIES[VSERVER_NAME_2][0], }) LUN_GET_ITER_RESPONSE = etree.XML(""" /vol/%(volume)s/fakelun %(volume)s %(vserver)s 1 """ % { 'vserver': VSERVER_NAME, 'volume': SHARE_NAME, }) VOLUME_GET_ITER_JUNCTIONED_VOLUMES_RESPONSE = etree.XML(""" fake_volume test 1 """) VOLUME_GET_ITER_VOLUME_TO_MANAGE_RESPONSE = etree.XML(""" %(aggr)s /%(volume)s %(volume)s %(vserver)s rw %(size)s 1 """ % { 'aggr': SHARE_AGGREGATE_NAME, 'vserver': VSERVER_NAME, 'volume': SHARE_NAME, 'size': SHARE_SIZE, }) SIS_GET_ITER_RESPONSE = etree.XML(""" true /vol/%(volume)s enabled %(vserver)s """ % { 'vserver': VSERVER_NAME, 'volume': SHARE_NAME, })