Example #1
0
def subscribe_to_tools_channel(server_id, kickstart_session_id):
    log_debug(3)
    row = get_kickstart_session_info(kickstart_session_id, server_id)
    org_id = row["org_id"]
    scheduler = row["scheduler"]
    ks_type_id = row["virtualization_type"]
    ks_type = _get_ks_virt_type(ks_type_id)

    if ks_type == "para_host":
        action_id = rhnAction.schedule_server_action(
            server_id,
            action_type="kickstart_host.add_tools_channel",
            action_name="Subscribe server to RHN Tools channel.",
            delta_time=0,
            scheduler=scheduler,
            org_id=org_id,
        )
    elif ks_type == "para_guest":
        action_id = rhnAction.schedule_server_action(
            server_id,
            action_type="kickstart_guest.add_tools_channel",
            action_name="Subscribe guest to RHN Tools channel.",
            delta_time=0,
            scheduler=scheduler,
            org_id=org_id,
        )
    else:
        action_id = None
    return action_id
Example #2
0
def subscribe_to_tools_channel(server_id, kickstart_session_id):
    log_debug(3)
    row = get_kickstart_session_info(kickstart_session_id, server_id)
    org_id = row['org_id']
    scheduler = row['scheduler']
    ks_type_id = row['virtualization_type']
    ks_type = _get_ks_virt_type(ks_type_id)

    if ks_type == 'para_host':
        action_id = rhnAction.schedule_server_action(
            server_id,
            action_type='kickstart_host.add_tools_channel',
            action_name='Subscribe server to the Tools channel.',
            delta_time=0,
            scheduler=scheduler,
            org_id=org_id,
        )
    elif ks_type == 'para_guest':
        action_id = rhnAction.schedule_server_action(
            server_id,
            action_type='kickstart_guest.add_tools_channel',
            action_name='Subscribe guest to the Tools channel.',
            delta_time=0,
            scheduler=scheduler,
            org_id=org_id,
        )
    else:
        action_id = None
    return action_id
Example #3
0
def schedule_virt_pkg_install(server_id, kickstart_session_id):
    log_debug(3)
    row = get_kickstart_session_info(kickstart_session_id, server_id)
    org_id = row['org_id']
    scheduler = row['scheduler']
    ks_type_id = row['virtualization_type']
    log_debug(1, "VIRTUALIZATION_TYPE: %s" % str(ks_type_id))
    ks_type = _get_ks_virt_type(ks_type_id)
    log_debug(1, "VIRTUALZIATION_TYPE_LABEL: %s" % str(ks_type))

    if ks_type == 'para_host':
        log_debug(1, "SCHEDULING VIRT HOST PACKAGE INSTALL...")
        action_id = rhnAction.schedule_server_action(
            server_id,
            action_type='kickstart_host.schedule_virt_host_pkg_install',
            action_name="Schedule install of mgr-virtualization-host package.",
            delta_time=0,
            scheduler=scheduler,
            org_id=org_id,
        )
    elif ks_type == 'para_guest':
        log_debug(1, "SCHEDULING VIRT GUEST PACKAGE INSTALL...")
        action_id = rhnAction.schedule_server_action(
            server_id,
            action_type='kickstart_guest.schedule_virt_guest_pkg_install',
            action_name="Schedule install of mgr-virtualization-guest package.",
            delta_time=0,
            scheduler=scheduler,
            org_id=org_id,
        )
    else:
        log_debug(1, "NOT A VIRT KICKSTART")
        action_id = None

    return action_id
Example #4
0
def subscribe_to_tools_channel(server_id, kickstart_session_id):
    log_debug(3)
    row = get_kickstart_session_info(kickstart_session_id, server_id)
    org_id = row['org_id']
    scheduler = row['scheduler']
    ks_type_id = row['virtualization_type']
    ks_type = _get_ks_virt_type(ks_type_id)

    if ks_type == 'para_host':
        action_id = rhnAction.schedule_server_action(
            server_id,
            action_type='kickstart_host.add_tools_channel',
            action_name='Subscribe server to the Tools channel.',
            delta_time=0, scheduler=scheduler, org_id=org_id,
        )
    elif ks_type == 'para_guest':
        action_id = rhnAction.schedule_server_action(
            server_id,
            action_type='kickstart_guest.add_tools_channel',
            action_name='Subscribe guest to the Tools channel.',
            delta_time=0, scheduler=scheduler, org_id=org_id,
        )
    else:
        action_id = None
    return action_id
Example #5
0
def schedule_virt_pkg_install(server_id, kickstart_session_id):
    log_debug(3)
    row = get_kickstart_session_info(kickstart_session_id, server_id)
    org_id = row['org_id']
    scheduler = row['scheduler']
    ks_type_id = row['virtualization_type']
    log_debug(1, "VIRTUALIZATION_TYPE: %s" % str(ks_type_id))
    ks_type = _get_ks_virt_type(ks_type_id)
    log_debug(1, "VIRTUALZIATION_TYPE_LABEL: %s" % str(ks_type))

    if ks_type == 'para_host':
        log_debug(1, "SCHEDULING VIRT HOST PACKAGE INSTALL...")
        action_id = rhnAction.schedule_server_action(
            server_id,
            action_type='kickstart_host.schedule_virt_host_pkg_install',
            action_name="Schedule install of rhn-virtualization-host package.",
            delta_time=0, scheduler=scheduler, org_id=org_id,
        )
    elif ks_type == 'para_guest':
        log_debug(1, "SCHEDULING VIRT GUEST PACKAGE INSTALL...")
        action_id = rhnAction.schedule_server_action(
            server_id,
            action_type='kickstart_guest.schedule_virt_guest_pkg_install',
            action_name="Schedule install of rhn-virtualization-guest package.",
            delta_time=0, scheduler=scheduler, org_id=org_id,
        )
    else:
        log_debug(1, "NOT A VIRT KICKSTART")
        action_id = None

    return action_id
Example #6
0
def schedule_kickstart_delta(server_id, kickstart_session_id,
                             installs, removes):
    log_debug(3, server_id, kickstart_session_id)
    row = get_kickstart_session_info(kickstart_session_id, server_id)
    org_id = row['org_id']
    scheduler = row['scheduler']

    action_id = rhnAction.schedule_server_action(
        server_id,
        action_type='packages.runTransaction', action_name="Package delta",
        delta_time=0, scheduler=scheduler, org_id=org_id,
    )

    package_delta_id = rhnSQL.Sequence('rhn_packagedelta_id_seq').next()

    h = rhnSQL.prepare(_query_insert_package_delta)
    h.execute(package_delta_id=package_delta_id)

    h = rhnSQL.prepare(_query_insert_action_package_delta)
    h.execute(action_id=action_id, package_delta_id=package_delta_id)

    h = rhnSQL.prepare(_query_insert_package_delta_element)
    col_names = ['n', 'v', 'r', 'e']
    __execute_many(h, installs, col_names, operation='insert', a=None,
                   package_delta_id=package_delta_id)
    __execute_many(h, removes, col_names, operation='delete', a=None,
                   package_delta_id=package_delta_id)

    update_ks_session_table(kickstart_session_id, 'package_synch_scheduled',
                            action_id, server_id)

    return action_id
Example #7
0
def schedule_config_deploy(server_id, action_id, kickstart_session_id, server_profile):
    """ schedule a configfiles.deploy action dependent on the current action """
    log_debug(3, server_id, action_id, kickstart_session_id)
    row = get_kickstart_session_info(kickstart_session_id, server_id)
    org_id = row["org_id"]
    scheduler = row["scheduler"]
    deploy_configs = row["deploy_configs"] == "Y" and ks_activation_key_deploy_config(kickstart_session_id)

    if not deploy_configs:
        # Nothing more to do here
        update_ks_session_table(kickstart_session_id, "complete", next_action_id=None, server_id=server_id)
        return None

    if server_profile:
        # Have to schedule a package deploy action
        aid = schedule_rhncfg_install(server_id, action_id, scheduler, server_profile)
    else:
        aid = action_id

    next_action_id = rhnAction.schedule_server_action(
        server_id,
        action_type="configfiles.deploy",
        action_name="Deploy config files",
        delta_time=0,
        scheduler=scheduler,
        org_id=org_id,
        prerequisite=aid,
    )
    # Deploy all of the config files that are part of this server's config
    # channels
    h = rhnSQL.prepare(_query_schedule_config_files)
    h.execute(server_id=server_id, action_id=next_action_id)
    update_ks_session_table(kickstart_session_id, "configuration_deploy", next_action_id, server_id)
    return next_action_id
Example #8
0
def schedule_kickstart_delta(server_id, kickstart_session_id, installs, removes):
    log_debug(3, server_id, kickstart_session_id)
    row = get_kickstart_session_info(kickstart_session_id, server_id)
    org_id = row["org_id"]
    scheduler = row["scheduler"]

    action_id = rhnAction.schedule_server_action(
        server_id,
        action_type="packages.runTransaction",
        action_name="Package delta",
        delta_time=0,
        scheduler=scheduler,
        org_id=org_id,
    )

    package_delta_id = rhnSQL.Sequence("rhn_packagedelta_id_seq").next()

    h = rhnSQL.prepare(_query_insert_package_delta)
    h.execute(package_delta_id=package_delta_id)

    h = rhnSQL.prepare(_query_insert_action_package_delta)
    h.execute(action_id=action_id, package_delta_id=package_delta_id)

    h = rhnSQL.prepare(_query_insert_package_delta_element)
    col_names = ["n", "v", "r", "e"]
    __execute_many(h, installs, col_names, operation="insert", a=None, package_delta_id=package_delta_id)
    __execute_many(h, removes, col_names, operation="delete", a=None, package_delta_id=package_delta_id)

    update_ks_session_table(kickstart_session_id, "package_synch_scheduled", action_id, server_id)

    return action_id
Example #9
0
def schedule_config_deploy(server_id, action_id, kickstart_session_id,
        server_profile):
    log_debug(3, server_id, action_id, kickstart_session_id)
    row = get_kickstart_session_info(kickstart_session_id, server_id)
    org_id = row['org_id']
    scheduler = row['scheduler']
    deploy_configs = (row['deploy_configs'] == 'Y')

    if not deploy_configs:
        # Nothing more to do here
        update_ks_session_table(kickstart_session_id, 'complete',
            next_action_id=None, server_id=server_id)
        return None

    if server_profile:
        # Have to schedule a package deploy action
        aid = schedule_rhncfg_install(server_id, action_id, scheduler,
            server_profile)
    else:
        aid = action_id

    next_action_id = rhnAction.schedule_server_action(
        server_id,
        action_type='configfiles.deploy',
        action_name='Deploy config files',
        delta_time=0, scheduler=scheduler, org_id=org_id,
        prerequisite=aid,
    )
    # Deploy all of the config files that are part of this server's config
    # channels
    h = rhnSQL.prepare(_query_schedule_config_files)
    h.execute(server_id=server_id, action_id=next_action_id)
    update_ks_session_table(kickstart_session_id, 'configuration_deploy',
        next_action_id, server_id)
    return next_action_id
def schedule_deploy(server_id, action_id, dry_run=0):
    log_debug(2, server_id, action_id)
    s = rhnServer.search(server_id)

    # Schedule an rhncfg install
    new_action_id = server_kickstart.schedule_rhncfg_install(server_id,
                                                             action_id,
                                                             scheduler=None)

    new_action_id_2 = rhnAction.schedule_server_action(
        server_id,
        action_type='configfiles.deploy',
        action_name="Activation Key Config Auto-Deploy",
        delta_time=0,
        scheduler=None,
        org_id=s.server['org_id'],
        prerequisite=new_action_id,
    )

    if (not dry_run):
        h = rhnSQL.prepare(_query_copy_revs_from_shadow_action)
        h.execute(action_id=action_id,
                  new_action_id=new_action_id_2,
                  server_id=server_id)
    else:
        log_debug(4, "dry run requested")

    log_debug(4, "scheduled config deploy for activation key")

    raise ShadowAction("Config deploy scheduled")
Example #11
0
def schedule_deploy(server_id, action_id, dry_run=0):
    log_debug(2, server_id, action_id)
    s = rhnServer.search(server_id)

    # Schedule an rhncfg install
    new_action_id = server_kickstart.schedule_rhncfg_install(server_id,
        action_id, scheduler=None)

    new_action_id_2 = rhnAction.schedule_server_action(
        server_id,
        action_type='configfiles.deploy',
        action_name="Activation Key Config Auto-Deploy",
        delta_time=0, scheduler=None,
        org_id=s.server['org_id'],
        prerequisite=new_action_id,
        )

    if (not dry_run):
        h = rhnSQL.prepare(_query_copy_revs_from_shadow_action)
        h.execute(action_id=action_id, new_action_id=new_action_id_2,
            server_id=server_id)
    else:
        log_debug(4, "dry run requested")

    log_debug(4, "scheduled config deploy for activation key")

    raise ShadowAction("Config deploy scheduled")
Example #12
0
def schedule_kickstart_delta(server_id, kickstart_session_id,
                             installs, removes):
    log_debug(3, server_id, kickstart_session_id)
    row = get_kickstart_session_info(kickstart_session_id, server_id)
    org_id = row['org_id']
    scheduler = row['scheduler']

    action_id = rhnAction.schedule_server_action(
        server_id,
        action_type='packages.runTransaction', action_name="Package delta",
        delta_time=0, scheduler=scheduler, org_id=org_id,
    )

    package_delta_id = rhnSQL.Sequence('rhn_packagedelta_id_seq').next()

    h = rhnSQL.prepare(_query_insert_package_delta)
    h.execute(package_delta_id=package_delta_id)

    h = rhnSQL.prepare(_query_insert_action_package_delta)
    h.execute(action_id=action_id, package_delta_id=package_delta_id)

    h = rhnSQL.prepare(_query_insert_package_delta_element)
    col_names = ['n', 'v', 'r', 'e']
    __execute_many(h, installs, col_names, operation='insert', a=None,
                   package_delta_id=package_delta_id)
    __execute_many(h, removes, col_names, operation='delete', a=None,
                   package_delta_id=package_delta_id)

    update_ks_session_table(kickstart_session_id, 'package_synch_scheduled',
                            action_id, server_id)

    return action_id
Example #13
0
def schedule_kickstart_sync(server_id, kickstart_session_id):
    row = get_kickstart_session_info(kickstart_session_id, server_id)
    org_id = row['org_id']
    scheduler = row['scheduler']

    # Create a new action
    action_id = rhnAction.schedule_server_action(
        server_id,
        action_type='kickstart.schedule_sync',
        action_name="Schedule a package sync",
        delta_time=0, scheduler=scheduler, org_id=org_id,
    )
    return action_id
Example #14
0
def schedule_kickstart_sync(server_id, kickstart_session_id):
    row = get_kickstart_session_info(kickstart_session_id, server_id)
    org_id = row['org_id']
    scheduler = row['scheduler']

    # Create a new action
    action_id = rhnAction.schedule_server_action(
        server_id,
        action_type='kickstart.schedule_sync',
        action_name="Schedule a package sync",
        delta_time=0, scheduler=scheduler, org_id=org_id,
    )
    return action_id
Example #15
0
def schedule_package_install(server_id, action_id, scheduler, packages):
    if not packages:
        # Nothing to do
        return action_id
    new_action_id = rhnAction.schedule_server_action(
        server_id, action_type='packages.update',
        action_name="Package update to enable configuration deployment",
        delta_time=0, scheduler=scheduler, prerequisite=action_id,
    )
    # Add entries to rhnActionPackage
    action_ids = [new_action_id] * len(packages)
    h = rhnSQL.prepare(_query_insert_action_packages)
    h.executemany(action_id=action_ids, package_id=packages)
    return new_action_id
Example #16
0
def schedule_package_install(server_id, action_id, scheduler, packages):
    if not packages:
        # Nothing to do
        return action_id
    new_action_id = rhnAction.schedule_server_action(
        server_id, action_type='packages.update',
        action_name="Package update to enable configuration deployment",
        delta_time=0, scheduler=scheduler, prerequisite=action_id,
    )
    # Add entries to rhnActionPackage
    action_ids = [new_action_id] * len(packages)
    h = rhnSQL.prepare(_query_insert_action_packages)
    h.executemany(action_id=action_ids, package_id=packages)
    return new_action_id
Example #17
0
def deploy_configs_if_needed(server):
    server_id = server['id']
    log_debug(4, server_id)
    # determine if there are actually any files to be deployed...
    revisions = {}

    h = rhnSQL.prepare(_query_token_latest_revisions)
    h.execute(server_id=server_id)

    while 1:
        row = h.fetchone_dict()
        if not row:
            break

        # only care about the 1st revision of a particular path due to
        # sql ordering...
        if row['path'] not in revisions:
            revisions[row['path']] = row['revision_id']

    if not len(revisions):
        return None

    # Get the latest action scheduled for this token
    last_action_id = rhnFlags.get('token_last_action_id')

    action_id = rhnAction.schedule_server_action(
        server_id,
        action_type='activation.schedule_deploy',
        action_name="Activation Key Config File Deployment",
        delta_time=0,
        scheduler=None,
        org_id=server['org_id'],
        prerequisite=last_action_id,
    )

    # This action becomes the latest now
    rhnFlags.set('token_last_action_id', action_id)

    log_debug(4, "scheduled activation key config deploy")

    h = rhnSQL.prepare(_query_add_revision_to_action)
    # XXX should use executemany() or execute_bulk
    for revision_id in revisions.values():
        log_debug(5, action_id, revision_id)
        h.execute(server_id=server_id,
                  action_id=action_id,
                  config_revision_id=revision_id)

    return action_id
Example #18
0
    def schedule_package_install(self):
        """
            Public function that schedules self.package for installation during the next rhn_check.
        """
        org_id, scheduler = self._get_action_info(self.this_action_id)

        self.new_action_id = rhnAction.schedule_server_action(
            self.server_id,
            action_type="packages.update",
            action_name="Scheduling install of virtualization host packages.",
            delta_time=0,
            scheduler=scheduler,
            org_id=org_id)

        self._add_package_to_install_action(self.new_action_id)
Example #19
0
def deploy_configs_if_needed(server):
    server_id = server['id']
    log_debug(4, server_id)
    # determine if there are actually any files to be deployed...
    revisions = {}

    h = rhnSQL.prepare(_query_token_latest_revisions)
    h.execute(server_id=server_id)

    while 1:
        row = h.fetchone_dict()
        if not row:
            break

        # only care about the 1st revision of a particular path due to
        # sql ordering...
        if not revisions.has_key(row['path']):
            revisions[row['path']] = row['revision_id']

    if not len(revisions):
        return None

    # Get the latest action scheduled for this token
    last_action_id = rhnFlags.get('token_last_action_id')

    action_id = rhnAction.schedule_server_action(
        server_id,
        action_type='activation.schedule_deploy',
        action_name="Activation Key Config File Deployment",
        delta_time=0, scheduler=None,
        org_id=server['org_id'],
        prerequisite=last_action_id,
    )

    # This action becomes the latest now
    rhnFlags.set('token_last_action_id', action_id)

    log_debug(4, "scheduled activation key config deploy")

    h = rhnSQL.prepare(_query_add_revision_to_action)
    # XXX should use executemany() or execute_bulk
    for revision_id in revisions.values():
        log_debug(5, action_id, revision_id)
        h.execute(server_id=server_id,
                  action_id=action_id,
                  config_revision_id=revision_id)

    return action_id
Example #20
0
    def schedule_package_install(self):
        """
            Public function that schedules self.package for installation during the next rhn_check.
        """
        org_id, scheduler = self._get_action_info(self.this_action_id)

        self.new_action_id = rhnAction.schedule_server_action(
            self.server_id,
            action_type="packages.update",
            action_name="Scheduling install of RHN's virtualization host packages.",
            delta_time=0,
            scheduler=scheduler,
            org_id=org_id
        )

        self._add_package_to_install_action(self.new_action_id)
Example #21
0
def schedule_pkg_install(server_id, action_id, dry_run=0):
    s = rhnServer.search(server_id)

    new_action_id = rhnAction.schedule_server_action(
        server_id,
        action_type='packages.update',
        action_name="Activation Key Package Auto-Install",
        delta_time=0, scheduler=None,
        org_id=s.server['org_id'],
        )

    if (not dry_run):
        h = rhnSQL.prepare(_query_copy_pkgs_from_shadow_action)
        h.execute(action_id=action_id, new_action_id=new_action_id)
    else:
        log_debug(4, "dry run requested")

    log_debug(4, "scheduled pkg install for activation key")

    raise ShadowAction("Package install scheduled")
Example #22
0
def schedule_config_deploy(server_id, action_id, kickstart_session_id,
                           server_profile):
    """ schedule a configfiles.deploy action dependent on the current action """
    log_debug(3, server_id, action_id, kickstart_session_id)
    row = get_kickstart_session_info(kickstart_session_id, server_id)
    org_id = row['org_id']
    scheduler = row['scheduler']
    deploy_configs = (row['deploy_configs'] == 'Y' and
                      ks_activation_key_deploy_config(kickstart_session_id))

    if not deploy_configs:
        # Nothing more to do here
        update_ks_session_table(kickstart_session_id,
                                'complete',
                                next_action_id=None,
                                server_id=server_id)
        return None

    if server_profile:
        # Have to schedule a package deploy action
        aid = schedule_rhncfg_install(server_id, action_id, scheduler,
                                      server_profile)
    else:
        aid = action_id

    next_action_id = rhnAction.schedule_server_action(
        server_id,
        action_type='configfiles.deploy',
        action_name='Deploy config files',
        delta_time=0,
        scheduler=scheduler,
        org_id=org_id,
        prerequisite=aid,
    )
    # Deploy all of the config files that are part of this server's config
    # channels
    h = rhnSQL.prepare(_query_schedule_config_files)
    h.execute(server_id=server_id, action_id=next_action_id)
    update_ks_session_table(kickstart_session_id, 'configuration_deploy',
                            next_action_id, server_id)
    return next_action_id
def schedule_pkg_install(server_id, action_id, dry_run=0):
    s = rhnServer.search(server_id)

    new_action_id = rhnAction.schedule_server_action(
        server_id,
        action_type='packages.update',
        action_name="Activation Key Package Auto-Install",
        delta_time=0,
        scheduler=None,
        org_id=s.server['org_id'],
    )

    if (not dry_run):
        h = rhnSQL.prepare(_query_copy_pkgs_from_shadow_action)
        h.execute(action_id=action_id, new_action_id=new_action_id)
    else:
        log_debug(4, "dry run requested")

    log_debug(4, "scheduled pkg install for activation key")

    raise ShadowAction("Package install scheduled")
Example #24
0
#
# This software is licensed to you under the GNU General Public License,
# version 2 (GPLv2). There is NO WARRANTY for this software, express or
# implied, including the implied warranties of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
# along with this software; if not, see
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
#
# Red Hat trademarks are not licensed under GPLv2. No permission is
# granted to use or replicate Red Hat trademarks that are incorporated
# in this software or its documentation.
#
from spacewalk.server import rhnSQL, rhnAction

rhnSQL.initDB('rhnuser/rhnuser@webdev')

server_id = 1003486768
try:
    action_id = rhnAction.schedule_server_action(server_id, 'rhnsd.configure')

    h = rhnSQL.prepare("""
        insert into rhnActionDaemonConfig (action_id, interval)
        values (:action_id, 10)
    """)
    h.execute(action_id=action_id)

except:
    rhnSQL.rollback()
    raise
rhnSQL.commit()
Example #25
0
def look_at_actions(server_id):
    h = rhnSQL.prepare(_query_action_lookup)
    h.execute(server_id=server_id)
    return h.fetchall_dict()


if __name__ == "__main__":
    myserver = TestServer()
    #myserver.upload_packages('/home/devel/wregglej/rpmtest')
    #handler = rhnHandler()
    #print handler.auth_system( myserver.getSystemId() )
    #up2date = myserver.getUp2date()
    #id = myserver.getSystemId()
    #print up2date.solvedep( id, ['libcaps.so'] )
    #print "Done!"
    #rhnserver = rhnServer.Server(myserver.testuser, org_id=myserver.org_id)

    fake_key = create_activation_key(org_id=myserver.org_id, user_id=myserver.testuser.getid(), channels=[myserver.label], server_id=myserver.getServerId())
    fake_action = rhnAction.schedule_server_action(myserver.getServerId(), "packages.update", action_name="Testing", delta_time=9999, org_id=myserver.org_id)
    fake_token = rhnServer.search_token(fake_key._token)

    print look_at_actions(myserver.getServerId())

    rhnFlags.set("registration_token", fake_token)
    myserver.testserver.use_token()

    print look_at_actions(myserver.getServerId())

    rhnAction.invalidate_action(myserver.getServerId(), fake_action)
    rhnSQL.rollback()
Example #26
0
    myserver = TestServer()
    #myserver.upload_packages('/home/devel/wregglej/rpmtest')
    #handler = rhnHandler()
    #print handler.auth_system( myserver.getSystemId() )
    #up2date = myserver.getUp2date()
    #id = myserver.getSystemId()
    #print up2date.solvedep( id, ['libcaps.so'] )
    #print "Done!"
    #rhnserver = rhnServer.Server(myserver.testuser, org_id=myserver.org_id)

    fake_key = create_activation_key(org_id=myserver.org_id,
                                     user_id=myserver.testuser.getid(),
                                     channels=[myserver.label],
                                     server_id=myserver.getServerId())
    fake_action = rhnAction.schedule_server_action(myserver.getServerId(),
                                                   "packages.update",
                                                   action_name="Testing",
                                                   delta_time=9999,
                                                   org_id=myserver.org_id)
    fake_token = rhnServer.search_token(fake_key._token)

    print look_at_actions(myserver.getServerId())

    rhnFlags.set("registration_token", fake_token)
    myserver.testserver.use_token()

    print look_at_actions(myserver.getServerId())

    rhnAction.invalidate_action(myserver.getServerId(), fake_action)
    rhnSQL.rollback()