Пример #1
0
    def create(self, context, healthmonitor):
        """
        Create a loadbalancer_healtmonitor object.
        """
        m = healthmonitor['healthmonitor']
        tenant_id = self._get_tenant_id_for_create(context, m)
        project = self._project_read(project_id=tenant_id)

        uuid = uuidutils.generate_uuid()
        props = self.make_properties(m)
        id_perms = IdPermsType(enable=True)
        monitor_db = LoadbalancerHealthmonitor(
            uuid,
            project,
            loadbalancer_healthmonitor_properties=props,
            id_perms=id_perms,
            display_name=m['name'])
        monitor_db.uuid = uuid

        try:
            pool = self._api.loadbalancer_pool_read(id=m['pool_id'])
        except NoIdError:
            raise loadbalancerv2.EntityNotFound(name='Pool', id=m['pool_id'])
        exist_hm_refs = pool.get_loadbalancer_healthmonitor_refs()
        if exist_hm_refs is not None:
            raise loadbalancerv2.OneHealthMonitorPerPool(
                pool_id=m['pool_id'], hm_id=exist_hm_refs[0]['uuid'])
        self._api.loadbalancer_healthmonitor_create(monitor_db)
        self._api.ref_update('loadbalancer-pool', m['pool_id'],
                             'loadbalancer-healthmonitor', uuid, None, 'ADD')
        return self.make_dict(monitor_db)
    def create(self, context, healthmonitor):
        """
        Create a loadbalancer_healtmonitor object.
        """
        m = healthmonitor['healthmonitor']
        tenant_id = self._get_tenant_id_for_create(context, m)
        project = self._project_read(project_id=tenant_id)

        uuid = uuidutils.generate_uuid()
        props = self.make_properties(m)
        id_perms = IdPermsType(enable=True)
        monitor_db = LoadbalancerHealthmonitor(
            uuid, project, loadbalancer_healthmonitor_properties=props,
            id_perms=id_perms)
        monitor_db.uuid = uuid

        try:
            pool = self._api.loadbalancer_pool_read(id=m['pool_id'])
        except NoIdError:
            raise loadbalancerv2.EntityNotFound(name='Pool', id=m['pool_id'])
        exist_hm_refs = pool.get_loadbalancer_healthmonitor_refs()
        if exist_hm_refs is not None:
            raise loadbalancerv2.OneHealthMonitorPerPool(pool_id=m['pool_id'],
                                               hm_id=exist_hm_refs[0]['uuid'])
        self._api.loadbalancer_healthmonitor_create(monitor_db)
        self._api.ref_update('loadbalancer-pool', m['pool_id'],
            'loadbalancer-health-monitor', uuid, None, 'ADD')
        return self.make_dict(monitor_db)
 def _create_monitor(self, health_monitor_id, tenant_id):
     id_perms = IdPermsType(uuid=health_monitor_id, enable=True)
     props = self._loadbalancer_healthmonitor_properties_build()
     monitor = LoadbalancerHealthmonitor(
         health_monitor_id,
         loadbalancer_healthmonitor_properties=props,
         id_perms=id_perms)
     monitor.parent_uuid = tenant_id
     monitor.uuid = health_monitor_id
     return monitor
 def _create_monitor(self, health_monitor_id, tenant_id):
     id_perms = IdPermsType(uuid=health_monitor_id, enable=True)
     props = self._loadbalancer_healthmonitor_properties_build()
     monitor = LoadbalancerHealthmonitor(
         health_monitor_id,
         loadbalancer_healthmonitor_properties=props,
         id_perms=id_perms)
     monitor.parent_uuid = tenant_id
     monitor.uuid = health_monitor_id
     return monitor
    def create(self, context, health_monitor):
        """
        Create a loadbalancer_healtmonitor object.
        """
        m = health_monitor['health_monitor']
        tenant_id = self._get_tenant_id_for_create(context, m)
        project = self._project_read(project_id=tenant_id)

        uuid = uuidutils.generate_uuid()
        props = self.make_properties(m)
        id_perms = IdPermsType(enable=True)
        monitor_db = LoadbalancerHealthmonitor(
            uuid, project, loadbalancer_healthmonitor_properties=props,
            id_perms=id_perms)
        monitor_db.uuid = uuid

        self._api.loadbalancer_healthmonitor_create(monitor_db)
        return self.make_dict(monitor_db)
    def create(self, context, health_monitor):
        """
        Create a loadbalancer_healtmonitor object.
        """
        m = health_monitor['health_monitor']
        tenant_id = self._get_tenant_id_for_create(context, m)
        project = self._project_read(project_id=tenant_id)

        uuid = uuidutils.generate_uuid()
        props = self.make_properties(m)
        id_perms = IdPermsType(enable=True)
        monitor_db = LoadbalancerHealthmonitor(
            uuid, project, loadbalancer_healthmonitor_properties=props,
            id_perms=id_perms)
        monitor_db.uuid = uuid

        self._api.loadbalancer_healthmonitor_create(monitor_db)
        return self.make_dict(monitor_db)
 def healthmonitor_read(*args, **kwargs):
     hm = LoadbalancerHealthmonitor('hm1', self._project)
     hm.uuid = kwargs['id']
     return hm
 def healthmonitor_read(*args, **kwargs):
     hm = LoadbalancerHealthmonitor('hm1', self._project)
     hm.uuid = kwargs['id']
     return hm