def configure_hadoop(self): """ Configure environment for running Hadoop on demand. """ all_done = False try: log.debug("Setting up Hadoop environment") etcFile = open("/etc/environment", "a") etcFile.write("JAVA_HOME=\"/usr\"\n") etcFile.flush() etcFile.close() log.debug("Hadoop id_rsa set from::" + self.id_rsa_path) hadoop_id_rsa = "/home/ubuntu/.ssh/id_rsa" shutil.copy(self.id_rsa_path, hadoop_id_rsa) misc.run("chown -c ubuntu {0}".format(hadoop_id_rsa)) log.debug("Hadoop authFile saved to {0}".format(hadoop_id_rsa)) authFile = open("/home/ubuntu/.ssh/authorized_keys", "a") pubKeyFile = open(self.id_rsa_pub_key_path) authFile.write(pubKeyFile.read()) authFile.flush() authFile.close() pubKeyFile.close() misc.run("chown -c ubuntu /home/ubuntu/.ssh/authorized_keys") log.debug("Adding hadoop nfs export as /opt/hadoop") NFSExport.add_nfs_share("/opt/hadoop") all_done = True except Exception, e: log.debug("Error while configuring HADOOP: {0}".format(e)) all_done = False
def status(self): """ Update the status of this data service: make sure the mount point exists and that it is in /etc/exports for NFS """ # log.debug("Checking the status of {0}".format(self.fs.mount_point)) if self.fs._service_transitioning(): # log.debug("Data service {0} # transitioning".format(self.fs.get_full_name())) pass elif self.fs._service_starting(): # log.debug("Data service {0} # starting".format(self.fs.get_full_name())) pass elif not os.path.exists(self.fs.mount_point): # log.debug("Data service {0} dir {1} not there?".format( # self.fs.get_full_name(), self.fs.mount_point)) self.fs.state = service_states.UNSTARTED else: try: if NFSExport.find_mount_point_entry(self.fs.mount_point) > -1: self.fs.state = service_states.RUNNING # Transient storage needs to be special-cased because # it's not a mounted disk per se but a disk on an # otherwise default device for an instance (i.e., /mnt) update_size_cmd = ("df --block-size 1 | grep /mnt$ | " "awk '{print $2, $3, $5}'") # Some AWS instance types do not have transient storage # and /mnt is just part of / so report that file system size if not misc.getoutput(update_size_cmd, quiet=True): update_size_cmd = ("df --block-size 1 | grep /$ | " "awk '{print $2, $3, $5}'") self.fs._update_size(cmd=update_size_cmd) else: # Or should this set it to UNSTARTED? Because this FS is just an # NFS-exported file path... log.warning( "Data service {0} not found in /etc/exports; error!". format(self.fs.get_full_name())) self.fs.state = service_states.ERROR except Exception, e: log.error( "Error checking the status of {0} service: {1}".format( self.fs.get_full_name(), e)) self.fs.state = service_states.ERROR
def status(self): """ Update the status of this data service: ake sure the mount point exists and that it is in /etc/exports for NFS """ # log.debug("Checking the status of {0}".format(self.fs.mount_point)) if self.fs._service_transitioning(): # log.debug("Data service {0} # transitioning".format(self.fs.get_full_name())) pass elif self.fs._service_starting(): # log.debug("Data service {0} # starting".format(self.fs.get_full_name())) pass elif not os.path.exists(self.fs.mount_point): # log.debug("Data service {0} dir {1} not there?".format( # self.fs.get_full_name(), self.fs.mount_point)) self.fs.state = service_states.UNSTARTED else: try: if NFSExport.find_mount_point_entry(self.fs.mount_point) > -1: self.fs.state = service_states.RUNNING # Transient storage needs to be special-cased because # it's not a mounted disk per se but a disk on an # otherwise default device for an instance (i.e., /mnt) update_size_cmd = ("df --block-size 1 | grep /mnt$ | " "awk '{print $2, $3, $5}'") # Some AWS instance types do not have transient storage # and /mnt is just part of / so report that file system size if not misc.getoutput(update_size_cmd, quiet=True): update_size_cmd = ("df --block-size 1 | grep /$ | " "awk '{print $2, $3, $5}'") self.fs._update_size(cmd=update_size_cmd) else: # Or should this set it to UNSTARTED? Because this FS is just an # NFS-exported file path... log.warning("Data service {0} not found in /etc/exports; error!" .format(self.fs.get_full_name())) self.fs.state = service_states.ERROR except Exception, e: log.error("Error checking the status of {0} service: {1}".format( self.fs.get_full_name(), e)) self.fs.state = service_states.ERROR