コード例 #1
0
    def add_content(self, user, content_url):
        content_info = {
            "url": content_url,
            "enabled": True,
            "description": "Created by SMDS",
            "content_provider_id": self.content_provider['content_provider_id']
        }

        rc = None
        try:
            # try the new API (works with CoSFA)
            rc = self.cdn_api.Create(self.CDN_auth, "Content", content_info)

        except Exception, e:
            traceback.print_exc()
            # possibly using the old API
            try:
                logger.warn(
                    "VerivueCoBlitz(add_content): new API failed; trying old API"
                )
                rc = self.cdn_api.AddContent(
                    self.CDN_auth, content_info['content_provider_id'],
                    content_info)
            except Exception, e2:
                logger.exception(
                    e2,
                    "VerivueCoBlitz(add_content): could not add content '%s'" %
                    content_url)
コード例 #2
0
 def get_contents( self, filter_=None, ret=None  ):
    content = None
    try:
       # try the new API (works with CoSFA)
       content = self.cdn_api.ListAll( self.CDN_auth, "Content", filter_, ret )
    except Exception, e:
       # possibly using the old API
       try:
          logger.warn("VerivueCoBlitz: new API failed; trying old API")
          content = self.cdn_api.GetContents( self.CDN_auth, filter_, ret )
       
       except Exception, e:
          logger.exception( e, "Could not get content")
コード例 #3
0
    def get_contents(self, filter_=None, ret=None):
        content = None
        try:
            # try the new API (works with CoSFA)
            content = self.cdn_api.ListAll(self.CDN_auth, "Content", filter_,
                                           ret)
        except Exception, e:
            # possibly using the old API
            try:
                logger.warn("VerivueCoBlitz: new API failed; trying old API")
                content = self.cdn_api.GetContents(self.CDN_auth, filter_, ret)

            except Exception, e:
                logger.exception(e, "Could not get content")
コード例 #4
0
 def rm_content( self, content_id ):
    rc = None
    try:
       # try the new API (works with CoSFA)
       rc = self.cdn_api.Delete( self.CDN_auth, "Content", content_id )
       
    except Exception, e:
       traceback.print_exc()
       
       # possibly using the old API
       try:
          logger.warn("VerivueCoBlitz(rm_contet): new API failed; trying old API")
          rc = self.cdn_api.DeleteContent( self.CDN_auth, content_id )
       except Exception, e2:
          logger.exception( e2, "VerivueCoBlitz(rm_content): could not remove content '%s'" % content_id )
コード例 #5
0
    def setup(self, api):
        self.api = api

        self.CDN_auth = {
            "AuthMethod": "password",
            "Username": api.config.MD_CDN_USERNAME,
            "AuthString": api.config.MD_CDN_PASSWORD,
        }

        # read the SFA credential, if it exists
        try:
            credf = open(api.config.MD_SFA_CREDENTIAL)
            credstr = credf.read()
            credf.close()

            self.CDN_auth["SFA_DelegatedCred"] = credstr
        except:
            logger.warn("VerivueCoBlitz: no SFA credential given")

        rc = None

        # connect to the CMI
        self.cdn_api = xmlrpclib.ServerProxy(api.config.MD_CDN_API_URL,
                                             allow_none=True)

        # get our content provider struct
        try:
            self.content_provider = self.cdn_api.Read(
                self.CDN_auth, "ContentProvider",
                api.config.MD_CONTENT_PROVIDER)[0]
            rc = 1
        except Exception, e:
            try:
                logger.warn(
                    "VerivueCoBlitz(setup): new API failed; trying old API")
                self.content_provider = self.cdn_api.GetContentProviders(
                    self.CDN_auth,
                    {'account': api.config.MD_CONTENT_PROVIDER})[0]
                rc = 1
            except Exception, e2:
                logger.exception(
                    e2,
                    "VerivueCoBlitz(setup): could not look up SMDS CDN content provider account '%s'"
                    % api.config.MD_CONTENT_PROVIDER)
                rc = None
コード例 #6
0
    def rm_content(self, content_id):
        rc = None
        try:
            # try the new API (works with CoSFA)
            rc = self.cdn_api.Delete(self.CDN_auth, "Content", content_id)

        except Exception, e:
            traceback.print_exc()

            # possibly using the old API
            try:
                logger.warn(
                    "VerivueCoBlitz(rm_contet): new API failed; trying old API"
                )
                rc = self.cdn_api.DeleteContent(self.CDN_auth, content_id)
            except Exception, e2:
                logger.exception(
                    e2,
                    "VerivueCoBlitz(rm_content): could not remove content '%s'"
                    % content_id)
コード例 #7
0
ファイル: mdserver.py プロジェクト: scottjiang1415/syndicate
    def stop_server(self):
        # signal the controller on this metadata server's host to stop this metadata server
        old_status = self['status']
        self['status'] = 'stopped'

        server = self.api.connect_mdctl(self['host'])

        logger.info("Stopping metadata server '%s'" % self['name'])

        rc = 0
        try:
            as_dict = {}
            as_dict.update(self)
            rc = server.stop_server(as_dict)
            if rc == 0:
                logger.warn("Server '%s' was not running" % self['name'])
                rc = 1  # it's OK if it wasn't running

        except Exception, e:
            logger.exception(e, "Could not stop metadata server")
            rc = -500
コード例 #8
0
 def add_content( self, user, content_url ):
    content_info = {
       "url":                  content_url,
       "enabled":              True,
       "description":          "Created by SMDS",
       "content_provider_id":  self.content_provider['content_provider_id']
    }
    
    rc = None
    try:
       # try the new API (works with CoSFA)
       rc = self.cdn_api.Create( self.CDN_auth, "Content", content_info )
       
    except Exception, e:
       traceback.print_exc()
       # possibly using the old API
       try:
          logger.warn("VerivueCoBlitz(add_content): new API failed; trying old API")
          rc = self.cdn_api.AddContent( self.CDN_auth, content_info['content_provider_id'], content_info )
       except Exception, e2:
          logger.exception( e2, "VerivueCoBlitz(add_content): could not add content '%s'" % content_url )
コード例 #9
0
ファイル: mdserver.py プロジェクト: etherparty/syndicate
 def stop_server(self):
    # signal the controller on this metadata server's host to stop this metadata server
    old_status = self['status']
    self['status'] = 'stopped'
    
    server = self.api.connect_mdctl( self['host'] )
    
    logger.info("Stopping metadata server '%s'" % self['name'])
    
    rc = 0
    try:
       as_dict = {}
       as_dict.update( self )
       rc = server.stop_server( as_dict )
       if rc == 0:
          logger.warn( "Server '%s' was not running" % self['name'])
          rc = 1      # it's OK if it wasn't running
          
    except Exception, e:
       logger.exception( e, "Could not stop metadata server")
       rc = -500;
コード例 #10
0
 def setup(self, api):
    self.api = api
    
    self.CDN_auth = {
       "AuthMethod": "password",
       "Username": api.config.MD_CDN_USERNAME,
       "AuthString": api.config.MD_CDN_PASSWORD,
    }
    
    # read the SFA credential, if it exists
    try:
       credf = open(api.config.MD_SFA_CREDENTIAL)
       credstr = credf.read()
       credf.close()
       
       self.CDN_auth["SFA_DelegatedCred"] = credstr
    except:
       logger.warn("VerivueCoBlitz: no SFA credential given")
    
    rc = None
    
    # connect to the CMI
    self.cdn_api = xmlrpclib.ServerProxy( api.config.MD_CDN_API_URL, allow_none = True )
    
    # get our content provider struct
    try:
       self.content_provider = self.cdn_api.Read( self.CDN_auth, "ContentProvider", api.config.MD_CONTENT_PROVIDER )[0]
       rc = 1
    except Exception, e:
       try:
          logger.warn("VerivueCoBlitz(setup): new API failed; trying old API")
          self.content_provider = self.cdn_api.GetContentProviders( self.CDN_auth, {'account': api.config.MD_CONTENT_PROVIDER} )[0]
          rc = 1
       except Exception, e2:
          logger.exception(e2, "VerivueCoBlitz(setup): could not look up SMDS CDN content provider account '%s'" % api.config.MD_CONTENT_PROVIDER )
          rc = None
コード例 #11
0
ファイル: mdctl.py プロジェクト: scottjiang1415/syndicate
    users = []
    lineno = 0
    while True:
        line = sf.readline()
        lineno += 1

        if len(line) == 0:
            break

        line = line.strip()
        if len(line) == 0:
            continue

        parts = line.split(":")
        if len(parts) != 3:
            logger.warn("Invalid line %s in %s" % (lineno, secret_line))
            continue

        users.append(user_entry(int(parts[0]), parts[1], parts[2]))

    return users


def write_secrets_file(user_list, secrets_file):
    """
   Generate a secrets file from a list of user dictionaries.
   """

    # create the secrets file
    try:
        sf = open(secrets_file, "w")
コード例 #12
0
ファイル: mdctl.py プロジェクト: etherparty/syndicate
   users = []
   lineno = 0
   while True:
      line = sf.readline()
      lineno += 1
      
      if len(line) == 0:
         break

      line = line.strip()
      if len(line) == 0:
         continue

      parts = line.split(":")
      if len(parts) != 3:
         logger.warn("Invalid line %s in %s" % (lineno, secret_line))
         continue
         
      users.append( user_entry( int(parts[0]), parts[1], parts[2] ) )

   return users

   
   
def write_secrets_file( user_list, secrets_file ):
   """
   Generate a secrets file from a list of user dictionaries.
   """
   
   # create the secrets file
   try: