Пример #1
0
    def test_getid(self):
        self.assertEqual(base.getid(4), 4)

        class TmpObject(object):
            id = 4

        self.assertEqual(base.getid(TmpObject), 4)
Пример #2
0
    def deactivate(self, zone, node, options):
        """Deactivates the given node."""

        url = '/zones/{}/nodes/{}/deactivate'.format(base.getid(zone),
                                                     base.getid(node))

        return self._post(url, body=options, response_key='device')
Пример #3
0
    def execute_service(self, zone, role, component, service, node):
        """Execute a specific service by zone, role, component

        :param zone: The ID of the :class: `Zone` to get.
        :rtype: :class:`Zone`

        :param role: The ID of the :class: `Role` to get.
        :rtype: :class:`Zone`

        :param component: The ID (Name of the component) of the :class:
        `Component` to get.
        :rtype: :class:`Component`

        :param service: The ID of the :class: `Service` to get.
        :rtype: :class:`Service`

        :param node: The ID of the :class: `Node` where to execute the action.
        :rtype: :class:`Node`
        """

        body = {
            'node_id': base.getid(node)
        }

        res = self._create("/zones/%s/roles/%s/components/%s/services/%s"
                           % (base.getid(zone),
                              base.getid(role),
                              component.name,
                              service.name), body=body, response_key="task")
        res.zone = zone
        res.node = node
        return res
Пример #4
0
    def execute_service(self, zone, role, component, service, node):
        """Execute a specific service by zone, role, component

        :param zone: The ID of the :class: `Zone` to get.
        :rtype: :class:`Zone`

        :param role: The ID of the :class: `Role` to get.
        :rtype: :class:`Zone`

        :param component: The ID (Name of the component) of the :class:
        `Component` to get.
        :rtype: :class:`Component`

        :param service: The ID of the :class: `Service` to get.
        :rtype: :class:`Service`

        :param node: The ID of the :class: `Node` where to execute the action.
        :rtype: :class:`Node`
        """

        body = {'node_id': base.getid(node)}

        res = self._create(
            "/zones/%s/roles/%s/components/%s/services/%s" %
            (base.getid(zone), base.getid(role), component.name, service.name),
            body=body,
            response_key="task")
        res.zone = zone
        res.node = node
        return res
Пример #5
0
    def deactivate(self, zone, node, options):
        """Deactivates the given node."""

        url = '/zones/{}/nodes/{}/deactivate'.format(base.getid(zone),
                                                     base.getid(node))

        return self._post(url, body=options, response_key='device')
    def list_zone_role(self, zone, role):
        """Get all components by zone and role.

        :param zone: The ID of the :class: `Zone` to get.
        :rtype: :class:`Zone`

        :param role: The ID of the :class: `Role` to get.
        :rtype: :class:`Zone`
        """
        return self._list("/zones/%s/roles/%s/components" % (base.getid(zone),
                                                             base.getid(role)),
                          "components")
Пример #7
0
    def list_node(self, zone, node):
        """Get all tasks by zone and node.

        :param zone: The ID of the :class: `Zone` to get.
        :rtype: :class:`Zone`

        :param profile: The ID of the :class: `Node` to get.
        :rtype: :class:`Node`
        """
        return self._list(
            "/zones/%s/nodes/%s/tasks" % (base.getid(zone), base.getid(node)),
            "tasks")
    def list_zone_role(self, zone, role):
        """Get all components by zone and role.

        :param zone: The ID of the :class: `Zone` to get.
        :rtype: :class:`Zone`

        :param role: The ID of the :class: `Role` to get.
        :rtype: :class:`Zone`
        """
        return self._list(
            "/zones/%s/roles/%s/components" %
            (base.getid(zone), base.getid(role)), "components")
Пример #9
0
    def list_node(self, zone, node):
        """Get all tasks by zone and node.

        :param zone: The ID of the :class: `Zone` to get.
        :rtype: :class:`Zone`

        :param profile: The ID of the :class: `Node` to get.
        :rtype: :class:`Node`
        """
        return self._list("/zones/%s/nodes/%s/tasks" % (base.getid(zone),
                                                        base.getid(node)),
                          "tasks")
Пример #10
0
    def delete(self, architecture, profile):
        """
        Delete a profile.

        :param architecture: The ID of the :class: `Architecture` to get.
        :rtype: :class:`Architecture`

        :param profile: The ID of the :class: `Profile` to delete.
        :rtype: :class:`Profile`
        """

        self._delete("/archs/%s/profiles/%s" %
                     (base.getid(architecture), base.getid(profile)))
Пример #11
0
    def delete(self, architecture, profile):
        """
        Delete a profile.

        :param architecture: The ID of the :class: `Architecture` to get.
        :rtype: :class:`Architecture`

        :param profile: The ID of the :class: `Profile` to delete.
        :rtype: :class:`Profile`
        """

        self._delete("/archs/%s/profiles/%s" % (base.getid(architecture),
                                                base.getid(profile)))
Пример #12
0
    def state(self, zone, node, task):
        """Get a specific task by zone and node.

        :param zone: The ID of the :class: `Zone` to get.
        :rtype: :class:`Zone`

        :param profile: The ID of the :class: `Node` to get.
        :rtype: :class:`Node`

        :param profile: The ID of the :class: `Task` to get.
        :rtype: :class:`Task`
        """
        return self._get(
            "/zones/%s/nodes/%s/tasks/%s/state" %
            (base.getid(zone), base.getid(node), task.uuid), "task")
    def delete(self, architecture):
        """
        Delete an architecture.

        :param architecture: The :class:`Architecture` to delete.
        """
        self._delete("/archs/%s" % base.getid(architecture))
Пример #14
0
    def delete(self, zone, task, node):
        """
        Delete a specific task.

        :param zone: The  ID of the :class: `Zone` to get.
        :rtype: :class:`Zone`

        :param task: The UUID of the :class: `Task` to delete.
        :rtype: :class:`Task`

        :param node: The ID of the :class: `Node` to get
        :rtype: :class:`Node`
        """

        self._delete("/zones/%s/nodes/%s/tasks/%s" %
                     (base.getid(zone), base.getid(node), task.uuid))
Пример #15
0
    def get(self, zone):
        """Get a specific zone .

        :param zone: The ID of the :class: `Zone` to get.
        :rtype: :class:`Zone`
        """
        return self._get("/zones/%s" % base.getid(zone), "zone")
Пример #16
0
    def list(self, zone):
        """Get a list of nodes by a specific zone.

        :param zone: The ID of the :class: `Zone` to get its nodes.
        :rtype: :class:`Zone`
        """
        return self._list("/zones/%s/nodes" % base.getid(zone), "nodes")
Пример #17
0
    def delete(self, datastore):
        """
       Delete an datastore.

       :param datastore: The :class:`Datastore` to delete.
       """
        self._delete("/datastores/%s" % base.getid(datastore))
Пример #18
0
    def delete(self, datastore):
        """
       Delete an datastore.

       :param datastore: The :class:`Datastore` to delete.
       """
        self._delete("/datastores/%s" % base.getid(datastore))
Пример #19
0
    def get(self, zone):
        """Get a specific zone .

        :param zone: The ID of the :class: `Zone` to get.
        :rtype: :class:`Zone`
        """
        return self._get("/zones/%s" % base.getid(zone), "zone")
Пример #20
0
    def delete(self, architecture):
        """
        Delete an architecture.

        :param architecture: The :class:`Architecture` to delete.
        """
        self._delete("/archs/%s" % base.getid(architecture))
Пример #21
0
    def get_node(self, zone, node, task):
        """Get a specific task by zone and node.

        :param zone: The ID of the :class: `Zone` to get.
        :rtype: :class:`Zone`

        :param profile: The ID of the :class: `Node` to get.
        :rtype: :class:`Node`

        :param profile: The ID of the :class: `Task` to get.
        :rtype: :class:`Task`
        """
        return self._get("/zones/%s/nodes/%s/tasks/%s" % (base.getid(zone),
                                                          base.getid(node),
                                                          task),
                         "task")
Пример #22
0
    def cancel(self, zone, node, task):
        """Cancel a task by zone and node.

        :param zone: The ID of the :class: `Zone` to get.
        :rtype: :class:`Zone`

        :param role: The ID of the :class: `Node` to get.
        :rtype: :class:`Node`

        :param role: The ID of the :class: `Task` to get.
        :rtype: :class:`Task`
        """

        return self.api.client.post(
            "/zones/%s/nodes/%s/tasks/%s/cancel" %
            (base.getid(zone), base.getid(node), task.uuid))
Пример #23
0
    def get(self, datastore):
        """Get a specific datastore from pool.

        :param datastore: The ID of the :class: `Datastore` to get.
        :rtype: :class:`Datastore`
        """

        return self._get('/datastores/%s' % base.getid(datastore), 'datastore')
Пример #24
0
    def get(self, component):
        """Get a specific component.

        :param component: The ID (Name of the component) of the :class:
        `Component` to get.
        :rtype: :class:`Component`
        """
        return self._get("/components/%s" % base.getid(component), "component")
Пример #25
0
    def get(self, device):
        """Get a specific device from pool.

        :param device: The ID of the :class: `Device` to get.
        :rtype: :class:`Device`
        """

        return self._get('/pool/devices/%s' % base.getid(device), 'device')
Пример #26
0
    def space(self, datastore):
        """Get a specific datastore and its space

        :param datastore: The ID of the :class: `Datastore` to get.
        :rtype: :class:`Datastore`
        """
        return self._get('/datastores/%s/space' % base.getid(datastore),
                         'datastore')
    def get(self, architecture):
        """Get a specific architecture.

        :param architecture: The ID of the :class: `Architecture` to get.
        :rtype: :class:`Architecture`
        """
        return self._get("/archs/%s" % base.getid(architecture),
                         "architecture")
Пример #28
0
    def list(self, zone):
        """Get a list of nodes by a specific zone.

        :param zone: The ID of the :class: `Zone` to get its nodes.
        :rtype: :class:`Zone`
        """
        return self._list("/zones/%s/nodes" % base.getid(zone),
                          "nodes")
Пример #29
0
    def cancel(self, zone, node, task):
        """Cancel a task by zone and node.

        :param zone: The ID of the :class: `Zone` to get.
        :rtype: :class:`Zone`

        :param role: The ID of the :class: `Node` to get.
        :rtype: :class:`Node`

        :param role: The ID of the :class: `Task` to get.
        :rtype: :class:`Task`
        """

        return self.api.client.post("/zones/%s/nodes/%s/tasks/%s/cancel"
                                    % (base.getid(zone),
                                       base.getid(node),
                                       task.uuid))
Пример #30
0
    def get_zone_role(self, zone, role, component_id):
        """Get a component by zone and role.

        :param zone: The ID of the :class: `Zone` to get.
        :rtype: :class:`Zone`

        :param role: The ID of the :class: `Role` to get.
        :rtype: :class:`Zone`

         :param component: The ID (Name of the component) of the :class:
        `Component` to get.
        :rtype: :class:`Component`
        """

        return self._get(
            "/zones/%s/roles/%s/components/%s" %
            (base.getid(zone), base.getid(role), component_id), "component")
Пример #31
0
    def get(self, component):
        """Get a specific component.

        :param component: The ID (Name of the component) of the :class:
        `Component` to get.
        :rtype: :class:`Component`
        """
        return self._get("/components/%s" % base.getid(component), "component")
Пример #32
0
    def get(self, architecture):
        """Get a specific architecture.

        :param architecture: The ID of the :class: `Architecture` to get.
        :rtype: :class:`Architecture`
        """
        return self._get("/archs/%s" % base.getid(architecture),
                         "architecture")
Пример #33
0
    def get(self, datastore):
        """Get a specific datastore from pool.

        :param datastore: The ID of the :class: `Datastore` to get.
        :rtype: :class:`Datastore`
        """

        return self._get('/datastores/%s' % base.getid(datastore), 'datastore')
Пример #34
0
    def space(self, datastore):
        """Get a specific datastore and its space

        :param datastore: The ID of the :class: `Datastore` to get.
        :rtype: :class:`Datastore`
        """
        return self._get('/datastores/%s/space' % base.getid(datastore),
                         'datastore')
Пример #35
0
    def delete(self, zone, task, node):
        """
        Delete a specific task.

        :param zone: The  ID of the :class: `Zone` to get.
        :rtype: :class:`Zone`

        :param task: The UUID of the :class: `Task` to delete.
        :rtype: :class:`Task`

        :param node: The ID of the :class: `Node` to get
        :rtype: :class:`Node`
        """

        self._delete("/zones/%s/nodes/%s/tasks/%s" % (base.getid(zone),
                                                      base.getid(node),
                                                      task.uuid))
Пример #36
0
    def template(self, architecture):
        """Get a specific template (Profile) by architecture.

        :param architecture: The ID of the :class: `Architecture` to get its
        template.
        :rtype: :class:`Architecture`
        """
        return self._get("/archs/%s/get_template" % base.getid(architecture),
                         "profile")
Пример #37
0
    def content(self, datastore):
        """Get a specific datastore and its content

        :param datastore: The ID of the :class: `Datastore` to get.
        :rtype: :class:`Datastore`
        """

        return self._get('/datastores/%s/content' % base.getid(datastore),
                         'datastore')
Пример #38
0
    def update(self, datastore, **kwargs):
        """
        Update the parameters of the datastore
        """

        if not kwargs:
            return

        return self._update("/datastores/%s" % base.getid(datastore), kwargs)
Пример #39
0
    def content(self, datastore):
        """Get a specific datastore and its content

        :param datastore: The ID of the :class: `Datastore` to get.
        :rtype: :class:`Datastore`
        """

        return self._get('/datastores/%s/content' % base.getid(datastore),
                         'datastore')
Пример #40
0
    def detach(self, datastore, **kwargs):
        """
        Attach a datastore.

        :param datastore: The ID of the :class: `Datastore` to detach.
        :rtype: :class:`Datastore`
        """
        return self._update("/datastores/%s/detach" % base.getid(datastore),
                            kwargs)
Пример #41
0
    def update(self, architecture, profile, profile_file):
        """
        Update the name, components

        :param architecture: The ID of the :class: `Architecture` to get.
        :rtype: :class:`Architecture`

        :param profile: The ID of the :class: `Profile` to update.
        :rtype: :class:`Profile`

        :param profile: Profile JSON format define with updates
        """
        if not profile_file:
            return

        return self._update(
            "/archs/%s/profiles/%s" %
            (base.getid(architecture), base.getid(profile)), profile_file)
Пример #42
0
    def list_zone_role_component(self, zone, role, component):
        """Get all services by zone, role and component.

        :param zone: The ID of the :class: `Zone` to get.
        :rtype: :class:`Zone`

        :param role: The ID of the :class: `Role` to get.
        :rtype: :class:`Zone`

        :param component: The ID (Name of the component) of the :class:
        `Component` to get.
        :rtype: :class:`Component`
        """
        return self._list("/zones/%s/roles/%s/components/%s/services"
                          % (base.getid(zone),
                             base.getid(role),
                             component.name),
                          "services")
Пример #43
0
    def detach(self, datastore, **kwargs):
        """
        Attach a datastore.

        :param datastore: The ID of the :class: `Datastore` to detach.
        :rtype: :class:`Datastore`
        """
        return self._update("/datastores/%s/detach" % base.getid(datastore),
                            kwargs)
Пример #44
0
    def delete(self, zone):
        """
        Delete a zone.

        :param profile: The ID of the :class: `Zone` to delete.
        :rtype: :class:`Zone`
        """

        self._delete("/zones/%s" % base.getid(zone))
Пример #45
0
    def update(self, datastore, **kwargs):
        """
        Update the parameters of the datastore
        """

        if not kwargs:
            return

        return self._update("/datastores/%s" % base.getid(datastore), kwargs)
Пример #46
0
    def template(self, architecture):
        """Get a specific template (Profile) by architecture.

        :param architecture: The ID of the :class: `Architecture` to get its
        template.
        :rtype: :class:`Architecture`
        """
        return self._get("/archs/%s/get_template" % base.getid(architecture),
                         "profile")
Пример #47
0
    def delete(self, zone):
        """
        Delete a zone.

        :param profile: The ID of the :class: `Zone` to delete.
        :rtype: :class:`Zone`
        """

        self._delete("/zones/%s" % base.getid(zone))
Пример #48
0
    def update(self, architecture, profile, profile_file):
        """
        Update the name, components

        :param architecture: The ID of the :class: `Architecture` to get.
        :rtype: :class:`Architecture`

        :param profile: The ID of the :class: `Profile` to update.
        :rtype: :class:`Profile`

        :param profile: Profile JSON format define with updates
        """
        if not profile_file:
            return

        return self._update("/archs/%s/profiles/%s"
                            % (base.getid(architecture),
                               base.getid(profile)),
                            profile_file)
Пример #49
0
    def property_delete(self, architecture, profile, property_key):

        profile_dict = profile._info
        props_dict = profile_dict['properties']

        if property_key in props_dict:
            del props_dict[property_key]
        else:
            msg = "No profile property with a key: '%s' exists." % \
                  (property_key)
            raise exceptions.CommandError(msg)

        profile_dict['properties'] = props_dict
        del profile_dict['_links']
        profile_body = {"profile": profile_dict}

        return self._update(
            "/archs/%s/profiles/%s" %
            (base.getid(architecture), base.getid(profile)), profile_body)
Пример #50
0
    def get_zone_role(self, zone, role, component_id):
        """Get a component by zone and role.

        :param zone: The ID of the :class: `Zone` to get.
        :rtype: :class:`Zone`

        :param role: The ID of the :class: `Role` to get.
        :rtype: :class:`Zone`

         :param component: The ID (Name of the component) of the :class:
        `Component` to get.
        :rtype: :class:`Component`
        """

        return self._get("/zones/%s/roles/%s/components/%s"
                         % (base.getid(zone),
                            base.getid(role),
                            component_id),
                         "component")
Пример #51
0
    def property_delete(self, architecture, profile, property_key):

        profile_dict = profile._info
        props_dict = profile_dict['properties']

        if property_key in props_dict:
            del props_dict[property_key]
        else:
            msg = "No profile property with a key: '%s' exists." % \
                  (property_key)
            raise exceptions.CommandError(msg)

        profile_dict['properties'] = props_dict
        del profile_dict['_links']
        profile_body = {"profile": profile_dict}

        return self._update("/archs/%s/profiles/%s" %
                           (base.getid(architecture),
                            base.getid(profile)), profile_body)
Пример #52
0
    def get(self, zone, node):
        """Get a specific node by zone.

        :param zone: The ID of the :class: `Zone` to get.
        :rtype: :class:`Zone`

        :param profile: The ID of the :class: `Node` to get.
        :rtype: :class:`Node`
        """
        return self._get("/zones/%s/nodes/%s" % (base.getid(zone), node),
                         'node')
Пример #53
0
    def get(self, zone, node):
        """Get a specific node by zone.

        :param zone: The ID of the :class: `Zone` to get.
        :rtype: :class:`Zone`

        :param profile: The ID of the :class: `Node` to get.
        :rtype: :class:`Node`
        """
        return self._get("/zones/%s/nodes/%s" % (base.getid(zone), node),
                         'node')
Пример #54
0
    def get(self, zone, task):
        """Get a specific task by zone.

        :param zone: The ID of the :class: `Zone` to get.
        :rtype: :class:`Zone`

        :param task: The ID of the :class: `Task` to get.
        :rtype: :class:`Task`
        """
        return self._get("/zones/%s/tasks/%s" % (base.getid(zone), task),
                         "task")
Пример #55
0
    def get(self, zone, role):
        """Get a specific role by zone.

        :param zone: The ID of the :class: `Zone` to get.
        :rtype: :class:`Zone`

        :param role: The ID of the :class: `Role` to get.
        :rtype: :class:`Role`
        """
        return self._get("/zones/%s/roles/%s" % (base.getid(zone), role),
                         "role")
Пример #56
0
    def get(self, zone, role):
        """Get a specific role by zone.

        :param zone: The ID of the :class: `Zone` to get.
        :rtype: :class:`Zone`

        :param role: The ID of the :class: `Role` to get.
        :rtype: :class:`Role`
        """
        return self._get("/zones/%s/roles/%s" % (base.getid(zone), role),
                         "role")
Пример #57
0
    def get(self, architecture, profile):
        """Get a specific profile by architecture.

        :param architecture: The ID of the :class: `Architecture` to get.
        :rtype: :class:`Architecture`

        :param profile: The ID of the :class: `Profile` to get.
        :rtype: :class:`Profile`
        """
        return self._get("/archs/%s/profiles/%s" % (base.getid(architecture),
                                                    profile),
                         "profile")
Пример #58
0
    def get(self, zone, task):
        """Get a specific task by zone.

        :param zone: The ID of the :class: `Zone` to get.
        :rtype: :class:`Zone`

        :param task: The ID of the :class: `Task` to get.
        :rtype: :class:`Task`
        """
        return self._get("/zones/%s/tasks/%s" % (base.getid(zone),
                                                 task),
                         "task")
Пример #59
0
    def update_zone_role(self, zone, role, component_id, component_file):
        """Update a component by zone and role.

        :param zone: The ID of the :class: `Zone` to get.
        :rtype: :class:`Zone`

        :param role: The ID of the :class: `Role` to get.
        :rtype: :class:`Zone`

         :param component: The ID (Name of the component) of the :class:
        `Component` to get.
        :rtype: :class:`Component`
        """

        if not component_file:
            return

        return self._update("/zones/%s/roles/%s/components/%s"
                            % (base.getid(zone),
                               base.getid(role),
                               component_id),
                            component_file)