def configureCloudAdminSshKeysNode(self): self.createDirsCmd("%s/.ssh/" % self.oneHome) self.setOwnerCmd("%s/.ssh/" % self.oneHome) # FIXME: why ssh key-pair from the Frontend is pushed to the Node? # ssh-keygen on the Node should be used to generate the user # specific ssh key-pair on that machine. oneKey = fileGetContent("%s/.ssh/id_rsa" % self.oneHome) self._filePutContentAsOneAdmin("%s/.ssh/id_rsa" % self.oneHome, oneKey) oneKeyPub = fileGetContent("%s/.ssh/id_rsa.pub" % self.oneHome) self._filePutContentAsOneAdmin("%s/.ssh/authorized_keys" % self.oneHome, oneKeyPub) self.chmodCmd("%s/.ssh/id_rsa" % self.oneHome, 0600) self._configureCloudAdminSsh()
def _buildFixedNetworkTemplate(self, networkName): vnetTpl = fileGetContent(join(Defaults.SHARE_DIR, "vnet/fixed.net")) ips = self._getIPs(networkName) macs = self._getMACs(networkName) leases = ['LEASES = [ IP="%s", MAC="%s"]' % (ip, mac) for ip, mac in zip(ips, macs)] vnetTpl = vnetTpl % ( {"network_name": networkName, "bridge": self.config.get("node_bridge_name"), "leases": "\n".join(leases)} ) return vnetTpl
def _buildRangedNetworkTemplate(self, networkName): vnetTpl = fileGetContent(join(Defaults.SHARE_DIR, "vnet/ranged.net")) vnetTpl = vnetTpl % ( { "network_name": networkName, "bridge": self.config.get("node_bridge_name"), "network_size": self.config.get("one_%s_network_size" % networkName), "network_addr": self.config.get("one_%s_network" % networkName), } ) return vnetTpl
def _extractPdiskPassword(self): pswd = self._randomPassword() if not os.path.isfile(self.authnConfigFile): lines = [] else: fileContent = fileGetContent(self.authnConfigFile) lines = fileContent.split('\n') pattern = '^\s*%s\s*=\s*([\w-]+)(?:\s*,.*)?$' % (self.pdiskUsername) search = re.compile(pattern) for line in lines: if search.match(line): pswd = search.findall(line)[0] return pswd
def _configurePolicies(self): oneAuthTpl = self._getTemplateFile("quota.conf.tpl", "ONE auth configuration") authConfFile = self.cloudConfDir + "auth/quota.conf" self.quotaMemoryKB = getValueInKB(self.quotaMemory) self.frontend.filePutContentsCmd(authConfFile, fileGetContent(oneAuthTpl) % self.__dict__)
def _configureOneDaemon(self): onedTpl = self._getTemplateFile("oned.conf.tpl", "ONe daemon configuration") conf = self.config.copy() conf["vm_dir"] = self.cloudVarLibDir self.frontend.filePutContentsCmd(self.cloudConfFile, fileGetContent(onedTpl) % conf)
def _writeConfigFromTemplate(self, config, tpl): filePutContent(config, fileGetContent(tpl) % self.__dict__)
def _writeConfigFromTemplate(self): filePutContent(PolicyValidator.CONFIG, fileGetContent(PolicyValidator.TEMPLATE_CFG) % self.__dict__)
def _writePdiskBackendConfig(self): printStep('Writing backend configuration...') config = self.__dict__.copy() config['persistentDiskBackendSections'] = self._stripMultiLineValue(config['persistentDiskBackendSections']) self.system._remoteFilePutContents(self.pdiskConfigBackendFile, fileGetContent(self.pdiskConfigBackendTpl) % config)