"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "cobbler/action_litesync.py" between
cobbler-2.8.4.tar.gz and cobbler-3.0.0.tar.gz

About: cobbler is a Linux installation and deployment server that allows for rapid setup of network installation environments. It can help with installation, DNS, DHCP, package updates, power management, configuration management orchestration, and much more.

action_litesync.py  (cobbler-2.8.4):action_litesync.py  (cobbler-3.0.0)
skipping to change at line 26 skipping to change at line 26
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy 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 along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA 02110-1301 USA
""" """
from builtins import object
import os import os
import os.path import os.path
import utils from . import clogger
import clogger from . import module_loader
import module_loader from . import utils
class BootLiteSync: class CobblerLiteSync(object):
""" """
Handles conversion of internal state to the tftpboot tree layout Handles conversion of internal state to the tftpboot tree layout
""" """
def __init__(self,config,verbose=False,logger=None): def __init__(self, collection_mgr, verbose=False, logger=None):
""" """
Constructor Constructor
""" """
self.verbose = verbose self.verbose = verbose
self.config = config self.collection_mgr = collection_mgr
self.distros = config.distros() self.distros = collection_mgr.distros()
self.profiles = config.profiles() self.profiles = collection_mgr.profiles()
self.systems = config.systems() self.systems = collection_mgr.systems()
self.images = config.images() self.images = collection_mgr.images()
self.settings = config.settings() self.settings = collection_mgr.settings()
self.repos = config.repos() self.repos = collection_mgr.repos()
if logger is None: if logger is None:
logger = clogger.Logger() logger = clogger.Logger()
self.logger = logger self.logger = logger
self.tftpd = module_loader.get_module_from_file( self.tftpd = module_loader.get_module_from_file("tftpd", "module", "in_t
"tftpd","module","in_tftpd" ftpd").get_manager(collection_mgr, logger)
).get_manager(config,logger) self.sync = collection_mgr.api.get_sync(verbose, logger=self.logger)
self.sync = config.api.get_sync(verbose,logger=self.logger)
self.sync.make_tftpboot() self.sync.make_tftpboot()
def add_single_distro(self, name): def add_single_distro(self, name):
# get the distro record # get the distro record
distro = self.distros.find(name=name) distro = self.distros.find(name=name)
if distro is None: if distro is None:
return return
# copy image files to images/$name in webdir & tftpboot: # copy image files to images/$name in webdir & tftpboot:
self.sync.pxegen.copy_single_distro_files(distro, self.sync.tftpgen.copy_single_distro_files(distro, self.settings.webdir,
self.settings.webdir,True) True)
self.tftpd.add_single_distro(distro) self.tftpd.add_single_distro(distro)
# create the symlink for this distro # create the symlink for this distro
src_dir = utils.find_distro_path(self.settings,distro) src_dir = utils.find_distro_path(self.settings, distro)
dst_dir = os.path.join(self.settings.webdir,"links",name) dst_dir = os.path.join(self.settings.webdir, "links", name)
if os.path.exists(dst_dir): if os.path.exists(dst_dir):
self.logger.warning("skipping symlink, destination (%s) exists" % ds t_dir) self.logger.warning("skipping symlink, destination (%s) exists" % ds t_dir)
elif utils.path_tail(os.path.join(self.settings.webdir,"ks_mirror"),src_ elif utils.path_tail(os.path.join(self.settings.webdir, "distro_mirror")
dir) == "": , src_dir) == "":
self.logger.warning("skipping symlink, the source (%s) is not in %s" self.logger.warning("skipping symlink, the source (%s) is not in %s"
% (src_dir,os.path.join(self.settings.webdir,"ks_mirror"))) % (src_dir, os.path.join(self.settings.webdir, "distro_mirror")))
else: else:
try: try:
self.logger.info("trying symlink %s -> %s" % (src_dir,dst_dir)) self.logger.info("trying symlink %s -> %s" % (src_dir, dst_dir))
os.symlink(src_dir, dst_dir) os.symlink(src_dir, dst_dir)
except (IOError, OSError): except (IOError, OSError):
self.logger.error("symlink failed (%s -> %s)" % (src_dir,dst_dir )) self.logger.error("symlink failed (%s -> %s)" % (src_dir, dst_di r))
# generate any templates listed in the distro # generate any templates listed in the distro
self.sync.pxegen.write_templates(distro,write_file=True) self.sync.tftpgen.write_templates(distro, write_file=True)
# cascade sync # cascade sync
kids = distro.get_children() kids = distro.get_children()
for k in kids: for k in kids:
self.add_single_profile(k.name, rebuild_menu=False) self.add_single_profile(k.name, rebuild_menu=False)
self.sync.pxegen.make_pxe_menu() self.sync.tftpgen.make_pxe_menu()
def add_single_image(self, name): def add_single_image(self, name):
image = self.images.find(name=name) image = self.images.find(name=name)
self.sync.pxegen.copy_single_image_files(image) self.sync.tftpgen.copy_single_image_files(image)
kids = image.get_children() kids = image.get_children()
for k in kids: for k in kids:
self.add_single_system(k.name) self.add_single_system(k.name)
self.sync.pxegen.make_pxe_menu() self.sync.tftpgen.make_pxe_menu()
def remove_single_distro(self, name): def remove_single_distro(self, name):
bootloc = utils.tftpboot_location() bootloc = self.settings.tftpboot_location
# delete contents of images/$name directory in webdir # delete contents of images/$name directory in webdir
utils.rmtree(os.path.join(self.settings.webdir, "images", name)) utils.rmtree(os.path.join(self.settings.webdir, "images", name))
# delete contents of images/$name in tftpboot # delete contents of images/$name in tftpboot
utils.rmtree(os.path.join(bootloc, "images", name)) utils.rmtree(os.path.join(bootloc, "images", name))
# delete potential symlink to tree in webdir/links # delete potential symlink to tree in webdir/links
utils.rmfile(os.path.join(self.settings.webdir, "links", name)) utils.rmfile(os.path.join(self.settings.webdir, "links", name))
def remove_single_image(self, name): def remove_single_image(self, name):
bootloc = utils.tftpboot_location() bootloc = self.settings.tftpboot_location
utils.rmfile(os.path.join(bootloc, "images2", name)) utils.rmfile(os.path.join(bootloc, "images2", name))
def add_single_profile(self, name, rebuild_menu=True): def add_single_profile(self, name, rebuild_menu=True):
# get the profile object: # get the profile object:
profile = self.profiles.find(name=name) profile = self.profiles.find(name=name)
if profile is None: if profile is None:
# most likely a subprofile's kid has been # most likely a subprofile's kid has been
# removed already, though the object tree has # removed already, though the object tree has
# not been reloaded ... and this is just noise. # not been reloaded ... and this is just noise.
return return
# rebuild the yum configuration files for any attached repos # rebuild the yum configuration files for any attached repos
# generate any templates listed in the distro # generate any templates listed in the distro
self.sync.pxegen.write_templates(profile) self.sync.tftpgen.write_templates(profile)
# cascade sync # cascade sync
kids = profile.get_children() kids = profile.get_children()
for k in kids: for k in kids:
if k.COLLECTION_TYPE == "profile": if k.COLLECTION_TYPE == "profile":
self.add_single_profile(k.name, rebuild_menu=False) self.add_single_profile(k.name, rebuild_menu=False)
else: else:
self.add_single_system(k.name) self.add_single_system(k.name)
if rebuild_menu: if rebuild_menu:
self.sync.pxegen.make_pxe_menu() self.sync.tftpgen.make_pxe_menu()
return True return True
def remove_single_profile(self, name, rebuild_menu=True): def remove_single_profile(self, name, rebuild_menu=True):
# delete profiles/$name file in webdir # delete profiles/$name file in webdir
utils.rmfile(os.path.join(self.settings.webdir, "profiles", name)) utils.rmfile(os.path.join(self.settings.webdir, "profiles", name))
# delete contents on kickstarts/$name directory in webdir # delete contents on autoinstalls/$name directory in webdir
utils.rmtree(os.path.join(self.settings.webdir, "kickstarts", name)) utils.rmtree(os.path.join(self.settings.webdir, "autoinstalls", name))
if rebuild_menu: if rebuild_menu:
self.sync.pxegen.make_pxe_menu() self.sync.tftpgen.make_pxe_menu()
def update_system_netboot_status(self,name): def update_system_netboot_status(self, name):
self.tftpd.update_netboot(name) self.tftpd.update_netboot(name)
def add_single_system(self, name): def add_single_system(self, name):
# get the system object: # get the system object:
system = self.systems.find(name=name) system = self.systems.find(name=name)
if system is None: if system is None:
return return
# rebuild system_list file in webdir # rebuild system_list file in webdir
if self.settings.manage_dhcp: if self.settings.manage_dhcp:
self.sync.dhcp.regen_ethers() self.sync.dhcp.regen_ethers()
if self.settings.manage_dns: if self.settings.manage_dns:
self.sync.dns.regen_hosts() self.sync.dns.regen_hosts()
# write the PXE files for the system # write the PXE files for the system
self.tftpd.add_single_system(system) self.tftpd.add_single_system(system)
def remove_single_system(self, name): def remove_single_system(self, name):
bootloc = utils.tftpboot_location() bootloc = self.settings.tftpboot_location
system_record = self.systems.find(name=name) # delete contents of autoinsts_sys/$name in webdir
# delete contents of kickstarts_sys/$name in webdir
system_record = self.systems.find(name=name) system_record = self.systems.find(name=name)
itanic = False for (name, interface) in list(system_record.interfaces.items()):
profile = self.profiles.find(name=system_record.profile) filename = system_record.get_config_filename(interface=name)
if profile is not None: utils.rmfile(os.path.join(bootloc, "pxelinux.cfg", filename))
distro = self.distros.find(name=profile.get_conceptual_parent().name utils.rmfile(os.path.join(bootloc, "grub", filename.upper()))
)
if distro is not None and distro in [ "ia64", "IA64"]:
itanic = True
for (name,interface) in system_record.interfaces.iteritems():
filename = utils.get_config_filename(system_record,interface=name)
if not itanic:
utils.rmfile(os.path.join(bootloc, "pxelinux.cfg", filename))
utils.rmfile(os.path.join(bootloc, "grub", filename.upper()))
else:
utils.rmfile(os.path.join(bootloc, filename))
 End of changes. 24 change blocks. 
43 lines changed or deleted 42 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)