def test_in_container_host_config_dir_does_not_exist(self):
     """
     Verify that in_container returns false when utils.HOST_CONFIG_DIR dir does not exist.
     :return:
     """
     utils.HOST_CONFIG_DIR = "/does/not/exist/"
     self.assertFalse(utils.in_container())
Exemple #2
0
def main():
    """
    Run the cli (Do the syspurpose tool thing!!)
    :return: 0
    """
    log.debug("Running the syspurpose utility...")

    parser = setup_arg_parser()
    args = parser.parse_args()

    # Syspurpose is not intended to be used in containers for the time being (could change later).
    if in_container():
        print(_("WARNING: Setting syspurpose in containers has no effect."
              "Please run syspurpose on the host.\n"))

    try:
        from subscription_manager.identity import Identity
        from subscription_manager.cp_provider import CPProvider
        identity = Identity()
        uuid = identity.uuid
        uep = CPProvider().get_consumer_auth_cp()
    except ImportError:
        uuid = None
        uep = None
        print(_("Warning: Unable to sync system purpose with subscription management server:"
                " subscription_manager module is not available."))

    syspurposestore = SyncedStore(uep=uep, consumer_uuid=uuid)
    if getattr(args, 'func', None) is not None:
        args.func(args, syspurposestore)
    else:
        parser.print_help()
        return 0

    return 0
def main():
    """
    Run the cli (Do the syspurpose tool thing!!)
    :return: 0
    """
    log.debug("Running the syspurpose utility...")

    parser = setup_arg_parser()
    args = parser.parse_args()

    # Syspurpose is not intended to be used in containers for the time being (could change later).
    if in_container():
        print(_("WARNING: Setting syspurpose in containers has no effect."
              "Please run syspurpose on the host.\n"))

    try:
        from subscription_manager.identity import Identity
        from subscription_manager.cp_provider import CPProvider
        identity = Identity()
        uuid = identity.uuid
        uep = CPProvider().get_consumer_auth_cp()
    except ImportError:
        uuid = None
        uep = None
        print(_("Warning: Unable to sync system purpose with subscription management server:"
                " subscription_manager module is not available."))

    syspurposestore = SyncedStore(uep=uep, consumer_uuid=uuid)
    if getattr(args, 'func', None) is not None:
        result = args.func(args, syspurposestore)
    else:
        parser.print_help()
        return 0

    return 0
 def test_in_container_host_config_dir_exists(self):
     """
     Verify that in_container returns true when utils.HOST_CONFIG_DIR dir exists.
     :return:
     """
     temp_dir = self._mktmp()
     utils.HOST_CONFIG_DIR = temp_dir
     self.assertTrue(utils.in_container())
Exemple #5
0
def main():
    """
    Run the cli (Do the syspurpose tool thing!!)
    :return: 0
    """
    parser = setup_arg_parser()
    args = parser.parse_args()

    # Syspurpose is not intended to be used in containers for the time being (could change later).
    if in_container():
        print(
            _("WARNING: Setting syspurpose in containers has no effect."
              "Please run syspurpose on the host.\n"))

    syspurposestore = SyspurposeStore.read(USER_SYSPURPOSE)

    if args.func is not None:
        args.func(args, syspurposestore)
    else:
        parser.print_help()

    if args.requires_write:
        syspurposestore.write()

        try:
            syspurpose_sync = SyspurposeSync()
        except ImportError:
            print(
                _("Warning: Unable to sync system purpose with subscription management server: rhsm module is not available."
                  ))
        else:
            ret = syspurpose_sync.send_syspurpose_to_candlepin(syspurposestore)
            if ret:
                print(
                    _("System purpose successfully sent to subscription management server."
                      ))
            else:
                print(
                    _("Unable to send system purpose to subscription management server"
                      ))
    return 0
Exemple #6
0
def main():
    """
    Run the cli (Do the syspurpose tool thing!!)
    :return: 0
    """

    parser = setup_arg_parser()
    args = parser.parse_args()

    # Syspurpose is not intended to be used in containers for the time being (could change later).
    if in_container():
        print(_("WARNING: Setting syspurpose in containers has no effect."
              "Please run syspurpose on the host.\n"))

    print(_("The 'syspurpose' command is deprecated and will be removed in a future major release."
        " Please use the 'subscription-manager syspurpose' command going forward."), file=sys.stderr)
    try:
        from subscription_manager.identity import Identity
        from subscription_manager.cp_provider import CPProvider
        identity = Identity()
        uuid = identity.uuid
        uep = CPProvider().get_consumer_auth_cp()
    except ImportError:
        uuid = None
        uep = None
        print(_("Warning: Unable to sync system purpose with subscription management server:"
                " subscription_manager module is not available."))

    syspurposestore = SyncedStore(uep=uep, consumer_uuid=uuid, use_valid_fields=True)
    if getattr(args, 'func', None) is not None:
        args.func(args, syspurposestore)
    else:
        parser.print_help()
        return 0

    return 0