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
    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
Beispiel #3
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
Beispiel #4
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        
Beispiel #5
0
 def read_config(self, init_glob=None, init_locs=None):
     # Leverage the fact that conf files are python syntax.
     # save on parsing code
     # Create global and local dicts for the file.
     # Initialize locals to the vars.
     globs = {}
     locs = {}
     cmd = '\n'.join(self.imps)
     # Use exec to do the standard imports and
     # define variables we are passing to the script.
     exec cmd in globs, locs
     return PyConfig.read_config(self, globs, locs)
Beispiel #6
0
 def read_config(self, init_glob=None, init_locs=None):
     # Leverage the fact that conf files are python syntax.
     # save on parsing code
     # Create global and local dicts for the file.
     # Initialize locals to the vars.
     globs = {}
     locs = {}
     cmd = "\n".join(self.imps)
     # Use exec to do the standard imports and
     # define variables we are passing to the script.
     exec cmd in globs, locs
     return PyConfig.read_config(self, globs, locs)
Beispiel #7
0
    def __init__(self, node=None, filename=None, config=None):
        """
        read stuff from file and populate the config
        when filename is None, creates an empty config
        """

        self.convirt_generated = False
        self.storage_stats = None

        PyConfig.__init__(self, node, filename, VMConfig.signature, config)

        if filename is None and config is None: return

        if len(self.lines) > 0:
            if self.lines[0].find(self.signature) >= 0:
                self.convirt_generated = True

        if self["name"] is None:
            raise Exception("No dom name specified")

        #pick up the name from the file
        self.name = self["name"]
        self.id = self["uuid"]
Beispiel #8
0
    def __init__(self, node=None, filename=None, config=None):
        """
        read stuff from file and populate the config
        when filename is None, creates an empty config
        """

        self.convirt_generated = False
        self.storage_stats = None

        PyConfig.__init__(self, node, filename, VMConfig.signature, config)

        if filename is None and config is None:
            return

        if len(self.lines) > 0:
            if self.lines[0].find(self.signature) >= 0:
                self.convirt_generated = True

        if self["name"] is None:
            raise Exception("No dom name specified")

        # pick up the name from the file
        self.name = self["name"]
        self.id = self["uuid"]
Beispiel #9
0
 def create_image_config(self, node=None, filename=None, config=None):
     return PyConfig(node, filename, signature=None, config=config)
Beispiel #10
0
 def write(self):
     """Writes the settings out to the filename specified during
     initialization"""
     self.name = self["name"]
     PyConfig.write(self)
     self.convirt_generated = True
Beispiel #11
0
 def write(self):
     """Writes the settings out to the filename specified during
     initialization"""
     self.name = self["name"]
     PyConfig.write(self)
     self.convirt_generated = True