コード例 #1
0
ファイル: horizon.py プロジェクト: jaybuff/Openstack-Anvil
 def _install_node_repo(self):
     repo_url = self.get_option('nodejs_repo')
     if not repo_url:
         return
     # Download the said url and install it so that we can actually install
     # the node.js requirement which seems to be needed by horizon for css compiling??
     repo_basename = sh.basename(repo_url)
     (_fn, fn_ext) = os.path.splitext(repo_basename)
     fn_ext = fn_ext.lower().strip()
     if fn_ext not in ['.rpm', '.repo']:
         LOG.warn("Unknown node.js repository configuration extension %s (we only support .rpm or .repo)!", colorizer.quote(fn_ext))
         return
     with NamedTemporaryFile(suffix=fn_ext) as temp_fh:
         LOG.info("Downloading node.js repository configuration from %s to %s.", repo_url, temp_fh.name)
         down.UrlLibDownloader(repo_url, temp_fh.name).download()
         temp_fh.flush()
         if fn_ext == ".repo":
             # Just write out the repo file after downloading it...
             repo_file_name = sh.joinpths("/etc/yum.repos.d", repo_basename)
             if not sh.exists(repo_file_name):
                 with sh.Rooted(True):
                     sh.write_file(repo_file_name, sh.load_file(temp_fh.name),
                                   tracewriter=self.tracewriter)
                     sh.chmod(repo_file_name, 0644)
         elif fn_ext == ".rpm":
             # Install it instead from said rpm (which likely is a
             # file that contains said repo location)...
             packager = yum.YumPackager(self.distro).direct_install(temp_fh.name)
コード例 #2
0
ファイル: nova.py プロジェクト: apugachev-gd/Openstack-Anvil
 def _configure_instances_path(self, instances_path, nova_conf):
     nova_conf.add('instances_path', instances_path)
     if not sh.isdir(instances_path):
         LOG.debug("Attempting to create instance directory: %r", instances_path)
         sh.mkdirslist(instances_path, tracewriter=self.tracewriter)
         LOG.debug("Adjusting permissions of instance directory: %r", instances_path)
         sh.chmod(instances_path, 0777)
コード例 #3
0
ファイル: nova.py プロジェクト: gerardo8a/Openstack-Anvil
 def _setup_cleaner(self):
     LOG.info("Configuring cleaner template: %s", colorizer.quote(CLEANER_DATA_CONF))
     (_fn, contents) = utils.load_template(self.name, CLEANER_DATA_CONF)
     # FIXME(harlowja), stop placing in checkout dir...
     cleaner_fn = sh.joinpths(sh.joinpths(self.get_option('app_dir'), BIN_DIR), CLEANER_DATA_CONF)
     sh.write_file(cleaner_fn, contents)
     sh.chmod(cleaner_fn, 0755)
     self.tracewriter.file_touched(cleaner_fn)
コード例 #4
0
ファイル: swift.py プロジェクト: krtyyy/Openstack-Anvil
 def _setup_binaries(self):
     startmain_file = sh.joinpths(self.get_option("app_dir"), BIN_DIR, SWIFT_STARTMAIN)
     makerings_file = sh.joinpths(self.get_option("app_dir"), BIN_DIR, SWIFT_MAKERINGS)
     sh.move(sh.joinpths(self.get_option("cfg_dir"), SWIFT_MAKERINGS), makerings_file)
     sh.chmod(makerings_file, 0777)
     self.tracewriter.file_touched(makerings_file)
     sh.move(sh.joinpths(self.get_option("cfg_dir"), SWIFT_STARTMAIN), startmain_file)
     sh.chmod(startmain_file, 0777)
     self.tracewriter.file_touched(startmain_file)
コード例 #5
0
ファイル: horizon.py プロジェクト: apugachev-gd/anvil
 def _setup_logs(self, clear=False):
     log_fns = [self.access_log, self.error_log]
     utils.log_iterable(log_fns, logger=LOG,
                        header="Adjusting %s log files" % (len(log_fns)))
     for fn in log_fns:
         if clear:
             sh.unlink(fn, True)
         sh.touch_file(fn, die_if_there=False, tracewriter=self.tracewriter)
         sh.chmod(fn, 0666)
     return len(log_fns)
コード例 #6
0
ファイル: horizon.py プロジェクト: samitny/Openstack-Anvil
 def _setup_logs(self, clear):
     log_fns = [self.access_log, self.error_log]
     utils.log_iterable(log_fns, logger=LOG,
                        header="Adjusting %s log files" % (len(log_fns)))
     for fn in log_fns:
         with sh.Rooted(True):
             if clear:
                 sh.unlink(fn, True)
             sh.mkdirslist(sh.dirname(fn))
             sh.touch_file(fn, die_if_there=False)
             sh.chmod(fn, 0666)
         self.tracewriter.file_touched(fn)
     return len(log_fns)
コード例 #7
0
ファイル: nova.py プロジェクト: krtyyy/Openstack-Anvil
 def _generate_root_wrap(self):
     if not self.cfg.getboolean("nova", "do_root_wrap"):
         return False
     else:
         lines = list()
         lines.append("%s ALL=(root) NOPASSWD: %s" % (sh.getuser(), self.root_wrap_bin))
         fc = utils.joinlinesep(*lines)
         root_wrap_fn = sh.joinpths(self.distro.get_command_config("sudoers_dir"), "nova-rootwrap")
         self.tracewriter.file_touched(root_wrap_fn)
         with sh.Rooted(True):
             sh.write_file(root_wrap_fn, fc)
             sh.chmod(root_wrap_fn, 0440)
             sh.chown(root_wrap_fn, sh.getuid(sh.ROOT_USER), sh.getgid(sh.ROOT_GROUP))
         return True
コード例 #8
0
 def _do_upstart_configure(self, app_name, app_pth, app_dir, program_args):
     # TODO FIXME symlinks won't work. Need to copy the files there.
     # https://bugs.launchpad.net/upstart/+bug/665022
     cfg_fn = sh.joinpths(CONF_ROOT, app_name + CONF_EXT)
     if sh.isfile(cfg_fn):
         LOG.debug("Upstart config file already exists: %r" % (cfg_fn))
         return
     LOG.debug("Loading upstart template to be used by: %r" % (cfg_fn))
     (_, contents) = utils.load_template('general', UPSTART_CONF_TMPL)
     params = self._get_upstart_conf_params(app_pth, app_name, *program_args)
     adjusted_contents = utils.param_replace(contents, params)
     LOG.debug("Generated up start config for %r: %s" % (app_name, adjusted_contents))
     with sh.Rooted(True):
         sh.write_file(cfg_fn, adjusted_contents)
         sh.chmod(cfg_fn, 0666)
コード例 #9
0
ファイル: rhel.py プロジェクト: hshah19/anvil
 def _fix_log_dir(self):
     # This seems needed...
     #
     # Due to the following:
     # <<< Restarting rabbitmq-server: RabbitMQ is not running
     # <<< sh: /var/log/rabbitmq/startup_log: Permission denied
     # <<< FAILED - check /var/log/rabbitmq/startup_{log, _err}
     #
     # See: http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/2011-March/011916.html
     # This seems like a bug, since we are just using service init and service restart...
     # And not trying to run this service directly...
     base_dir = sh.joinpths("/var/log", 'rabbitmq')
     if sh.isdir(base_dir):
         # Seems like we need root perms to list that directory...
         for fn in sh.listdir(base_dir):
             if re.match("(.*?)(err|log)$", fn, re.I):
                 sh.chmod(sh.joinpths(base_dir, fn), 0o666)
コード例 #10
0
 def _configure_instances_path(self, instances_path, nova_conf):
     nova_conf.add('instances_path', instances_path)
     LOG.debug("Attempting to create instance directory: %r", instances_path)
     self.tracewriter.dirs_made(*sh.mkdirslist(instances_path))
     LOG.debug("Adjusting permissions of instance directory: %r", instances_path)
     sh.chmod(instances_path, 0777)
     instance_parent = sh.dirname(instances_path)
     LOG.debug("Adjusting permissions of instance directory parent: %r", instance_parent)
     # In cases where you are using kvm + qemu
     # On certain distros (ie RHEL) this user needs to be able
     # To enter the parents of the instance path, if this is in /home/BLAH/ then
     # Without enabling the whole path, this user can't write there. This helps fix that...
     with sh.Rooted(True):
         for p in sh.explode_path(instance_parent):
             if not os.access(p, os.X_OK) and sh.isdir(p):
                 # Need to be able to go into that directory
                 sh.chmod(p, os.stat(p).st_mode | 0755)
コード例 #11
0
ファイル: nova.py プロジェクト: samitny/Openstack-Anvil
 def _configure_instances_path(self, instances_path, nova_conf):
     nova_conf.add('instances_path', instances_path)
     LOG.debug("Attempting to create instance directory: %r", instances_path)
     self.installer.tracewriter.dirs_made(*sh.mkdirslist(instances_path))
     LOG.debug("Adjusting permissions of instance directory: %r", instances_path)
     sh.chmod(instances_path, 0777)
コード例 #12
0
 def _do_socketdir_init(self, socketdir, perm):
     LOG.debug("Making screen socket directory %r (with permissions %o)" % (socketdir, perm))
     with sh.Rooted(True):
         dirs = sh.mkdirslist(socketdir)
         for d in dirs:
             sh.chmod(d, perm)