def test_lab(self, lab_id, lab_src_url, revision_tag=None):
     Logging.LOGGER.debug("Controller.test_lab() for lab ID %s and git url %s" \
                         % (lab_id, lab_src_url))
     try:
         lab_spec = LabManager.get_lab_reqs(lab_id, lab_src_url, revision_tag)
         self.update_lab_spec(lab_spec, lab_id, lab_src_url, revision_tag)
         if lab_spec['lab']['runtime_requirements']['hosting'] == 'dedicated':
            """ TODO: Undeploy , fnd proper place to invoke undeploy""" 
            self.undeploy_lab(lab_id)
         vmpoolmgr = VMPoolManager.VMPoolManager()
         Logging.LOGGER.debug("Controller: test_lab(); invoking create_vm() on vmpoolmgr")
         lab_state = vmpoolmgr.create_vm(lab_spec)
         Logging.LOGGER.debug("Controller: test_lab(): Returned from VMPool = %s" % (str(lab_state)))
         ip = lab_state['vm_info']['vm_ip']
         port = lab_state['vm_info']['vmm_port']
         vmmgrurl = "http://" + ip
         Logging.LOGGER.debug("Controller: test_lab(): vmmgrurl = %s" % (vmmgrurl))
         try:
             (ret_val, ret_str) = LabManager.test_lab(vmmgrurl, port, lab_src_url, revision_tag)
             if(ret_val):
                 self.update_state(lab_state)
                 Logging.LOGGER.info("Controller: test_lab(): test succcessful")
                 return ip
             else:
                 Logging.LOGGER.error("Controller: test_lab(); Test failed with error:" + str(ret_str))
                 return "Test failed: See log file for errors"
         except Exception, e:
             Logging.LOGGER.error("Controller: test_lab(); Test failed with error: " + str(e))
             return "Test failed: See log file for errors"
             """ TODO: Garbage collection clean up for the created VM """ 
         finally:
             self.system.save()
Esempio n. 2
0
 def test_lab(self, lab_id, lab_src_url, revision_tag=None):
     Logging.LOGGER.debug("Controller.test_lab() for lab ID %s and git url %s" \
                         % (lab_id, lab_src_url))
     try:
         lab_spec = LabManager.get_lab_reqs(lab_id, lab_src_url, revision_tag)
         self.update_lab_spec(lab_spec, lab_id, lab_src_url, revision_tag)
         if lab_spec['lab']['runtime_requirements']['hosting'] == 'dedicated':
             self.undeploy_lab(lab_id)
         vmpoolmgr = VMPoolManager.VMPoolManager()
         lab_state = vmpoolmgr.create_vm(lab_spec)
         ip = lab_state['vm_info']['vm_ip']
         port = lab_state['vm_info']['vmm_port']
         vmmgrurl = "http://" + ip
         try:
             if LabManager.test_lab(vmmgrurl, port, lab_src_url, revision_tag):
                 self.update_state(lab_state)
                 Logging.LOGGER.info("Controller.test_lab: test succcessful")
                 return ip
             elif LabManager.test_lab(vmmgrurl, port, lab_src_url, revision_tag):
                 self.update_state(lab_state)
                 Logging.LOGGER.info("Controller.test_lab: test succcessful")
                 return ip
             else:
                 Logging.LOGGER.error("Test failed")
                 return "Test failed: See log file for errors"
         except Exception, e:
             Logging.LOGGER.error("Test failed with error: " + str(e))
             return "Test failed: See log file for errors"
         finally:
             self.system.save()
Esempio n. 3
0
 def test_lab(self, lab_id, lab_src_url, revision_tag=None):
     Logging.LOGGER.debug("Controller.test_lab() for lab ID %s and git url %s" \
                         % (lab_id, lab_src_url))
     try:
         lab_spec = LabManager.get_lab_reqs(lab_id, lab_src_url,
                                            revision_tag)
         self.update_lab_spec(lab_spec, lab_id, lab_src_url, revision_tag)
         if lab_spec['lab']['runtime_requirements'][
                 'hosting'] == 'dedicated':
             """ TODO: Undeploy , fnd proper place to invoke undeploy"""
             self.undeploy_lab(lab_id)
         vmpoolmgr = VMPoolManager.VMPoolManager()
         Logging.LOGGER.debug(
             "Controller: test_lab(); invoking create_vm() on vmpoolmgr")
         lab_state = vmpoolmgr.create_vm(lab_spec)
         Logging.LOGGER.debug(
             "Controller: test_lab(): Returned from VMPool = %s" %
             (str(lab_state)))
         ip = lab_state['vm_info']['vm_ip']
         port = lab_state['vm_info']['vmm_port']
         vmmgrurl = "http://" + ip
         Logging.LOGGER.debug("Controller: test_lab(): vmmgrurl = %s" %
                              (vmmgrurl))
         try:
             (ret_val,
              ret_str) = LabManager.test_lab(vmmgrurl, port, lab_src_url,
                                             revision_tag)
             if (ret_val):
                 self.update_state(lab_state)
                 Logging.LOGGER.info(
                     "Controller: test_lab(): test succcessful")
                 return ip
             else:
                 Logging.LOGGER.error(
                     "Controller: test_lab(); Test failed with error:" +
                     str(ret_str))
                 return "Test failed: See log file for errors"
         except Exception, e:
             Logging.LOGGER.error(
                 "Controller: test_lab(); Test failed with error: " +
                 str(e))
             return "Test failed: See log file for errors"
             """ TODO: Garbage collection clean up for the created VM """
         finally:
             self.system.save()
Esempio n. 4
0
def get_lab_spec(repo_name, GIT_CLONE_LOC, lab_src_url, LAB_SPEC_LOC, source):
    Logging.LOGGER.error("%s: get_lab_spec(); repo_name = %s" %
                         (source, repo_name))
    # Allow no lab spec but not an invalid json as a lab spec
    spec_path = GIT_CLONE_LOC + repo_name + LAB_SPEC_LOC
    if not os.path.exists(spec_path):
        Logging.LOGGER.error("%s: get_lab_spec(); Lab spec file not found" %
                             (source))
        raise Lab.ManagerLabSpecInvalid("Lab spec file not found")
    try:
        return json.loads(open(spec_path).read())
    except Exception, e:
        Logging.LOGGER.error("%s: get_lab_spec(); Lab spec JSON invalid: %s " %
                             ((source) + str(e), spec_path))
        raise LabManager.LabSpecInvalid("Lab spec JSON invalid: " + str(e))
Esempio n. 5
0
 def test_lab(self, lab_id, lab_src_url, revision_tag=None):
     Logging.LOGGER.debug("Controller.test_lab() for lab ID %s and git url %s" \
                         % (lab_id, lab_src_url))
     try:
         lab_spec = LabManager.get_lab_reqs(lab_id, lab_src_url,
                                            revision_tag)
         self.update_lab_spec(lab_spec, lab_id, lab_src_url, revision_tag)
         if lab_spec['lab']['runtime_requirements'][
                 'hosting'] == 'dedicated':
             self.undeploy_lab(lab_id)
         vmpoolmgr = VMPoolManager.VMPoolManager()
         lab_state = vmpoolmgr.create_vm(lab_spec)
         ip = lab_state['vm_info']['vm_ip']
         port = lab_state['vm_info']['vmm_port']
         vmmgrurl = "http://" + ip
         try:
             if LabManager.test_lab(vmmgrurl, port, lab_src_url,
                                    revision_tag):
                 self.update_state(lab_state)
                 Logging.LOGGER.info(
                     "Controller.test_lab: test succcessful")
                 return ip
             elif LabManager.test_lab(vmmgrurl, port, lab_src_url,
                                      revision_tag):
                 self.update_state(lab_state)
                 Logging.LOGGER.info(
                     "Controller.test_lab: test succcessful")
                 return ip
             else:
                 Logging.LOGGER.error("Test failed")
                 return "Test failed: See log file for errors"
         except Exception, e:
             Logging.LOGGER.error("Test failed with error: " + str(e))
             return "Test failed: See log file for errors"
         finally:
             self.system.save()
Esempio n. 6
0
clientID = os.environ['CLIENT_ID']
clientSecret = os.environ['CLIENT_SECRET']
veritoken = os.environ['VERIFY_TOKEN']
commandSalt = os.environ['COMMAND_SALT']
agentSalt = os.environ['AGENT_SALT']

# Dictionary of SlackClients stored by TeamID
clientDictionary = {}

# Plugin objects
dante = DantesUpdater.Dantes_Updater()
user = UserManager.UserManager()
infra = InfraManager.InfraManager()
update = Updater.Updater()
status = StatusManager.StatusManager()
lab = LabManager.LabManager()

commandDict = {
        'dante':dante,
        'infra':infra,
        'user':user,
        'update':update,
        'agent':AgentManager,
        'status':status,
        'lab':lab
        }

# Encoder objects
commandHashids = Hashids(salt=commandSalt)
agentHashids = Hashids(salt=agentSalt)