Beispiel #1
0
 def test_slices_dict_with_all_its_original_keys_and_filtered_nones(self):
     self.assertEqual(
         slice_dict(self.test_dict, "A", "B", "C", "D", allow_none=False), {
             "A": "a",
             "B": "b",
             "C": "c"
         })
Beispiel #2
0
    def update(self, tpl_id, data):
        """
        update config template

        :type  data['name']: string
        :param data['name']: template name

        :type  data['template']: string
        :param data['template']:
        :type  data['snippet']: string
        :param data['snippet']:
        :type  data['audit_comment']: string
        :param data['audit_comment']:
        :type  data['template_kind_id']: string
        :param data['template_kind_id']: not relevant for snippet

        :type  data['template_combinations_attributes']: string
        :param data['template_combinations_attributes']: Array of template combinations (hostgroup_id, environment_id)

        :type  data['operatingsystem_ids']: string
        :param data['operatingsystem_ids']: Array of operating systems ID to associate the template with
        """
        path = "/api/config_templates/%s" % (tpl_id)
        data = slice_dict(data, \
            'name', 'template', 'snippet', 'audit_comment', \
            'template_kind_id', 'template_combinations_attributes', \
            'operatingsystem_ids', allow_none=False)
        return self.server.PUT(path, {"config_template": data})[1]
Beispiel #3
0
 def create(self, data):
     """
     :type data['name']: string
     """
     path = "/api/architectures/"
     data = slice_dict(data, 'name')
     return self.server.POST(path, {'architecture': data})[1]
Beispiel #4
0
 def update(self, arch_id, data):
     """
     :type arch_id: string
     :param arch_id: architecture identifier
     :type data['name']: string
     """
     path = "/api/architectures/%s/" % str(arch_id)
     data = slice_dict(data, 'name')
     return self.server.PUT(path, {'architecture': data})[1]
Beispiel #5
0
    def revision(self, queries):
        """
        revision config template

        :type  data['version']: string
        :param data['version']: template version
        """
        path = "/api/config_templates/revision"
        queries = slice_dict(queries, 'version')
        return self.server.GET(path, queries)[1]
Beispiel #6
0
    def show(self, proxy_id, queries=None):
        """
        show smart proxy

        :type  data['proxy_id']: string
        :param data['proxy_id']: domain name (no slashes)
        """
        path = "/api/smart_proxies/%s" % (proxy_id)
        queries = slice_dict(queries or {}, 'id')
        return self.server.GET(path, queries)[1]
Beispiel #7
0
    def update(self, subnet_id, data):
        """
        Update a subnet

        :type  subnet_id: string
        :param subnet_id: <p>Subnet numeric identifier</p>

        :type  data['name']: string
        :param data['name']: <p>Subnet name</p>

        :type  data['network']: string
        :param data['network']: <p>Subnet network</p>

        :type  data['mask']: string
        :param data['mask']: <p>Netmask for this subnet</p>

        :type  data['gateway']: string
        :param data['gateway']: <p>Primary DNS for this subnet</p>

        :type  data['dns_primary']: string
        :param data['dns_primary']: <p>Primary DNS for this subnet</p>

        :type  data['dns_secondary']: string
        :param data['dns_secondary']: <p>Secondary DNS for this subnet</p>

        :type  data['from']: string
        :param data['from']: <p>Starting IP Address for IP auto suggestion</p>

        :type  data['to']: string
        :param data['to']: <p>Ending IP Address for IP auto suggestion</p>

        :type  data['vlanid']: string
        :param data['vlanid']: <p>VLAN ID for this subnet</p>

        :type  data['domain_ids']: string
        :param data['domain_ids']: <p>Domains in which this subnet is part</p>

        :type  data['dhcp_id']: string
        :param data['dhcp_id']: <p>DHCP Proxy to use within this subnet</p>

        :type  data['tftp_id']: string
        :param data['tftp_id']: <p>TFTP Proxy to use within this subnet</p>

        :type  data['dns_id']: string
        :param data['dns_id']: <p>DNS Proxy to use within this subnet</p>
        """
        path = "/api/subnets/%s" % (subnet_id)
        data = slice_dict(data, \
            'name', 'network', 'mask', 'gateway', 'dns_primary', \
            'dns_secondary', 'from', 'to', 'vlanid', 'domain_ids', \
            'dhcp_id', 'tftp_id', 'dns_id')
        return self.server.PUT(path, {"subnet": data})[1]
Beispiel #8
0
    def list(self, queries):
        """
        list domain

        :type  queries['search']: string
        :param queries['search']: Filter results

        :type  queries['order']: string
        :param queries['order']: Sort results
        """
        path = "/api/domains"
        queries = slice_dict(queries, 'search', 'order', allow_none=False)
        return self.server.GET(path, queries)[1]
Beispiel #9
0
    def list(self, queries):
        """
        list config template

        :type  queries['search']: string
        :param queries['search']: filter results

        :type  queries['order']: string
        :param queries['order']: sort results
        """
        path = "/api/config_templates"
        queries = slice_dict(queries, 'search', 'order', allow_none=False)
        return self.server.GET(path, queries)[1]
Beispiel #10
0
    def list(self, queries=None):
        """
        list smart proxy

        :type  data['search']: string
        :param data['search']: Filter results

        :type  data['order']: string
        :param data['order']: Sort results
        """
        path = "/api/smart_proxies"
        queries = slice_dict(queries or {}, 'search', 'order')
        return self.server.GET(path, queries)[1]
Beispiel #11
0
    def list(self, queries=None):
        """
        List subnets

        :type  data['search']: string
        :param data['search']: <p>Filter results</p>

        :type  data['order']: string
        :param data['order']: <p>Sort results</p>
        """
        path = "/api/subnets"
        if queries:
            queries = slice_dict(queries, 'search', 'order')
        return self.server.GET(path, queries)[1]
Beispiel #12
0
    def create(self, data):
        """
        The fullname field is used for human readability in reports
        and other pages that refer to domains, and also available as
        an external node parameter

        :type  data['name']: string
        :param data['name']: The smart proxy name

        :type  data['url']: string
        :param data['url']: The smart proxy URL starting with 'http://' or 'https://'
        """
        path = "/api/smart_proxies"
        data = slice_dict(data, 'name', 'url')
        return self.server.POST(path, {"smart_proxy": data})[1]
Beispiel #13
0
    def create(self, data):
        """
        create hardware model

        :type  data['name']: string
        :param data['name']:
        :type  data['info']: string
        :param data['info']:
        :type  data['vendor_class']: string
        :param data['vendor_class']:
        :type  data['hardware_model']: string
        :param data['hardware_model']:
        """
        data = slice_dict(data, 'name', 'info', 'vendor_class', 'hardware_model')
        return self.server.POST(self.__path(), {"hardware_model": data})[1]
Beispiel #14
0
    def update(self, proxy_id, data):
        """
        update smart proxy

        :type  data['proxy_id']: string
        :param data['proxy_id']: domain name (no slashes)

        :type  data['name']: string
        :param data['name']: The smart proxy name

        :type  data['url']: string
        :param data['url']: The smart proxy URL starting with 'http://' or 'https://'
        """
        path = "/api/smart_proxies/%s" % (proxy_id)
        data = slice_dict(data, 'name', 'url')
        return self.server.PUT(path, {"smart_proxy": data})[1]
Beispiel #15
0
    def update(self, resource_id, data):
        """
        :type resource_id: string
        :param resource_id: compute resource identifier

        :type data['name']: string

        :type data['provider']: string
        :param data['provider']: Provider type, one of: Libvirt Ovirt EC2 Vmware Openstack Rackspace

        :type data['url']: string
        :param data['url']: URL for Libvirt, Ovirt, and Openstack

        :type data['description']: string

        :type data['user']: string
        :param data['user']: Username for Ovirt, EC2, Vmware, Openstack. Access Key for EC2.

        :type data['password']: string
        :param data['password']: Password for Ovirt, EC2, Vmware, Openstack. Secret key for EC2

        :type data['uuid']: string
        :param data['uuid']: for Ovirt, Vmware Datacenter

        :type data['region']: string
        :param data['region']: for EC2 only

        :type data['tenant']: string
        :param data['tenant']: for Openstack only

        :type data['server']: string
        :param data['server']: for Vmware
        """
        data = slice_dict(data,
            'name',
            'url',
            'description',
            'user',
            'password',
            'uuid',
            'region',
            'tenant',
            'server'
        )
        return self.server.PUT(self.__path(resource_id), {'compute_resource': data})[1]
Beispiel #16
0
    def create(self, data):
        """
        :type name: string

        :type provider: string
        :param provider: Provider type, one of: Libvirt Ovirt EC2 Vmware Openstack Rackspace

        :type url: string
        :param url: URL for Libvirt, Ovirt, and Openstack

        :type description: string

        :type user: string
        :param user: Username for Ovirt, EC2, Vmware, Openstack. Access Key for EC2.

        :type password: string
        :param password: Password for Ovirt, EC2, Vmware, Openstack. Secret key for EC2

        :type uuid: string
        :param uuid: for Ovirt, Vmware Datacenter

        :type region: string
        :param region: for EC2 only

        :type tenant: string
        :param tenant: for Openstack only

        :type server: string
        :param server: for Vmware
        """
        data = slice_dict(data,
            'name',
            'provider',
            'url',
            'description',
            'user',
            'password',
            'uuid',
            'region',
            'tenant',
            'server'
        )
        return self.server.POST(self.__path(), {'compute_resource': data})[1]
Beispiel #17
0
    def create(self, data):
        """
        create config template

        :type  data['name']: string
        :param data['name']: template name

        :type  data['template']: string
        :param data['template']:
        :type  data['snippet']: string
        :param data['snippet']:
        :type  data['audit_comment']: string
        """
        path = "/api/config_templates"
        data = slice_dict(data, \
            'name', 'template', 'snippet', 'audit_comment', \
            'template_kind_id', 'template_combinations_attributes', \
            'operatingsystem_ids')
        return self.server.POST(path, {"config_template": data})[1]
Beispiel #18
0
    def update(self, model_id, data):
        """
        update hardware model

        :type  model_id: string
        :param model_id: hardware model name
        :type  data: hash
        :param data: hardware model info
        :type  data['name']: string
        :param data['name']:
        :type  data['info']: string
        :param data['info']:
        :type  data['vendor_class']: string
        :param data['vendor_class']:
        :type  data['hardware_model']: string
        :param data['hardware_model']:
        """
        data = slice_dict(data, 'name', 'info', 'vendor_class', 'hardware_model')
        return self.server.PUT(self.__path(model_id), {"hardware_model": data})[1]
Beispiel #19
0
    def update(self, domain_id, data):
        """
        update domain

        :type  domain_id: string

        :type  data['name']: string
        :param data['name']: The full DNS Domain name

        :type  data['fullname']: string
        :param data['fullname']: Full name describing the domain

        :type  data['dns_id']: string
        :param data['dns_id']: DNS Proxy to use within this domain

        :type  data['domain_parameters_attributes']: string
        :param data['domain_parameters_attributes']: Array of parameters (name, value)
        """
        path = "/api/domains/%s" % str(domain_id)
        data = slice_dict(data, 'name', 'fullname', 'dns_id')
        return self.server.PUT(path, {"domain": data})[1]
Beispiel #20
0
    def create(self, data):
        """
        The fullname< field is used for human readability in reports
        and other pages that refer to domains, and also available
        as an external node parameter


        :type  data['name']: string
        :param data['name']: The full DNS Domain name

        :type  data['fullname']: string
        :param data['fullname']: Full name describing the domain

        :type  data['dns_id']: string
        :param data['dns_id']: DNS Proxy to use within this domain

        :type  data['domain_parameters_attributes']: string
        :param data['domain_parameters_attributes']: Array of parameters (name, value)
        """
        path = "/api/domains"
        data = slice_dict(data, 'name', 'fullname', 'dns_id')
        return self.server.POST(path, {"domain": data})[1]
Beispiel #21
0
 def test_slices_dict_with_one_of_its_original_keys(self):
     self.assertEqual(slice_dict(self.test_dict, "A", "Z"), {"A": "a"})
Beispiel #22
0
 def test_slices_dict_with_all_its_original_keys_and_filtered_nones(self):
     self.assertEqual(
         slice_dict(self.test_dict, "A", "B", "C", "D", allow_none=False),
         {"A": "a", "B": "b", "C": "c"}
     )
Beispiel #23
0
 def test_slices_dict_with_one_of_its_original_keys(self):
     self.assertEqual(
         slice_dict(self.test_dict, "A", "Z"),
         {"A": "a"}
     )
Beispiel #24
0
 def test_returns_empty_dict_if_no_keys_specified(self):
     self.assertEqual(slice_dict(self.test_dict), {})
Beispiel #25
0
 def test_slices_dict(self):
     self.assertEqual(slice_dict(self.test_dict, "A"), {"A": "a"})
Beispiel #26
0
 def test_returns_empty_dict_if_no_keys_specified(self):
     self.assertEqual(
         slice_dict(self.test_dict),
         {}
     )
Beispiel #27
0
 def test_slices_dict_with_all_its_original_keys(self):
     self.assertEqual(
         slice_dict(self.test_dict, "A", "B", "C", "D"),
         self.test_dict
     )
Beispiel #28
0
 def test_slices_dict_with_all_its_original_keys(self):
     self.assertEqual(slice_dict(self.test_dict, "A", "B", "C", "D"),
                      self.test_dict)
Beispiel #29
0
 def test_slices_dict(self):
     self.assertEqual(
         slice_dict(self.test_dict, "A"),
         {"A": "a"}
     )