本文整理汇总了Python中service.accounts.openstack.AccountDriver.hashpass方法的典型用法代码示例。如果您正苦于以下问题:Python AccountDriver.hashpass方法的具体用法?Python AccountDriver.hashpass怎么用?Python AccountDriver.hashpass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类service.accounts.openstack.AccountDriver
的用法示例。
在下文中一共展示了AccountDriver.hashpass方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from service.accounts.openstack import AccountDriver [as 别名]
# 或者: from service.accounts.openstack.AccountDriver import hashpass [as 别名]
def main():
"""
Generate openstack users then add them to the DB
"""
driver = AccountDriver(secrets.OPENSTACK_ARGS)
#Build the admin driver for openstack first.
driver.create_identity(secrets.OPENSTACK_ADMIN_KEY,
secrets.OPENSTACK_ADMIN_SECRET, secrets.OPENSTACK_ADMIN_TENANT,
True)
success = 1
#Add the others
core_services = ['atmo_test']#'sgregory', 'jmatt', 'edwins', 'cjlarose','mlent']
for username in core_services:
try:
password = driver.hashpass(username)
user = driver.get_user(username)
if not user:
user = driver.create_user(username, usergroup=True)
print 'New OStack User - %s Pass - %s' % (user.name,password)
else:
print 'Found OStack User - %s Pass - %s' % (user.name,password)
#ASSERT: User exists on openstack, create an identity for them.
ident = driver.create_identity(user.name, password, project_name=username)
success += 1
print 'New OStack Identity - %s:%s' % (ident.id, ident)
except Exception as e:
print "Problem adding username: %s" % username
print e
raise
print "Total users created:%s/%s" % (success,len(core_services))
示例2: setUp
# 需要导入模块: from service.accounts.openstack import AccountDriver [as 别名]
# 或者: from service.accounts.openstack.AccountDriver import hashpass [as 别名]
def setUp(self):
#Initialize core DB
#Ensure there is an account created/ready to go
#self.euca_admin_id = create_euca_provider()
#self.euca_provider = self.euca_admin_id.provider
#euca_accounts = EucaAccounts(self.euca_provider)
#euca_user = euca_accounts.get_user(settings.TEST_RUNNER_USER)
#self.euca_id = euca_accounts.create_account(euca_user, max_quota=True)
self.os_admin_id = create_os_provider()
self.os_provider = self.os_admin_id.provider
os_accounts = OSAccounts(self.os_provider)
self.os_id = os_accounts.create_account(
settings.TEST_RUNNER_USER,
os_accounts.hashpass(settings.TEST_RUNNER_USER), max_quota=True)
user = AtmosphereUser.objects.get(username=settings.TEST_RUNNER_USER)
user.is_staff = True
user.is_superuser = True
user.save()
#Initialize API
self.api_client = TokenAPIClient()
self.api_client.login(
username=settings.TEST_RUNNER_USER,
password=settings.TEST_RUNNER_PASS)
reverse_link = reverse('api:v1:instance-list',
args=[self.os_id.provider.id,
self.os_id.id])
self.os_instance_url = urljoin(settings.SERVER_URL, reverse_link)
reverse_link = reverse('api:v1:machine-request-list',
args=[self.os_id.provider.id,
self.os_id.id])
self.os_request_url = urljoin(settings.SERVER_URL, reverse_link)
示例3: setUp
# 需要导入模块: from service.accounts.openstack import AccountDriver [as 别名]
# 或者: from service.accounts.openstack.AccountDriver import hashpass [as 别名]
def setUp(self):
#Initialize core DB
self.euca_admin_id = create_euca_provider()
self.euca_provider = self.euca_admin_id.provider
self.os_admin_id = create_os_provider()
self.os_provider = self.os_admin_id.provider
#Ensure there is an account created/ready to go
euca_accounts = EucaAccounts(self.euca_provider)
euca_user = euca_accounts.get_user(settings.TEST_RUNNER_USER)
self.euca_id = euca_accounts.create_account(euca_user)
os_accounts = OSAccounts(self.os_provider)
self.os_id = os_accounts.create_account(
settings.TEST_RUNNER_USER,
os_accounts.hashpass(settings.TEST_RUNNER_USER))
#Initialize API
self.api_client = TokenAPIClient()
self.api_client.login(
username=settings.TEST_RUNNER_USER,
password=settings.TEST_RUNNER_PASS)
reverse_link = reverse('api:public_apis:machine-list',
args=[self.os_id.provider.id,
self.os_id.id])
self.os_machine_url = urljoin(settings.SERVER_URL, reverse_link)
reverse_link = reverse('api:public_apis:machine-list',
args=[self.euca_id.provider.id,
self.euca_id.id])
self.euca_machine_url = urljoin(settings.SERVER_URL, reverse_link)
示例4: setUp
# 需要导入模块: from service.accounts.openstack import AccountDriver [as 别名]
# 或者: from service.accounts.openstack.AccountDriver import hashpass [as 别名]
def setUp(self):
#Initialize core DB
self.euca_admin_id = create_euca_provider()
self.euca_provider = self.euca_admin_id.provider
self.os_admin_id = create_os_provider()
self.os_provider = self.os_admin_id.provider
#Ensure there is an account created/ready to go
euca_accounts = EucaAccounts(self.euca_provider)
euca_user = euca_accounts.get_user(settings.TEST_RUNNER_USER)
self.euca_id = euca_accounts.create_account(euca_user, max_quota=True)
os_accounts = OSAccounts(self.os_provider)
self.os_id = os_accounts.create_account(
settings.TEST_RUNNER_USER,
os_accounts.hashpass(settings.TEST_RUNNER_USER), max_quota=True)
#user = AtmosphereUser.objects.get(username=settings.TEST_RUNNER_USER)
#user.is_staff = True
#user.is_superuser = True
#user.save()
#Initialize API
self.api_client = TokenAPIClient()
self.api_client.login(
username=settings.TEST_RUNNER_USER,
password=settings.TEST_RUNNER_PASS)
reverse_link = reverse('api:public_apis:instance-list',
args=[self.os_id.provider.id,
self.os_id.id])
self.os_instance_url = urljoin(settings.SERVER_URL, reverse_link)
reverse_link = reverse('api:public_apis:volume-list',
args=[self.os_id.provider.id,
self.os_id.id])
#Prepare Openstack
self.os_volume_url = urljoin(settings.SERVER_URL, reverse_link)
instance_data = {
"size_alias":"2",
"machine_alias":"0f539197-3718-40bc-8a29-c22e0841684f",
"name":"test volume attachment",
"delete_before":False
}
(self.os_instance_id, self.os_instance_ip) = standup_instance(
self, self.os_instance_url, **instance_data)
#Prepare Eucalyptus
reverse_link = reverse('api:public_apis:volume-list',
args=[self.euca_id.provider.id,
self.euca_id.id])
self.euca_volume_url = urljoin(settings.SERVER_URL, reverse_link)
reverse_link = reverse('api:public_apis:instance-list',
args=[self.euca_id.provider.id,
self.euca_id.id])
self.euca_instance_url = urljoin(settings.SERVER_URL, reverse_link)
instance_data = {
"size_alias":"m1.small",
"machine_alias":"emi-E7F8300F",
"name":"test volume attachment",
"delete_before":False
}
(self.euca_instance_id, self.euca_instance_ip) = standup_instance(
self, self.euca_instance_url, **instance_data)
示例5: setUp_openstack
# 需要导入模块: from service.accounts.openstack import AccountDriver [as 别名]
# 或者: from service.accounts.openstack.AccountDriver import hashpass [as 别名]
def setUp_openstack():
# Initialize core DB
global os_base_instance_url
os_admin_id = create_os_provider()
os_provider = os_admin_id.provider
os_accounts = OSAccounts(os_provider)
os_id = os_accounts.create_account(
settings.TEST_RUNNER_USER, os_accounts.hashpass(settings.TEST_RUNNER_USER), max_quota=True
)
reverse_link = reverse("instance-list", args=[os_id.provider.id, os_id.id])
os_base_instance_url = urljoin(settings.SERVER_URL, reverse_link)
示例6: main
# 需要导入模块: from service.accounts.openstack import AccountDriver [as 别名]
# 或者: from service.accounts.openstack.AccountDriver import hashpass [as 别名]
def main():
"""
Add a user to openstack.
"""
parser = argparse.ArgumentParser()
parser.add_argument('users', type=str, nargs='+')
args = parser.parse_args()
openstack_prov = Provider.objects.get(location='iPlant Cloud - Tucson')
driver = AccountDriver(openstack_prov)
success = 0
for username in args.users:
print "Adding username... %s" % username
try:
if not is_atmo_user(username):
print "User is not in the atmo-user group.\n"\
+ "User does not exist in Atmosphere."
raise Exception("User does not exist in Atmosphere.")
user = driver.get_user(username)
if not user:
identity = driver.create_account(username)
credentials = identity.credential_set.all()
print 'New OStack User - Credentials: %s ' % (credentials)
send_new_provider_email(username, "Openstack")
else:
password = driver.hashpass(username)
identity = driver.create_identity(user.name,
password,
project_name=username)
credentials = identity.credential_set.all()
print 'Found OStack User - Credentials: %s' % (credentials)
#ASSERT: User exists on openstack, create an identity for them.
success += 1
print 'New OStack Identity - %s:%s' % (identity.id, identity)
except Exception as e:
print "Problem adding username: %s" % username
print e
raise
print "Total users created:%s/%s" % (success, len(args.users))