Ejemplo n.º 1
0
    def __init__(self):
        """Initializer.

        A global session with the VC will be established. In addition to this
        the moref of the configured DVS will be learnt. This will be used in
        the operations supported by the manager.

        NOTE: the DVS port group name will be the Neutron network UUID.
        """
        self._session = dvs_utils.dvs_create_session()
        # In the future we may decide to support more than one DVS
        self._dvs_moref = self._get_dvs_moref(self._session,
                                              dvs_utils.dvs_name_get())
Ejemplo n.º 2
0
 def delete_port_group(self, net_id):
     """Delete a specific port group."""
     moref = self._net_id_to_moref(net_id)
     task = self._session.invoke_api(self._session.vim,
                                     'Destroy_Task',
                                     moref)
     try:
         self._session.wait_for_task(task)
     except Exception:
         # NOTE(garyk): handle more specific exceptions
         with excutils.save_and_reraise_exception():
             LOG.exception(_LE('Failed to delete port group for %s.'),
                           net_id)
     LOG.info(_LI("%(net_id)s delete from %(dvs)s."),
              {'net_id': net_id,
               'dvs': dvs_utils.dvs_name_get()})
Ejemplo n.º 3
0
 def add_port_group(self, net_id, vlan_tag=None):
     """Add a new port group to the configured DVS."""
     pg_spec = self._get_port_group_spec(net_id, vlan_tag)
     task = self._session.invoke_api(self._session.vim,
                                     'CreateDVPortgroup_Task',
                                     self._dvs_moref,
                                     spec=pg_spec)
     try:
         # NOTE(garyk): cache the returned moref
         self._session.wait_for_task(task)
     except Exception:
         # NOTE(garyk): handle more specific exceptions
         with excutils.save_and_reraise_exception():
             LOG.exception(_LE('Failed to create port group for '
                               '%(net_id)s with tag %(tag)s.'),
                           {'net_id': net_id, 'tag': vlan_tag})
     LOG.info(_LI("%(net_id)s with tag %(vlan_tag)s created on %(dvs)s."),
              {'net_id': net_id,
               'vlan_tag': vlan_tag,
               'dvs': dvs_utils.dvs_name_get()})
Ejemplo n.º 4
0
 def test_dvs_name_get(self):
     cfg.CONF.set_override('dvs_name', 'fake-dvs', group='dvs')
     self.assertEqual('fake-dvs',
                      dvs_utils.dvs_name_get())