Example #1
0
 def _create_ssl_cert(self, edge_id=None):
     # Create a self signed certificate in the backend if both Cert details
     # and private key are not supplied in nsx.ini
     if (not cfg.CONF.nsxv.metadata_nova_client_cert and
         not cfg.CONF.nsxv.metadata_nova_client_priv_key):
         h = self.nsxv_plugin.nsx_v.vcns.create_csr(edge_id)[0]
         # Extract the CSR ID from header
         csr_id = lbaas_common.extract_resource_id(h['location'])
         # Create a self signed certificate
         cert = self.nsxv_plugin.nsx_v.vcns.create_csr_cert(csr_id)[1]
         cert_id = cert['objectId']
     else:
         # Raise an error if either the Cert path or the private key is not
         # configured
         error = None
         if not cfg.CONF.nsxv.metadata_nova_client_cert:
             error = _('Metadata certificate path not configured')
         elif not cfg.CONF.nsxv.metadata_nova_client_priv_key:
             error = _('Metadata client private key not configured')
         if error:
             raise nsxv_exc.NsxPluginException(err_msg=error)
         pem_encoding = utils.read_file(
             cfg.CONF.nsxv.metadata_nova_client_cert)
         priv_key = utils.read_file(
             cfg.CONF.nsxv.metadata_nova_client_priv_key)
         request = {
             'pemEncoding': pem_encoding,
             'privateKey': priv_key}
         cert = self.nsxv_plugin.nsx_v.vcns.upload_edge_certificate(
             edge_id, request)[1]
         cert_id = cert.get('certificates')[0]['objectId']
     return cert_id
Example #2
0
 def _create_ssl_cert(self, edge_id=None):
     # Create a self signed certificate in the backend if both Cert details
     # and private key are not supplied in nsx.ini
     if (not cfg.CONF.nsxv.metadata_nova_client_cert and
         not cfg.CONF.nsxv.metadata_nova_client_priv_key):
         h = self.nsxv_plugin.nsx_v.vcns.create_csr(edge_id)[0]
         # Extract the CSR ID from header
         csr_id = lbaas_common.extract_resource_id(h['location'])
         # Create a self signed certificate
         cert = self.nsxv_plugin.nsx_v.vcns.create_csr_cert(csr_id)[1]
         cert_id = cert['objectId']
     else:
         # Raise an error if either the Cert path or the private key is not
         # configured
         error = None
         if not cfg.CONF.nsxv.metadata_nova_client_cert:
             error = _('Metadata certificate path not configured')
         elif not cfg.CONF.nsxv.metadata_nova_client_priv_key:
             error = _('Metadata client private key not configured')
         if error:
             raise nsxv_exc.NsxPluginException(err_msg=error)
         pem_encoding = utils.read_file(
             cfg.CONF.nsxv.metadata_nova_client_cert)
         priv_key = utils.read_file(
             cfg.CONF.nsxv.metadata_nova_client_priv_key)
         request = {
             'pemEncoding': pem_encoding,
             'privateKey': priv_key}
         cert = self.nsxv_plugin.nsx_v.vcns.upload_edge_certificate(
             edge_id, request)[1]
         cert_id = cert.get('certificates')[0]['objectId']
     return cert_id