def proxy_image(self): if Appliance.get().enable_image_caching: url = self.cached_url else: url = self.url tmp_file = self.get_data(url) osid = create_os_image(name=self.name, disk_format=self.disk_format, container_format=self.container_format, fd=tmp_file).id # close tmp file fd, this should delete it from the disk tmp_file.close() self.update(osid=osid)
def proxy_image(self): if Appliance.get().enable_image_caching: url = self.cached_url else: url = self.url tmp_file = self.get_data(url) osid = create_os_image( name=self.name, disk_format=self.disk_format, container_format=self.container_format, fd=tmp_file).id # close tmp file fd, this should delete it from the disk tmp_file.close() self.update(osid=osid)
def cached_url(self): # resolve url to it's final destination urlinfo = urllib2.build_opener().open(urllib2.Request(self.url)) # remove protocol from url proto_search = re.compile('^(http|https)://(.*)$').search(urlinfo.url) # clean up the open connection urlinfo.close() if proto_search: proto = proto_search.group(1) host_path = proto_search.group(2) url = 'http://{0}:8080/{1}/{2}'.format(Appliance.get().local_ip, proto, host_path) else: url = self.url return url
def action(ip=('i', default_ip)): """ Installs a new database configuration for the appliance. """ # create all tables db.create_all() if not Appliance.get(): # initialize the appliance object appliance = Appliance() appliance.initialize(ip) # sync flavors from pool (openstack sync comes later when we have a user) flavors = Flavors().sync() # configure output configure_blurb()
def save(self, *args, **kwargs): if Appliance.get().enable_image_caching: url = self.cached_url else: url = self.url if (self.osid == None or not os_image_exists(self.osid)): if self.decompress: app.logger.info("Proxying image in order to decompress {0}.".format( url)) self.proxy_image() else: app.logger.info("Creating image with location {0}.".format( url)) self.osid = create_os_image( name=self.name, url=url, disk_format=self.disk_format, container_format=self.container_format).id super(Images, self).save(*args, **kwargs)
def save(self, *args, **kwargs): if Appliance.get().enable_image_caching: url = self.cached_url else: url = self.url if (self.osid == None or not os_image_exists(self.osid)): if self.decompress: app.logger.info( "Proxying image in order to decompress {0}.".format(url)) self.proxy_image() else: app.logger.info( "Creating image with location {0}.".format(url)) self.osid = create_os_image( name=self.name, url=url, disk_format=self.disk_format, container_format=self.container_format).id super(Images, self).save(*args, **kwargs)
def configure_flavors(): # check configuration settings = Status().check_settings() # flavors without the ones that were synced from pool are not installed on # openstack cluster yet flavors = Flavors.query.filter_by(installed=True).all() # load appliance appliance = Appliance.get() # how much is BTC? try: quote = float( coinbase_get_quote( currency='btc_to_usd')['result']['btc_to_usd']) / 1000000 except: quote = 0 return render_template('configure/flavors.html', settings=settings, quote=quote, flavors=flavors, appliance=appliance)
def configure_flavors(): # check configuration settings = Status().check_settings() # flavors without the ones that were synced from pool are not installed on # openstack cluster yet flavors = Flavors.query.filter_by(installed=True).all() # load appliance appliance = Appliance.get() # how much is BTC? try: quote = float(coinbase_get_quote(currency='btc_to_usd')['result']['btc_to_usd'])/1000000 except: quote = 0 return render_template( 'configure/flavors.html', settings=settings, quote=quote, flavors=flavors, appliance=appliance )
def appliance(self): return Appliance.get()