Esempio n. 1
0
def create_table_and_exit():
    from users import UserModel
    from analytics.SendToRemarkableRequestModel import SendToRemarkableRequestModel

    if not UserModel.exists():
        UserModel.create_table(wait=True)
    if not SendToRemarkableRequestModel.exists():
        SendToRemarkableRequestModel.create_table(wait=True)
    exit(0)
Esempio n. 2
0
    def __init__(self):
        objstore_loc = config.get_object_store() + '_ginger'
        self._objstore = ObjectStore(objstore_loc)

        sub_models = []
        firmware = FirmwareModel()
        powerprofiles = PowerProfilesModel()
        powerprofile = PowerProfileModel()
        users = UsersModel()
        user = UserModel()
        interfaces = InterfacesModel()
        interface = InterfaceModel()
        network = NetworkModel()
        archives = ArchivesModel(objstore=self._objstore)
        archive = ArchiveModel(objstore=self._objstore)
        backup = BackupModel(objstore=self._objstore,
                             archives_model=archives,
                             archive_model=archive)
        san_adapters = SanAdaptersModel()
        san_adapter = SanAdapterModel()
        sensors = SensorsModel()
        ibm_sep = SepModel()

        features = [
            firmware, backup, network, powerprofiles, san_adapters, sensors,
            ibm_sep, users
        ]
        capabilities = CapabilitiesModel(features)

        sub_models = [
            backup, archives, archive, firmware, interfaces, interface,
            network, powerprofiles, powerprofile, users, user, san_adapters,
            san_adapter, sensors, ibm_sep, capabilities
        ]
        super(GingerModel, self).__init__(sub_models)
Esempio n. 3
0
    def __init__(self):
        objstore_loc = config.get_object_store() + '_ginger'
        self._objstore = ObjectStore(objstore_loc)

        sub_models = []
        firmware = FirmwareModel()
        powerprofiles = PowerProfilesModel()
        powerprofile = PowerProfileModel()
        users = UsersModel()
        user = UserModel()
        interfaces = InterfacesModel()
        interface = InterfaceModel()
        cfginterface = CfginterfaceModel()
        cfginterfaces = CfginterfacesModel()
        dasddevs = DASDdevsModel()
        dasddev = DASDdevModel(objstore=self._objstore)
        dasdpartitions = DASDPartitionsModel()
        dasdpartition = DASDPartitionModel()
        network = NetworkModel()
        filesystems = FileSystemsModel()
        filesystem = FileSystemModel()
        archives = ArchivesModel(objstore=self._objstore)
        archive = ArchiveModel(objstore=self._objstore)
        backup = BackupModel(objstore=self._objstore,
                             archives_model=archives,
                             archive_model=archive)
        san_adapters = SanAdaptersModel()
        san_adapter = SanAdapterModel()
        sensors = SensorsModel()
        ibm_sep = SepModel()
        subscription = SubscriptionModel()
        subscriber = SubscribersModel()

        features = [
            firmware, backup, dasddevs, dasdpartitions, network, powerprofiles,
            san_adapters, sensors, ibm_sep, users, filesystems
        ]
        capabilities = CapabilitiesModel(features)

        sub_models = [
            backup, archives, archive, firmware, interfaces, interface,
            cfginterface, cfginterfaces, dasddevs, dasddev, dasdpartitions,
            dasdpartition, network, filesystems, filesystem, powerprofiles,
            powerprofile, users, user, san_adapters, san_adapter, sensors,
            ibm_sep, subscription, subscriber, capabilities
        ]
        super(GingerModel, self).__init__(sub_models)
Esempio n. 4
0
class NoticeModel(ModelBase):
	def __init__(self):
		self.name = "notices"
		self.users = UserModel()
		super(NoticeModel, self).__init__()

	def add_notice(self, data):
		notice = {
					"content": data["content"],
					"publisher": ModelBase.get_oid(data["publisher"]),
					"create_date": datetime.utcnow(),
					"invalid_date": datetime.utcnow() + timedelta(days = int(data["life"]))
				}	
		return str(self.collection.insert(notice))
	
	def to_user(self, notice):
		user_id = str(notice["publisher"])
		user = self.users.get_one(user_id)
		notice["publisher"] = user["name"]
		notice["create_date"] = notice["create_date"].strftime('%Y-%m-%d')
		notice["invalid_date"] = notice["invalid_date"].strftime('%Y-%m-%d')
		return notice

	def get_one(self, notice_id):
		notice = self.collection.find_one(ModelBase.get_oid(notice_id))
		notice = self.to_user(notice)
		return ModelBase.transform_id(notice)

	def get_all(self):
		cursor = self.collection.find().sort("create_date", -1)
		notice_list = ModelBase.cursor2list(cursor)
		return [self.to_user(notice) for notice in notice_list]

	def get_effective(self):
		cursor = self.collection.find(invalid_date = {'$gte': datetime.utcnow()}).sort("create_date", -1)
		notice_list = ModelBase.cursor2list(cursor)
		return [self.to_user(notice) for notice in notice_list]
Esempio n. 5
0
COMMON_SEQUENCES = [
    "0123456789",
    "`1234567890-=",
    "~!@#$%^&*()_+",
    "abcdefghijklmnopqrstuvwxyz",
    "qwertyuiop[]\\asdfghjkl;\'zxcvbnm,./",
    'qwertyuiop{}|asdfghjkl;"zxcvbnm<>?',
    "qwertyuiopasdfghjklzxcvbnm",
    "1qaz2wsx3edc4rfv5tgb6yhn7ujm8ik,9ol.0p;/-['=]\\",
    "qazwsxedcrfvtgbyhnujmikolp",
    "qwertzuiopü+asdfghjklöä#<yxcvbnm,.-",
    "qwertzuiopü*asdfghjklöä'>yxcvbnm;:_",
    "qaywsxedcrfvtgbzhnujmikolp",
]

User = UserModel()
PASSWORD_MIN_LENGTH = 6
PASSWORD_MAX_LENGTH = 15
PASSWORD_DICTIONARY = None
PASSWORD_MATCH_THRESHOLD = 0.9
PASSWORD_COMMON_SEQUENCES = COMMON_SEQUENCES
PASSWORD_COMPLEXITY = {  # You can omit any or all of these for no limit for that particular set
    "UPPER": 0,  # Uppercase
    "LOWER": 0,  # Lowercase
    "LETTERS": 1,  # Either uppercase or lowercase letters
    "DIGITS": 0,  # Digits
    "PUNCTUATION": 0,  # Punctuation (string.punctuation)
    #"SPECIAL": 1,      # Not alphanumeric, space or punctuation character
    "WORDS":
    0  # Words (alphanumeric sequences separated by a whitespace or punctuation character)
}
Esempio n. 6
0
	def __init__(self):
		self.name = "notices"
		self.users = UserModel()
		super(NoticeModel, self).__init__()
Esempio n. 7
0
def create_table_and_exit():
    from users import UserModel
    if not UserModel.exists():
        UserModel.create_table(wait=True)
    exit(0)