예제 #1
0
 def __init__(self, host, proxy=None):
     super().__init__()
     logging.debug('contractor: connecting...')
     self.cinp = client.CInP(host, '/api/v1/', proxy)
     root = self.cinp.describe('/api/v1/')
     if root['api-version'] != CONTRACTOR_API_VERSION:
         raise Exception('Expected API version "{0}" found "{1}"'.format(
             CONTRACTOR_API_VERSION, root['api-version']))
예제 #2
0
    def __init__(self, host, proxy, name, psk):
        self.name = name
        self.cinp = client.CInP(host, '/api/v1/', proxy)

        root = self.cinp.describe('/api/v1/Repo')
        if root['api-version'] != PACKRAT_API_VERSION:
            raise Exception('Expected API version "{0}" found "{1}"'.format(
                PACKRAT_API_VERSION, root['api-version']))
예제 #3
0
파일: MCP.py 프로젝트: pnhowe/MCP-agent
  def __init__( self, host, proxy, job_id, instance_id, cookie, stop_event ):
    self.cinp = client.CInP( host, '/api/v1/', proxy, retry_event=stop_event )
    self.job_id = job_id
    self.instance_id = instance_id
    self.cookie = cookie

    root, _ = self.cinp.describe( '/api/v1/', retry_count=30 )  # very tollerant for the initial describe, let things settle

    if root[ 'api-version' ] not in MCP_API_VERSIONS:
      raise Exception( 'Expected API version (one of) "{0}" found "{1}"'.format( MCP_API_VERSIONS, root[ 'api-version' ] ) )
예제 #4
0
    def __init__(self, host, username, password, proxy):
        self.cinp = client.CInP(host, '/api/v2/', proxy)

        root = self.cinp.describe('/api/v2/')
        if root['api-version'] != PACKRAT_API_VERSION:
            raise Exception('Expected API version "{0}" found "{1}"'.format(
                PACKRAT_API_VERSION, root['api-version']))

        self.token = self.cinp.call('/api/v2/Auth/User(login)', {
            'username': username,
            'password': password
        })
        self.cinp.setAuth(username, self.token)
예제 #5
0
    def __init__(self, host, proxy, username, password):
        super().__init__()
        self.username = username
        self.cinp = client.CInP(host, '/api/v1/', proxy)

        root, _ = self.cinp.describe('/api/v1/', retry_count=10)
        if root['api-version'] != CONTRACTOR_API_VERSION:
            raise Exception('Expected API version "{0}" found "{1}"'.format(
                CONTRACTOR_API_VERSION, root['api-version']))

        self.token = self.cinp.call('/api/v1/Auth/User(login)', {
            'username': self.username,
            'password': password
        },
                                    retry_count=10)
        self.cinp.setAuth(username, self.token)
예제 #6
0
  def __init__( self, host, proxy, name, psk ):
    super().__init__()

    try:
      os.makedirs( DOWNLOAD_TMP_DIR )
    except OSError as e:
      if e.errno == errno.EEXIST and os.path.isdir( DOWNLOAD_TMP_DIR ):
        pass
      else:
        raise e

    self.cinp = client.CInP( host, '/api/v2/', proxy )
    # self.token = self.cinp.call( '/api/v1/Auth(login)', { 'username': name, 'password': psk } )[ 'value' ]
    # self.cinp.setAuth( name, self.token )
    # self.keepalive = KeepAlive( self.cinp )
    # self.keepalive.start()
    self.name = name
    root = self.cinp.describe( '/api/v2/' )
    if root[ 'api-version' ] != PACKRAT_API_VERSION:
      raise PackratException( 'Expected API version "{0}" found "{1}"'.format( PACKRAT_API_VERSION, root[ 'api-version' ] ) )