Example #1
0
 def setUp(self):
     logger.clear_dcm_logging()
     test_conf_path = test_utils.get_conf_file()
     self.conf_obj = config.AgentConfig([test_conf_path])
     self.test_base_path = tempfile.mkdtemp()
     self.db_path = os.path.join(self.test_base_path, "agentdb.db")
     self.db = persistence.SQLiteAgentDB(self.db_path)
Example #2
0
    def __init__(self, conf, job_id, items_map, name, arguments):
        super(AddUser, self).__init__(conf, job_id, items_map, name, arguments)

        self.ordered_param_list = [
            self.args.userId, self.args.userId, self.args.firstName,
            self.args.lastName,
            self.args.administrator.lower()
        ]
        self.ssh_public_key = self.args.authentication
        self._db = persistence.SQLiteAgentDB(conf.storage_dbfile)
Example #3
0
    def setUp(self):
        self.test_conf_path = \
            os.path.join(self.test_base_path, "etc", "agent.conf")
        self.conf_obj = config.AgentConfig([self.test_conf_path])
        self.svc = service.DCMAgent(self.conf_obj)

        self._event = threading.Event()

        utils.verify_config_file(self.conf_obj)
        # script_dir must be forced to None so that we get the built in dir
        self.svc.pre_threads()
        self.conf_obj.start_job_runner()

        self.disp = dispatcher.Dispatcher(self.conf_obj)

        self.req_conn = test_conn.RequestConnection()
        self.reply_conn = test_conn.ReplyConnection()

        self.db = persistence.SQLiteAgentDB(
            os.path.join(self.test_base_path, "etc", "agentdb.sql"))
        self.request_listener = reply.RequestListener(self.conf_obj,
                                                      self.reply_conn,
                                                      self.disp, self.db)
        observers = self.request_listener.get_reply_observers()
        observers.append(self)
        self.req_conn.set_request_listener(self.request_listener)

        self.agent_id = "theAgentID" + str(uuid.uuid4())
        self.customer_id = 50

        handshake_doc = {}
        handshake_doc["version"] = "1"
        handshake_doc["agentID"] = self.agent_id
        handshake_doc["cloudId"] = "Amazon"
        handshake_doc["customerId"] = self.customer_id
        handshake_doc["regionId"] = None
        handshake_doc["zoneId"] = "rack2"
        handshake_doc["serverId"] = "thisServer"
        handshake_doc["serverName"] = "dcm.testagent.com"
        handshake_doc["ephemeralFileSystem"] = "/tmp"
        handshake_doc["encryptedEphemeralFsKey"] = "DEADBEAF"

        self.svc.conn = self.reply_conn
        self.svc.disp = self.disp
        self.svc.request_listener = self.request_listener

        self.svc.handshaker.incoming_document({
            "handshake": handshake_doc,
            "return_code": 200
        })

        self.disp.start_workers(self.request_listener)
Example #4
0
 def __init__(self, conf):
     self.shutting_down = False
     self.conn = None
     self.conf = conf
     self.disp = None
     self.intrusion_detection = None
     self.request_listener = None
     self.g_logger = logging.getLogger(__name__)
     self._db = persistence.SQLiteAgentDB(conf.storage_dbfile)
     self.db_cleaner = None
     self.handshaker = handshake.HandshakeManager(self.conf, self._db)
     events.global_pubsub.subscribe(events.DCMAgentTopics.CLEANUP,
                                    self.clean_db_handler)
Example #5
0
 def setUp(self):
     self.db = persistence.SQLiteAgentDB(":memory:")
     self.conf = config.AgentConfig([])
Example #6
0
 def __init__(self, conf, job_id, items_map, name, arguments):
     super(CleanImage, self).__init__(conf, job_id, items_map, name,
                                      arguments)
     self._done_event = threading.Event()
     self._topic_error = None
     self._db = persistence.SQLiteAgentDB(conf.storage_dbfile)
Example #7
0
 def setUp(self):
     self.db = persistence.SQLiteAgentDB(":memory:")
Example #8
0
 def setUp(self):
     _, self.db_file = tempfile.mkstemp("test_db")
     self.db = persistence.SQLiteAgentDB(self.db_file)