Skip to content

Commit

Permalink
Interns symbols from Alexandria package
Browse files Browse the repository at this point in the history
  • Loading branch information
zodmaner committed May 26, 2016
1 parent 001a8df commit e29db7c
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 55 deletions.
22 changes: 11 additions & 11 deletions compute-api.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
(def-openstack-api create-server (server-name image-id flavor-id)
(response :post ((get-public-url "nova") "/servers")
(st-json:write-json-to-string
(alexandria:plist-hash-table
(plist-hash-table
(list "server"
(alexandria:plist-hash-table
(plist-hash-table
(list "name" server-name
"imageRef" image-id
"flavorRef" flavor-id))))))
Expand All @@ -76,17 +76,17 @@
(def-openstack-api create-floating-ip (&key (pool "public"))
(response :post ((get-public-url "nova") "/os-floating-ips")
(st-json:write-json-to-string
(alexandria:plist-hash-table
(plist-hash-table
(list "pool" pool))))
"Creates/allocates a new floating IP."
(st-json:getjso* "floating_ip.ip" (st-json:read-json response)))

(def-openstack-api associate-floating-ip (server-id floating-ip)
(response :post ((get-public-url "nova") "/servers/" server-id "/action")
(st-json:write-json-to-string
(alexandria:plist-hash-table
(plist-hash-table
(list "addFloatingIp"
(alexandria:plist-hash-table
(plist-hash-table
(list "address" floating-ip))))))
"Associates a floating IP with an active server."
response)
Expand All @@ -106,9 +106,9 @@
"Adds a security rule that accepts all incoming ICMP connection to
the default security group."
(create-default-security-group-rule (st-json:write-json-to-string
(alexandria:plist-hash-table
(plist-hash-table
(list "security_group_default_rule"
(alexandria:plist-hash-table
(plist-hash-table
(list "ip_protocol" "ICMP"
"from_port" "-1"
"to_port" "-1"
Expand All @@ -118,9 +118,9 @@ the default security group."
"Adds a security rule that accepts all incoming TCP connection to
the default security group."
(create-default-security-group-rule (st-json:write-json-to-string
(alexandria:plist-hash-table
(plist-hash-table
(list "security_group_default_rule"
(alexandria:plist-hash-table
(plist-hash-table
(list "ip_protocol" "TCP"
"from_port" "1"
"to_port" "65535"
Expand All @@ -130,9 +130,9 @@ the default security group."
"Adds a security rule that accepts all incoming UDP connection to
the default security group."
(create-default-security-group-rule (st-json:write-json-to-string
(alexandria:plist-hash-table
(plist-hash-table
(list "security_group_default_rule"
(alexandria:plist-hash-table
(plist-hash-table
(list "ip_protocol" "UDP"
"from_port" "1"
"to_port" "65535"
Expand Down
6 changes: 3 additions & 3 deletions identity-api.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ that is returned to a specified stream symbol."
:post
nil
(st-json:write-json-to-string
(alexandria:plist-hash-table
(plist-hash-table
(list "auth"
(alexandria:plist-hash-table
(plist-hash-table
(list "tenantName" (if (null (tenant-name ,os-c))
(progn
(setf (tenant-name ,os-c) (username ,os-c))
(tenant-name ,os-c))
(tenant-name ,os-c))
"passwordCredentials"
(alexandria:plist-hash-table
(plist-hash-table
(list "username" (username ,os-c)
"password" (password ,os-c)))))))))
,@body))
Expand Down
3 changes: 2 additions & 1 deletion package.lisp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
;;;; package.lisp

(defpackage #:trivial-openstack
(:use #:cl)
(:use #:cl
#:alexandria)
(:export #:get-value
#:with-openstack-response
#:def-openstack-api
Expand Down
44 changes: 22 additions & 22 deletions t/t.mock-compute-server/mock-compute-server.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,28 @@ acceptor and shutdown the server."
(:get
(when (string= *token* (hunchentoot:header-in* "X-Auth-Token"))
(st-json:write-json-to-string
(alexandria:plist-hash-table
(plist-hash-table
(list "flavors"
(list
(alexandria:plist-hash-table
(plist-hash-table
(list "name" "m1.tiny"
"id" "1"))
(alexandria:plist-hash-table
(plist-hash-table
(list "name" "m1.small"
"id" "2"))
(alexandria:plist-hash-table
(plist-hash-table
(list "name" "m1.medium"
"id" "3"))
(alexandria:plist-hash-table
(plist-hash-table
(list "name" "m1.large"
"id" "4"))
(alexandria:plist-hash-table
(plist-hash-table
(list "name" "m1.nano"
"id" "42"))
(alexandria:plist-hash-table
(plist-hash-table
(list "name" "m1.xlarge"
"id" "5"))
(alexandria:plist-hash-table
(plist-hash-table
(list "name" "m1.micro"
"id" "84"))))))))))

Expand All @@ -62,9 +62,9 @@ acceptor and shutdown the server."
(:get
(when (string= *token* (hunchentoot:header-in* "X-Auth-Token"))
(st-json:write-json-to-string
(alexandria:plist-hash-table
(plist-hash-table
(list "flavor"
(alexandria:plist-hash-table
(plist-hash-table
(list "name" "m1.tiny"
"vcpus" 1
"ram" 512
Expand All @@ -87,17 +87,17 @@ acceptor and shutdown the server."
(string= "c4947a88-3b38-44d5-b605-edad3cf1191b" image-ref)
(string= "1" flavor-ref))
(st-json:write-json-to-string
(alexandria:plist-hash-table
(plist-hash-table
(list "server"
(alexandria:plist-hash-table
(plist-hash-table
(list "id" "0a427e44-8d69-4b02-a747-0eb731ba02ad")))))))))
(:get
(when (string= *token* (hunchentoot:header-in* "X-Auth-Token"))
(st-json:write-json-to-string
(alexandria:plist-hash-table
(plist-hash-table
(list "servers"
(list
(alexandria:plist-hash-table
(plist-hash-table
(list "name" "test-00"
"id" "0a427e44-8d69-4b02-a747-0eb731ba02ad"))))))))))

Expand All @@ -108,18 +108,18 @@ acceptor and shutdown the server."
(:get
(when (string= *token* (hunchentoot:header-in* "X-Auth-Token"))
(st-json:write-json-to-string
(alexandria:plist-hash-table
(plist-hash-table
(list "servers"
(list
(alexandria:plist-hash-table
(plist-hash-table
(list "name" "test-00"
"id" "0a427e44-8d69-4b02-a747-0eb731ba02ad"
"status" "ACTIVE"
"addresses"
(alexandria:plist-hash-table
(plist-hash-table
(list "private"
(list
(alexandria:plist-hash-table
(plist-hash-table
(list "addr" "10.0.0.2"
"OS-EXT-IPS:type" "fixed")))))))))))))))

Expand Down Expand Up @@ -149,17 +149,17 @@ acceptor and shutdown the server."
(pool (st-json:getjso "pool" request-jso)))
(when (string= "public" pool)
(st-json:write-json-to-string
(alexandria:plist-hash-table
(plist-hash-table
(list "floating_ip"
(alexandria:plist-hash-table
(plist-hash-table
(list "ip" "192.168.1.225")))))))))
(:get
(when (string= *token* (hunchentoot:header-in* "X-Auth-Token"))
(st-json:write-json-to-string
(alexandria:plist-hash-table
(plist-hash-table
(list "floating_ips"
(list
(alexandria:plist-hash-table
(plist-hash-table
(list "ip" "192.168.1.225"
"fixed_ip" :null
"pool" "public"))))))))))
Expand Down
3 changes: 2 additions & 1 deletion t/t.mock-compute-server/package.lisp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
;;;; t.mock-compute-server module's package.lisp

(defpackage #:t.mock-compute-server
(:use #:cl)
(:use #:cl
#:alexandria)
(:import-from #:t.mock-identity-server
#:*tenant-id*
#:*token*)
Expand Down
18 changes: 9 additions & 9 deletions t/t.mock-identity-server/mock-identity-server.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -45,29 +45,29 @@ and shutdown the server."
(when (and (string= username "dummy") (string= password "swordfish")
(string= tenant-name "dummy"))
(st-json:write-json-to-string
(alexandria:plist-hash-table
(plist-hash-table
(list "access"
(alexandria:plist-hash-table
(plist-hash-table
(list "token"
(alexandria:plist-hash-table
(plist-hash-table
(list "id" *token* "expires" (make-token-expiration-time)))
"serviceCatalog"
(list
(alexandria:plist-hash-table
(plist-hash-table
(list "name" "nova" "type" "compute"
"endpoints" (list (alexandria:plist-hash-table
"endpoints" (list (plist-hash-table
(list "publicURL" #Uhttp://localhost:8774/v2.1/{*tenant-id*}
"adminURL" #Uhttp://localhost:8774/v2.1/{*tenant-id*}
"region" "RegionOne")))))
(alexandria:plist-hash-table
(plist-hash-table
(list "name" "glance" "type" "image"
"endpoints" (list (alexandria:plist-hash-table
"endpoints" (list (plist-hash-table
(list "publicURL" #Uhttp://localhost:9292
"adminURL" #Uhttp://localhost:9292
"region" "RegionOne")))))
(alexandria:plist-hash-table
(plist-hash-table
(list "name" "keystone" "type" "identity"
"endpoints" (list (alexandria:plist-hash-table
"endpoints" (list (plist-hash-table
(list "publicURL" #Uhttp://localhost:5000/v2.0
"adminURL" #Uhttp://localhost:5000/v2.0
"region" "RegionOne"))))))))))))))))
3 changes: 2 additions & 1 deletion t/t.mock-identity-server/package.lisp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
;;;; t.mock-identity-server module's package.lisp

(defpackage #:t.mock-identity-server
(:use #:cl)
(:use #:cl
#:alexandria)
(:export #:*tenant-id*
#:*token*
#:start-mock-identity-server
Expand Down
8 changes: 4 additions & 4 deletions t/t.mock-image-server/mock-image-server.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ and shutdown the server."
(:get
(when (string= *token* (hunchentoot:header-in* "X-Auth-Token"))
(st-json:write-json-to-string
(alexandria:plist-hash-table
(plist-hash-table
(list "images"
(list
(alexandria:plist-hash-table
(plist-hash-table
(list "name" "cirros-0.3.4-x86_64-uec"
"id" "c4947a88-3b38-44d5-b605-edad3cf1191b"))
(alexandria:plist-hash-table
(plist-hash-table
(list "name" "cirros-0.3.4-x86_64-uec-ramdisk"
"id" "619726e7-b3b1-4d39-8669-cf05fb04981d"))
(alexandria:plist-hash-table
(plist-hash-table
(list "name" "cirros-0.3.4-x86_64-uec-kernel"
"id" "b5afe28f-3ed5-4d4e-8094-fac19d2d7ac3"))))))))))
3 changes: 2 additions & 1 deletion t/t.mock-image-server/package.lisp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
;;;; t.mock-image-server module's package.lisp

(defpackage #:t.mock-image-server
(:use #:cl)
(:use #:cl
#:alexandria)
(:import-from #:t.mock-identity-server
#:*tenant-id*
#:*token*)
Expand Down
4 changes: 2 additions & 2 deletions trivial-openstack.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ rightmost) key.
Note that supplying multiple keys only makes sense when the alist has
other alists nested inside."
(if (cdr keys)
(let ((new-alist (alexandria:assoc-value alist (car keys) :test #'string=)))
(let ((new-alist (assoc-value alist (car keys) :test #'string=)))
(apply #'get-value new-alist (cdr keys)))
(alexandria:assoc-value alist (car keys) :test #'string=)))
(assoc-value alist (car keys) :test #'string=)))

(defmacro with-openstack-response (stream (uri http-method &optional x-auth-token content)
&body body)
Expand Down

0 comments on commit e29db7c

Please sign in to comment.