[Spacewalk-list] Channel/repository Relationship

Michael Snyder msnyder at digitalriver.com
Sat Nov 16 14:09:13 UTC 2013


There were no replies to this, so I went into the wilderness...

To recap, my goal was to find a programmatic method to associate a repository to a channel.  The challenge that drove this was to deploy a current Spacewalk environment, but replicate software channels from the old environment.  The code to create channels and repos is centered around invocations of "spacecmd" (verbs "softwarechannel_create" and "repo_create"), but there is no verb in the CLI for associating a repository to a channel.

The following bash function is called out, with arguments of the channel and repository names, and directly engages PostgreSQL to insert a relationship:

# $1 = channel
# $2 = repo
fn_bind_repo ()
{
	psql -U [postgres_user] -h [postgres_server] <<FIN
	  insert into rhnchannelcontentsource ( channel_id, source_id )
	    select rhnchannel.id, rhncontentsource.id from rhnchannel, rhncontentsource where rhnchannel.label = '$1' and rhncontentsource.label = '$2';
FIN

	return $?
}

If there *is* a "spacecmd" verb or API call that accomplishes this, then my apologies for going off the beaten path.  Otherwise, would this be a base for an RFE to add verbs to the CLI/API functionality?

Best Regards,
Michael Snyder


-----Original Message-----
From: Michael Snyder 
Sent: Tuesday, August 20, 2013 12:32 PM
To: spacewalk-list at redhat.com
Subject: Channel/repository Relationship

Greetings!

I am working on an upgrade from Spacewalk 1.8 to 2.0, and have found an interesting challenge in the process.  One of the goals is to populate the new system repositories from the old system, and to uniformly establish distinct repositories which are then referenced by the channels.

"spacecmd" has been instrumental in providing data from the old system useful for creating the existing channels, and I have also successfully established matching repositories for the channels.  Some examples for the channel and repo creations, as driven through scripting on both ends with "spacecmd":

 - spacecmd "softwarechannel_create -n centos6-base-x86_64 -l legacy-centos6-base-x86_64 -a x86_64"
 - spacecmd "repo_create -n centos6-base-x86_64-repo -u http://[old_spacewalk_server]/ks/dist/centos6-base-x86_64"

The one detail that I can't seem to solve is registering/relating the repository to the channel.  I have not found any spacecmd verb that corresponds to something like:

 - spacecmd "softwarechannel_addrepo -r centos6-base-x86_64-repo centos6-base-x86_64"
 - spacecmd "softwarechannel_addrepo -r [repo_name] channel_name"   #to be more generic ...

(and of course, proposing an "add" verb implies that a "delete" counterpart should exist)

Have I missed this functionality expressed with a different verb?  Can this be done in a programmatic way?

Best Regards,
Michael Snyder 





More information about the Spacewalk-list mailing list