def run(self): banner("Install Cloudmesh Management") obj = Mongo() obj.check_mongo() get_mongo_db("manage", DBConnFactory.TYPE_MONGOENGINE) install.run(self) banner("Adding Super User") users = Users() found = User.objects(username='******') if not found: data = User( status="approved", title="None", firstname="Super", lastname="User", email="*****@*****.**", username="******", active=True, password=sha256_crypt.encrypt("MyPassword"), phone="555-555-5555", department="IT", institution="IU", institutionrole="Other", address="IU", country="United States(US)", citizenship="United States(US)", bio="Manage Project Committee", url="http://cloudmesh.github.io/cloudmesh.html", advisor="None", confirm=sha256_crypt.encrypt("MyPassword"), projects=[], ) users.add(data)
def main(): from cloudmesh_database.dbconn import get_mongo_db, get_mongo_dbname_from_collection, DBConnFactory # this returns a mongoengine connection to the db of the 'experiment' collection (from yaml config) conn1 = get_mongo_db("experiment", DBConnFactory.TYPE_MONGOENGINE) print(conn1) # this returns a pymongo collection for 'pbs' conn2 = get_mongo_db("pbs") print(conn2)
def main(): from cloudmesh_database.dbconn import get_mongo_db, get_mongo_dbname_from_collection, DBConnFactory # this returns a mongoengine connection to the db of the 'experiment' collection (from yaml config) conn1 = get_mongo_db("experiment", DBConnFactory.TYPE_MONGOENGINE) print (conn1) # this returns a pymongo collection for 'pbs' conn2 = get_mongo_db("pbs") print (conn2)
def setup(self): # HEADING() db_name = get_mongo_dbname_from_collection("manage") if db_name: meta = {'db_alias': db_name} obj = Mongo() obj.check_mongo() get_mongo_db("manage", DBConnFactory.TYPE_MONGOENGINE) pass
def main(): # # this returns a mongoengine connection to the db of the 'experiment' collection (from yaml config) # The db has to exist and be initiated before connection # get_mongo_db("example", DBConnFactory.TYPE_MONGOENGINE) # delete all entries. Use with cautious ExampleRecord.objects().delete() # sample data to populate citycountry = [{ 'city': 'New York', 'country': 'US' }, { 'city': 'Beijing', 'country': 'China' }, { 'city': 'Los Angeles', 'country': 'US' }, { 'city': 'London', 'country': 'UK' }, { 'city': 'Shanghai', 'country': 'China' }] # populate the db for entry in citycountry: arecord = ExampleRecord(city=entry['city'], country=entry['country'], description='a city with so many people') # this saves the record arecord.save() # query all records in the db that are 'ExampleRecord' object allrecords = ExampleRecord.objects() print("\nAll records in db") print("-" * 80) for arecord in allrecords: print('city:%s\t|country:%s' % (arecord.city, arecord.country)) print('\tdescription:%s' % arecord.description) # query with condition somerecords = ExampleRecord.objects(country='US') print("\nUS cities in db") print("-" * 80) for arecord in somerecords: print('city:%s\t|country:%s' % (arecord.city, arecord.country)) print('\tdescription:%s' % arecord.description)
def get_current_user_role(): filename = path_expand("~/.cloudmesh/{0}/{1}".format("accounts", ".config")) with open(filename, 'r') as yamlfile: cfg = yaml.load(yamlfile) username = cfg['user'] db_name = get_mongo_dbname_from_collection("manage") if db_name: meta = {'db_alias': db_name} ## ## obj = Mongo() obj.check_mongo() ## ## get_mongo_db("manage", DBConnFactory.TYPE_MONGOENGINE) found = User.objects(username=username).only('roles').first() return found.roles pass
def main(): # # this returns a mongoengine connection to the db of the 'experiment' collection (from yaml config) # The db has to exist and be initiated before connection # get_mongo_db("example", DBConnFactory.TYPE_MONGOENGINE) # delete all entries. Use with cautious ExampleRecord.objects().delete() # sample data to populate citycountry = [{'city':'New York', 'country':'US'}, {'city':'Beijing', 'country':'China'}, {'city':'Los Angeles', 'country':'US'}, {'city':'London', 'country':'UK'}, {'city':'Shanghai', 'country':'China'}] # populate the db for entry in citycountry: arecord = ExampleRecord(city=entry['city'], country=entry['country'], description='a city with so many people') # this saves the record arecord.save() # query all records in the db that are 'ExampleRecord' object allrecords = ExampleRecord.objects() print "\nAll records in db" print "-"*80 for arecord in allrecords: print 'city:%s\t|country:%s' % (arecord.city, arecord.country) print '\tdescription:%s' % arecord.description # query with condition somerecords = ExampleRecord.objects(country='US') print "\nUS cities in db" print "-"*80 for arecord in somerecords: print 'city:%s\t|country:%s' % (arecord.city, arecord.country) print '\tdescription:%s' % arecord.description
from cloudmesh_database.dbconn import get_mongo_db, DBConnFactory from cloudmesh_management.project import Projects from cloudmesh_management.user import Users from cloudmesh_management.base_user import User from cloudmesh_management.base_project import Project from cmd3.console import Console from faker import Factory from pprint import pprint from passlib.hash import sha256_crypt import uuid from cloudmesh_base.util import banner from cloudmesh_management.mongo import Mongo obj = Mongo() obj.check_mongo() get_mongo_db("manage", DBConnFactory.TYPE_MONGOENGINE) # -------------------------------------------- # The generate class generates 10 random users # -------------------------------------------- users = Users() projects = Projects() # http://www.joke2k.net/faker fake = Factory.create() def random_user(): """
def __init__(self): obj = Mongo() obj.check_mongo() get_mongo_db("manage", DBConnFactory.TYPE_MONGOENGINE)
from cloudmesh_management.project import Projects from cloudmesh_management.user import Users from cloudmesh_management.base_user import User from cloudmesh_management.base_project import Project from cmd3.console import Console from faker import Factory from pprint import pprint from passlib.hash import sha256_crypt import uuid from cloudmesh_base.util import banner from cloudmesh_management.mongo import Mongo obj = Mongo() obj.check_mongo() get_mongo_db("manage", DBConnFactory.TYPE_MONGOENGINE) # -------------------------------------------- # The generate class generates 10 random users # -------------------------------------------- users = Users() projects = Projects() # http://www.joke2k.net/faker fake = Factory.create() def random_user(): """
def __init__(self): obj = Mongo() obj.check_mongo() get_mongo_db("manage", DBConnFactory.TYPE_MONGOENGINE) self.projects = Project.objects() self.users = User.objects()