Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
RECIRCLE
/
interface-openstack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
2
Merge Requests
4
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
e01d873c
authored
Jul 09, 2019
by
Bodor Máté
Browse files
Options
Browse Files
Download
Plain Diff
Resolve merge conflict
parents
f5b818e4
78f5ae4a
Pipeline
#757
failed with stage
in 37 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 additions
and
161 deletions
+1
-161
.gitignore
+1
-0
main.py
+0
-161
No files found.
.gitignore
View file @
e01d873c
...
@@ -26,6 +26,7 @@ share/python-wheels/
...
@@ -26,6 +26,7 @@ share/python-wheels/
.installed.cfg
.installed.cfg
*.egg
*.egg
MANIFEST
MANIFEST
example.py
# PyInstaller
# PyInstaller
# Usually these files are written by a python script from a template
# Usually these files are written by a python script from a template
...
...
main.py
deleted
100644 → 0
View file @
f5b818e4
# This file is for testing the openstack api access
if
__name__
==
"__main__"
:
from
sys
import
path
from
os.path
import
dirname
as
dir
path
.
append
(
dir
(
path
[
0
]))
from
implementation.vm.instance
import
OSVirtualMachineManager
from
interface.vm.resources
import
BlockDeviceMapping
,
Flavor
# from implementation.network.OpenstackFloatingIPManager import OpenstackFloatingIPManager
# from implementation.network.OpenstackNetworkManager import OpenstackNetworkManager
# from implementation.network.OpenstackPortManager import OpenstackPortManager
# from implementation.network.OpenstackRouterManager import OpenstackRouterManager
# from implementation.network.OpenstackSubnetManager import OpenstackSubnetManager
# openstack.enable_logging(debug=True)
auth
=
{
"auth_url"
:
"http://10.34.0.113/identity/v3"
,
"username"
:
"admin"
,
"project_id"
:
"2db5309f541c4466bc80bc534cf579d7"
,
"project_name"
:
"admin"
,
"password"
:
"64c7ee341d03844c548c"
,
"user_domain_name"
:
"Default"
,
"user_domain_id"
:
"Default"
,
"region_name"
:
"RegionOne"
,
}
interface
=
OSVirtualMachineManager
(
auth
=
auth
)
block_dev_map
=
BlockDeviceMapping
(
boot_index
=
0
,
uuid
=
"da51253f-867c-472d-8ce0-81e7b7126d60"
,
source_type
=
"image"
,
volume_size
=
10
,
destination_type
=
"volume"
,
delete_on_termination
=
True
,
disk_bus
=
"scsi"
)
networks
=
[{
"uuid"
:
"c03d0d4b-413e-4cc6-9ebe-c0b5ca0dac3a"
}]
print
(
'#'
*
40
)
# interface.create_vm_from_template('new_server', resource, "cirros-0.4.0-x86_64-disk")
# interface.stop_vm('a6bc504f-a422-4492-b429-e5dad2df12f4')
# server = interface.openstack.compute.get_server("8e94c162-f8ed-4872-b9e5-50bf33040b5b")
#
# print(server)
# print(interface.delete_flavor("flavorTest"))
for
flavor
in
interface
.
list_flavors
():
print
(
flavor
.
JSON
())
for
vm
in
interface
.
list_all_vm
():
print
(
vm
.
JSON
())
print
(
"*"
*
50
)
# print(interface.create_base_vm("BaseTest", "2", networks, block_dev_map).JSON())
print
(
"*********TEST SERVER**********"
)
print
(
interface
.
get_vm
(
"fb91a363-e23b-4fb6-8770-357509b753da"
)
.
JSON
())
print
(
interface
.
openstack
.
get_server
(
"fb91a363-e23b-4fb6-8770-357509b753da"
))
print
(
"*********TEST SUSPEND**********"
)
interface
.
suspend_vm
(
"fb91a363-e23b-4fb6-8770-357509b753da"
)
interface
.
detach_volume
(
"8e94c162-f8ed-4872-b9e5-50bf33040b5b"
,
"83d4f11a-f6a8-4f50-8a95-8f5016604780"
)
# print(interface.convert_server_to_instance(server).JSON())
# print(interface.openstack.compute.get_server("8e94c162-f8ed-4872-b9e5-50bf33040b5b"))
# print(server.JSON())
# print(interface.get_vnc_console("8e94c162-f8ed-4872-b9e5-50bf33040b5b"))
# print(interface.convert_server_to_instance(server))
# print(interface.get_vnc_console("New test"))
# interface.create_template("New test", "test_template")
# interface.create_vm_from_template("test_template", resource, [{"uuid": "c03d0d4b-413e-4cc6-9ebe-c0b5ca0dac3a"}])
# interface.resize_vm(server, resource)
# interface.reboot_vm(server.id)
# interface.reset_vm(server.id)
# interface.suspend_vm(server.id)
# interface.wake_up_vm(server.id)
# interface.destroy_vm(server.id)
# ==============================================================================
# Network test
# ==============================================================================
# os = openstack.connect(cloud='openstack')
#
# router_manager = OpenstackRouterManager(os)
# network_manager = OpenstackNetworkManager(os)
# subnet_manager = OpenstackSubnetManager(os)
# port_manager = OpenstackPortManager(os)
# floating_ip_manager = OpenstackFloatingIPManager(os)
#
# '''
# Network setup steps:
# - Create inner network
# - Create subnet for inner network
# - Create router
# - Add public network to router as gateway
# - Add inner subnet to router as interface
# - Add interface (or port?) to vm
# - Get the port of the vm
# - Create floating ip to public network
# - Associate floating ip and vm port
# '''
#
# #router = router_manager.create()
# router = router_manager.get('3ee87bcd-b1b5-4e14-86a1-ce691bd3e5a2')
#
# print('Router:')
# print('\t%s' % router)
#
# #network = network_manager.create()
# public_network = network_manager.get('3b349c93-8b2c-4abd-b8ce-22b7db4cca98')
# inner_network = network_manager.get('8df0d7ab-7d56-4496-aca0-317af66b3ebc')
#
# print('Network:')
# print('\tPublic: %s' % public_network)
# print('\tInner: %s' % inner_network)
#
# #subnet = subnet_manager.create(network.id, 4, '10.34.0.0/16')
# public_subnet = subnet_manager.get('8a7e05f8-6358-48f7-9104-990d350425a0')
# # create(inner_network.id, 4, '10.0.0.0/24')
# inner_subnet = subnet_manager.get('34911571-c929-4433-b4e6-305fcb585a91')
#
# print('Subnet:')
# print('\tPublic: %s' % public_subnet)
# print('\tInner: %s' % inner_subnet)
#
# vm_port = port_manager.get('85202d6d-7aa0-44bc-a5eb-78b0519066c5') # inner
#
# print('Port:')
# print('\tVM: %s' % vm_port)
#
# #floating_ip = floating_ip_manager.create(public_network.id)
# floating_ip = floating_ip_manager.get('fe1e329f-aedb-4b3e-a649-9fec8eb3ece5')
#
# print('Floating IP:')
# print('\tFloating IP: %s' % floating_ip)
#
#
# print(router_manager.add_interface(router.id, inner_subnet.id)) # TODO: fix error msg
# print(router_manager.add_gateway(router.id, public_network.id)) # TODO: fix it!
#
# print(floating_ip_manager.update(floating_ip.id, {
# 'port_id': vm_port.id
# }))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment