Ejemplo n.º 1
0
    def __get_options(self, interconnects, facts):
        interconnect_uri = interconnects[0]['uri']

        if self.options.get('nameServers'):
            name_servers = self.oneview_client.interconnects.get_name_servers(interconnect_uri)
            facts['interconnect_name_servers'] = name_servers

        if self.options.get('statistics'):
            facts['interconnect_statistics'] = self.oneview_client.interconnects.get_statistics(interconnect_uri)

        if self.options.get('portStatistics'):
            port_name = self.options['portStatistics']
            port_statistics = self.oneview_client.interconnects.get_statistics(interconnect_uri, port_name)
            facts['interconnect_port_statistics'] = port_statistics

        if self.options.get('subPortStatistics'):
            facts['interconnect_subport_statistics'] = None
            sub_options = self.options['subPortStatistics']
            if isinstance(sub_options, dict) and sub_options.get('portName') and sub_options.get('subportNumber'):
                facts['interconnect_subport_statistics'] = self.oneview_client.interconnects.get_subport_statistics(
                    interconnect_uri, sub_options['portName'], sub_options['subportNumber'])

        if self.options.get('ports'):
            ports = self.oneview_client.interconnects.get_ports(interconnect_uri)
            facts['interconnect_ports'] = ports

        if self.options.get('port'):
            port_name = self.options.get('port')
            port_id = "{}:{}".format(extract_id_from_uri(interconnect_uri), port_name)
            port = self.oneview_client.interconnects.get_port(interconnect_uri, port_id)
            facts['interconnect_port'] = port
Ejemplo n.º 2
0
    def get_backup(self, id_or_uri):
        """
        Get the details for the backup from an Artifact Bundle.

        Args:
            id_or_uri: ID or URI of the Artifact Bundle.

        Returns:
            Dict: Backup for an Artifacts Bundle.
        """
        uri = self.BACKUPS_PATH + '/' + extract_id_from_uri(id_or_uri)
        return self._client.get(id_or_uri=uri)
Ejemplo n.º 3
0
    def download_archive(self, id_or_uri, file_path):
        """
        Download the details of the archived OS Volume.

        Args:
            id_or_uri: ID or URI of the OS Volume.
            file_path (str): Destination file path.

        Returns:
            bool: Indicates if the resource was successfully downloaded.
        """
        uri = self.URI + "/archive/" + extract_id_from_uri(id_or_uri)
        return self._client.download(uri, file_path)
Ejemplo n.º 4
0
    def download_artifact_bundle(self, id_or_uri, file_path):
        """
        Download the Artifact Bundle.

        Args:
            id_or_uri: ID or URI of the Artifact Bundle.
            file_path(str): Destination file path.

        Returns:
            bool: Successfully downloaded.
        """
        uri = self.DOWNLOAD_PATH + '/' + extract_id_from_uri(id_or_uri)
        return self._client.download(uri, file_path)
Ejemplo n.º 5
0
    def download(self, id_or_uri, file_path):
        """
        Downloads the content of the selected Golden Image as per the specified attributes.

        Args:
            id_or_uri: ID or URI of the Golden Image.
            file_path(str): Destination file path.

        Returns:
            bool: Successfully downloaded.
        """
        uri = self.URI + "/download/" + extract_id_from_uri(id_or_uri)
        return self._client.download(uri, file_path)
Ejemplo n.º 6
0
    def download_archive(self, id_or_uri, file_path):
        """
        Download the details of the archived OS Volume.

        Args:
            id_or_uri: ID or URI of the OS Volume.
            file_path (str): Destination file path.

        Returns:
            bool: Indicates if the resource was successfully downloaded.
        """
        uri = self.URI + "/archive/" + extract_id_from_uri(id_or_uri)
        return self._client.download(uri, file_path)
    def download(self, id_or_uri, file_path):
        """
        Downloads the content of the selected Golden Image as per the specified attributes.

        Args:
            id_or_uri: ID or URI of the Golden Image.
            file_path(str): Destination file path.

        Returns:
            bool: Successfully downloaded.
        """
        uri = self.URI + "/download/" + extract_id_from_uri(id_or_uri)
        return self._client.download(uri, file_path)
Ejemplo n.º 8
0
    def download_archive(self, id_or_uri, file_path):
        """
        Download the details of the Golden Image capture logs, which has been archived based on the specific attribute
        ID.

        Args:
            id_or_uri: ID or URI of the Golden Image.
            file_path (str): File name to save the archive.

        Returns:
            bool: Success.
        """
        uri = self.URI + "/archive/" + extract_id_from_uri(id_or_uri)
        return self._client.download(uri, file_path)
    def download_archive(self, id_or_uri, file_path):
        """
        Download the details of the Golden Image capture logs, which has been archived based on the specific attribute
        ID.

        Args:
            id_or_uri: ID or URI of the Golden Image.
            file_path (str): File name to save the archive.

        Returns:
            bool: Success.
        """
        uri = self.URI + "/archive/" + extract_id_from_uri(id_or_uri)
        return self._client.download(uri, file_path)
Ejemplo n.º 10
0
    def retrieve_differences(self, id_or_uri, content, timeout=-1):
        """
        Retrieves the modified contents of the selected Plan Script according to the provided content object, as per
        the selected attributes.

        Args:
            id_or_uri: ID or URI of the Plan Script.
            content (str): Plan Script content.
            timeout:
                Timeout in seconds. Waits for task completion by default. The timeout does not abort the operation
                in OneView, it just stops waiting for its completion.

        Returns:
            dict: Script differences.
        """
        uri = self.URI + "/differences/" + extract_id_from_uri(id_or_uri)
        return self._client.create(content, uri=uri, timeout=timeout)
Ejemplo n.º 11
0
    def stop_artifact_creation(self, id_or_uri, task_uri):
        """
        Stops creation of the selected Artifact Bundle.

        Args:
            id_or_uri: ID or URI of the Artifact Bundle.
            task_uri: Task URI associated with the Artifact Bundle.

        Returns:
            string:
        """
        data = {
            "taskUri": task_uri
        }

        uri = self.URI + '/' + extract_id_from_uri(id_or_uri) + self.STOP_CREATION_PATH

        return self._client.update(data, uri=uri)
    def get_appliance(self, id_or_uri, fields=''):
        """
        Gets the particular Image Streamer resource based on its ID or URI.

        Args:
            id_or_uri:
                Can be either the Os Deployment Server ID or the URI
            fields:
                Specifies which fields should be returned in the result.

        Returns:
             dict: Image Streamer resource.
        """
        uri = self.URI + '/image-streamer-appliances/' + extract_id_from_uri(id_or_uri)
        if fields:
            uri += '?fields=' + fields

        return self._client.get(uri)
    def __get_options(self, interconnects, facts):

        options = transform_list_to_dict(self.module.params['options'])

        interconnect_uri = interconnects[0]['uri']

        if options.get('nameServers'):
            name_servers = self.oneview_client.interconnects.get_name_servers(
                interconnect_uri)
            facts['interconnect_name_servers'] = name_servers

        if options.get('statistics'):
            facts[
                'interconnect_statistics'] = self.oneview_client.interconnects.get_statistics(
                    interconnect_uri)

        if options.get('portStatistics'):
            port_name = options['portStatistics']
            port_statistics = self.oneview_client.interconnects.get_statistics(
                interconnect_uri, port_name)
            facts['interconnect_port_statistics'] = port_statistics

        if options.get('subPortStatistics'):
            facts['interconnect_subport_statistics'] = None
            sub_options = options['subPortStatistics']
            if type(sub_options) is dict and sub_options.get(
                    'portName') and sub_options.get('subportNumber'):
                facts[
                    'interconnect_subport_statistics'] = self.oneview_client.interconnects.get_subport_statistics(
                        interconnect_uri, sub_options['portName'],
                        sub_options['subportNumber'])

        if options.get('ports'):
            ports = self.oneview_client.interconnects.get_ports(
                interconnect_uri)
            facts['interconnect_ports'] = ports

        if options.get('port'):
            port_name = options.get('port')
            port_id = "{}:{}".format(extract_id_from_uri(interconnect_uri),
                                     port_name)
            port = self.oneview_client.interconnects.get_port(
                interconnect_uri, port_id)
            facts['interconnect_port'] = port
Ejemplo n.º 14
0
    def get_appliance(self, id_or_uri, fields=''):
        """
        Gets the particular Image Streamer resource based on its ID or URI.

        Args:
            id_or_uri:
                Can be either the Os Deployment Server ID or the URI
            fields:
                Specifies which fields should be returned in the result.

        Returns:
             dict: Image Streamer resource.
        """
        uri = self.URI + '/image-streamer-appliances/' + extract_id_from_uri(
            id_or_uri)
        if fields:
            uri += '?fields=' + fields

        return self._client.get(uri)