def _PUT(self, *param, **params): host_id = self.chk_hostby1(param) if host_id is None: return web.notfound() if not validates_network_storage(self): self.logger.debug("Network storage update failed. Did not validate.") return web.badrequest(self.view.alert) hostname = self.input.network_storage_host_name port = self.input.network_storage_port_number iqn = self.input.network_storage_iqn auth = self.input.network_storage_authentication user = self.input.network_storage_user password = self.input.network_storage_password auto_start = False if is_param(self.input, 'network_storage_auto_start'): auto_start = True options = {'auth' : auth, 'iqn' : iqn, 'target' : hostname} if port: options['port'] = port if auth == ISCSI_CONFIG_VALUE_AUTH_METHOD_CHAP: options['user'] = user try: password_file_name = '/tmp/' + generate_phrase(12,'abcdefghijklmnopqrstuvwxyz') create_file(password_file_name, password) options['password-file'] = password_file_name except Exception, e: self.logger.error('Failed to create tmp password file. - file=%s' % (password_file_name)) options['password'] = password
def _POST(self, *param, **params): host_id = self.chk_hostby1(param) if host_id is None: return web.notfound() if not validates_network_storage(self): self.logger.debug("Network storage add failed. Did not validate.") return web.badrequest(self.view.alert) hostname = self.input.network_storage_host_name port = self.input.network_storage_port_number auth = self.input.network_storage_authentication user = self.input.network_storage_user password = self.input.network_storage_password auto_start = False if is_param(self.input, 'network_storage_auto_start'): auto_start = True options = {'auth': auth} if port: options['target'] = "%s:%s" % (hostname, port) else: options['target'] = hostname if auth == ISCSI_CONFIG_VALUE_AUTH_METHOD_CHAP: options['user'] = user try: password_file_name = '/tmp/' + generate_phrase( 12, 'abcdefghijklmnopqrstuvwxyz') create_file(password_file_name, password) options['password-file'] = password_file_name except Exception, e: self.logger.error( 'Failed to create tmp password file. - file=%s' % (password_file_name)) options['password'] = password
def _POST(self, *param, **params): host_id = self.chk_hostby1(param) if host_id is None: return web.notfound() if not validates_network_storage(self): self.logger.debug("Network storage add failed. Did not validate.") return web.badrequest(self.view.alert) hostname = self.input.network_storage_host_name port = self.input.network_storage_port_number auth = self.input.network_storage_authentication user = self.input.network_storage_user password = self.input.network_storage_password auto_start = False if is_param(self.input, "network_storage_auto_start"): auto_start = True options = {"auth": auth} if port: options["target"] = "%s:%s" % (hostname, port) else: options["target"] = hostname if auth == ISCSI_CONFIG_VALUE_AUTH_METHOD_CHAP: options["user"] = user try: password_file_name = "/tmp/" + generate_phrase(12, "abcdefghijklmnopqrstuvwxyz") create_file(password_file_name, password) options["password-file"] = password_file_name except Exception, e: self.logger.error("Failed to create tmp password file. - file=%s" % (password_file_name)) options["password"] = password
def _POST(self, *param, **params): if not validates_icon(self): self.logger.debug("Create Icon is failed, Invalid input value") return web.badrequest(add_prefix(self.view.alert, "400")) icon_filevalue = self.input.multi_icon.value icon_filename = "%s.%s" % (uniq_filename(), imghdr.what(None, icon_filevalue)) if is_path(icon_filename) is True: return web.badrequest("Not to include the path.") icon_realpath = ICON_DIR_TPL % (karesansui.dirname, icon_filename) icon_webpath = ICON_DIR_TPL % (web.ctx.homepath, icon_filename) if os.path.exists(icon_realpath): web.conflict(icon_webpath, add_prefix("icon already exists", "409")) try: create_file(icon_realpath, icon_filevalue) except IOError, ioe: self.logger.error("Failed to write icon file. - filename=%s" % icon_filename) return web.internalerror( add_prefix("Failed to create icon file.", "500"))
def _DELETE(self, *param, **params): fname = '%s%s' % (LOGOUT_FILE_PREFIX, self.me.email,) try: create_file(fname, "") except IOError, ioe: self.logger.error("Logout failed, Failed to create logout file. - filename=%s" % fname) raise # return 500(Internal Server Error)
def _POST(self, *param, **params): if not validates_icon(self): self.logger.debug("Create Icon is failed, Invalid input value") return web.badrequest(add_prefix(self.view.alert, "400")) icon_filevalue = self.input.multi_icon.value icon_filename = "%s.%s" % (uniq_filename(), imghdr.what(None, icon_filevalue)) if is_path(icon_filename) is True: return web.badrequest("Not to include the path.") icon_realpath = ICON_DIR_TPL % (karesansui.dirname, icon_filename) icon_webpath = ICON_DIR_TPL % (web.ctx.homepath, icon_filename) if os.path.exists(icon_realpath): web.conflict(icon_webpath, add_prefix("icon already exists", "409")) try: create_file(icon_realpath, icon_filevalue) except IOError, ioe: self.logger.error("Failed to write icon file. - filename=%s" % icon_filename) return web.internalerror(add_prefix("Failed to create icon file.", "500"))