Exemple #1
0
	def get(self):
		adminoptions    = AdminOptions.get_by_key_name('credentials')
		if adminoptions:
			monitoroptions  = EC2PricingMonitor.get_by_key_name(adminoptions.accountname)
			if monitoroptions:
				user = users.get_current_user()
				input_data_settings = {}
				for instance in self.instances2var.keys():
					url = "http://www.cloudexchange.org/data/"+instance+".csv"
					logging.info("fetching from URL: %s" % url)
					try:
						result = urlfetch.fetch(url)
						logging.info("return code : %s" % result.status_code)
					except:
						logging.info("got exception from urlfetch")
					if result.status_code == 200:
						content = result.content
						logging.info("content : %s" % content)
						input_data_settings[instance] = r"<settings><data_sets><data_set did='0'><csv><data>%s</data></csv></data_set></data_sets></settings>" % content.replace('\n',','+self.instances_privcost[instance]+','+self.instances_basiccost[instance]+'\\n')
						logging.info("input_data_settings: %s" % input_data_settings[instance])
					else:
						input_data_settings[instance] = r"<settings><data_sets><data_set did='0'><csv><data>2009-11-30 21:21:21,0.029\n2009-12-01 05:12:36,0.029\n2009-12-01 05:12:37,0.03\n2009-12-01 09:59:04,0.03</data></csv></data_set></data_sets></settings>"
						logging.info("input_data_settings: %s" % input_data_settings[instance])
				template_values = {}
				for instance,variable in self.instances2var.iteritems():
					template_values[variable] = input_data_settings[instance]
				template_values['monitoroptions'] = monitoroptions
#				template_values = {'eu_west_small_linux_data': input_data_settings['eu-west-1.linux.m1.small'],'us_west_small_linux_data': input_data_settings['us-west-1.linux.m1.small'],'us_east_small_linux_data': input_data_settings['us-east-1.linux.m1.small'],}
				path = os.path.join(os.path.dirname(__file__), 'dashboard.html')
				self.response.out.write(template.render(path, template_values))
			else :
				self.redirect('/admin')
		else :
			self.redirect('/admin')
Exemple #2
0
	def get(self):
		adminoptions = AdminOptions.get_by_key_name('credentials')
		if adminoptions:  
			twitterpass = adminoptions.twitterpass
			twitteruser = adminoptions.twitteruser
			prowlkey = adminoptions.prowlkey
			monitoroptions = EC2PricingMonitor.get_by_key_name(adminoptions.accountname)
			logging.info("accountname = %s" % adminoptions.accountname)
		else:
			twitterpass = "******"
			twitteruser = "******"
			prowlkey = "Change Me"
			monitoroptions = EC2PricingMonitor();
		serverlist = db.GqlQuery("SELECT * FROM Server")
		user = users.get_current_user()
		template_values = {'user': user, 'twitteruser': twitteruser, 'twitterpass': twitterpass, 'serverlist': serverlist, 'prowlkey': prowlkey, 'adminoptions': adminoptions,'monitoroptions': monitoroptions}
		path = os.path.join(os.path.dirname(__file__), 'admin.html')
		self.response.out.write(template.render(path, template_values))