Skip to content

Commit

Permalink
Add support for configuring password retrieve function
Browse files Browse the repository at this point in the history
The OpenStack Dashboard has supported retrieving the instance
password from Nova since Icehouse. This feature is disabled by
default. Allow user to enable it.

Change-Id: Iaeeac46f56c36bc7620471c52fd0e56b1e9f1512
Closes-Bug: 1651893
  • Loading branch information
fnordahl committed Dec 23, 2016
1 parent 1e3fe19 commit 8f3a93a
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 8 deletions.
4 changes: 4 additions & 0 deletions config.yaml
Expand Up @@ -215,6 +215,10 @@ options:
type: boolean
default: False
description: Enable cinder backup panel.
password-retrieve:
type: boolean
default: False
description: Enable "Retrieve password" instance action.
prefer-ipv6:
type: boolean
default: False
Expand Down
1 change: 1 addition & 0 deletions hooks/horizon_contexts.py
Expand Up @@ -193,6 +193,7 @@ def __call__(self):
"neutron_network_firewall": config("neutron-network-firewall"),
"neutron_network_vpn": config("neutron-network-vpn"),
"cinder_backup": config("cinder-backup"),
"password_retrieve": config("password-retrieve"),
'virtualenv': git_pip_venv_dir(projects_yaml)
if config('openstack-origin-git') else None,
}
Expand Down
4 changes: 4 additions & 0 deletions templates/icehouse/local_settings.py
Expand Up @@ -521,4 +521,8 @@
# see https://docs.djangoproject.com/en/dev/ref/settings/.
ALLOWED_HOSTS = '*'

{% if password_retrieve %}
OPENSTACK_ENABLE_PASSWORD_RETRIEVE = True
{% endif %}

{{ settings|join('\n\n') }}
3 changes: 3 additions & 0 deletions templates/juno/local_settings.py
Expand Up @@ -168,6 +168,9 @@
#Setting this to True, will add a new "Retrieve Password" action on instance,
#allowing Admin session password retrieval/decryption.
#OPENSTACK_ENABLE_PASSWORD_RETRIEVE = False
{% if password_retrieve %}
OPENSTACK_ENABLE_PASSWORD_RETRIEVE = True
{% endif %}

# The Xen Hypervisor has the ability to set the mount point for volumes
# attached to instances (other Hypervisors currently do not). Setting
Expand Down
3 changes: 3 additions & 0 deletions templates/liberty/local_settings.py
Expand Up @@ -191,6 +191,9 @@
# Setting this to True, will add a new "Retrieve Password" action on instance,
# allowing Admin session password retrieval/decryption.
#OPENSTACK_ENABLE_PASSWORD_RETRIEVE = False
{% if password_retrieve %}
OPENSTACK_ENABLE_PASSWORD_RETRIEVE = True
{% endif %}

# The Launch Instance user experience has been significantly enhanced.
# You can choose whether to enable the new launch instance experience,
Expand Down
3 changes: 3 additions & 0 deletions templates/mitaka/local_settings.py
Expand Up @@ -256,6 +256,9 @@
# Setting this to True, will add a new "Retrieve Password" action on instance,
# allowing Admin session password retrieval/decryption.
#OPENSTACK_ENABLE_PASSWORD_RETRIEVE = False
{% if password_retrieve %}
OPENSTACK_ENABLE_PASSWORD_RETRIEVE = True
{% endif %}

# The Launch Instance user experience has been significantly enhanced.
# You can choose whether to enable the new launch instance experience,
Expand Down
3 changes: 3 additions & 0 deletions templates/newton/local_settings.py
Expand Up @@ -258,6 +258,9 @@
# Setting this to True, will add a new "Retrieve Password" action on instance,
# allowing Admin session password retrieval/decryption.
#OPENSTACK_ENABLE_PASSWORD_RETRIEVE = False
{% if password_retrieve %}
OPENSTACK_ENABLE_PASSWORD_RETRIEVE = True
{% endif %}

# The Launch Instance user experience has been significantly enhanced.
# You can choose whether to enable the new launch instance experience,
Expand Down
60 changes: 52 additions & 8 deletions unit_tests/test_horizon_contexts.py
Expand Up @@ -113,7 +113,10 @@ def test_HorizonContext_defaults(self):
"neutron_network_lb": False,
"neutron_network_firewall": False,
"neutron_network_vpn": False,
"cinder_backup": False})
"cinder_backup": False,
"password_retrieve": False,
}
)

def test_HorizonContext_debug(self):
self.test_config.set('debug', 'yes')
Expand All @@ -130,7 +133,10 @@ def test_HorizonContext_debug(self):
"neutron_network_lb": False,
"neutron_network_firewall": False,
"neutron_network_vpn": False,
"cinder_backup": False})
"cinder_backup": False,
"password_retrieve": False,
}
)

def test_HorizonContext_ubuntu_theme(self):
self.test_config.set('ubuntu-theme', False)
Expand All @@ -147,7 +153,10 @@ def test_HorizonContext_ubuntu_theme(self):
"neutron_network_lb": False,
"neutron_network_firewall": False,
"neutron_network_vpn": False,
"cinder_backup": False})
"cinder_backup": False,
"password_retrieve": False,
}
)

def test_HorizonContext_default_theme(self):
self.test_config.set('ubuntu-theme', False)
Expand All @@ -165,7 +174,10 @@ def test_HorizonContext_default_theme(self):
"neutron_network_lb": False,
"neutron_network_firewall": False,
"neutron_network_vpn": False,
"cinder_backup": False})
"cinder_backup": False,
"password_retrieve": False,
}
)

def test_HorizonContext_compression(self):
self.test_config.set('offline-compression', 'no')
Expand All @@ -182,7 +194,10 @@ def test_HorizonContext_compression(self):
"neutron_network_lb": False,
"neutron_network_firewall": False,
"neutron_network_vpn": False,
"cinder_backup": False})
"cinder_backup": False,
"password_retrieve": False,
}
)

def test_HorizonContext_role(self):
self.test_config.set('default-role', 'foo')
Expand All @@ -199,7 +214,10 @@ def test_HorizonContext_role(self):
"neutron_network_lb": False,
"neutron_network_firewall": False,
"neutron_network_vpn": False,
"cinder_backup": False})
"cinder_backup": False,
"password_retrieve": False,
}
)

def test_HorizonContext_webroot(self):
self.test_config.set('webroot', '/')
Expand All @@ -216,7 +234,10 @@ def test_HorizonContext_webroot(self):
"neutron_network_lb": False,
"neutron_network_firewall": False,
"neutron_network_vpn": False,
"cinder_backup": False})
"cinder_backup": False,
"password_retrieve": False,
}
)

def test_HorizonContext_panels(self):
self.test_config.set('neutron-network-dvr', True)
Expand All @@ -238,7 +259,30 @@ def test_HorizonContext_panels(self):
"neutron_network_lb": True,
"neutron_network_firewall": True,
"neutron_network_vpn": True,
"cinder_backup": True})
"cinder_backup": True,
"password_retrieve": False,
}
)

def test_HorizonContext_password_retrieve(self):
self.test_config.set('password-retrieve', True)
self.assertEquals(horizon_contexts.HorizonContext()(),
{'compress_offline': True, 'debug': False,
'default_role': 'Member', 'webroot': '/horizon',
'ubuntu_theme': True,
'default_theme': None,
'virtualenv': None,
'secret': 'secret',
'support_profile': None,
"neutron_network_dvr": False,
"neutron_network_l3ha": False,
"neutron_network_lb": False,
"neutron_network_firewall": False,
"neutron_network_vpn": False,
"cinder_backup": False,
"password_retrieve": True,
}
)

def test_IdentityServiceContext_not_related(self):
self.relation_ids.return_value = []
Expand Down

0 comments on commit 8f3a93a

Please sign in to comment.