def make_app(global_conf, full_stack=True, **app): app = make_base_app(global_conf, full_stack=True, **app) license_file = tg.config.get(stackone.core.utils.constants.license_file) try: init_firewall_for_all_csep() except Exception as e: print 'Error while ensuring firewall ', print e try: update_vm_status() except Exception as e: print 'Error while updating the vm status to None ', print e try: Basic.getImageStore().init_scan_dirs() except Exception as e: print 'Error while scanning the image store ', print e try: populate_custom_fence_resources(Basic.getManagedNode(), True) except Exception as e: print 'Error while populating custom fence resources ', print e try: reset_transient_state() except Exception as e: print 'Error while resetting the state ', print e try: storage_stats_data_upgrade() except Exception as e: print 'Error while recomputing storage stats ', print e try: unreserve_disks_on_cms_start() except Exception as e: print 'Error while unreserving storage disks ', print e sc = ServiceCentral(zopelessmaker) sc.start() atexit.register(sc.quit) base_config.stackone_service_central = sc MetricsService().init_mappers() #Node.use_bash_timeout = eval(tg.config.get('use_bash_timeout')) Node.default_bash_timeout = tg.config.get('bash_default_timeout') Node.bash_dir = os.path.join(tg.config.get('stackone_cache_dir'), 'common/scripts') Node.local_bash_dir = tg.config.get('common_script') try: add_deployment_stats_task() except Exception,ex: print 'Error while adding deployment stats task' print ex
def __init__(self): self.manager = Basic.getGridManager() self.storage_manager = StorageManager() self.backup_manager = BackupManager()
def __init__(self): self.manager = Basic.getGridManager()
def import_vcenter_templates(self, auth, node_id, dc_id, vcenter_id, dc): from stackone.viewModel import Basic from stackone.model.ManagedNode import ManagedNode from stackone.model.ImageStore import VcenterImage, VcenterImageGroup, ImageStore import transaction image_store = Basic.getImageStore() registry = Basic.getPlatformRegistry() msg = '' dcname = dc.get('name') dc_moid = dc.get('moid') dc_actual_name = dc.get('actual_name') mnode = DBSession.query(ManagedNode).filter(ManagedNode.id == node_id).first() if not mnode: msg += '\nCould not find Server with ID:%s' % node_id raise Exception(msg) msg += '\nImporting Templates from Server: %s' % mnode.hostname templates = self.vcenter_manager.get_templates_from_host(mnode) temp_lib_ent = None dc_ent = auth.get_entity(dc_id) if not dc_ent: msg += '\nCould not find Datacenter' raise Exception(msg) temp_lib_ents = auth.get_child_entities_by_type(dc_ent, constants.IMAGE_STORE) TemplateLibrary_Name = dcname + '_TemplateLibrary' if temp_lib_ents: temp_lib_ent = temp_lib_ents[0] else: msg += '\nCreating Vcenter TemplateLibrary %s' % TemplateLibrary_Name vimage_store = image_store.create_vcenter_templateLib(registry, TemplateLibrary_Name) DBSession.add(vimage_store) transaction.commit() temp_lib_ent = auth.add_entity(vimage_store.name, vimage_store.id, to_unicode(constants.IMAGE_STORE), dc_ent) if not temp_lib_ent: msg += '\nCould not find Vcenter Template Library' raise Exception(msg) img_gp_ent = auth.get_entity_by_entity_attributes(self.get_entity_attributes_dict(external_manager_id=vcenter_id, external_id=dc_moid), entityType=to_unicode(constants.IMAGE_GROUP)) if not img_gp_ent: msg += '\nCreating Image Group %s' % dcname img_gp = image_store.create_vcenter_image_group(dcname) DBSession.add(img_gp) cntx = {'external_manager_id': vcenter_id, 'external_id': dc_moid} img_gp_ent = self.vcenter_manager.add_vcenter_entity(auth, cntx, img_gp.name, img_gp.id, to_unicode(constants.IMAGE_GROUP), temp_lib_ent) else: img_gp = DBSession.query(VcenterImageGroup).filter(VcenterImageGroup.id == img_gp_ent.entity_id).first() img_gp.name = dcname DBSession.add(img_gp) msg += '\nImage Group %s already exist' % dcname for template in templates: img_name = template.config.name moid = self.get_moid(template) img_ent = auth.get_entity_by_entity_attributes(self.get_entity_attributes_dict(external_manager_id=vcenter_id, external_id=moid), entityType=to_unicode(constants.IMAGE)) if not img_ent: image = image_store.create_image_instance(img_name, constants.VCENTER) msg += '\nCreated Image:%s' % img_name else: image = DBSession.query(VcenterImage).filter(VcenterImage.name == img_name).first() msg += '\nUpdating Image:%s' % img_name vm_config = image.get_vm_config(mnode) image_config = image.get_image_config(vm_config) vm_config['dc_actual_name'] = dc_actual_name vm_config['dc_name'] = dcname vm_config['external_manager_id'] = vcenter_id image.vm_config = get_config_text(vm_config) image.image_config = get_config_text(image_config) DBSession.add(image) if not img_ent: cntx = {'external_manager_id': vcenter_id, 'external_id': moid} self.vcenter_manager.add_vcenter_entity(auth, cntx, img_name, image.id, to_unicode(constants.IMAGE), img_gp_ent) continue import transaction transaction.commit() print '#UIUpdateManager: Updating Entities' UIUpdateManager().set_updated_entities(img_gp_ent.entity_id) return msg