def test_create_host_existed(self): unity = t_unity() def f(): # the 'flocker-3' is the Host_10 name unity.create_host("flocker-3") assert_that(f, raises(UnityHostNameInUseError))
def test_create_host_existed(self): unity = t_unity() def f(): # the 'flocker-3' is the Host_10 name unity.create_host("flocker-3") assert_that(f, raises(UnityHostNameInUseError))
def test_get_initiator_by_name(self): unity = t_unity() wwn = "50:00:14:40:47:B0:0C:44:50:00:14:42:D0:0C:44:10" filtered = unity.get_initiator(initiator_id=wwn) assert_that(len(filtered), equal_to(1)) assert_that(filtered, instance_of(UnityHostInitiatorList)) initiator = filtered.first_item assert_that(initiator, instance_of(UnityHostInitiator)) assert_that(initiator.existed, equal_to(True)) assert_that(initiator.initiator_id, equal_to(wwn))
def test_get_initiator_by_name(self): unity = t_unity() wwn = "50:00:14:40:47:B0:0C:44:50:00:14:42:D0:0C:44:10" filtered = unity.get_initiator(initiator_id=wwn) assert_that(len(filtered), equal_to(1)) assert_that(filtered, instance_of(UnityHostInitiatorList)) initiator = filtered.first_item assert_that(initiator, instance_of(UnityHostInitiator)) assert_that(initiator.existed, equal_to(True)) assert_that(initiator.initiator_id, equal_to(wwn))
def test_get_capability_profile_service_levels(self): unity = t_unity() level_s = ServiceLevelEnum.SILVER level_p = ServiceLevelEnum.PLATINUM cp = unity.get_capability_profile(service_levels=[level_s, level_p]) assert_that(cp, instance_of(UnityCapabilityProfileList)) assert_that(len(cp), 2) # use Enum or EnumList are both ok cp2 = unity.get_capability_profile(service_levels=level_s) assert_that(cp2, instance_of(UnityCapabilityProfileList)) assert_that(len(cp2), 1) assert_that(cp2[0].existed, equal_to(True)) level_enum_list = ServiceLevelEnumList.parse([level_s, level_p]) assert_that(level_enum_list, instance_of(ServiceLevelEnumList)) cp3 = unity.get_capability_profile(service_levels=level_enum_list) assert_that(cp3, instance_of(UnityCapabilityProfileList)) assert_that(len(cp3), 2) assert_that(cp3[0].existed, equal_to(True))
def test_get_capability_profile_service_levels(self): unity = t_unity() level_s = ServiceLevelEnum.SILVER level_p = ServiceLevelEnum.PLATINUM cp = unity.get_capability_profile(service_levels=[level_s, level_p]) assert_that(cp, instance_of(UnityCapabilityProfileList)) assert_that(len(cp), 2) # use Enum or EnumList are both ok cp2 = unity.get_capability_profile(service_levels=level_s) assert_that(cp2, instance_of(UnityCapabilityProfileList)) assert_that(len(cp2), 1) assert_that(cp2[0].existed, equal_to(True)) level_enum_list = ServiceLevelEnumList.parse([level_s, level_p]) assert_that(level_enum_list, instance_of(ServiceLevelEnumList)) cp3 = unity.get_capability_profile(service_levels=level_enum_list) assert_that(cp3, instance_of(UnityCapabilityProfileList)) assert_that(len(cp3), 2) assert_that(cp3[0].existed, equal_to(True))
def test_get_capability_profile_usage_tags(self): unity = t_unity() tag = "capacity" cp = unity.get_capability_profile(usage_tags=tag) assert_that(cp, instance_of(UnityCapabilityProfileList)) assert_that(len(cp), 1) assert_that(cp[0].existed, equal_to(True)) assert_that(tag, is_in(cp[0].usage_tags)) cp2 = unity.get_capability_profile(usage_tags=[tag]) assert_that(cp2, instance_of(UnityCapabilityProfileList)) assert_that(len(cp2), 1) assert_that(cp2[0].existed, equal_to(True)) assert_that(tag, is_in(cp2[0].usage_tags)) # None tags will not pass to rest url # it's same with get_capability_profile() cp3 = unity.get_capability_profile(usage_tags=None) assert_that(cp3, instance_of(UnityCapabilityProfileList)) assert_that(len(cp3), 2) assert_that(cp3[0].existed, equal_to(True))
def test_get_capability_profile_usage_tags(self): unity = t_unity() tag = "capacity" cp = unity.get_capability_profile(usage_tags=tag) assert_that(cp, instance_of(UnityCapabilityProfileList)) assert_that(len(cp), 1) assert_that(cp[0].existed, equal_to(True)) assert_that(tag, is_in(cp[0].usage_tags)) cp2 = unity.get_capability_profile(usage_tags=[tag]) assert_that(cp2, instance_of(UnityCapabilityProfileList)) assert_that(len(cp2), 1) assert_that(cp2[0].existed, equal_to(True)) assert_that(tag, is_in(cp2[0].usage_tags)) # None tags will not pass to rest url # it's same with get_capability_profile() cp3 = unity.get_capability_profile(usage_tags=None) assert_that(cp3, instance_of(UnityCapabilityProfileList)) assert_that(len(cp3), 2) assert_that(cp3[0].existed, equal_to(True))
def test_get_initiator_by_id(self): unity = t_unity() initiator = unity.get_initiator(_id="HostInitiator_2") assert_that(initiator, instance_of(UnityHostInitiator)) assert_that(initiator.id, equal_to("HostInitiator_2"))
def test_get_host_list(self): unity = t_unity() hosts = unity.get_host() assert_that(hosts, instance_of(UnityHostList)) assert_that(len(hosts), equal_to(7))
def test_get_spa(self): unity = t_unity() sp = unity.get_sp('spa') assert_that(sp, instance_of(UnityStorageProcessor)) assert_that(sp.get_id(), equal_to('spa'))
def test_get_doc_enum_member(self): unity = t_unity() doc = unity.get_doc(HealthEnum.NON_RECOVERABLE) assert_that(doc, contains_string('OK But Minor Warning'))
def test_get_host_by_address_not_found(self): unity = t_unity() hosts = unity.get_host(address='8.8.8.9') assert_that(len(hosts), equal_to(0))
def test_get_dns_server(self): unity = t_unity() dns_servers = unity.get_dns_server() assert_that(dns_servers, instance_of(UnityFileDnsServerList)) assert_that(len(dns_servers), equal_to(1))
def test_create_nas_server(self): unity = t_unity() sp = unity.get_sp(_id='spa') pool = unity.get_pool(_id='pool_1') nas_server = unity.create_nas_server('nas3', sp, pool) assert_that(nas_server.existed, equal_to(True))
def test_get_file_interface(self): unity = t_unity() fi_list = unity.get_file_interface() assert_that(fi_list, instance_of(UnityFileInterfaceList)) assert_that(len(fi_list), equal_to(1))
def test_get_ip_ports(self): unity = t_unity() ip_ports = unity.get_ip_port() assert_that(ip_ports, instance_of(UnityIpPortList)) assert_that(len(ip_ports), equal_to(8))
def test_create_nas_server(self): unity = t_unity() sp = unity.get_sp(_id='spa') pool = unity.get_pool(_id='pool_1') nas_server = unity.create_nas_server('nas3', sp, pool) assert_that(nas_server.existed, equal_to(True))
def test_get_nas_servers(self): unity = t_unity() nas_servers = unity.get_nas_server() assert_that(nas_servers, instance_of(UnityNasServerList)) assert_that(len(nas_servers), equal_to(3))
def test_get_snap_by_name(self): unity = t_unity() snap = unity.get_snap(name='2016-03-15_10:56:08') assert_that(snap.name, equal_to('2016-03-15_10:56:08')) assert_that(snap.existed, equal_to(True))
def test_get_snaps_all(self): unity = t_unity() snaps = unity.get_snap() assert_that(snaps, instance_of(UnitySnapList)) assert_that(len(snaps), equal_to(3))
def test_get_pools(self): unity = t_unity() pools = unity.get_pool() assert_that(pools, instance_of(UnityPoolList)) assert_that(len(pools), equal_to(2))
def test_get_snap_by_name(self): unity = t_unity() snap = unity.get_snap(name='2016-03-15_10:56:08') assert_that(snap.name, equal_to('2016-03-15_10:56:08')) assert_that(snap.existed, equal_to(True))
def test_get_nfs_server(self): unity = t_unity() nfs_servers = unity.get_nfs_server() assert_that(nfs_servers, instance_of(UnityNfsServerList)) assert_that(len(nfs_servers), equal_to(1))
def test_get_file_interface(self): unity = t_unity() fi_list = unity.get_file_interface() assert_that(fi_list, instance_of(UnityFileInterfaceList)) assert_that(len(fi_list), equal_to(1))
def test_get_dns_server(self): unity = t_unity() dns_servers = unity.get_dns_server() assert_that(dns_servers, instance_of(UnityFileDnsServerList)) assert_that(len(dns_servers), equal_to(1))
def test_get_nfs_share(self): unity = t_unity() shares = unity.get_nfs_share() assert_that(shares, instance_of(UnityNfsShareList)) assert_that(len(shares), equal_to(2))
def test_get_file_system(self): unity = t_unity() filesystems = unity.get_filesystem() assert_that(filesystems, instance_of(UnityFileSystemList)) assert_that(len(filesystems), equal_to(3))
def test_system_get_cifs_share_by_name(self): unity = t_unity() cs = unity.get_cifs_share(name='cs1') assert_that(cs, instance_of(UnityCifsShare)) assert_that(cs.name, equal_to('cs1'))
def test_get_nfs_share(self): unity = t_unity() shares = unity.get_nfs_share() assert_that(shares, instance_of(UnityNfsShareList)) assert_that(len(shares), equal_to(2))
def test_get_doc_resource(self): unity = t_unity() doc = unity.get_doc(unity.get_snap()) assert_that( doc, contains_string('For a file system or VMware NFS datastore'))
def test_get_host_by_address_found(self): unity = t_unity() host = unity.get_host(address='8.8.8.8') assert_that(host.type, equal_to(HostTypeEnum.SUBNET))
def test_get_pools(self): unity = t_unity() pools = unity.get_pool() assert_that(pools, instance_of(UnityPoolList)) assert_that(len(pools), equal_to(2))
def test_get_host_by_address_not_found(self): unity = t_unity() hosts = unity.get_host(address='8.8.8.9') assert_that(len(hosts), equal_to(0))
def test_get_initiators(self): unity = t_unity() initiators = unity.get_initiator() assert_that(initiators, instance_of(UnityHostInitiatorList)) assert_that(len(initiators), equal_to(4))
def test_system_info(self): unity = t_unity() assert_that(unity.info, instance_of(UnityBasicSystemInfo))
def test_get_portal_list(self): unity = t_unity() portals = unity.get_iscsi_portal() assert_that(portals, instance_of(UnityIscsiPortalList))
def test_system_get_cifs_share_by_name(self): unity = t_unity() cs = unity.get_cifs_share(name='cs1') assert_that(cs, instance_of(UnityCifsShare)) assert_that(cs.name, equal_to('cs1'))
def test_get_snaps_all(self): unity = t_unity() snaps = unity.get_snap() assert_that(snaps, instance_of(UnitySnapList)) assert_that(len(snaps), equal_to(3))
def f(): unity = t_unity() unity.get_filesystem(name='not_found')
def test_get_nas_servers(self): unity = t_unity() nas_servers = unity.get_nas_server() assert_that(nas_servers, instance_of(UnityNasServerList)) assert_that(len(nas_servers), equal_to(3))
def test_get_doc_enum_member(self): unity = t_unity() doc = unity.get_doc(HealthEnum.NON_RECOVERABLE) assert_that(doc, contains_string('OK But Minor Warning'))
def test_get_ip_ports(self): unity = t_unity() ip_ports = unity.get_ip_port() assert_that(ip_ports, instance_of(UnityIpPortList)) assert_that(len(ip_ports), equal_to(8))
def test_get_doc_enum(self): unity = t_unity() doc = unity.get_doc(HealthEnum) assert_that(doc, contains_string('OK But Minor Warning'))
def test_get_nfs_server(self): unity = t_unity() nfs_servers = unity.get_nfs_server() assert_that(nfs_servers, instance_of(UnityNfsServerList)) assert_that(len(nfs_servers), equal_to(1))
def test_get_doc_resource(self): unity = t_unity() doc = unity.get_doc(unity.get_snap()) assert_that(doc, contains_string( 'For a file system or VMware NFS datastore'))
def test_get_file_system(self): unity = t_unity() filesystems = unity.get_filesystem() assert_that(filesystems, instance_of(UnityFileSystemList)) assert_that(len(filesystems), equal_to(3))
def test_get_sp_all(self): unity = t_unity() sps = unity.get_sp() assert_that(sps, instance_of(UnityStorageProcessorList)) assert_that(len(sps), equal_to(2))
def test_get_host_by_address_found(self): unity = t_unity() host = unity.get_host(address='8.8.8.8') assert_that(host.type, equal_to(HostTypeEnum.SUBNET))
def test_get_spa(self): unity = t_unity() sp = unity.get_sp('spa') assert_that(sp, instance_of(UnityStorageProcessor)) assert_that(sp.get_id(), equal_to('spa'))
def test_system_info(self): unity = t_unity() assert_that(unity.info, instance_of(UnityBasicSystemInfo))
def test_get_initiators(self): unity = t_unity() initiators = unity.get_initiator() assert_that(initiators, instance_of(UnityHostInitiatorList)) assert_that(len(initiators), equal_to(4))
def f(): unity = t_unity() unity.get_filesystem(name='not_found')
def test_get_host_list(self): unity = t_unity() hosts = unity.get_host() assert_that(hosts, instance_of(UnityHostList)) assert_that(len(hosts), equal_to(7))
def test_get_doc_enum(self): unity = t_unity() doc = unity.get_doc(HealthEnum) assert_that(doc, contains_string('OK But Minor Warning'))
def test_get_ethernet_list(self): unity = t_unity() ports = unity.get_ethernet_port() assert_that(ports, instance_of(UnityEthernetPortList))
def test_get_sp_all(self): unity = t_unity() sps = unity.get_sp() assert_that(sps, instance_of(UnityStorageProcessorList)) assert_that(len(sps), equal_to(2))
def test_get_portal_list(self): unity = t_unity() portals = unity.get_iscsi_portal() assert_that(portals, instance_of(UnityIscsiPortalList))
def test_get_ethernet_list(self): unity = t_unity() ports = unity.get_ethernet_port() assert_that(ports, instance_of(UnityEthernetPortList))
def test_get_initiator_by_id(self): unity = t_unity() initiator = unity.get_initiator(_id="HostInitiator_2") assert_that(initiator, instance_of(UnityHostInitiator)) assert_that(initiator.id, equal_to("HostInitiator_2"))