Exemple #1
0
	def get(self, demo_name = None, token = None):
		# grab the instance
		instance = Instance.get_by_token(token)
		if not instance:
			self.add_message("That instance cannot be found.", 'error')
			return self.redirect_to('demos', demo_name=demo_name)

		# setup channel to do page refresh
		channel_token = token
		refresh_channel = channel.create_channel(channel_token)

		# hack in time max for timer
		instance.data_max = int(instance.expires - int(instance.started.strftime('%s')))

		# dict the meta
		if instance.meta:
			instance.meta_dict = json.loads(instance.meta)
		else:
			instance.meta_dict = {}

		params = {
			'instance': instance,
			'refresh_channel': refresh_channel,
			'channel_token': channel_token 
		}
		return self.render_template('site/demos/%s_instance.html' % demo_name, **params)
	def get(self, token = None):
		# lookup up bid
		bid = InstanceBid.get_by_token(token)
		if not bid:
			self.add_message("Instance reservation token %s has expired." % token, 'error')
			return self.redirect_to('lab-launcher')

		# grab the instance
		instance = Instance.get_by_token(token)
		if not instance:
			self.add_message("Could not find an instance with token %s." % token, 'error')
			return self.redirect_to('lab-launcher')

		# setup channel to do page refresh
		channel_token = token
		refresh_channel = channel.create_channel(channel_token)

		# params build out
		params = {
			'bid': bid,
			'instance': instance,
			'refresh_channel': refresh_channel,
			'channel_token': channel_token 
		}

		return self.render_template('lab/bid.html', **params)
Exemple #3
0
	def delete(self, token=None):
		bid = InstanceBid.get_by_token(token)

		# delete the bid
		if bid:
			bid.key.delete()

		# patch up the respective instance if it's not been started
		instance = Instance.get_by_token(token)

		if instance:
			# only patch instance if it's not been started
			if instance.state <= 1:
					instance.reserved = False
					instance.token = None
					instance.put()

		return
Exemple #4
0
	def get(self, token = None):
		# lookup up bid
		bid = InstanceBid.get_by_token(token)
		if not bid:
			self.add_message("Instance reservation token %s has expired." % token, 'error')
			return self.redirect_to('projects')

		# grab the project from the bid
		project = Project.get_by_id(bid.wisp.get().project.id())

		# grab the instance
		instance = Instance.get_by_token(token)
		if not instance:
			self.add_message("All available instance reservations are in use. Please try again in a few minutes.", 'error')
			return self.redirect_to('projects')

		# grab and render the README.md file
		content = urlfetch.fetch('http://10.0.1.80:8079/wisps/6048757061779456/README.md').content

		readme_html = bleach.clean(
			markdown.markdown(
				unicode(content, 'utf-8')
			), 
			config.bleach_tags,
			config.bleach_attributes
		)	

		# setup channel to do page refresh
		channel_token = token
		refresh_channel = channel.create_channel(channel_token)

		params = {
			'instance': instance,
			'bid': bid,
			'project': project,
			'readme_html': readme_html,
			'refresh_channel': refresh_channel,
			'channel_token': channel_token 
		}
		return self.render_template('project/bid.html', **params)
	def get(self, token = None):
		# grab the instance
		instance = Instance.get_by_token(token)
		if not instance:
			self.add_message("Could not find an instance with token %s." % token, 'error')
			return self.redirect_to('lab-launcher')

		# hack in time max for timer
		instance.data_max = int(instance.expires - int(instance.started.strftime('%s')))

		# setup channel to do page refresh
		channel_token = token
		refresh_channel = channel.create_channel(channel_token)

		# params build out
		params = {
			'instance': instance,
			'refresh_channel': refresh_channel,
			'channel_token': channel_token 
		}

		return self.render_template('lab/instance.html', **params)
Exemple #6
0
	def get(self, token=None):
		# response, type, cross posting
		params = {}
		self.response.headers['Content-Type'] = "application/json"
		self.response.headers['Access-Control-Allow-Origin'] = '*'

		# look for instance bid first
		bid = InstanceBid.get_by_token(token)

		if bid:
			# build out the response
			params['response'] = "success"
			params['message'] = "Reservation found by token."	
			params['instancebid'] = bid

			# return response
			self.response.set_status(201)
			return self.render_template('api/bid.json', **params)

		else:
			# look for instance
			instance = Instance.get_by_token(token)
			
			if instance:
				# build out the response
				params['response'] = "success"
				params['message'] = "Instance found by token."	
				params['instance'] = instance

				# return response
				self.response.set_status(201)
				return self.render_template('api/instancedetail.json', **params)
			
			else:
				# build out the error response
				params['response'] = "error"
				params['message'] = "No resources found by token."

				return self.render_template('api/response.json', **params)