Skip to content
This repository has been archived by the owner on Apr 7, 2022. It is now read-only.

Commit

Permalink
[RFR] Add _fill_vmrc_console_endpoint_dicts to provider.create_rest() (
Browse files Browse the repository at this point in the history
…#9701)

* Add _fill_vmrc_console_endpoint_dicts

* Add VMRCEndpoint

Co-authored-by: Parthvi Vala <[email protected]>
Co-authored-by: Kedar Kulkarni <[email protected]>
  • Loading branch information
2 people authored and mshriver committed Dec 4, 2019
1 parent 730c7a4 commit 770c5ed
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 4 deletions.
34 changes: 32 additions & 2 deletions cfme/common/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ def _fill_amqp_endpoint_dicts(self, provider_attributes, connection_configs):
events_connection["endpoint"]["security_protocol"] = security_protocol
connection_configs.append(events_connection)

def _fill_smartstate_endpoint_dicts(self, provider_attributes, connection_configs):
def _fill_smartstate_endpoint_dicts(self, provider_attributes):
"""Fills dicts with smartstate endpoint data.
Helper method for ``self.create_rest``
Expand All @@ -433,6 +433,26 @@ def _fill_smartstate_endpoint_dicts(self, provider_attributes, connection_config
"auth_type": "smartstate_docker",
})

def _fill_vmrc_console_endpoint_dicts(self, provider_attributes):
"""Fills dicts with VMRC console endpoint data
Helper method for ``self.create_rest``
"""
if "vmrc" not in self.endpoints:
return

endpoints_vmrc = self.endpoints["vmrc"]
if isinstance(provider_attributes["credentials"], dict):
provider_attributes["credentials"] = [provider_attributes["credentials"]]

provider_attributes["credentials"].append(
{
"auth_type": "console",
"userid": endpoints_vmrc.credentials.principal,
"password": endpoints_vmrc.credentials.secret,
}
)

def _compile_connection_configurations(self, provider_attributes, connection_configs):
"""Compiles together all dicts with data for ``connection_configurations``.
Expand Down Expand Up @@ -480,7 +500,8 @@ def create_rest(self, check_existing=False, validate_inventory=False):
self._fill_candu_endpoint_dicts(provider_attributes, connection_configs)
self._fill_rsa_endpoint_dicts(connection_configs)
self._fill_amqp_endpoint_dicts(provider_attributes, connection_configs)
self._fill_smartstate_endpoint_dicts(provider_attributes, connection_configs)
self._fill_smartstate_endpoint_dicts(provider_attributes)
self._fill_vmrc_console_endpoint_dicts(provider_attributes)
self._compile_connection_configurations(provider_attributes, connection_configs)

try:
Expand Down Expand Up @@ -1267,6 +1288,15 @@ def view_value_mapping(self):
return {}


class VMRCEndpoint(DefaultEndpoint):
credential_class = Credential
name = 'vmrc'

@property
def view_value_mapping(self):
return {}


class DefaultEndpointForm(View):
hostname = Input('default_hostname')
username = Input('default_userid')
Expand Down
12 changes: 10 additions & 2 deletions cfme/infrastructure/provider/virtualcenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from cfme.common.candu_views import VMUtilizationView
from cfme.common.provider import DefaultEndpoint
from cfme.common.provider import DefaultEndpointForm
from cfme.common.provider import VMRCEndpoint
from cfme.exceptions import ItemNotFound
from cfme.infrastructure.provider import InfraProvider
from cfme.services.catalogs.catalog_items import VMwareCatalogItem
Expand Down Expand Up @@ -69,17 +70,24 @@ def deployment_helper(self, deploy_args):
@classmethod
def from_config(cls, prov_config, prov_key, appliance=None):
appliance = appliance or cls.appliance
endpoint = VirtualCenterEndpoint(**prov_config['endpoints']['default'])
endpoints = {
VirtualCenterEndpoint.name: VirtualCenterEndpoint(**prov_config['endpoints']['default'])
}

vmrc_endpoint_config = prov_config["endpoints"].get(VMRCEndpoint.name, {})
if vmrc_endpoint_config:
endpoints[VMRCEndpoint.name] = VMRCEndpoint(**vmrc_endpoint_config)

if prov_config.get('discovery_range'):
start_ip = prov_config['discovery_range']['start']
end_ip = prov_config['discovery_range']['end']
else:
start_ip = end_ip = prov_config.get('ipaddress')

return appliance.collections.infra_providers.instantiate(
prov_class=cls,
name=prov_config['name'],
endpoints={endpoint.name: endpoint},
endpoints=endpoints,
zone=prov_config['server_zone'],
key=prov_key,
start_ip=start_ip,
Expand Down

0 comments on commit 770c5ed

Please sign in to comment.