def _get_param_map(self, app_name): root_params = comp.ProgramRuntime._get_param_map(self, app_name) if app_name == VNC_PROXY_APP and utils.service_enabled(settings.NOVA, self.instances, False): #have to reach into the nova conf (puke) nova_runtime = self.instances[settings.NOVA] root_params['NOVA_CONF'] = sh.joinpths(nova_runtime.cfgdir, nova.API_CONF) return root_params
def _configure_network_settings(self, nova_conf): #TODO this might not be right.... if utils.service_enabled(settings.QUANTUM, self.instances, False): nova_conf.add('network_manager', QUANTUM_MANAGER) nova_conf.add('quantum_connection_host', self.cfg.get('quantum', 'q_host')) nova_conf.add('quantum_connection_port', self.cfg.get('quantum', 'q_port')) if self.cfg.get('quantum', 'q_plugin') == 'openvswitch': for (key, value) in QUANTUM_OPENSWITCH_OPS.items(): if value is None: nova_conf.add_simple(key) else: nova_conf.add(key, value) if utils.service_enabled(settings.MELANGE_CLIENT, self.instances, False): nova_conf.add('quantum_ipam_lib', QUANTUM_IPAM_LIB) nova_conf.add_simple('use_melange_mac_generation') nova_conf.add('melange_host', self.cfg.get('melange', 'm_host')) nova_conf.add('melange_port', self.cfg.get('melange', 'm_port')) else: nova_conf.add('network_manager', NET_MANAGER_TEMPLATE % (self._getstr('network_manager', DEF_NET_MANAGER))) #dhcp bridge stuff??? nova_conf.add('dhcpbridge_flagfile', sh.joinpths(self.cfgdir, API_CONF)) #Network prefix for the IP network that all the projects for future VM guests reside on. Example: 192.168.0.0/12 nova_conf.add('fixed_range', self._getstr('fixed_range')) # The value for vlan_interface may default to the the current value # of public_interface. We'll grab the value and keep it handy. public_interface = self._getstr('public_interface') vlan_interface = self._getstr('vlan_interface', public_interface) #do a little check to make sure actually have that interface set... if not utils.is_interface(public_interface): msg = "Public interface %s is not a known interface" % (public_interface) raise exceptions.ConfigException(msg) if not utils.is_interface(vlan_interface): msg = "VLAN interface %s is not a known interface" % (vlan_interface) raise exceptions.ConfigException(msg) nova_conf.add('public_interface', public_interface) nova_conf.add('vlan_interface', vlan_interface) #This forces dnsmasq to update its leases table when an instance is terminated. nova_conf.add_simple('force_dhcp_release')
def _fix_quantum(self): if not (utils.service_enabled(settings.QUANTUM_CLIENT, self.instances, False)): #make the fake quantum (apparently needed so imports don't fail???) #TODO remove this... quantum_dir = sh.joinpths(self.dash_dir, 'quantum') if not sh.isdir(quantum_dir): self.tracewriter.make_dir(quantum_dir) self.tracewriter.touch_file(sh.joinpths(quantum_dir, '__init__.py')) self.tracewriter.touch_file(sh.joinpths(quantum_dir, 'client.py'))
def _fix_quantum(self): if not (utils.service_enabled(settings.QUANTUM_CLIENT, self.instances, False)): #make the fake quantum (apparently needed so imports don't fail???) #TODO remove this... quantum_dir = sh.joinpths(self.dash_dir, 'quantum') if not sh.isdir(quantum_dir): self.tracewriter.dirs_made(*sh.mkdirslist(quantum_dir)) for fn in FAKE_QUANTUM_FILES: self.tracewriter.file_touched(sh.touch_file(sh.joinpths(quantum_dir, fn)))
def _get_symlinks(self): links = comp.PythonInstallComponent._get_symlinks(self) src = self._get_target_config_name(HORIZON_APACHE_CONF) links[src] = APACHE_CONF_TARGETS[self.distro] if utils.service_enabled(settings.QUANTUM_CLIENT, self.instances, False): #TODO remove this junk, blah, puke that we have to do this qc = self.instances[settings.QUANTUM_CLIENT] src_pth = sh.joinpths(qc.appdir, 'quantum') tgt_dir = sh.joinpths(self.dash_dir, 'quantum') links[src_pth] = tgt_dir return links
def __init__(self, ni): self.cfg = ni.cfg self.instances = ni.instances self.component_root = ni.component_root self.appdir = ni.appdir self.tracewriter = ni.tracewriter self.paste_conf_fn = ni.paste_conf_fn self.distro = ni.distro self.cfgdir = ni.cfgdir self.xvnc_enabled = ni.xvnc_enabled self.volumes_enabled = ni.volumes_enabled self.novnc_enabled = utils.service_enabled(settings.NOVNC, self.instances)
def _config_adjust(self, contents, name): if name == ROOT_CONF: #use config parser and #then extract known configs that #will need locations/directories/files made (or touched)... with io.BytesIO(contents) as stream: config = cfg.IgnoreMissingConfigParser() config.readfp(stream) log_filename = config.get('default', 'log_file') if log_filename: LOG.info("Ensuring log file %s exists and is empty." % (log_filename)) log_dir = sh.dirname(log_filename) if log_dir: LOG.info("Ensuring log directory %s exists." % (log_dir)) self.tracewriter.make_dir(log_dir) #destroy then recreate it (the log file) sh.unlink(log_filename) sh.touch_file(log_filename) self.tracewriter.file_touched(log_filename) elif name == CATALOG_CONF: nlines = list() if utils.service_enabled(settings.SWIFT, self.instances): mp = dict() mp['SERVICE_HOST'] = self.cfg.get('host', 'ip') nlines.append("# Swift additions") nlines.extend(utils.param_replace_list(SWIFT_TEMPL_ADDS, mp)) nlines.append("") if utils.service_enabled(settings.QUANTUM, self.instances) or \ utils.service_enabled(settings.QUANTUM_CLIENT, self.instances): mp = dict() mp['SERVICE_HOST'] = self.cfg.get('host', 'ip') nlines.append("# Quantum additions") nlines.extend(utils.param_replace_list(QUANTUM_TEMPL_ADDS, mp)) nlines.append("") if nlines: nlines.insert(0, contents) contents = cfg.add_header(name, utils.joinlinesep(*nlines)) return contents
def _setup_network_init(self): tgt_fn = sh.joinpths(self.bindir, NET_INIT_CONF) if sh.isfile(tgt_fn): LOG.info("Creating your nova network to be used with instances.") #still there, run it #these environment additions are important #in that they eventually affect how this script runs if utils.service_enabled(settings.QUANTUM, self.instances, False): LOG.info("Waiting %s seconds so that quantum can start up before running first time init." % (WAIT_ONLINE_TO)) time.sleep(WAIT_ONLINE_TO) env = dict() env['ENABLED_SERVICES'] = ",".join(self.instances.keys()) setup_cmd = NET_INIT_CMD_ROOT + [tgt_fn] LOG.info("Running (%s) command to initialize nova's network." % (" ".join(setup_cmd))) sh.execute(*setup_cmd, env_overrides=env, run_as_root=False) LOG.debug("Removing (%s) file since we successfully initialized nova's network." % (tgt_fn)) sh.unlink(tgt_fn)
def _config_adjust(self, contents, config_fn): if config_fn not in ADJUST_CONFIGS: return contents if config_fn == PASTE_CONF and utils.service_enabled(settings.KEYSTONE, self.instances, False): newcontents = contents with io.BytesIO(contents) as stream: config = cfg.IgnoreMissingConfigParser() config.readfp(stream) mods = 0 for section in PASTE_PIPELINE_KEYSTONE_ADJUST.keys(): if config.has_section(section): section_vals = PASTE_PIPELINE_KEYSTONE_ADJUST.get(section) for (k, v) in section_vals.items(): config.set(section, k, v) mods += 1 if mods > 0: with io.BytesIO() as outputstream: config.write(outputstream) outputstream.flush() newcontents = cfg.add_header(config_fn, outputstream.getvalue()) contents = newcontents return contents
def get_dependencies(self): deps = comp.PythonRuntime.get_dependencies(self) if utils.service_enabled(settings.QUANTUM, self.instances, False): deps.append(settings.QUANTUM) return deps
def post_install(self): comp.PkgInstallComponent.post_install(self) if self.q_vswitch_service and utils.service_enabled(settings.DB, self.instances, False): self._setup_db() if self.q_vswitch_agent: self._setup_bridge()