Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JS2 support OS app creds #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions djcloudbridge/migrations/0003_auto_20220620_1838.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Generated by Django 3.2.9 on 2022-06-20 18:38

from django.db import migrations, models
import fernet_fields.fields


class Migration(migrations.Migration):

dependencies = [
('djcloudbridge', '0002_openstackcredentials_os_project_domain_id'),
]

operations = [
migrations.AddField(
model_name='openstackcredentials',
name='os_application_credential_id',
field=models.CharField(blank=True, max_length=100, null=True),
),
migrations.AddField(
model_name='openstackcredentials',
name='os_application_credential_secret',
field=fernet_fields.fields.EncryptedCharField(blank=True, max_length=150, null=True),
),
migrations.AlterField(
model_name='openstackcredentials',
name='os_password',
field=fernet_fields.fields.EncryptedCharField(blank=True, max_length=50, null=True),
),
migrations.AlterField(
model_name='openstackcredentials',
name='os_project_name',
field=models.CharField(blank=True, max_length=50, null=True),
),
migrations.AlterField(
model_name='openstackcredentials',
name='os_username',
field=models.CharField(blank=True, max_length=50, null=True),
),
]
18 changes: 13 additions & 5 deletions djcloudbridge/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,11 @@ def to_dict(self):


class OpenStackCredentials(CloudCredentials):
os_username = models.CharField(max_length=50, blank=False, null=False)
os_password = EncryptedCharField(max_length=50, blank=False, null=False)
os_project_name = models.CharField(max_length=50, blank=False, null=False)
os_application_credential_id = models.CharField(max_length=100, blank=True, null=True)
os_application_credential_secret = EncryptedCharField(max_length=150, blank=True, null=True)
os_username = models.CharField(max_length=50, blank=True, null=True)
os_password = EncryptedCharField(max_length=50, blank=True, null=True)
os_project_name = models.CharField(max_length=50, blank=True, null=True)
os_project_domain_id = models.CharField(max_length=50, blank=True,
null=True)
os_project_domain_name = models.CharField(max_length=50, blank=True,
Expand All @@ -251,8 +253,14 @@ class Meta:

def to_dict(self):
d = super(OpenStackCredentials, self).to_dict()
d['os_username'] = self.os_username
d['os_password'] = self.os_password
if self.os_username:
d['os_username'] = self.os_username
if self.os_password:
d['os_password'] = self.os_password
if self.os_application_credential_id:
d['os_application_credential_id'] = self.os_application_credential_id
if self.os_application_credential_secret:
d['os_application_credential_secret'] = self.os_application_credential_secret
if self.os_project_name:
d['os_project_name'] = self.os_project_name
if self.os_project_domain_id:
Expand Down
3 changes: 3 additions & 0 deletions djcloudbridge/view_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ def get_credentials_from_dict(payload):
if 'os_username' in payload.keys() and 'os_password' in payload.keys():
creds = {'os_username': payload.pop('os_username'),
'os_password': payload.pop('os_password')}
elif 'os_application_credential_id' in payload.keys() and 'os_application_credential_secret' in payload.keys():
creds = {'os_application_credential_id': payload.pop('os_application_credential_id'),
'os_application_credential_secret': payload.pop('os_application_credential_secret')}
elif ('aws_access_key' in payload.keys() and
'aws_secret_key' in payload.keys()):
creds = {'aws_access_key': payload.pop('aws_access_key'),
Expand Down