How to use the common.format_err_msg_and_raise function in common

To help you get started, we’ve selected a few common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CoprHD / coprhd-controller / cli / src / authentication.py View on Github external
remove_whitelist.split(','), searchscope, description,
                disable, None, maxpagesize,
                add_groupobjectclasses.split(','), remove_groupobjectclasses.split(','),
                add_groupmemberattributes.split(','), remove_groupmemberattributes.split(','),
                force_groupattributeupdate)

    except IOError as e:
        common.format_err_msg_and_raise("update", "authentication provider",
                                        e[1], e.errno)

    except SOSError as e:
        common.format_err_msg_and_raise("update", "authentication provider",
                                        e.err_text, e.err_code)

    except ConfigParser.NoOptionError as e:
        common.format_err_msg_and_raise("update", "authentication provider",
                                        str(e), SOSError.NOT_FOUND_ERR)

    except (ConfigParser.ParsingError, ConfigParser.Error) as e:
        common.format_err_msg_and_raise("update", "authentication provider",
                                        str(e), SOSError.VALUE_ERR)
github CoprHD / coprhd-controller / cli / src / storageportgroup.py View on Github external
def storageportgroup_create(args):

    if(args.type != 'vmax'):
        errorMessage = "For device type " + args.storagetype + \
            ", storage port group create is not supported." + \
            " Supported only for 'vmax' type systems."
        common.format_err_msg_and_raise(
            "create", "storageportgroup", errorMessage,
            SOSError.CMD_LINE_ERR)

    try:
        storage_portgroup = Storageportgroup(args.ip, args.port)
        storage_portgroup.storageportgroup_add(args.storagesystem,
            args.serialnumber,
            args.type,
            args.portgroupname,
            args.storageports)
    except SOSError as e:
        common.format_err_msg_and_raise(
            "create", "storageportgroup", e.err_text, e.err_code)
github emcvipr / controller-openstack-cinder / cinder / volume / drivers / emc / vipr / cli / cluster.py View on Github external
def cluster_update(args):
    obj = Cluster(args.ip, args.port)
    try:
        if(args.datacenter or args.vcenter):
            if(args.datacenter == None or args.vcenter == None):
                print "Both vCenter and Data Center details are required"
                return
                
        obj.cluster_update(args.name, args.tenant, args.project, args.datacenter, args.vcenter, args.label)
    except SOSError as e:
        common.format_err_msg_and_raise("update", "cluster", e.err_text, e.err_code)
github CoprHD / coprhd-controller / cli / src / virtualpool.py View on Github external
def vpool_allow_tenant(args):

    obj = VirtualPool(args.ip, args.port)
    try:
        obj.vpool_allow_tenant(args.name, args.type, args.tenant)
    except SOSError as e:
        common.format_err_msg_and_raise("allow", "vpool", e.err_text,
                                        e.err_code)
github CoprHD / coprhd-controller / cli / src / cluster.py View on Github external
res = obj.cluster_get_hosts(args.name,args.datacenter, args.vcenter, args.tenant)

        if(len(res) > 0):
            if(args.verbose):
                return common.format_json_object(res)
            elif(args.long):
                from common import TableGenerator
                TableGenerator(res, ['name', 'type',
                               'job_discovery_status',
                                     'job_metering_status']).printTable()
            else:
                from common import TableGenerator
                TableGenerator(res, ['name']).printTable()

    except SOSError as e:
        common.format_err_msg_and_raise("get hosts", "cluster",
                                        e.err_text, e.err_code)
github emcvipr / controller-openstack-cinder / cinder / volume / drivers / emc / vipr / cli / exportgroup.py View on Github external
def exportgroup_remove_host(args):
    try:
        objExGroup = ExportGroup(args.ip, args.port)
        objExGroup.exportgroup_remove_host(args.name, args.tenant, args.project, args.hostlabel)
    except SOSError as e:
        raise common.format_err_msg_and_raise("remove_host", "exportgroup", e.err_text, e.err_code)
github CoprHD / coprhd-controller / cli / src / sysmanager.py View on Github external
def update_site(args):
    obj = Configuration(args.ip, Configuration.DEFAULT_SYSMGR_PORT)
    try:
        res = obj.update_site(args.name, args.newname, args.desc)
        return
    except SOSError as e:
        common.format_err_msg_and_raise(
            "update",
            "site",
            e.err_text,
            e.err_code)
github emcvipr / controller-openstack-cinder / cinder / volume / drivers / emc / vipr / cli / volume.py View on Github external
def unmanaged_volume_ingest(args):
    obj = Volume(args.ip, args.port)
    try:
        if(not args.tenant):
            args.tenant=""
        res = obj.unmanaged_volume_ingest(args.tenant, args.project, 
                             args.varray, args.vpool, args.volumes)
    except SOSError as e:
        common.format_err_msg_and_raise("ingest", "unmanaged", e.err_text, e.err_code)
github CoprHD / coprhd-controller / cli / src / assetoptions.py View on Github external
assetOptionsObj = AssetOptions(args.ip, args.uiPort)
    from common import TableGenerator

    try:

        if (args.params is not None and len(args.params) % 2 != 0):
            raise SOSError(
                SOSError.CMD_LINE_ERR,
                "List of parameter name/value pairs is not even")

        assetOptionsList = assetOptionsObj.list(args.type, args.params)

        if(len(assetOptionsList) > 0):
            TableGenerator(assetOptionsList, ['key', 'value']).printTable()
    except SOSError as e:
        common.format_err_msg_and_raise("list", "assetoptions",
                                        e.err_text, e.err_code)
github CoprHD / coprhd-controller / cli / src / exportgroup.py View on Github external
def exportgroup_remove_host(args):
    try:
        objExGroup = ExportGroup(args.ip, args.port)
        objExGroup.exportgroup_remove_host(
            args.name, args.tenant, args.project, args.hostlabel, args.sync)
    except SOSError as e:
        raise common.format_err_msg_and_raise("remove_host", "exportgroup",
                                              e.err_text, e.err_code)