Revision 6e8091f9 lib/rapi/client.py

b/lib/rapi/client.py
1761 1761
    return self._SendRequest(HTTP_POST, "/%s/networks" % GANETI_RAPI_VERSION,
1762 1762
                             query, body)
1763 1763

  
1764
  def ConnectNetwork(self, network_name, group_name, mode, link):
1764
  def ConnectNetwork(self, network_name, group_name, mode, link, dry_run=False):
1765 1765
    """Connects a Network to a NodeGroup with the given netparams
1766 1766

  
1767 1767
    """
......
1771 1771
      "network_link": link
1772 1772
      }
1773 1773

  
1774
    query = []
1775
    _AppendDryRunIf(query, dry_run)
1776

  
1774 1777
    return self._SendRequest(HTTP_PUT,
1775 1778
                             ("/%s/networks/%s/connect" %
1776
                             (GANETI_RAPI_VERSION, network_name)), None, body)
1779
                             (GANETI_RAPI_VERSION, network_name)), query, body)
1777 1780

  
1778
  def DisconnectNetwork(self, network_name, group_name):
1781
  def DisconnectNetwork(self, network_name, group_name, dry_run=False):
1779 1782
    """Connects a Network to a NodeGroup with the given netparams
1780 1783

  
1781 1784
    """
1782 1785
    body = {
1783 1786
      "group_name": group_name
1784 1787
      }
1788

  
1789
    query = []
1790
    _AppendDryRunIf(query, dry_run)
1791

  
1785 1792
    return self._SendRequest(HTTP_PUT,
1786 1793
                             ("/%s/networks/%s/disconnect" %
1787
                             (GANETI_RAPI_VERSION, network_name)), None, body)
1794
                             (GANETI_RAPI_VERSION, network_name)), query, body)
1788 1795

  
1789 1796

  
1797
  def ModifyNetwork(self, network, **kwargs):
1798
    """Modifies a network.
1799

  
1800
    More details for parameters can be found in the RAPI documentation.
1801

  
1802
    @type network: string
1803
    @param network: Network name
1804
    @rtype: string
1805
    @return: job id
1806

  
1807
    """
1808
    return self._SendRequest(HTTP_PUT,
1809
                             ("/%s/networks/%s/modify" %
1810
                              (GANETI_RAPI_VERSION, network)), None, kwargs)
1811

  
1790 1812
  def DeleteNetwork(self, network, dry_run=False):
1791 1813
    """Deletes a network.
1792 1814

  
......
1806 1828
                             ("/%s/networks/%s" %
1807 1829
                              (GANETI_RAPI_VERSION, network)), query, None)
1808 1830

  
1831
  def GetNetworkTags(self, network):
1832
    """Gets tags for a network.
1833

  
1834
    @type network: string
1835
    @param network: Node group whose tags to return
1836

  
1837
    @rtype: list of strings
1838
    @return: tags for the network
1839

  
1840
    """
1841
    return self._SendRequest(HTTP_GET,
1842
                             ("/%s/networks/%s/tags" %
1843
                              (GANETI_RAPI_VERSION, network)), None, None)
1844

  
1845
  def AddNetworkTags(self, network, tags, dry_run=False):
1846
    """Adds tags to a network.
1847

  
1848
    @type network: str
1849
    @param network: network to add tags to
1850
    @type tags: list of string
1851
    @param tags: tags to add to the network
1852
    @type dry_run: bool
1853
    @param dry_run: whether to perform a dry run
1854

  
1855
    @rtype: string
1856
    @return: job id
1857

  
1858
    """
1859
    query = [("tag", t) for t in tags]
1860
    _AppendDryRunIf(query, dry_run)
1861

  
1862
    return self._SendRequest(HTTP_PUT,
1863
                             ("/%s/networks/%s/tags" %
1864
                              (GANETI_RAPI_VERSION, network)), query, None)
1865

  
1866
  def DeleteNetworkTags(self, network, tags, dry_run=False):
1867
    """Deletes tags from a network.
1868

  
1869
    @type network: str
1870
    @param network: network to delete tags from
1871
    @type tags: list of string
1872
    @param tags: tags to delete
1873
    @type dry_run: bool
1874
    @param dry_run: whether to perform a dry run
1875
    @rtype: string
1876
    @return: job id
1877

  
1878
    """
1879
    query = [("tag", t) for t in tags]
1880
    _AppendDryRunIf(query, dry_run)
1881

  
1882
    return self._SendRequest(HTTP_DELETE,
1883
                             ("/%s/networks/%s/tags" %
1884
                              (GANETI_RAPI_VERSION, network)), query, None)
1885

  
1886

  
1809 1887
  def GetGroups(self, bulk=False):
1810 1888
    """Gets all node groups in the cluster.
1811 1889

  

Also available in: Unified diff