I'm trying to create instances using openstacksdk python api everything is ok but even when i use:
conn2 = conn.connect_as_project(proj.name)
server = conn2.create_server(......)
the server is being created under property of admin project, not the project mentioned in proj.name I even tried project.id but didn't worked.
Finally instead of:
conn2 = conn.connect_as_project(project_id)
I used:
conn2 = openstack.connection.Connection(
region_name='RegionOne',
auth=dict(
auth_url='http://controller:5000/v3',
username=u_name,
password=password,
project_id=project_id,
user_domain_id='default'),
compute_api_version='2',
identity_interface='internal')
and it worked.
I did this just fine...the only difference is that the project is a new project and I have to give credentials to the user I was using.
It was something like that:
project = sconn.create_project(
name=name, domain_id='default')
user_id = conn.current_user_id
user = conn.get_user(user_id)
roles = conn.list_roles()
for r in roles:
conn.identity.assign_project_role_to_user(
project.id, user.id, r.id
)
# Make sure the roles are correctly assigned to the user before proceed
conn2 = self.conn.connect_as_project(project.name)
After that, anything created (servers, keypairs, networks, etc) is under the new project.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.