コード例 #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')
コード例 #6
0
    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")
コード例 #8
0
    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")
コード例 #13
0
    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')
コード例 #27
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")
コード例 #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)