示例#1
0
    def test_190_create_server_neutron(self):
        network_id = nested_search(
            "networks/*/name=%s/id" % self.config["nova"]["network_label"],
            neutron.GET("/%s/networks" % neutron_api_ver, code=200)[1],
        )[0]
        image = nova.GET("/images?name=test-image")[1]["images"][0]["id"]
        flavor = nested_search("/flavors/*/name=m1.tiny/id", nova.GET("/flavors")[1])[0]

        # TODO(brett): Investigate performance.
        # It's now taking 90+ seconds for server to go active on Cent (Havana).
        # Don't see any obvious timeouts or exceptions in cluster.
        r, d = nova.POST(
            "/servers",
            body={
                "server": {
                    "name": "testing server creation",
                    "imageRef": image,
                    "flavorRef": flavor,
                    "max_count": 1,
                    "min_count": 1,
                    "networks": [{"uuid": network_id}],
                    "security_groups": [{"name": "test-sec-group"}],
                }
            },
            code=202,
        )
        server_id = d["server"]["id"]
        r, d = nova.GET_with_keys_eq(
            "/servers/%s" % server_id, {"/server/status": "ACTIVE"}, code=200, timeout=120, delay=5
        )
        ip = d["server"]["addresses"][self.config["nova"]["network_label"]][0]["addr"]

        netns = "qdhcp-%s" % network_id
        if not self.ping_host(ip, netns=netns, delay=5, timeout=120):
            raise AssertionError("Server is active but does not ping")
示例#2
0
 def test_210_list_addresses(self):
     label = self.config["nova"]["network_label"]
     r, d = nova.GET("/servers")
     sid = nested_search("/servers/*/name=testing server creation/id", d)[0]
     addrs = nova.GET("/servers/%s/ips" % (sid), code=200)[1]
     if not len(nested_search("/addresses/%s" % (label), addrs)[0]) > 0:
         raise AssertionError("No addresses found for network %s" % (label))
示例#3
0
    def test_190_create_server_neutron(self):
        network_id = nested_search(
            'networks/*/name=%s/id' % self.config['nova']['network_label'],
            neutron.GET('/%s/networks' % neutron_api_ver, code=200)[1])[0]
        image = nova.GET("/images?name=test-image")[1]['images'][0]['id']
        flavor = nested_search("/flavors/*/name=m1.tiny/id",
                               nova.GET("/flavors")[1])[0]

        r, d = nova.POST("/servers",
                         body={
                             "server": {
                                 "name": "testing server creation",
                                 "imageRef": image,
                                 "flavorRef": flavor,
                                 "max_count": 1,
                                 "min_count": 1,
                                 "networks": [{
                                     "uuid": network_id
                                 }]
                             }
                         },
                         code=202)
        server_id = d['server']['id']
        r, d = nova.GET_with_keys_eq("/servers/%s" % server_id,
                                     {"/server/status": "ACTIVE"},
                                     code=200,
                                     timeout=60,
                                     delay=5)
        ip = d['server']['addresses'][self.config['nova']
                                      ['network_label']][0]['addr']

        netns = "qdhcp-%s" % network_id
        if not self.ping_host(ip, netns=netns, delay=5, timeout=200):
            raise AssertionError("Server is active but does not ping")
示例#4
0
    def test_190_create_server_neutron(self):
        network_id = nested_search(
            'networks/*/name=%s/id' % self.config['nova']['network_label'],
            neutron.GET('/%s/networks' % neutron_api_ver, code=200)[1])[0]
        image = nova.GET("/images?name=test-image")[1]['images'][0]['id']
        flavor = nested_search("/flavors/*/name=m1.tiny/id",
                               nova.GET("/flavors")[1])[0]


        r, d = nova.POST("/servers",
                        body={"server": 
                                 {"name": "testing server creation", 
                                 "imageRef": image, "flavorRef": flavor, 
                                 "max_count": 1, "min_count": 1, 
                                 "networks": [{"uuid": network_id}],
                                 "security_groups": [{"name": "test-sec-group"}]
                                 }
                             },
                        code=202) 
        server_id = d['server']['id']
        r, d = nova.GET_with_keys_eq("/servers/%s" % server_id,
                                     {"/server/status": "ACTIVE"},
                                     code=200, timeout=60, delay=5)
        ip = d['server']['addresses'][self.config['nova']['network_label']][0]['addr']

        netns="qdhcp-%s" % network_id
        if not self.ping_host(ip, netns=netns, delay=5, timeout=120):
            raise AssertionError("Server is active but does not ping")
示例#5
0
 def test_901_delete_security_group_rule(self):
     data = nova.GET("/os-security-groups")[1]
     gid = nested_search("/security_groups/*/name=kongsec/id", data)[0]
     rids = nested_search("/security_groups/*/rules/*/parent_group_id=" +\
                         str(gid) + "/id", data)
     for rid in rids:
         nova.DELETE("/os-security-group-rules/%s" % rid, code=202)
示例#6
0
 def test_210_list_addresses(self):
     label = self.config['nova']['network_label']
     r, d = nova.GET("/servers")
     sid = nested_search("/servers/*/name=testing server creation/id", d)[0]
     addrs = nova.GET('/servers/%s/ips' % (sid), code=200)[1]
     if not len(nested_search('/addresses/%s' % (label), addrs)[0]) > 0:
         raise AssertionError("No addresses found for network %s" % (label))
示例#7
0
 def test_901_delete_security_group_rule(self):
     data = nova.GET("/os-security-groups")[1]
     gid = nested_search("/security_groups/*/name=kongsec/id",
                         data)[0]
     rids = nested_search("/security_groups/*/rules/*/parent_group_id=" +\
                         str(gid) + "/id", data)
     for rid in rids:
         nova.DELETE("/os-security-group-rules/%s" % rid, code=202)
示例#8
0
 def test_901_delete_security_group_rule_diablo_final(self):
     data = nova.GET("/os-security-groups")[1]
     gid = nested_search("/security_groups/*/name=kongsec/id", data)[0]
     rids = nested_search("/security_groups/*/rules/*/parent_group_id=" + str(gid) + "/id", data)
     try:
         for rid in rids:
             nova.DELETE("/os-security-group-rules/%s" % rid, code=202)
     except ValueError:
         pass
示例#9
0
    def test_010_dhcp_agent_network_add(self):
        dhcp_agent_id = nested_search(
            'agents/*/agent_type=DHCP agent/id',
            neutron.GET('/%s/agents' % api_ver, code=200)[1])[0]
        network_id = nested_search(
            'networks/*/name=test-network/id',
            neutron.GET('/%s/networks' % api_ver, code=200)[1])[0]

        resp, body = neutron.POST('/%s/agents/%s/dhcp-networks.json' %
                                  (api_ver, dhcp_agent_id),
                                  body={'network_id': '%s' % network_id},
                                  code=201)
示例#10
0
    def test_920_security_group_rule_delete(self):
        secgroup_id = nested_search(
            "security_groups/*/name=test-sec-group/id",
            neutron.GET("/%s/security-groups" % neutron_api_ver, code=200)[1],
        )[0]
        resp, body = neutron.GET("/%s/security-groups/%s" % (neutron_api_ver, secgroup_id))

        try:
            secgroup_rule_id = nested_search("security_group/security_group_rules/*/protocol=icmp/id", body)[0]
            neutron.DELETE("/%s/security-group-rules/%s.json" % (neutron_api_ver, secgroup_rule_id), code=204)
        except IndexError:
            pass
示例#11
0
    def test_026_security_group_rule_show(self):
        secgroup_id = nested_search(
            'security_groups/*/name=test-sec-group/id',
            neutron.GET('/%s/security-groups' % api_ver, code=200)[1])[0]
        resp, body = neutron.GET('/%s/security-groups/%s' %
                                 (api_ver, secgroup_id))

        secgroup_rule_id = nested_search(
            'security_group/security_group_rules/*/protocol=icmp/id', body)

        neutron.GET('/%s/security-group-rules/%s.json' %
                    (api_ver, secgroup_rule_id))
示例#12
0
    def test_026_security_group_rule_show(self):
        secgroup_id = nested_search(
            'security_groups/*/name=test-sec-group/id',
            neutron.GET('/%s/security-groups' % api_ver, code=200)[1])[0]
        resp, body = neutron.GET(
            '/%s/security-groups/%s'
            % (api_ver, secgroup_id))

        secgroup_rule_id = nested_search(
            'security_group/security_group_rules/*/protocol=icmp/id', body)[0]

        neutron.GET(
            '/%s/security-group-rules/%s.json' % (api_ver, secgroup_rule_id))
示例#13
0
 def test_200_create_server(self):
     image = nova.GET("/images?name=test-image")[1]['images'][0]['id']
     flavor = nested_search("/flavors/*/name=m1.tiny/id",
                            nova.GET("/flavors")[1])[0]
     r, d = nova.POST("/servers",
                      body={
                          "server": {
                              "name": "testing server creation",
                              "flavorRef": flavor,
                              "imageRef": image,
                              "security_groups": [{
                                  "name": "kongsec"
                              }]
                          }
                      },
                      code=202)
     server_id = d['server']['id']
     r, d = nova.GET_with_keys_eq("/servers/%s" % server_id,
                                  {"/server/status": "ACTIVE"},
                                  code=200,
                                  timeout=60,
                                  delay=5)
     net = d['server']['addresses'][self.config['nova']['network_label']]
     good = False
     for i in net:
         if self.ping_host(i['addr'], delay=5, timeout=200):
             good = True
     if not good:
         raise AssertionError("Server is active but does not ping")
示例#14
0
 def test_nova_list_flavors(self):
     r, d = nova.GET("/flavors", code=200)
     if len(d['flavors']) == 0:
         raise AssertionError("No flavors configured in openstack")
     if len(nested_search("/flavors/*/name=m1.tiny",
                          nova.GET("/flavors")[1])) == 0:
         raise AssertionError("No flavor m1.tiny found.")
示例#15
0
 def _init_keystone(self, service, target):
     (url, user, password, tenantname, region) = self.get_config()
     body = {"auth": {"passwordCredentials": {"username": user,
             "password": password}, "tenantName": tenantname}}
     request_t = []
     response_t = []
     try:
         response, data = self.POST(url, body=body, code=200)
     except AssertionError:
         try:
             response, data = self.POST(url, body=body['auth'], code=200)
             data['access'] = data['auth']
         except:
             request_t = [print_curl_request]
             response_t = [print_it]
             print "Failed to auth.  Trying once more with verbosity"
             response, data = self.POST(url, body=body, code=200, 
                                        request_transformers=request_t,
                                        response_transformers=response_t)
     services = nested_get("/access/serviceCatalog", data)
     try:
         endpoint = nested_search(
             "/access/serviceCatalog/*/type=%s/endpoints/*/region=%s/%s" %
             (service, region, target), data)[0]
     except IndexError:
         endpoint = []
     finally:
         if endpoint == []:
             raise ValueError(('No endpoint found for service "%s" in'
                              + ' region "%s" with target "%s"\n'
                              + 'service catalog: "%s"') %
                              (service, region, target, services))
     token = nested_get("/access/token/id", data)
     return endpoint, token, services, data
示例#16
0
 def test_200_create_server(self):
     image = nova.GET("/images?name=test-image")[1]["images"][0]["id"]
     flavor = nested_search("/flavors/*/name=m1.tiny/id", nova.GET("/flavors")[1])[0]
     r, d = nova.POST(
         "/servers",
         body={
             "server": {
                 "name": "testing server creation",
                 "flavorRef": flavor,
                 "imageRef": image,
                 "security_groups": [{"name": "kongsec"}],
             }
         },
         code=202,
     )
     server_id = d["server"]["id"]
     r, d = nova.GET_with_keys_eq(
         "/servers/%s" % server_id, {"/server/status": "ACTIVE"}, code=200, timeout=60, delay=5
     )
     net = d["server"]["addresses"][self.config["nova"]["network_label"]]
     good = False
     for i in net:
         if self.ping_host(i["addr"], delay=5, timeout=200):
             good = True
     if not good:
         raise AssertionError("Server is active but does not ping")
示例#17
0
    def test_045_security_group_rule_delete(self):
        secgroup_id = nested_search(
            'security_groups/*/name=test-sec-group/id',
            neutron.GET('/%s/security-groups' % api_ver, code=200)[1])[0]
        resp, body = neutron.GET(
            '/%s/security-groups/%s' % (api_ver, secgroup_id))

        try:
            secgroup_rule_id = nested_search(
                'security_group/security_group_rules/*/protocol=icmp/id',
                body)[0]
            neutron.DELETE(
                '/%s/security-group-rules/%s.json'
                % (api_ver, secgroup_rule_id), code=204)
        except IndexError:
            pass
示例#18
0
    def test_161_security_group_rule_create(self):
        secgroup_id = nested_search(
            "security_groups/*/name=test-sec-group/id",
            neutron.GET("/%s/security-groups" % neutron_api_ver, code=200)[1],
        )[0]

        resp, body = neutron.POST(
            "/%s/security-group-rules.json" % neutron_api_ver,
            body={
                "security_group_rule": {
                    "ethertype": "IPv4",
                    "direction": "ingress",
                    "protocol": "ICMP",
                    "security_group_id": "%s" % secgroup_id,
                }
            },
        )

        secgroup_rule_id = body["security_group_rule"]["id"]

        resp, body = neutron.GET_with_keys_eq(
            "/%s/security-group-rules/%s.json" % (neutron_api_ver, secgroup_rule_id),
            {"/security_group_rule/protocol": "icmp"},
            code=200,
        )
示例#19
0
    def test_045_security_group_rule_delete(self):
        secgroup_id = nested_search(
            'security_groups/*/name=test-sec-group/id',
            neutron.GET('/%s/security-groups' % api_ver, code=200)[1])[0]
        resp, body = neutron.GET('/%s/security-groups/%s' %
                                 (api_ver, secgroup_id))

        try:
            secgroup_rule_id = nested_search(
                'security_group/security_group_rules/*/protocol=icmp/id',
                body)[0]
            neutron.DELETE('/%s/security-group-rules/%s.json' %
                           (api_ver, secgroup_rule_id),
                           code=204)
        except IndexError:
            pass
示例#20
0
 def test_902_delete_security_group_diablo_final(self):
     gid = nested_search("/security_groups/*/name=kongsec/id",
                         nova.GET("/os-security-groups")[1])[0]
     nova.DELETE("/os-security-groups/%s" % gid,
                 timeout=60,
                 delay=5,
                 code=404)
示例#21
0
 def test_nova_list_flavors(self):
     r, d = nova.GET("/flavors", code=200)
     if len(d['flavors']) == 0:
         raise AssertionError("No flavors configured in openstack")
     if len(nested_search("/flavors/*/name=m1.tiny",
                          nova.GET("/flavors")[1])) == 0:
         raise AssertionError("No flavor m1.tiny found.")
示例#22
0
 def test_002_agent_show(self):
     agent_id = nested_search(
         'agents/*/id',
         neutron.GET(
             '/%s/agents' % api_ver,
             code=200)
         [1])[0]
     neutron.GET('/%s/agents/%s' % (api_ver, agent_id), code=200)
示例#23
0
    def test_008_net_show(self):
        network_id = nested_search('networks/*/name=test-network/id',
                                   neutron.GET(
                                       '/%s/networks' % api_ver,
                                       code=200)
                                   [1])[0]

        neutron.GET('/%s/networks/%s' % (api_ver, network_id), code=200)
示例#24
0
    def test_020_quota_list(self):
        tenant_id = neutron.GET(
            '/%s/quotas/tenant.json' % api_ver)[1]['tenant']['tenant_id']

        resp, body = neutron.GET('/%s/quotas.json' % api_ver, code=200)

        our_quota = nested_search(
            'quotas/*/tenant_id=%s/tenant_id' % tenant_id, body)[0]
        assert our_quota == tenant_id
示例#25
0
 def test_151_create_security_group_rule(self):
     gid = nested_search("/security_groups/*/name=kongsec/id",
                         nova.GET("/os-security-groups")[1])[0]
     nova.POST("/os-security-group-rules",
               body={"security_group_rule":
                     {"from_port": "-1", "to_port": "-1",
                      "parent_group_id": "%s" % gid,
                      "cidr": "0.0.0.0/0", "ip_protocol": "icmp"}},
                      code=200)
示例#26
0
    def test_020_quota_list(self):
        tenant_id = neutron.GET('/%s/quotas/tenant.json' %
                                api_ver)[1]['tenant']['tenant_id']

        resp, body = neutron.GET('/%s/quotas.json' % api_ver, code=200)

        our_quota = nested_search(
            'quotas/*/tenant_id=%s/tenant_id' % tenant_id, body)[0]
        assert our_quota == tenant_id
示例#27
0
 def test_keystone_v2_02_create_tenant_user(self):
     response, data = admin.GET("/tenants")
     kong_tenant = nested_search("/tenants/*/name=kongtenant/id", data)[0]
     user = {"user": {
                          "name": "kongadmin",
                          "password": "******",
                          "tenantid": kong_tenant,
                          "email": ""}}
     admin.POST("/users", body=user, code=200)
示例#28
0
 def test_keystone_v2_02_create_tenant_user(self):
     response, data = admin.GET("/tenants")
     kong_tenant = nested_search("/tenants/*/name=kongtenant/id", data)[0]
     user = {"user": {
                          "name": "kongadmin",
                          "password": "******",
                          "tenantid": kong_tenant,
                          "email": ""}}
     admin.POST("/users", body=user, code=200)
示例#29
0
 def test_151_create_security_group_rule(self):
     gid = nested_search("/security_groups/*/name=kongsec/id",
                         nova.GET("/os-security-groups")[1])[0]
     nova.POST("/os-security-group-rules",
               body={"security_group_rule":
                     {"from_port": "-1", "to_port": "-1",
                      "parent_group_id": "%s" % gid,
                      "cidr": "0.0.0.0/0", "ip_protocol": "icmp"}},
                      code=200)
示例#30
0
    def test_006_net_list_on_dhcp_agent(self):
        dhcp_agent_id = nested_search(
            'agents/*/agent_type=DHCP agent/id',
            neutron.GET('/%s/agents' % api_ver, code=200)[1])

        if dhcp_agent_id:
            neutron.GET('/%s/subnets.json?id=%s' % (api_ver, dhcp_agent_id),
                        code=200)
        else:
            pass
示例#31
0
    def test_014_delete_volume_type(self):
        type_id = nested_search('/volume_types/*/name=test-type/id',
                                cinder.GET('/types')[1])[0]

        resp, body = cinder.DELETE('/types/%s' % type_id, code=202)

        resp, body = cinder.GET('/types/%s' % type_id,
                                code=404,
                                timeout=10,
                                delay=5)
示例#32
0
    def test_013_delete_volume(self):
        volume_id = nested_search('/volumes/*/display_name=test-volume/id',
                                  cinder.GET('/volumes/detail')[1])[0]

        resp, body = cinder.DELETE('/volumes/%s' % volume_id, code=202)

        resp, body = cinder.GET('/volumes/%s' % volume_id,
                                code=404,
                                timeout=80,
                                delay=5)
示例#33
0
    def test_100_delete_container(self):
        # need to get a list of objects in the container and delete them
        response, body = swift.GET(('/%s?format=json') % (CONTAINER), code=200)
        # pull the objects out of the returned json
        objects = nested_search('*/name', body)
        # delete the objects one by one
        for obj in objects:
            swift.DELETE('%s/%s' % (CONTAINER, obj), code=204)

        # now we can delete the container
        swift.DELETE('/%s?format=json' % (CONTAINER), code=204)
示例#34
0
    def test_100_delete_container(self):
        # need to get a list of objects in the container and delete them
        response, body = swift.GET(('/%s?format=json') % (CONTAINER), code=200)
        # pull the objects out of the returned json
        objects = nested_search('*/name', body)
        # delete the objects one by one
        for obj in objects:
            swift.DELETE('%s/%s' % (CONTAINER, obj), code=204)

        # now we can delete the container
        swift.DELETE('/%s?format=json' % (CONTAINER), code=204)
示例#35
0
    def test_013_delete_volume(self):
        volume_id = nested_search(
            '/volumes/*/display_name=test-volume/id',
            cinder.GET('/volumes/detail')[1])[0]

        resp, body = cinder.DELETE(
            '/volumes/%s' % volume_id, code=202)

        resp, body = cinder.GET(
            '/volumes/%s' % volume_id,
            code=404, timeout=80, delay=5)
示例#36
0
    def test_012_delete_snapshot(self):
        snapshot_id = nested_search(
            '/snapshots/*/display_name=test-snapshot/id',
            cinder.GET('/snapshots/detail')[1])[0]

        resp, body = cinder.DELETE('/snapshots/%s' % snapshot_id, code=202)

        resp, body = cinder.GET('/snapshots/%s' % snapshot_id,
                                code=404,
                                timeout=80,
                                delay=5)
示例#37
0
    def test_012_delete_snapshot(self):
        snapshot_id = nested_search(
            '/snapshots/*/display_name=test-snapshot/id',
            cinder.GET('/snapshots/detail')[1])[0]

        resp, body = cinder.DELETE(
            '/snapshots/%s' % snapshot_id,
            code=202)

        resp, body = cinder.GET(
            '/snapshots/%s' % snapshot_id,
            code=404, timeout=80, delay=5)
示例#38
0
    def test_014_delete_volume_type(self):
        type_id = nested_search(
            '/volume_types/*/name=test-type/id',
            cinder.GET('/types')[1])[0]

        resp, body = cinder.DELETE(
            '/types/%s' % type_id,
            code=202)

        resp, body = cinder.GET(
            '/types/%s' % type_id,
            code=404, timeout=10, delay=5)
示例#39
0
 def test_203_update_server(self):
     r, d = nova.GET("/servers/detail")
     sid = nested_search("/servers/*/name=testing server creation/id", d)[0]
     name = "updated"
     nova.PUT_with_keys_eq(
         "/servers/%s" % sid,
         {"/server/name": name},
         body={"server": {"name": name}},
         code=200)
     nova.PUT("/servers/%s" % sid,
              body={"server":
                    {"name": "testing server creation"}})
示例#40
0
 def test_203_update_server(self):
     r, d = nova.GET("/servers/detail")
     sid = nested_search("/servers/*/name=testing server creation/id", d)[0]
     name = "updated"
     nova.PUT_with_keys_eq(
         "/servers/%s" % sid,
         {"/server/name": name},
         body={"server": {"name": name}},
         code=200)
     nova.PUT("/servers/%s" % sid,
              body={"server":
                    {"name": "testing server creation"}})
示例#41
0
    def test_006_net_list_on_dhcp_agent(self):
        dhcp_agent_id = nested_search(
            'agents/*/agent_type=DHCP agent/id',
            neutron.GET(
                '/%s/agents' % api_ver,
                code=200)
            [1])

        if dhcp_agent_id:
            neutron.GET('/%s/subnets.json?id=%s' % (api_ver, dhcp_agent_id),
                        code=200)
        else:
            pass
示例#42
0
    def test_011_subnet_create(self):
        network_id = nested_search(
            'networks/*/name=test-network/id',
            neutron.GET('/%s/networks' % api_ver, code=200)[1])[0]

        resp, body = neutron.POST(
            '/%s/subnets.json' % api_ver,
            body={'subnet': {
                  'network_id': '%s' % network_id,
                  'ip_version': 4,
                  'cidr': '192.168.78.0/29',
                  'name': 'test-subnet'}},
            code=201)
示例#43
0
    def test_170_subnet_create(self):
        network_id = nested_search(
            'networks/*/name=%s/id' % self.config['nova']['network_label'],
            neutron.GET('/%s/networks' % neutron_api_ver, code=200)[1])[0]

        resp, body = neutron.POST(
            '/%s/subnets.json' % neutron_api_ver,
            body={'subnet': {
                  'network_id': '%s' % network_id,
                  'ip_version': 4,
                  'cidr': '192.168.78.0/29',
                  'name': 'test-subnet'}},
            code=201)
示例#44
0
    def test_170_subnet_create(self):
        network_id = nested_search(
            'networks/*/name=%s/id' % self.config['nova']['network_label'],
            neutron.GET('/%s/networks' % neutron_api_ver, code=200)[1])[0]

        resp, body = neutron.POST('/%s/subnets.json' % neutron_api_ver,
                                  body={
                                      'subnet': {
                                          'network_id': '%s' % network_id,
                                          'ip_version': 4,
                                          'cidr': '192.168.78.0/29',
                                          'name': 'test-subnet'
                                      }
                                  },
                                  code=201)
示例#45
0
    def test_070_dhcp_agent_network_remove(self):
        resp, body = neutron.GET(
            '/%s/networks.json?fields=id&name=test-network' % api_ver,
            code=200)

        network_ids = [p['id'] for p in body['networks']]

        dhcp_agent_id = nested_search(
            'agents/*/agent_type=DHCP agent/id',
            neutron.GET('/%s/agents' % api_ver, code=200)[1])[0]

        for net in network_ids:
            resp, body = neutron.DELETE('/%s/agents/%s/dhcp-networks/%s' %
                                        (api_ver, dhcp_agent_id, net),
                                        code=204)
示例#46
0
    def test_011_subnet_create(self):
        network_id = nested_search(
            'networks/*/name=test-network/id',
            neutron.GET('/%s/networks' % api_ver, code=200)[1])[0]

        resp, body = neutron.POST('/%s/subnets.json' % api_ver,
                                  body={
                                      'subnet': {
                                          'network_id': '%s' % network_id,
                                          'ip_version': 4,
                                          'cidr': '192.168.78.0/29',
                                          'name': 'test-subnet'
                                      }
                                  },
                                  code=201)
示例#47
0
    def test_170_subnet_create(self):
        network_id = nested_search(
            "networks/*/name=%s/id" % self.config["nova"]["network_label"],
            neutron.GET("/%s/networks" % neutron_api_ver, code=200)[1],
        )[0]

        resp, body = neutron.POST(
            "/%s/subnets.json" % neutron_api_ver,
            body={
                "subnet": {
                    "network_id": "%s" % network_id,
                    "ip_version": 4,
                    "cidr": "192.168.78.0/29",
                    "name": "test-subnet",
                }
            },
            code=201,
        )
示例#48
0
    def test_011_create_snapshot(self):
        volume_id = nested_search(
            '/volumes/*/display_name=test-volume/id',
            cinder.GET('/volumes/detail')[1])[0]

        resp, body = cinder.POST(
            '/snapshots',
            body={"snapshot":
            {"display_name": "test-snapshot",
            "volume_id": volume_id}},
            code=200)

        snapshot_id = body["snapshot"]["id"]

        resp, body = cinder.GET_with_keys_eq(
            '/snapshots/%s' % snapshot_id,
            {"/snapshot/status": "available"},
            code=200, timeout=60, delay=5)
示例#49
0
    def test_014_subnet_update(self):
        subnet_id = nested_search(
            'subnets/*/name=test-subnet/id',
            neutron.GET('/%s/subnets' % api_ver, code=200)[1])[0]

        resp, body = neutron.PUT(
            '/%s/subnets/%s.json' % (api_ver, subnet_id),
            body={'subnet': {
                  'name': 'a-new-test-subnet'}},
            code=200)

        resp, body = neutron.GET_with_keys_eq(
            '/%s/subnets/%s' % (api_ver, subnet_id),
            {'/subnet/name': 'a-new-test-subnet'},
            code=200)

        neutron.PUT(
            '/%s/subnets/%s.json' % (api_ver, subnet_id),
            body={'subnet': {'name': 'test-subnet'}}, code=200)
示例#50
0
    def test_161_security_group_rule_create(self):
        secgroup_id = nested_search(
            'security_groups/*/name=test-sec-group/id',
            neutron.GET('/%s/security-groups' % neutron_api_ver, code=200)[1])[0]

        resp, body = neutron.POST(
            '/%s/security-group-rules.json' % neutron_api_ver,
            body={'security_group_rule': {
                  'ethertype': 'IPv4',
                  'direction': 'ingress',
                  'protocol': 'ICMP',
                  'security_group_id': '%s' % secgroup_id}})

        secgroup_rule_id = body['security_group_rule']['id']

        resp, body = neutron.GET_with_keys_eq(
            '/%s/security-group-rules/%s.json' % (neutron_api_ver, secgroup_rule_id),
            {'/security_group_rule/protocol': 'icmp'},
            code=200)
示例#51
0
 def _init_keystone(self, service, target):
     (url, user, password, tenantname, region) = self.get_config()
     body = {
         "auth": {
             "passwordCredentials": {
                 "username": user,
                 "password": password
             },
             "tenantName": tenantname
         }
     }
     request_t = []
     response_t = []
     try:
         response, data = self.POST(url, body=body, code=200)
     except AssertionError:
         try:
             response, data = self.POST(url, body=body['auth'], code=200)
             data['access'] = data['auth']
         except:
             request_t = [print_curl_request]
             response_t = [print_it]
             print "Failed to auth.  Trying once more with verbosity"
             response, data = self.POST(url,
                                        body=body,
                                        code=200,
                                        request_transformers=request_t,
                                        response_transformers=response_t)
     services = nested_get("/access/serviceCatalog", data)
     try:
         endpoint = nested_search(
             "/access/serviceCatalog/*/type=%s/endpoints/*/region=%s/%s" %
             (service, region, target), data)[0]
     except IndexError:
         endpoint = []
     finally:
         if endpoint == []:
             raise ValueError(('No endpoint found for service "%s" in' +
                               ' region "%s" with target "%s"\n' +
                               'service catalog: "%s"') %
                              (service, region, target, services))
     token = nested_get("/access/token/id", data)
     return endpoint, token, services, data
示例#52
0
    def test_019_quota_update(self):
        tenant_id = neutron.GET('/%s/quotas/tenant.json' %
                                api_ver)[1]['tenant']['tenant_id']
        current_subnet_quota = nested_search(
            'quota/subnet',
            neutron.GET('/%s/quotas/%s' % (api_ver, tenant_id),
                        code=200)[1])[0]
        target_subnet_quota = int(current_subnet_quota) + 1

        resp, body = neutron.PUT(
            '/%s/quotas/%s.json' % (api_ver, tenant_id),
            body={'quota': {
                'subnet': '%d' % target_subnet_quota
            }},
            code=200)

        resp, body = neutron.GET_with_keys_eq(
            '/%s/quotas/%s' % (api_ver, tenant_id),
            {'/quota/subnet': target_subnet_quota},
            code=200)
示例#53
0
    def test_019_quota_update(self):
        tenant_id = neutron.GET(
            '/%s/quotas/tenant.json' % api_ver)[1]['tenant']['tenant_id']
        current_subnet_quota = nested_search(
            'quota/subnet',
            neutron.GET(
                '/%s/quotas/%s' % (api_ver, tenant_id),
                code=200)
            [1])[0]
        target_subnet_quota = int(current_subnet_quota) + 1

        resp, body = neutron.PUT(
            '/%s/quotas/%s.json' % (api_ver, tenant_id),
            body={'quota': {'subnet': '%d' % target_subnet_quota}},
            code=200)

        resp, body = neutron.GET_with_keys_eq(
            '/%s/quotas/%s' % (api_ver, tenant_id),
            {'/quota/subnet': target_subnet_quota},
            code=200)
示例#54
0
    def test_011_create_snapshot(self):
        volume_id = nested_search('/volumes/*/display_name=test-volume/id',
                                  cinder.GET('/volumes/detail')[1])[0]

        resp, body = cinder.POST('/snapshots',
                                 body={
                                     "snapshot": {
                                         "display_name": "test-snapshot",
                                         "volume_id": volume_id
                                     }
                                 },
                                 code=200)

        snapshot_id = body["snapshot"]["id"]

        resp, body = cinder.GET_with_keys_eq('/snapshots/%s' % snapshot_id,
                                             {"/snapshot/status": "available"},
                                             code=200,
                                             timeout=60,
                                             delay=5)
示例#55
0
    def test_018_port_update(self):
        port_id = nested_search(
            'ports/*/name=test-port/id',
            neutron.GET('/%s/ports' % api_ver, code=200)[1])[0]

        resp, body = neutron.PUT('/%s/ports/%s.json' % (api_ver, port_id),
                                 body={'port': {
                                     'name': 'a-new-test-port'
                                 }},
                                 code=200)

        resp, body = neutron.GET_with_keys_eq(
            '/%s/ports/%s' % (api_ver, port_id),
            {'/port/name': 'a-new-test-port'},
            code=200)

        neutron.PUT('/%s/ports/%s.json' % (api_ver, port_id),
                    body={'port': {
                        'name': 'test-port'
                    }},
                    code=200)
示例#56
0
    def test_009_net_update(self):
        network_id = nested_search(
            'networks/*/name=test-network/id',
            neutron.GET('/%s/networks' % api_ver, code=200)[1])[0]

        resp, body = neutron.PUT(
            '/%s/networks/%s.json' % (api_ver, network_id),
            body={'network': {
                'name': 'a-new-test-network'
            }},
            code=200)

        resp, body = neutron.GET_with_keys_eq(
            '/%s/networks/%s' % (api_ver, network_id),
            {'/network/name': 'a-new-test-network'},
            code=200)

        neutron.PUT('/%s/networks/%s.json' % (api_ver, network_id),
                    body={'network': {
                        'name': 'test-network'
                    }},
                    code=200)
示例#57
0
    def test_014_subnet_update(self):
        subnet_id = nested_search(
            'subnets/*/name=test-subnet/id',
            neutron.GET('/%s/subnets' % api_ver, code=200)[1])[0]

        resp, body = neutron.PUT(
            '/%s/subnets/%s.json' % (api_ver, subnet_id),
            body={'subnet': {
                'name': 'a-new-test-subnet'
            }},
            code=200)

        resp, body = neutron.GET_with_keys_eq(
            '/%s/subnets/%s' % (api_ver, subnet_id),
            {'/subnet/name': 'a-new-test-subnet'},
            code=200)

        neutron.PUT('/%s/subnets/%s.json' % (api_ver, subnet_id),
                    body={'subnet': {
                        'name': 'test-subnet'
                    }},
                    code=200)
示例#58
0
    def test_025_security_group_rule_create(self):
        secgroup_id = nested_search(
            'security_groups/*/name=test-sec-group/id',
            neutron.GET('/%s/security-groups' % api_ver, code=200)[1])[0]

        resp, body = neutron.POST('/%s/security-group-rules.json' % api_ver,
                                  body={
                                      'security_group_rule': {
                                          'ethertype': 'IPv4',
                                          'direction': 'ingress',
                                          'protocol': 'ICMP',
                                          'security_group_id':
                                          '%s' % secgroup_id
                                      }
                                  })

        secgroup_rule_id = body['security_group_rule']['id']

        resp, body = neutron.GET_with_keys_eq(
            '/%s/security-group-rules/%s.json' % (api_ver, secgroup_rule_id),
            {'/security_group_rule/protocol': 'icmp'},
            code=200)
示例#59
0
    def test_015_port_create(self):
        network_id = nested_search(
            'networks/*/name=test-network/id',
            neutron.GET('/%s/networks' % api_ver, code=200)[1])[0]

        resp, body = neutron.POST('/%s/ports.json' % api_ver,
                                  body={
                                      'port': {
                                          'network_id': '%s' % network_id,
                                          'admin_state_up': True,
                                          'name': 'test-port'
                                      }
                                  },
                                  code=201)

        port_id = body['port']['id']

        resp, body = neutron.GET_with_keys_eq('/%s/ports/%s' %
                                              (api_ver, port_id),
                                              {'/port/admin_state_up': True},
                                              code=200,
                                              timeout=10,
                                              delay=2)
示例#60
0
 def test_keystone_v2_05_delete_user_diablo(self):
     response, data = admin.GET("/users")
     kong_user = nested_search("/users/values/*/name=kongadmin/id", data)[0]
     admin.DELETE("/users/%s" % kong_user, code=204)