FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor


 
 
LinkBack Thread Tools
 
Old 04-23-2008, 08:07 PM
Scott Henson
 
Default cobbler_sync_master

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I've attached a small script that we use to sync multiple subcobbler
instances to a single master. We currently use an out of band copy
mechanism to get /var/www/cobbler/ks_mirror onto all our cobbler server,
but we had no way of getting cobbler to know about the distro and the
attached profiles. This script will add both, without syncing any data
and create the necessary symlinks in /var/www/cobbler/links.


Why should you use it?
We currently use it for network segmentation purposes. We have several
subcobblers that serve a single part of our network and we don't want to
have to import distros in each place. Instead we use snap mirroring to
get /var/www/cobbler/ks_mirror out and then run cobbler_sync_master to
get cobbler to create the distros and profiles in its configuration
files. This can also be used to distribute the load of a single network
across multiple cobblers mounting ks_mirror off the same nfs share.


How do you use it?
Easy! You use cobbler import to get the distro into the master server.
Then when the ks_mirror files arrive on the subcobblers, you run
'cobbler_sync_master --server master.example.com'. The script will add
any distros that it sees on the master that are not on the subcobbler
and that the kernel has arrived for.


If someone else finds this script useful I'll probably clean it up a bit
and we can throw it in scripts/. If more than a few people find this
useful I'd be willing to port it into cobbler core.


- --
Scott Henson
Red Hat Production Operations Release Engineer
WVU Alum BSAE/BSME
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iD8DBQFID5b/cQOfHbe3DKARAhGoAKC3J9S3csZHEaPhcX7it/ObUwK1lACg7NGG
LOEV4jWYsW6KF3vSJ2Gh8ic=
=Bb3Q
-----END PGP SIGNATURE-----

#!/usr/bin/python
"""
Sync Cobbler with Master

Copyright 2008, Red Hat, Inc
Scott Henson <shenson@redhat.com>

This software may be freely redistributed under the terms of the GNU
general public license.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
"""

from cobbler import api
from optparse import OptionParser
import xmlrpclib, os

def link_distro(settings, distro):
# find the tree location
dirname = os.path.dirname(distro.kernel)
tokens = dirname.split("/")
tokens = tokens[:-2]
base = "/".join(tokens)
dest_link = os.path.join(settings.webdir, "links", distro.name)

# create the links directory only if we are mirroring because with
# SELinux Apache can't symlink to NFS (without some doing)

if not os.path.exists(dest_link):
try:
os.symlink(base, dest_link)
except:
# this shouldn't happen but I've seen it ... debug ...
print _("- symlink creation failed: %(base)s, %(dest)s") % { "base" : base, "dest" : dest_link }


def add_distro(cobbler, distro):
#Register the distro
if os.path.exists(distro['kernel']):
new_distro = cobbler.new_distro()
new_distro.from_datastruct(distro)
#create the symlinks
link_distro(cobbler.settings(), new_distro)
#Add the distro permanently
cobbler.distros().add(new_distro, save=True)
print 'Added distro %s. Creating Links.' % distro['name']
return True
else:
print 'Distro %s not here yet.' % distro['name']
return False

def add_profile(cobbler, profile):
#Register the new profile
new_profile = cobbler.new_profile()
new_profile.from_datastruct(profile)
cobbler.profiles().add(new_profile, save=True)
print 'Added profile %s.' % profile['name']

def check_profile(cobbler, profile):
profiles = cobbler.profiles().to_datastruct()
if profile not in profiles:
for distro in cobbler.distros().to_datastruct():
if distro['name'] == profile['name']:
return True
return False


def main(uri):
remote = xmlrpclib.Server(uri)

cobbler = api.BootAPI()
settings = cobbler.settings()

local_profiles = cobbler.profiles()
local_distros = cobbler.distros()

remote_profiles = remote.get_profiles()
remote_distros = remote.get_distros()
needsync = False
for distro in remote_distros:
if distro not in local_distros.to_datastruct():
print 'Found distro %s.' % distro['name']
if add_distro(cobbler, distro) or needsync:
needsync = True
if needsync:
cobbler.sync()
needsync = False

for profile in remote_profiles:
if check_profile(cobbler, profile):
print 'Found profile %s.' % distro['name']
add_profile(cobbler, profile)
needsync = True
if needsync:
cobbler.sync()

if __name__=='__main__':
parser = OptionParser()
parser.add_option('-s', '--server', dest='server',
help='Server you wish to user',
default=None, type='string')
(opts, args) = parser.parse_args()

if opts.server is None:
parser.error('You must provide a server')
uri = 'http://%s/cobbler_api' % opts.server
main(uri)


_______________________________________________
et-mgmt-tools mailing list
et-mgmt-tools@redhat.com
https://www.redhat.com/mailman/listinfo/et-mgmt-tools
 
Old 04-23-2008, 08:17 PM
"Sandor W. Sklar"
 
Default cobbler_sync_master

On Apr 23, 2008, at 1:07 PM, Scott Henson wrote:


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I've attached a small script that we use to sync multiple subcobbler
instances to a single master. We currently use an out of band copy
mechanism to get /var/www/cobbler/ks_mirror onto all our cobbler
server, but we had no way of getting cobbler to know about the
distro and the attached profiles. This script will add both,
without syncing any data and create the necessary symlinks in /var/
www/cobbler/links.

<snip>
If someone else finds this script useful I'll probably clean it up a
bit and we can throw it in scripts/. If more than a few people find
this useful I'd be willing to port it into cobbler core.


I, for one, would find this very useful. We currently have a single
cobbler server, with all distros and repos stored on local disk.
We're in the process of re-architecting portions of our data center's
network, with the end result likely to be all of our RHEL physical
boxes and Xen guests behind different firewall segments, with most of
those systems accessing NFS filesystems on a private network from our
NetApp.


I'm not sure yet exactly how we're going to end up, but having
something like this tool will definitely give us more flexibility and
less duplication of (fairly) static data.


So, thanks! I would find this useful; even more useful if it became a
part of cobbler core, with good documentation on its use! :-)


-s-

_______________________________________________
et-mgmt-tools mailing list
et-mgmt-tools@redhat.com
https://www.redhat.com/mailman/listinfo/et-mgmt-tools
 
Old 04-28-2008, 03:34 PM
Michael DeHaan
 
Default cobbler_sync_master

Scott Henson wrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I've attached a small script that we use to sync multiple subcobbler
instances to a single master. We currently use an out of band copy
mechanism to get /var/www/cobbler/ks_mirror onto all our cobbler
server, but we had no way of getting cobbler to know about the distro
and the attached profiles. This script will add both, without syncing
any data and create the necessary symlinks in /var/www/cobbler/links.


Why should you use it?
We currently use it for network segmentation purposes. We have
several subcobblers that serve a single part of our network and we
don't want to have to import distros in each place. Instead we use
snap mirroring to get /var/www/cobbler/ks_mirror out and then run
cobbler_sync_master to get cobbler to create the distros and profiles
in its configuration files. This can also be used to distribute the
load of a single network across multiple cobblers mounting ks_mirror
off the same nfs share.


How do you use it?
Easy! You use cobbler import to get the distro into the master
server. Then when the ks_mirror files arrive on the subcobblers, you
run 'cobbler_sync_master --server master.example.com'. The script
will add any distros that it sees on the master that are not on the
subcobbler and that the kernel has arrived for.


If someone else finds this script useful I'll probably clean it up a
bit and we can throw it in scripts/. If more than a few people find
this useful I'd be willing to port it into cobbler core.


- --
Scott Henson
Red Hat Production Operations Release Engineer
WVU Alum BSAE/BSME
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iD8DBQFID5b/cQOfHbe3DKARAhGoAKC3J9S3csZHEaPhcX7it/ObUwK1lACg7NGG
LOEV4jWYsW6KF3vSJ2Gh8ic=
=Bb3Q
-----END PGP SIGNATURE-----

------------------------------------------------------------------------

_______________________________________________
et-mgmt-tools mailing list
et-mgmt-tools@redhat.com
https://www.redhat.com/mailman/listinfo/et-mgmt-tools


Very nice.

Scott, if you want, send in a patch to add it cobbler's core.

I'd recommend adding a "cobbler/action_syncmaster.py" and also a
"cobbler/modules/cli_syncmaster.py". If you poke around the modules
directory you should see how that works in terms of adding new commands
to the CLI.


Might we want to call it something without "sync" in it as we already
have "sync" and "reposync"?


loadmaster? clonemaster?

--Michael

_______________________________________________
et-mgmt-tools mailing list
et-mgmt-tools@redhat.com
https://www.redhat.com/mailman/listinfo/et-mgmt-tools
 
Old 04-28-2008, 03:42 PM
Matt Hyclak
 
Default cobbler_sync_master

On Mon, Apr 28, 2008 at 11:34:49AM -0400, Michael DeHaan enlightened us:
> Might we want to call it something without "sync" in it as we already
> have "sync" and "reposync"?
>
> loadmaster? clonemaster?
>

cobbler replicate

:-)

My $0.02

Matt

--
Matt Hyclak
Department of Mathematics
Department of Social Work
Ohio University
(740) 593-1263

_______________________________________________
et-mgmt-tools mailing list
et-mgmt-tools@redhat.com
https://www.redhat.com/mailman/listinfo/et-mgmt-tools
 
Old 04-28-2008, 03:54 PM
Michael DeHaan
 
Default cobbler_sync_master

Matt Hyclak wrote:

On Mon, Apr 28, 2008 at 11:34:49AM -0400, Michael DeHaan enlightened us:

Might we want to call it something without "sync" in it as we already
have "sync" and "reposync"?


loadmaster? clonemaster?




cobbler replicate

:-)

My $0.02

Matt



+1

And if it gets options later for doing rsync of ks_mirror and
repo_mirror data, even better.


--Michael

_______________________________________________
et-mgmt-tools mailing list
et-mgmt-tools@redhat.com
https://www.redhat.com/mailman/listinfo/et-mgmt-tools
 
Old 04-29-2008, 04:04 AM
Scott Henson
 
Default cobbler_sync_master

Michael DeHaan wrote:

Matt Hyclak wrote:

On Mon, Apr 28, 2008 at 11:34:49AM -0400, Michael DeHaan enlightened us:

Might we want to call it something without "sync" in it as we
already have "sync" and "reposync"?

loadmaster? clonemaster?




cobbler replicate

:-)

My $0.02

Matt



+1

And if it gets options later for doing rsync of ks_mirror and
repo_mirror data, even better.


Sounds like a good plan to me. I'll try to have an initial patch
Thursday sometime.


--
Scott Henson
Red Hat Production Operations Release Engineer
WVU Alum BSAE/BSME

_______________________________________________
et-mgmt-tools mailing list
et-mgmt-tools@redhat.com
https://www.redhat.com/mailman/listinfo/et-mgmt-tools
 

Thread Tools




All times are GMT. The time now is 10:55 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org