Esempio n. 1
0
    def populate_appliance_feeds(self):
        # fetch the feed confs from the catalog sources
        # currently catalog provides simple name space for placing
        # files not surfaced anywhere else in the model.

        feeds = {}  #store the feeds from all catalogs
        for c, c_info in self.catalogs.iteritems():
            print c, c_info
            if type(c_info) in [types.StringType, types.UnicodeType]:
                url = c_info
            # the c_info can be tuple containing other rich info
            # like proxy class to download etc. TBD
            try:
                feed_conf = self.fetch_catalog(c, url)
            except Exception, ex:
                feed_conf = self.get_conf_name(c)
                print "Error getting catalog ", c, url, ex
                #print "Will try to use ", feed_conf
                print "Continue using the existing data"
                continue

            if not os.path.exists(feed_conf):
                print "Skipping : %s does not exist.", feed_conf
                continue


#            if not self._feeds:
#                self._feeds = PyConfig(self.local_node, feed_conf)
#            else:
# merge the current feed data
            feed = PyConfig(self.local_node, feed_conf)
            for k, v in feed.iteritems():
                feeds[k] = v
Esempio n. 2
0
 def check_user_updates(self, username):
     update_items = []
     dep = None
     try:
         from convirt.model import Deployment
         deps = DBSession.query(Deployment).all()
         if len(deps) > 0:
             dep = deps[0]
             user_config_filename = os.path.abspath(
                 tg.config.get("user_config"))
             if not os.path.exists(user_config_filename):
                 user_config_file = open(user_config_filename, "w")
                 user_config_file.close()
             user_config = PyConfig(filename=user_config_filename)
             date = user_config.get(username)
             if date != None:
                 p_r_date = time.strptime(date, "%Y-%m-%d %H:%M:%S")
                 r_date = datetime(*p_r_date[0:5])
             else:
                 r_date = datetime.utcnow()
             edition = get_product_edition()
             (update_items,
              max_dt) = self.get_new_updates(dep.deployment_id, r_date,
                                             edition)
             user_config[username] = max_dt
             user_config.write()
         else:
             LOGGER.error(
                 "Deployment table is not set.Update can not proceed.")
             return
     except Exception, ex:
         traceback.print_exc()
         LOGGER.error("Error fetching updates:" + to_str(ex))
         return
Esempio n. 3
0
 def create_image_config(self, node=None, filename=None, config=None):
     return PyConfig(node, filename, signature=None, config=config)