Пример #1
0
def get_system(org_name, sys_name, env_name=None, sys_uuid=None):
    system_api = SystemAPI()
    if sys_uuid:
        systems = system_api.systems_by_org(org_name, {'uuid': sys_uuid})
        if systems is None:
            raise ApiDataError(_("Could not find System [ %(sys_name)s ] in Org [ %(org_name)s ]") \
                % {'sys_name':sys_name, 'org_name':org_name})
        elif len(systems) != 1:
            raise ApiDataError(_("Found ambiguous Systems [ %(sys_uuid)s ] in Org [ %(org_name)s ]") \
                % {'sys_uuid':sys_uuid, 'org_name':org_name})
    elif env_name is None:
        systems = system_api.systems_by_org(org_name, {'name': sys_name})
        if systems is None or len(systems) == 0:
            raise ApiDataError(_("Could not find System [ %(sys_name)s ] in Org [ %(org_name)s ]") \
                % {'sys_name':sys_name, 'org_name':org_name})
        elif len(systems) != 1:
            raise ApiDataError( _("Found ambiguous Systems [ %(sys_name)s ] " \
                "in Environment [ %(env_name)s ] in Org [ %(org_name)s ], "\
                "use --uuid to specify the system") % {'sys_name':sys_name, 'env_name':env_name, 'org_name':org_name})
    else:
        environment = get_environment(org_name, env_name)
        systems = system_api.systems_by_env(environment["id"],
                                            {'name': sys_name})
        if systems is None:
            raise ApiDataError(_("Could not find System [ %(sys_name)s ] " \
                "in Environment [ %(env_name)s ] in Org [ %(org_name)s ]") \
                % {'sys_name':sys_name, 'env_name':env_name, 'org_name':org_name})
        elif len(systems) != 1:
            raise ApiDataError(_("Found ambiguous Systems [ %(sys_name)s ] in Org [ %(org_name)s ], "\
                "you have to specify the environment") % {'sys_name':sys_name, 'org_name':org_name})

    return system_api.system(systems[0]['uuid'])
Пример #2
0
def get_system(org_name, sys_name, env_name=None):
    system_api = SystemAPI()
    if env_name is None:
        systems = system_api.systems_by_org(org_name, {'name': sys_name})
        if systems is None:
            raise ApiDataError(
                _("Could not find System [ %s ] in Org [ %s ]") %
                (sys_name, org_name))
        elif len(systems) != 1:
            raise ApiDataError(
                _("Found ambiguous Systems [ %s ] in Environment [ %s ] in Org [ %s ]"
                  ) % (sys_name, env_name, org_name))
    else:
        environment = get_environment(org_name, env_name)
        systems = system_api.systems_by_env(org_name, environment["id"],
                                            {'name': sys_name})
        if systems is None:
            raise ApiDataError(
                _("Could not find System [ %s ] in Environment [ %s ] in Org [ %s ]"
                  ) % (sys_name, env_name, org_name))
        elif len(systems) != 1:
            raise ApiDataError(_("Found ambiguous Systems [ %s ] in Org [ %s ], "\
                "you have to specify the environment") %
                (sys_name, org_name))

    return system_api.system(systems[0]['uuid'])
Пример #3
0
def get_system(org_name, sys_name, env_name=None, sys_uuid=None):
    system_api = SystemAPI()
    if sys_uuid:
        systems = system_api.systems_by_org(org_name, {'uuid': sys_uuid})
        if systems is None:
            raise ApiDataError(_("Could not find System [ %(sys_name)s ] in Org [ %(org_name)s ]") \
                % {'sys_name':sys_name, 'org_name':org_name})
        elif len(systems) != 1:
            raise ApiDataError(_("Found ambiguous Systems [ %(sys_uuid)s ] in Org [ %(org_name)s ]") \
                % {'sys_uuid':sys_uuid, 'org_name':org_name})
    elif env_name is None:
        systems = system_api.systems_by_org(org_name, {'name': sys_name})
        if systems is None or len(systems) == 0:
            raise ApiDataError(_("Could not find System [ %(sys_name)s ] in Org [ %(org_name)s ]") \
                % {'sys_name':sys_name, 'org_name':org_name})
        elif len(systems) != 1:
            raise ApiDataError( _("Found ambiguous Systems [ %(sys_name)s ] " \
                "in Environment [ %(env_name)s ] in Org [ %(org_name)s ], "\
                "use --uuid to specify the system") % {'sys_name':sys_name, 'env_name':env_name, 'org_name':org_name})
    else:
        environment = get_environment(org_name, env_name)
        systems = system_api.systems_by_env(environment["id"], {'name': sys_name})
        if systems is None:
            raise ApiDataError(_("Could not find System [ %(sys_name)s ] " \
                "in Environment [ %(env_name)s ] in Org [ %(org_name)s ]") \
                % {'sys_name':sys_name, 'env_name':env_name, 'org_name':org_name})
        elif len(systems) != 1:
            raise ApiDataError(_("Found ambiguous Systems [ %(sys_name)s ] in Org [ %(org_name)s ], "\
                "you have to specify the environment") % {'sys_name':sys_name, 'org_name':org_name})

    return system_api.system(systems[0]['uuid'])
Пример #4
0
def get_system(org_name, sys_name, env_name=None):
    system_api = SystemAPI()
    if env_name is None:
        systems = system_api.systems_by_org(org_name, {'name': sys_name})
        if systems is None:
            raise ApiDataError(_("Could not find System [ %s ] in Org [ %s ]") % (sys_name, org_name))
        elif len(systems) != 1:
            raise ApiDataError( _("Found ambiguous Systems [ %s ] in Environment [ %s ] in Org [ %s ]") %
                (sys_name, env_name, org_name))
    else:
        environment = get_environment(org_name, env_name)
        systems = system_api.systems_by_env(org_name, environment["id"], {'name': sys_name})
        if systems is None:
            raise ApiDataError(_("Could not find System [ %s ] in Environment [ %s ] in Org [ %s ]") %
                (sys_name, env_name, org_name))
        elif len(systems) != 1:
            raise ApiDataError(_("Found ambiguous Systems [ %s ] in Org [ %s ], "\
                "you have to specify the environment") %
                (sys_name, org_name))

    return system_api.system(systems[0]['uuid'])