OpenStack の ダッシュボードにアクセスできなくなった時の対処メモ
OpenStack の ダッシュボードにアクセスできなくなったのでその時の対処メモ。
■ 概要
OS を立ち上げ直したらなぜか OpenStack dashboard にアクセスできなくなった。
結論から言えば下記サイトの answer 1 の通りにやったら直った。
https://ask.openstack.org/en/question/95308/dashboard-uncontactable/
それだけの話だけどその時のログを残す。
■ いくつかのコンポーネントが上手く立ち上がらなかった
VMware で動かしている CentOS をいつも通り起動して OpenStack のダッシュボードにアクセスしたら入れなかった。
特に前回シャットダウンするときも変なことをした覚えはなく、恐らく単にコンポーネントの立ち上げに失敗しただけと思われる。
もう一度OS再起動したら直りそうな気もするけど、せっかくなのでなんとかしてみる。
とりあえず状況を確認する。
# openstack-status == Nova services == openstack-nova-api: active openstack-nova-compute: active openstack-nova-network: inactive (disabled on boot) openstack-nova-scheduler: active openstack-nova-cert: active openstack-nova-conductor: active openstack-nova-console: inactive (disabled on boot) openstack-nova-consoleauth: active openstack-nova-xvpvncproxy: inactive (disabled on boot) == Glance services == openstack-glance-api: active openstack-glance-registry: active == Keystone service == openstack-keystone: inactive (disabled on boot) == Horizon service == openstack-dashboard: uncontactable == neutron services == neutron-server: failed neutron-dhcp-agent: active neutron-l3-agent: active neutron-metadata-agent: active neutron-lbaas-agent: active neutron-lbaasv2-agent: inactive (disabled on boot) neutron-openvswitch-agent: active neutron-metering-agent: active == Swift services == openstack-swift-proxy: active openstack-swift-account: active openstack-swift-container: active openstack-swift-object: active == Cinder services == openstack-cinder-api: active openstack-cinder-scheduler: active openstack-cinder-volume: active openstack-cinder-backup: active == Ceilometer services == openstack-ceilometer-api: inactive (disabled on boot) openstack-ceilometer-central: active openstack-ceilometer-compute: active openstack-ceilometer-collector: active openstack-ceilometer-notification: active == Heat services == openstack-heat-api: active openstack-heat-api-cfn: inactive (disabled on boot) openstack-heat-api-cloudwatch: inactive (disabled on boot) openstack-heat-engine: active == Support services == mariadb: active openvswitch: active dbus: active target: active rabbitmq-server: active memcached: active == Keystone users == Warning keystonerc not sourced #
openstack-dashboard: が uncontactable になってるし
neutron-server: も failed になってる。
そりゃダッシュボードにアクセスできんわ。
■ failed と uncontactable のコンポーネントの状態を直す
まずは neutron-server を restart してみる。
# systemctl restart neutron-server.service # openstack-status == Nova services == openstack-nova-api: active openstack-nova-compute: active openstack-nova-network: inactive (disabled on boot) openstack-nova-scheduler: active openstack-nova-cert: active openstack-nova-conductor: active openstack-nova-console: inactive (disabled on boot) openstack-nova-consoleauth: active openstack-nova-xvpvncproxy: inactive (disabled on boot) == Glance services == openstack-glance-api: active openstack-glance-registry: active == Keystone service == openstack-keystone: inactive (disabled on boot) == Horizon service == openstack-dashboard: uncontactable == neutron services == neutron-server: active neutron-dhcp-agent: active neutron-l3-agent: active neutron-metadata-agent: active neutron-lbaas-agent: active neutron-lbaasv2-agent: inactive (disabled on boot) neutron-openvswitch-agent: active neutron-metering-agent: active == Swift services == openstack-swift-proxy: active openstack-swift-account: active openstack-swift-container: active openstack-swift-object: active == Cinder services == openstack-cinder-api: active openstack-cinder-scheduler: active openstack-cinder-volume: active openstack-cinder-backup: active == Ceilometer services == openstack-ceilometer-api: inactive (disabled on boot) openstack-ceilometer-central: active openstack-ceilometer-compute: active openstack-ceilometer-collector: active openstack-ceilometer-notification: active == Heat services == openstack-heat-api: active openstack-heat-api-cfn: inactive (disabled on boot) openstack-heat-api-cloudwatch: inactive (disabled on boot) openstack-heat-engine: active == Support services == mariadb: active openvswitch: active dbus: active target: active rabbitmq-server: active memcached: active == Keystone users == Warning keystonerc not sourced #
neutron-server は active になった。
openstack-dashboard もそれに引きずられて自動的に直ることを期待したけどそんなこともなく。
openstack-dashboard も同じように restart してみる。
# systemctl restart openstack-dashboard.service Failed to restart openstack-dashboard.service: Unit openstack-dashboard.service failed to load: No such file or directory. #
...もしかして openstack-dashboard は単体でどうこうするものではないのか ?
その辺もまだ理解していない。
その後色々試して格闘したがどうにもならず。。
ググっていった結果、このページに辿り着いた。
思考停止で answer 1 の通りにやってみる。
# systemctl restart rabbitmq-server # systemctl restart openstack-keystone You have new mail in /var/spool/mail/root # # ls -l /etc/systemd/system/ total 16 drwxr-xr-x. 2 root root 53 Nov 3 17:34 basic.target.wants drwxr-xr-x. 2 root root 30 Nov 3 15:39 bluetooth.target.wants lrwxrwxrwx. 1 root root 41 Nov 3 15:39 dbus-org.bluez.service -> /usr/lib/systemd/system/bluetooth.service lrwxrwxrwx. 1 root root 44 Nov 3 15:40 dbus-org.freedesktop.Avahi.service -> /usr/lib/systemd/system/avahi-daemon.service lrwxrwxrwx. 1 root root 44 Nov 3 15:41 dbus-org.freedesktop.ModemManager1.service -> /usr/lib/systemd/system/ModemManager.service lrwxrwxrwx. 1 root root 46 Nov 3 15:39 dbus-org.freedesktop.NetworkManager.service -> /usr/lib/systemd/system/NetworkManager.service lrwxrwxrwx. 1 root root 57 Nov 3 15:39 dbus-org.freedesktop.nm-dispatcher.service -> /usr/lib/systemd/system/NetworkManager-dispatcher.service lrwxrwxrwx. 1 root root 36 Nov 3 15:44 default.target -> /lib/systemd/system/graphical.target drwxr-xr-x. 2 root root 85 Nov 3 15:38 default.target.wants drwxr-xr-x. 2 root root 37 Nov 3 15:40 dev-virtio\x2dports-org.qemu.guest_agent.0.device.wants lrwxrwxrwx. 1 root root 35 Nov 3 15:40 display-manager.service -> /usr/lib/systemd/system/gdm.service drwxr-xr-x. 2 root root 31 Nov 3 15:38 getty.target.wants drwxr-xr-x. 2 root root 63 Nov 3 15:39 graphical.target.wants drwxr-xr-x. 2 root root 4096 Nov 5 19:27 multi-user.target.wants drwxr-xr-x. 2 root root 38 Nov 3 18:03 openstack-cinder-volume.service.requires drwxr-xr-x. 2 root root 25 Nov 3 15:39 printer.target.wants drwxr-xr-x. 2 root root 24 Nov 3 17:40 rabbitmq-server.service.d drwxr-xr-x. 2 root root 23 Nov 3 18:21 redis-sentinel.service.d drwxr-xr-x. 2 root root 23 Nov 3 18:21 redis.service.d drwxr-xr-x. 2 root root 30 Nov 3 15:39 remote-fs.target.wants drwxr-xr-x. 2 root root 4096 Nov 5 19:16 sockets.target.wants drwxr-xr-x. 2 root root 35 Nov 3 15:40 spice-vdagentd.target.wants drwxr-xr-x. 2 root root 25 Nov 3 16:34 sssd.service.d drwxr-xr-x. 2 root root 4096 Nov 5 19:16 sysinit.target.wants drwxr-xr-x. 2 root root 43 Nov 3 15:38 system-update.target.wants # # # ln -s /usr/lib/systemd/system/httpd.service /etc/systemd/system/openstack-keystone.service # # ls -l /etc/systemd/system/open* lrwxrwxrwx. 1 root root 37 Nov 12 15:38 /etc/systemd/system/openstack-keystone.service -> /usr/lib/systemd/system/httpd.service /etc/systemd/system/openstack-cinder-volume.service.requires: total 0 lrwxrwxrwx. 1 root root 49 Nov 3 18:03 openstack-losetup.service -> /usr/lib/systemd/system/openstack-losetup.service # systemctl daemon-reload # systemctl stop httpd.service # systemctl stop openstack-keystone.service # systemctl start openstack-keystone.service # # openstack-status == Nova services == openstack-nova-api: active openstack-nova-compute: active openstack-nova-network: inactive (disabled on boot) openstack-nova-scheduler: active openstack-nova-cert: active openstack-nova-conductor: active openstack-nova-console: inactive (disabled on boot) openstack-nova-consoleauth: active openstack-nova-xvpvncproxy: inactive (disabled on boot) == Glance services == openstack-glance-api: active openstack-glance-registry: active == Keystone service == openstack-keystone: active == Horizon service == openstack-dashboard: active == neutron services == neutron-server: active neutron-dhcp-agent: active neutron-l3-agent: active neutron-metadata-agent: active neutron-lbaas-agent: active neutron-lbaasv2-agent: inactive (disabled on boot) neutron-openvswitch-agent: active neutron-metering-agent: active == Swift services == openstack-swift-proxy: active openstack-swift-account: active openstack-swift-container: active openstack-swift-object: active == Cinder services == openstack-cinder-api: active openstack-cinder-scheduler: active openstack-cinder-volume: active openstack-cinder-backup: active == Ceilometer services == openstack-ceilometer-api: inactive (disabled on boot) openstack-ceilometer-central: active openstack-ceilometer-compute: active openstack-ceilometer-collector: active openstack-ceilometer-notification: active == Heat services == openstack-heat-api: active openstack-heat-api-cfn: inactive (disabled on boot) openstack-heat-api-cloudwatch: inactive (disabled on boot) openstack-heat-engine: active == Support services == mariadb: active openvswitch: active dbus: active target: active rabbitmq-server: active memcached: active == Keystone users == Warning keystonerc not sourced #
openstack-dashboard: が active になってる!
ダッシュボードにもアクセスできるようになった。
httpd の停止と httpd.service へリンクする openstack-keystone.service の作成がポイントだったようだ。
#これも何となくしか理解できていないが......。
しかし、今までこんな問題が発生しなかったのになんで起きたのかは分からず終い。
Mac で OpenStack コマンドラインクライアントを使う
Mac で OpenStack クライアントをインストールして使おうとしたら色々とハマったのでメモ。
■ 概要
Mac で OpenStack コマンドラインクライアントを使い、OpenStackを操作する。
Mac の VMware Fusion で動作している CentOS 仮想マシン上で動作している OpenStack へ、Mac のターミナルから OpenStack クライアントを用いてAPIを叩けるようにする。
環境:
Mac OS X El Captitan 10.11.6
VMware Fusion 8 (Mac上で動作)
CentOS 7 (VMware上で動作)
OpenStack Mitaka (CentOS上で動作)
※最終的にはクライアント使えるようになったが、よくわからないまま色々試したらできたという感じなので、あまり参考にならないかもしれない。
■ OpenStack コマンドラインクライアントのインストール
OpenStack Docs を参考にする
OpenStackクライアントのインストール方法は、基本的にはOpenStack Docsのここを参考に進める。
Docs の書いてある通りにいけば、Macの場合は
# easy_install pip
を実行して、
# pip install python-openstackclient
でインストール完了となる簡単なもの。
だが、実際はそう甘くはなかった。
なぜかOpenStack Docs の通りにはインストールができない
まずは easy_install pip をやってみる。
# easy_install pip Searching for pip Reading https://pypi.python.org/simple/pip/ Best match: pip 9.0.0 Downloading https://pypi.python.org/packages/5e/53/eaef47e5e2f75677c9de0737acc84b659b78a71c4086f424f55346a341b5/pip-9.0.0.tar.gz#md5=def0a8e3db26f896c128d063591bd008 Processing pip-9.0.0.tar.gz Writing /tmp/easy_install-e8Eela/pip-9.0.0/setup.cfg Running pip-9.0.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-e8Eela/pip-9.0.0/egg-dist-tmp-JFSa7W /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'python_requires' warnings.warn(msg) warning: no previously-included files found matching '.coveragerc' warning: no previously-included files found matching '.mailmap' warning: no previously-included files found matching '.travis.yml' warning: no previously-included files found matching '.landscape.yml' warning: no previously-included files found matching 'pip/_vendor/Makefile' warning: no previously-included files found matching 'tox.ini' warning: no previously-included files found matching 'dev-requirements.txt' warning: no previously-included files found matching 'appveyor.yml' no previously-included directories found matching '.github' no previously-included directories found matching '.travis' no previously-included directories found matching 'docs/_build' no previously-included directories found matching 'contrib' no previously-included directories found matching 'tasks' no previously-included directories found matching 'tests' File "build/bdist.macosx-10.11-intel/egg/pip/_vendor/html5lib/treewalkers/etree.py", line 13 from pip._vendor. import string_types ^ SyntaxError: invalid syntax File "/Library/Python/2.7/site-packages/pip-9.0.0-py2.7.egg/pip/_vendor/html5lib/treewalkers/etree.py", line 13 from pip._vendor. import string_types ^ SyntaxError: invalid syntax Adding pip 9.0.0 to easy-install.pth file Installing pip script to /usr/local/bin Installing pip2.7 script to /usr/local/bin Installing pip2 script to /usr/local/bin Installed /Library/Python/2.7/site-packages/pip-9.0.0-py2.7.egg Processing dependencies for pip Finished processing dependencies for pip #
……SyntaxError が出ているが、よく分からないのでとりあえず無視。
次に openstack クライアントをインストール。
# pip install python-openstackclient Collecting python-openstackclient Downloading python_openstackclient-3.3.0-py2.py3-none-any.whl (600kB) 100% |################################| 604kB 203kB/s Collecting pbr>=1.6 (from python-openstackclient) Downloading pbr-1.10.0-py2.py3-none-any.whl (96kB) 100% |################################| 102kB 117kB/s Collecting keystoneauth1>=2.10.0 (from python-openstackclient) Downloading keystoneauth1-2.15.0-py2.py3-none-any.whl (235kB) 100% |################################| 235kB 68kB/s Collecting Babel>=2.3.4 (from python-openstackclient) Downloading Babel-2.3.4-py2.py3-none-any.whl (7.1MB) 100% |################################| 7.1MB 76kB/s Collecting python-keystoneclient!=2.1.0,>=2.0.0 (from python-openstackclient) Downloading python_keystoneclient-3.6.0-py2.py3-none-any.whl (368kB) 100% |################################| 368kB 97kB/s Collecting python-novaclient!=2.33.0,>=2.29.0 (from python-openstackclient) Downloading python_novaclient-6.0.0-py2.py3-none-any.whl (359kB) 100% |################################| 368kB 179kB/s Collecting python-glanceclient>=2.5.0 (from python-openstackclient) Downloading python_glanceclient-2.5.0-py2.py3-none-any.whl (175kB) 100% |################################| 184kB 186kB/s Collecting python-cinderclient!=1.7.0,!=1.7.1,>=1.6.0 (from python-openstackclient) Downloading python_cinderclient-1.9.0-py2.py3-none-any.whl (295kB) 100% |################################| 296kB 112kB/s Collecting osc-lib>=1.0.2 (from python-openstackclient) Downloading osc_lib-1.2.0-py2-none-any.whl (66kB) 100% |################################| 71kB 92kB/s Collecting six>=1.9.0 (from python-openstackclient) Downloading six-1.10.0-py2.py3-none-any.whl Collecting oslo.utils>=3.16.0 (from python-openstackclient) Downloading oslo.utils-3.18.0-py2.py3-none-any.whl (96kB) 100% |################################| 102kB 100kB/s Collecting oslo.i18n>=2.1.0 (from python-openstackclient) Downloading oslo.i18n-3.10.0-py2.py3-none-any.whl (41kB) 100% |################################| 51kB 104kB/s Collecting openstacksdk>=0.9.7 (from python-openstackclient) Downloading openstacksdk-0.9.9-py2.py3-none-any.whl (522kB) 100% |################################| 532kB 172kB/s Collecting cliff>=2.2.0 (from python-openstackclient) Downloading cliff-2.2.0-py2-none-any.whl (44kB) 100% |################################| 51kB 110kB/s Collecting stevedore>=1.17.1 (from keystoneauth1>=2.10.0->python-openstackclient) Downloading stevedore-1.18.0-py2.py3-none-any.whl Collecting requests>=2.10.0 (from keystoneauth1>=2.10.0->python-openstackclient) Downloading requests-2.11.1-py2.py3-none-any.whl (514kB) 100% |################################| 522kB 135kB/s Collecting positional>=1.1.1 (from keystoneauth1>=2.10.0->python-openstackclient) Downloading positional-1.1.1.tar.gz Collecting iso8601>=0.1.11 (from keystoneauth1>=2.10.0->python-openstackclient) Downloading iso8601-0.1.11-py2.py3-none-any.whl Requirement already satisfied: pytz>=0a in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from Babel>=2.3.4->python-openstackclient) Collecting oslo.serialization>=1.10.0 (from python-keystoneclient!=2.1.0,>=2.0.0->python-openstackclient) Downloading oslo.serialization-2.14.0-py2.py3-none-any.whl Collecting debtcollector>=1.2.0 (from python-keystoneclient!=2.1.0,>=2.0.0->python-openstackclient) Downloading debtcollector-1.9.0-py2.py3-none-any.whl Collecting oslo.config>=3.14.0 (from python-keystoneclient!=2.1.0,>=2.0.0->python-openstackclient) Downloading oslo.config-3.19.0-py2.py3-none-any.whl (99kB) 100% |################################| 102kB 147kB/s Collecting simplejson>=2.2.0 (from python-novaclient!=2.33.0,>=2.29.0->python-openstackclient) Downloading simplejson-3.10.0.tar.gz (77kB) 100% |################################| 81kB 133kB/s Collecting PrettyTable<0.8,>=0.7 (from python-novaclient!=2.33.0,>=2.29.0->python-openstackclient) Downloading prettytable-0.7.2.zip Collecting warlock!=1.3.0,<2,>=1.0.1 (from python-glanceclient>=2.5.0->python-openstackclient) Downloading warlock-1.2.0.tar.gz Collecting os-client-config!=1.19.0,!=1.19.1,!=1.20.0,!=1.20.1,!=1.21.0,>=1.13.1 (from osc-lib>=1.0.2->python-openstackclient) Downloading os_client_config-1.22.0-py2.py3-none-any.whl (59kB) 100% |################################| 61kB 164kB/s Requirement already satisfied: pyparsing>=2.0.1 in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from oslo.utils>=3.16.0->python-openstackclient) Collecting funcsigs>=0.4; python_version == "2.7" or python_version == "2.6" (from oslo.utils>=3.16.0->python-openstackclient) Downloading funcsigs-1.0.2-py2.py3-none-any.whl Collecting netifaces>=0.10.4 (from oslo.utils>=3.16.0->python-openstackclient) Downloading netifaces-0.10.5.tar.gz Collecting netaddr!=0.7.16,>=0.7.13 (from oslo.utils>=3.16.0->python-openstackclient) Downloading netaddr-0.7.18-py2.py3-none-any.whl (1.5MB) 100% |################################| 1.5MB 123kB/s Collecting monotonic>=0.6 (from oslo.utils>=3.16.0->python-openstackclient) Downloading monotonic-1.2-py2.py3-none-any.whl Collecting PyYAML>=3.1.0 (from cliff>=2.2.0->python-openstackclient) Downloading PyYAML-3.12.tar.gz (253kB) 100% |################################| 256kB 143kB/s Collecting unicodecsv>=0.8.0; python_version < "3.0" (from cliff>=2.2.0->python-openstackclient) Downloading unicodecsv-0.14.1.tar.gz Collecting cmd2>=0.6.7 (from cliff>=2.2.0->python-openstackclient) Downloading cmd2-0.6.9.tar.gz (367kB) 100% |################################| 368kB 120kB/s Collecting wrapt (from positional>=1.1.1->keystoneauth1>=2.10.0->python-openstackclient) Downloading wrapt-1.10.8.tar.gz Collecting msgpack-python>=0.4.0 (from oslo.serialization>=1.10.0->python-keystoneclient!=2.1.0,>=2.0.0->python-openstackclient) Downloading msgpack-python-0.4.8.tar.gz (113kB) 100% |################################| 122kB 110kB/s Collecting rfc3986>=0.2.2 (from oslo.config>=3.14.0->python-keystoneclient!=2.1.0,>=2.0.0->python-openstackclient) Downloading rfc3986-0.4.1-py2.py3-none-any.whl Collecting jsonschema<3,>=0.7 (from warlock!=1.3.0,<2,>=1.0.1->python-glanceclient>=2.5.0->python-openstackclient) Downloading jsonschema-2.5.1-py2.py3-none-any.whl Collecting jsonpatch<2,>=0.10 (from warlock!=1.3.0,<2,>=1.0.1->python-glanceclient>=2.5.0->python-openstackclient) Downloading jsonpatch-1.14-py2.py3-none-any.whl Collecting requestsexceptions>=1.1.1 (from os-client-config!=1.19.0,!=1.19.1,!=1.20.0,!=1.20.1,!=1.21.0,>=1.13.1->osc-lib>=1.0.2->python-openstackclient) Downloading requestsexceptions-1.1.3-py2.py3-none-any.whl Collecting appdirs>=1.3.0 (from os-client-config!=1.19.0,!=1.19.1,!=1.20.0,!=1.20.1,!=1.21.0,>=1.13.1->osc-lib>=1.0.2->python-openstackclient) Downloading appdirs-1.4.0-py2.py3-none-any.whl Collecting functools32; python_version == "2.7" (from jsonschema<3,>=0.7->warlock!=1.3.0,<2,>=1.0.1->python-glanceclient>=2.5.0->python-openstackclient) Downloading functools32-3.2.3-2.zip Collecting jsonpointer>=1.9 (from jsonpatch<2,>=0.10->warlock!=1.3.0,<2,>=1.0.1->python-glanceclient>=2.5.0->python-openstackclient) Downloading jsonpointer-1.10-py2-none-any.whl Installing collected packages: pbr, six, stevedore, requests, wrapt, positional, iso8601, keystoneauth1, Babel, funcsigs, netifaces, netaddr, debtcollector, monotonic, oslo.i18n, oslo.utils, msgpack-python, oslo.serialization, rfc3986, oslo.config, python-keystoneclient, simplejson, PrettyTable, python-novaclient, functools32, jsonschema, jsonpointer, jsonpatch, warlock, python-glanceclient, python-cinderclient, requestsexceptions, PyYAML, appdirs, os-client-config, unicodecsv, cmd2, cliff, osc-lib, openstacksdk, python-openstackclient Found existing installation: six 1.4.1 DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project. Uninstalling six-1.4.1: Exception: Traceback (most recent call last): File "/Library/Python/2.7/site-packages/pip-9.0.0-py2.7.egg/pip/basecommand.py", line 215, in main status = self.run(options, args) File "/Library/Python/2.7/site-packages/pip-9.0.0-py2.7.egg/pip/commands/install.py", line 342, in run prefix=options.prefix_path, File "/Library/Python/2.7/site-packages/pip-9.0.0-py2.7.egg/pip/req/req_set.py", line 778, in install requirement.uninstall(auto_confirm=True) File "/Library/Python/2.7/site-packages/pip-9.0.0-py2.7.egg/pip/req/req_install.py", line 752, in uninstall paths_to_remove.remove(auto_confirm) File "/Library/Python/2.7/site-packages/pip-9.0.0-py2.7.egg/pip/req/req_uninstall.py", line 115, in remove renames(path, new_path) File "/Library/Python/2.7/site-packages/pip-9.0.0-py2.7.egg/pip/utils/__init__.py", line 267, in renames shutil.move(old, new) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move copy2(src, real_dst) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2 copystat(src, dst) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat os.chflags(dst, st.st_flags) OSError: [Errno 1] Operation not permitted: '/tmp/pip-ufqDGr-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'
エラーでインストールに失敗した。
OSError: [Errno 1] Operation not permitted: '/tmp/pip-ufqDGr-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info
どうやら six とかいうのが原因らしい(何がどう問題なのか理解していない)。
暫定対処でのインストール
色々ググったところ、sixをとりあえず無視してopenstackclientをインストールすればよさそうだと分かった。
以下でリトライする。
# pip install python-openstackclient --upgrade --ignore-installed six
# pip install python-openstackclient --upgrade --ignore-installed six Collecting python-openstackclient Using cached python_openstackclient-3.3.0-py2.py3-none-any.whl Collecting six Using cached six-1.10.0-py2.py3-none-any.whl Collecting pbr>=1.6 (from python-openstackclient) Using cached pbr-1.10.0-py2.py3-none-any.whl Collecting keystoneauth1>=2.10.0 (from python-openstackclient) Using cached keystoneauth1-2.15.0-py2.py3-none-any.whl Collecting Babel>=2.3.4 (from python-openstackclient) Using cached Babel-2.3.4-py2.py3-none-any.whl Collecting python-keystoneclient!=2.1.0,>=2.0.0 (from python-openstackclient) Using cached python_keystoneclient-3.6.0-py2.py3-none-any.whl Collecting python-novaclient!=2.33.0,>=2.29.0 (from python-openstackclient) Using cached python_novaclient-6.0.0-py2.py3-none-any.whl Collecting python-glanceclient>=2.5.0 (from python-openstackclient) Using cached python_glanceclient-2.5.0-py2.py3-none-any.whl Collecting python-cinderclient!=1.7.0,!=1.7.1,>=1.6.0 (from python-openstackclient) Using cached python_cinderclient-1.9.0-py2.py3-none-any.whl Collecting osc-lib>=1.0.2 (from python-openstackclient) Using cached osc_lib-1.2.0-py2-none-any.whl Collecting oslo.utils>=3.16.0 (from python-openstackclient) Using cached oslo.utils-3.18.0-py2.py3-none-any.whl Collecting oslo.i18n>=2.1.0 (from python-openstackclient) Using cached oslo.i18n-3.10.0-py2.py3-none-any.whl Collecting openstacksdk>=0.9.7 (from python-openstackclient) Using cached openstacksdk-0.9.9-py2.py3-none-any.whl Collecting cliff>=2.2.0 (from python-openstackclient) Using cached cliff-2.2.0-py2-none-any.whl Collecting stevedore>=1.17.1 (from keystoneauth1>=2.10.0->python-openstackclient) Using cached stevedore-1.18.0-py2.py3-none-any.whl Collecting requests>=2.10.0 (from keystoneauth1>=2.10.0->python-openstackclient) Using cached requests-2.11.1-py2.py3-none-any.whl Collecting positional>=1.1.1 (from keystoneauth1>=2.10.0->python-openstackclient) Using cached positional-1.1.1.tar.gz Collecting iso8601>=0.1.11 (from keystoneauth1>=2.10.0->python-openstackclient) Using cached iso8601-0.1.11-py2.py3-none-any.whl Collecting pytz>=0a (from Babel>=2.3.4->python-openstackclient) Downloading pytz-2016.7-py2.py3-none-any.whl (480kB) 100% |################################| 481kB 147kB/s Collecting oslo.serialization>=1.10.0 (from python-keystoneclient!=2.1.0,>=2.0.0->python-openstackclient) Using cached oslo.serialization-2.14.0-py2.py3-none-any.whl Collecting debtcollector>=1.2.0 (from python-keystoneclient!=2.1.0,>=2.0.0->python-openstackclient) Using cached debtcollector-1.9.0-py2.py3-none-any.whl Collecting oslo.config>=3.14.0 (from python-keystoneclient!=2.1.0,>=2.0.0->python-openstackclient) Using cached oslo.config-3.19.0-py2.py3-none-any.whl Collecting simplejson>=2.2.0 (from python-novaclient!=2.33.0,>=2.29.0->python-openstackclient) Using cached simplejson-3.10.0.tar.gz Collecting PrettyTable<0.8,>=0.7 (from python-novaclient!=2.33.0,>=2.29.0->python-openstackclient) Using cached prettytable-0.7.2.zip Collecting warlock!=1.3.0,<2,>=1.0.1 (from python-glanceclient>=2.5.0->python-openstackclient) Using cached warlock-1.2.0.tar.gz Collecting os-client-config!=1.19.0,!=1.19.1,!=1.20.0,!=1.20.1,!=1.21.0,>=1.13.1 (from osc-lib>=1.0.2->python-openstackclient) Using cached os_client_config-1.22.0-py2.py3-none-any.whl Collecting pyparsing>=2.0.1 (from oslo.utils>=3.16.0->python-openstackclient) Downloading pyparsing-2.1.10-py2.py3-none-any.whl (56kB) 100% |################################| 61kB 184kB/s Collecting funcsigs>=0.4; python_version == "2.7" or python_version == "2.6" (from oslo.utils>=3.16.0->python-openstackclient) Using cached funcsigs-1.0.2-py2.py3-none-any.whl Collecting netifaces>=0.10.4 (from oslo.utils>=3.16.0->python-openstackclient) Using cached netifaces-0.10.5.tar.gz Collecting netaddr!=0.7.16,>=0.7.13 (from oslo.utils>=3.16.0->python-openstackclient) Using cached netaddr-0.7.18-py2.py3-none-any.whl Collecting monotonic>=0.6 (from oslo.utils>=3.16.0->python-openstackclient) Using cached monotonic-1.2-py2.py3-none-any.whl Collecting PyYAML>=3.1.0 (from cliff>=2.2.0->python-openstackclient) Using cached PyYAML-3.12.tar.gz Collecting unicodecsv>=0.8.0; python_version < "3.0" (from cliff>=2.2.0->python-openstackclient) Using cached unicodecsv-0.14.1.tar.gz Collecting cmd2>=0.6.7 (from cliff>=2.2.0->python-openstackclient) Using cached cmd2-0.6.9.tar.gz Collecting wrapt (from positional>=1.1.1->keystoneauth1>=2.10.0->python-openstackclient) Using cached wrapt-1.10.8.tar.gz Collecting msgpack-python>=0.4.0 (from oslo.serialization>=1.10.0->python-keystoneclient!=2.1.0,>=2.0.0->python-openstackclient) Using cached msgpack-python-0.4.8.tar.gz Collecting rfc3986>=0.2.2 (from oslo.config>=3.14.0->python-keystoneclient!=2.1.0,>=2.0.0->python-openstackclient) Using cached rfc3986-0.4.1-py2.py3-none-any.whl Collecting jsonschema<3,>=0.7 (from warlock!=1.3.0,<2,>=1.0.1->python-glanceclient>=2.5.0->python-openstackclient) Using cached jsonschema-2.5.1-py2.py3-none-any.whl Collecting jsonpatch<2,>=0.10 (from warlock!=1.3.0,<2,>=1.0.1->python-glanceclient>=2.5.0->python-openstackclient) Using cached jsonpatch-1.14-py2.py3-none-any.whl Collecting requestsexceptions>=1.1.1 (from os-client-config!=1.19.0,!=1.19.1,!=1.20.0,!=1.20.1,!=1.21.0,>=1.13.1->osc-lib>=1.0.2->python-openstackclient) Using cached requestsexceptions-1.1.3-py2.py3-none-any.whl Collecting appdirs>=1.3.0 (from os-client-config!=1.19.0,!=1.19.1,!=1.20.0,!=1.20.1,!=1.21.0,>=1.13.1->osc-lib>=1.0.2->python-openstackclient) Using cached appdirs-1.4.0-py2.py3-none-any.whl Collecting functools32; python_version == "2.7" (from jsonschema<3,>=0.7->warlock!=1.3.0,<2,>=1.0.1->python-glanceclient>=2.5.0->python-openstackclient) Using cached functools32-3.2.3-2.zip Collecting jsonpointer>=1.9 (from jsonpatch<2,>=0.10->warlock!=1.3.0,<2,>=1.0.1->python-glanceclient>=2.5.0->python-openstackclient) Using cached jsonpointer-1.10-py2-none-any.whl Installing collected packages: pbr, six, stevedore, requests, wrapt, positional, iso8601, keystoneauth1, pytz, Babel, pyparsing, funcsigs, netifaces, netaddr, debtcollector, monotonic, oslo.i18n, oslo.utils, msgpack-python, oslo.serialization, rfc3986, oslo.config, python-keystoneclient, simplejson, PrettyTable, python-novaclient, functools32, jsonschema, jsonpointer, jsonpatch, warlock, python-glanceclient, python-cinderclient, requestsexceptions, PyYAML, appdirs, os-client-config, unicodecsv, cmd2, cliff, osc-lib, openstacksdk, python-openstackclient Running setup.py install for wrapt ... done Running setup.py install for positional ... done Running setup.py install for netifaces ... done Running setup.py install for msgpack-python ... done Running setup.py install for simplejson ... done Running setup.py install for PrettyTable ... done Running setup.py install for functools32 ... done Running setup.py install for warlock ... done Running setup.py install for PyYAML ... done Running setup.py install for unicodecsv ... done Running setup.py install for cmd2 ... done Successfully installed Babel-2.3.4 PrettyTable-0.7.2 PyYAML-3.12 appdirs-1.4.0 cliff-2.2.0 cmd2-0.6.9 debtcollector-1.9.0 funcsigs-1.0.2 functools32-3.2.3.post2 iso8601-0.1.11 jsonpatch-1.14 jsonpointer-1.10 jsonschema-2.5.1 keystoneauth1-2.15.0 monotonic-1.2 msgpack-python-0.4.8 netaddr-0.7.18 netifaces-0.10.5 openstacksdk-0.9.9 os-client-config-1.22.0 osc-lib-1.2.0 oslo.config-3.19.0 oslo.i18n-3.10.0 oslo.serialization-2.14.0 oslo.utils-3.18.0 pbr-1.10.0 positional-1.1.1 pyparsing-2.1.10 python-cinderclient-1.9.0 python-glanceclient-2.5.0 python-keystoneclient-3.6.0 python-novaclient-6.0.0 python-openstackclient-3.3.0 pytz-2016.7 requests-2.11.1 requestsexceptions-1.1.3 rfc3986-0.4.1 simplejson-3.10.0 six-1.10.0 stevedore-1.18.0 unicodecsv-0.14.1 warlock-1.2.0 wrapt-1.10.8 #
インストールできたようにみえる。
本当に使えるようになったか試してみる。そのために環境変数の設定をする。
APIアクセスするための環境変数の設定
OpenStack クライアントでAPIを叩くためには、環境変数の設定が必要となる。
その手順はこのDocsに記載されている。
ダッシュボードにアクセスして、rc.shファイルをダウンロードする。
画像では、OpenStack RC v2.0 と OpenStack RC v3 の2つがあるが、今回はとりあえずv3を選んだ。
"プロジェクト名-openrc.sh"という名前のファイルをダウンロードしたら、スクリプトを実行する。
ここで求められるパスワードは、対象のOpenStackユーザのパスワード。
# source /tmp/Test1-openrc.sh Please enter your OpenStack Password: #
これで環境変数の設定は完了。
コマンドラインツールを試してみる
いよいよコマンドラインツールで OpenStack の API を叩いてみる。
インスタンスは何も作っていないが、まずは nova list を実行してみる。空の表が表示されれば成功。
# nova list Traceback (most recent call last): File "/usr/local/bin/nova", line 7, in <module> from novaclient.shell import main File "/Library/Python/2.7/site-packages/novaclient/shell.py", line 44, in <module> import novaclient.auth_plugin File "/Library/Python/2.7/site-packages/novaclient/auth_plugin.py", line 23, in <module> from novaclient import utils File "/Library/Python/2.7/site-packages/novaclient/utils.py", line 22, in <module> from oslo_serialization import jsonutils File "/Library/Python/2.7/site-packages/oslo_serialization/jsonutils.py", line 44, in <module> import six.moves.xmlrpc_client as xmlrpclib ImportError: No module named xmlrpc_client #
またもエラー発生……。
このエラーにもかなり苦戦した。
色々調べたところ、これも結局 six とかいうツール(?)が原因で発生しているらしい。
sixのバージョンアップ
結論を述べると、six を 1.10.0 にバージョンアップさせると解決した(元は 1.4.1 だった)。
このページを参考にして対処した。
よく分からないまま対処したため、six も 1.10.0 以降のバージョンが既にあったかもしれない。
まず、参考にしたページに書いてあるリンクから、six の 1.10.0 をダウンロード。
https://pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz#md5=34eed507548117b2ab523ab14b2f8b55
次に解凍してinstallを実行。
# tar -zxvf six-1.10.0.tar.gz x six-1.10.0/ x six-1.10.0/six.egg-info/ x six-1.10.0/six.egg-info/top_level.txt x six-1.10.0/six.egg-info/SOURCES.txt x six-1.10.0/six.egg-info/dependency_links.txt x six-1.10.0/six.egg-info/PKG-INFO x six-1.10.0/CHANGES x six-1.10.0/six.py x six-1.10.0/documentation/ x six-1.10.0/documentation/conf.py x six-1.10.0/documentation/Makefile x six-1.10.0/documentation/index.rst x six-1.10.0/LICENSE x six-1.10.0/README x six-1.10.0/MANIFEST.in x six-1.10.0/setup.cfg x six-1.10.0/test_six.py x six-1.10.0/PKG-INFO x six-1.10.0/setup.py # # python ./six-1.10.0/setup.py install Traceback (most recent call last): File "./six-1.10.0/setup.py", line 19, in <module> with open("README", "r") as fp: IOError: [Errno 2] No such file or directory: 'README' #
しかしエラー。
ただ、これは実行時のディレクトリを変更すれば通った(実行時の相対パスの問題?)。
# cd ./six-1.10.0 # python ./setup.py install running install Checking .pth file support in /Library/Python/2.7/site-packages/ /usr/bin/python -E -c pass TEST PASSED: /Library/Python/2.7/site-packages/ appears to support .pth files running bdist_egg running egg_info writing six.egg-info/PKG-INFO writing top-level names to six.egg-info/top_level.txt writing dependency_links to six.egg-info/dependency_links.txt reading manifest file 'six.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' no previously-included directories found matching 'documentation/_build' writing manifest file 'six.egg-info/SOURCES.txt' installing library code to build/bdist.macosx-10.11-intel/egg running install_lib running build_py creating build creating build/lib copying six.py -> build/lib creating build/bdist.macosx-10.11-intel creating build/bdist.macosx-10.11-intel/egg copying build/lib/six.py -> build/bdist.macosx-10.11-intel/egg byte-compiling build/bdist.macosx-10.11-intel/egg/six.py to six.pyc creating build/bdist.macosx-10.11-intel/egg/EGG-INFO copying six.egg-info/PKG-INFO -> build/bdist.macosx-10.11-intel/egg/EGG-INFO copying six.egg-info/SOURCES.txt -> build/bdist.macosx-10.11-intel/egg/EGG-INFO copying six.egg-info/dependency_links.txt -> build/bdist.macosx-10.11-intel/egg/EGG-INFO copying six.egg-info/top_level.txt -> build/bdist.macosx-10.11-intel/egg/EGG-INFO zip_safe flag not set; analyzing archive contents... six: module references __path__ creating dist creating 'dist/six-1.10.0-py2.7.egg' and adding 'build/bdist.macosx-10.11-intel/egg' to it removing 'build/bdist.macosx-10.11-intel/egg' (and everything under it) Processing six-1.10.0-py2.7.egg creating /Library/Python/2.7/site-packages/six-1.10.0-py2.7.egg Extracting six-1.10.0-py2.7.egg to /Library/Python/2.7/site-packages Adding six 1.10.0 to easy-install.pth file Installed /Library/Python/2.7/site-packages/six-1.10.0-py2.7.egg Processing dependencies for six==1.10.0 Finished processing dependencies for six==1.10.0 #
問題なくインストールできたようだ。
再びコマンドラインツールを試してみる
six をアップデートしたので、もう一度コマンドラインツールを試してみる。
# nova list +----+------+--------+------------+-------------+----------+ | ID | Name | Status | Task State | Power State | Networks | +----+------+--------+------------+-------------+----------+ +----+------+--------+------------+-------------+----------+ #
ようやく成功!
インスタンスは作っていないので、空の表が表示された。
neutron のインストール
neutron も試してみる。
neutron は別途インストールしないといけないそうなので、インストールする。
# pip install python-neutronclient Collecting python-neutronclient Downloading python_neutronclient-6.0.0-py2.py3-none-any.whl (287kB) 100% |################################| 296kB 102kB/s Requirement already satisfied: os-client-config!=1.19.0,!=1.19.1,!=1.20.0,!=1.20.1,!=1.21.0,>=1.13.1 in /Library/Python/2.7/site-packages (from python-neutronclient) Requirement already satisfied: Babel>=2.3.4 in /Library/Python/2.7/site-packages (from python-neutronclient) Requirement already satisfied: keystoneauth1>=2.10.0 in /Library/Python/2.7/site-packages (from python-neutronclient) Requirement already satisfied: pbr>=1.6 in /Library/Python/2.7/site-packages (from python-neutronclient) Requirement already satisfied: simplejson>=2.2.0 in /Library/Python/2.7/site-packages (from python-neutronclient) Requirement already satisfied: netaddr!=0.7.16,>=0.7.12 in /Library/Python/2.7/site-packages (from python-neutronclient) Requirement already satisfied: debtcollector>=1.2.0 in /Library/Python/2.7/site-packages (from python-neutronclient) Requirement already satisfied: osc-lib>=1.0.2 in /Library/Python/2.7/site-packages (from python-neutronclient) Requirement already satisfied: requests>=2.10.0 in /Library/Python/2.7/site-packages (from python-neutronclient) Requirement already satisfied: six>=1.9.0 in /Library/Python/2.7/site-packages/six-1.10.0-py2.7.egg (from python-neutronclient) Requirement already satisfied: oslo.utils>=3.16.0 in /Library/Python/2.7/site-packages (from python-neutronclient) Requirement already satisfied: oslo.i18n>=2.1.0 in /Library/Python/2.7/site-packages (from python-neutronclient) Requirement already satisfied: oslo.serialization>=1.10.0 in /Library/Python/2.7/site-packages (from python-neutronclient) Requirement already satisfied: iso8601>=0.1.11 in /Library/Python/2.7/site-packages (from python-neutronclient) Requirement already satisfied: cliff!=1.16.0,!=1.17.0,>=1.15.0 in /Library/Python/2.7/site-packages (from python-neutronclient) Requirement already satisfied: requestsexceptions>=1.1.1 in /Library/Python/2.7/site-packages (from os-client-config!=1.19.0,!=1.19.1,!=1.20.0,!=1.20.1,!=1.21.0,>=1.13.1->python-neutronclient) Requirement already satisfied: PyYAML>=3.1.0 in /Library/Python/2.7/site-packages (from os-client-config!=1.19.0,!=1.19.1,!=1.20.0,!=1.20.1,!=1.21.0,>=1.13.1->python-neutronclient) Requirement already satisfied: appdirs>=1.3.0 in /Library/Python/2.7/site-packages (from os-client-config!=1.19.0,!=1.19.1,!=1.20.0,!=1.20.1,!=1.21.0,>=1.13.1->python-neutronclient) Requirement already satisfied: pytz>=0a in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from Babel>=2.3.4->python-neutronclient) Requirement already satisfied: stevedore>=1.17.1 in /Library/Python/2.7/site-packages (from keystoneauth1>=2.10.0->python-neutronclient) Requirement already satisfied: positional>=1.1.1 in /Library/Python/2.7/site-packages (from keystoneauth1>=2.10.0->python-neutronclient) Requirement already satisfied: wrapt>=1.7.0 in /Library/Python/2.7/site-packages (from debtcollector>=1.2.0->python-neutronclient) Requirement already satisfied: funcsigs>=0.4; python_version == "2.7" or python_version == "2.6" in /Library/Python/2.7/site-packages (from debtcollector>=1.2.0->python-neutronclient) Requirement already satisfied: pyparsing>=2.0.1 in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from oslo.utils>=3.16.0->python-neutronclient) Requirement already satisfied: netifaces>=0.10.4 in /Library/Python/2.7/site-packages (from oslo.utils>=3.16.0->python-neutronclient) Requirement already satisfied: monotonic>=0.6 in /Library/Python/2.7/site-packages (from oslo.utils>=3.16.0->python-neutronclient) Requirement already satisfied: msgpack-python>=0.4.0 in /Library/Python/2.7/site-packages (from oslo.serialization>=1.10.0->python-neutronclient) Requirement already satisfied: unicodecsv>=0.8.0; python_version < "3.0" in /Library/Python/2.7/site-packages (from cliff!=1.16.0,!=1.17.0,>=1.15.0->python-neutronclient) Requirement already satisfied: PrettyTable<0.8,>=0.7 in /Library/Python/2.7/site-packages (from cliff!=1.16.0,!=1.17.0,>=1.15.0->python-neutronclient) Requirement already satisfied: cmd2>=0.6.7 in /Library/Python/2.7/site-packages (from cliff!=1.16.0,!=1.17.0,>=1.15.0->python-neutronclient) Installing collected packages: python-neutronclient Successfully installed python-neutronclient-6.0.0 #
インストールできたので、ネットワークを表示させてみる。
既に2つのネットワークを作成していたので、それが表示されるはず。
# neutron net-list +--------------------------------------+--------------+------------------------------------------------------+ | id | name | subnets | +--------------------------------------+--------------+------------------------------------------------------+ | b0ff4813-7896-4c2e-bd5a-cf33159b7224 | Test-Private | 5ec5b9a5-4311-4451-81fb-fe9885db85ab 10.1.1.0/24 | | 1a6c8232-7d66-4eda-b1a0-7364324bd7b4 | Public | 78d72dae-bdf8-4fef-b877-bbe16ae11c9a 192.168.11.0/24 | +--------------------------------------+--------------+------------------------------------------------------+ #
これも成功。
ようやく、OpenStack コマンドラインツールの準備が完了した。
VMware上のCentOSに割り当てたディスク領域を拡張する
VMware Fusion 上の CentOS に割り当てているディスク領域を拡張した際の備忘録。
■概要
Mac の VMware Fusion で作成した CentOS 仮想マシンに割り当てているディスク領域を20GBから40GBに拡張する。
※環境
Mac OS X El Capitan
VMware Fusion 8
CentOS 7
■変更手順
①VMware Fusion 上でディスク容量を増やす
CentOSの仮想マシンをシステム終了している状態で、VMware Fusionの仮想マシン設定パネルを開く。
ここでディスク容量を変更できる。
20GBから40GBに変更する。
②CentOS側でパーティションの容量を増やす
現在のディスクの状態を確認
[root@localhost ~]# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda3 18555904 10241464 8314440 56% / devtmpfs 3119660 0 3119660 0% /dev tmpfs 3134112 184 3133928 1% /dev/shm tmpfs 3134112 9184 3124928 1% /run tmpfs 3134112 0 3134112 0% /sys/fs/cgroup /dev/loop0 1900368 6148 1772980 1% /srv/node/swiftloopback /dev/sda1 303788 199580 104208 66% /boot .host:/ 998041088 369500884 628540204 38% /mnt/hgfs tmpfs 626824 20 626804 1% /run/user/1000 [root@localhost ~]# [root@localhost ~]# fdisk -l /dev/sda Disk /dev/sda: 42.9 GB, 42949672960 bytes, 83886080 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x0000d44c Device Boot Start End Blocks Id System /dev/sda1 * 2048 616447 307200 83 Linux /dev/sda2 616448 4810751 2097152 82 Linux swap / Solaris /dev/sda3 4810752 41943039 18566144 83 Linux
現在のディスク容量にはまだ変化はないが、
/dev/sda3 18555904 10241464 8314440 56% /
/dev/sda3 4810752 41943039 18566144 83 Linux
増加したことは認識しているようだ。
Disk /dev/sda: 42.9 GB, 42949672960 bytes, 83886080 sectors
CentOS側の容量を拡張するため、/dev/sda3 の End を後ろに拡張する。
一度 /dev/sda3 を削除(d)し、End を変更した /dev/sda3 を作成(n)する。
作成の際、First sector と Last sector はデフォルトで設定している。
※パーティション設定を誤るとデータが消える恐れがあるので注意すること!
[root@localhost ~]# fdisk /dev/sda Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): d Partition number (1-3, default 3): 3 Partition 3 is deleted Command (m for help): p Disk /dev/sda: 42.9 GB, 42949672960 bytes, 83886080 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x0000d44c Device Boot Start End Blocks Id System /dev/sda1 * 2048 616447 307200 83 Linux /dev/sda2 616448 4810751 2097152 82 Linux swap / Solaris Command (m for help): n Partition type: p primary (2 primary, 0 extended, 2 free) e extended Select (default p): p Partition number (3,4, default 3): 3 First sector (4810752-83886079, default 4810752): Using default value 4810752 Last sector, +sectors or +size{K,M,G} (4810752-83886079, default 83886079): Using default value 83886079 Partition 3 of type Linux and of size 37.7 GiB is set Command (m for help): p Disk /dev/sda: 42.9 GB, 42949672960 bytes, 83886080 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x0000d44c Device Boot Start End Blocks Id System /dev/sda1 * 2048 616447 307200 83 Linux /dev/sda2 616448 4810751 2097152 82 Linux swap / Solaris /dev/sda3 4810752 83886079 39537664 83 Linux
設定したパーティションで保存(w)して fdisk を終了する。
※もし設定を誤ったりキャンセルしたい場合は'q'で抜ける
Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks.
警告が出て、再起動後に設定が反映されると言われたので再起動する。
再起動後、dfコマンドで確認するが、まだ /dev/sda3 の容量は変わっていない。
[root@localhost ~]# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda3 18555904 10241464 8314440 56% / devtmpfs 3119660 0 3119660 0% /dev tmpfs 3134112 184 3133928 1% /dev/shm tmpfs 3134112 9184 3124928 1% /run tmpfs 3134112 0 3134112 0% /sys/fs/cgroup /dev/loop0 1900368 6148 1772980 1% /srv/node/swiftloopback /dev/sda1 303788 199580 104208 66% /boot .host:/ 998041088 369500884 628540204 38% /mnt/hgfs tmpfs 626824 20 626804 1% /run/user/1000
最後に xfs_growfs コマンドで /dev/sda3 のサイズを変更する。
[root@localhost ~]# xfs_growfs /dev/sda3 meta-data=/dev/sda3 isize=256 agcount=4, agsize=1160384 blks = sectsz=512 attr=2, projid32bit=1 = crc=0 finobt=0 data = bsize=4096 blocks=4641536, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=0 log =internal bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 4641536 to 9884416
dfコマンドで再度確認すると、ちゃんと /dev/sda3 の容量が増加している。
[root@localhost ~]# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda3 39527424 10241680 29285744 26% / devtmpfs 3119660 0 3119660 0% /dev tmpfs 3134112 184 3133928 1% /dev/shm tmpfs 3134112 9184 3124928 1% /run tmpfs 3134112 0 3134112 0% /sys/fs/cgroup /dev/loop0 1900368 6148 1772980 1% /srv/node/swiftloopback /dev/sda1 303788 199580 104208 66% /boot .host:/ 998041088 369758552 628282536 38% /mnt/hgfs tmpfs 626824 20 626804 1% /run/user/1000
異なるxibにあるオブジェクト間でのデータ渡し(実装編)
注意事項
前回、異なるxibにあるオブジェクト間で、データを渡す方法について検討した。
検討して浮上した案は4つ。今回はその4つの案の実装を試みる。
■前回の案を実際に実装
前回検討した案は以下の通り。
・案1:NSWindowController経由
・案2:AppDelegate経由
・案3:クラス内グローバル変数
・案4:NSNotificationCenter経由
これらの案の実装として、メインウインドウに入力した文字をサブウインドウで表示するプログラムを作成する。
完成イメージ
■案1:NSWindowController経由
案1では、メインウインドウのテキストフィールドのデータをNSWindowControllerサブクラス経由で、サブウインドウがあるxib側のオブジェクトに渡している。
実際のプログラムはこちら。
GitHub - tnbinkttm203582/MultiWindowSample1: 異なるxibのオブジェクト間のデータ渡し 案1
AppControllerがSubWindowControllerを作ったあと、AppControllerがSubWindowControllerに、テキストフィールドの文字列を渡している。文字列を受け取ったSubWindowControllerは、そのままSubWindowAppControllerに渡している。
また、テキストフィールドの編集が完了する度に、SubWindowAppControllerへ文字列を渡している。
なおサブウインドウの文字列表記は、SubWindowAppControllerにあるtestStr変数にbindさせて表示している。
■案2:AppDelegate経由
AppDelegateにデータを置く方法は非常に簡単。
①最初から作成されているappDelegateに、受け渡したい変数とそのアクセサメソッドを追記。
②渡す側のオブジェクトで、プログラム共通のappDelegateのインスタンスを呼び出し、渡したいデータをセット。
③受け取る側のオブジェクトでappDelegateのインスタンスを呼び出し、データを取得。
appDelegateの呼び出しは以下の通り。
AppDelegate *appDele = (AppDelegate *) [[NSApplication sharedApplication] delegate];
あとは呼び出したappDelegateインスタンスにデータをセットしたり取り出したりすればよい。
ただし案1と違って、「誰が」、「いつ」SubWindowAppControllerにデータをセットすればいいのか考える必要がある。
案1では、中継役のSubWindowControllerが SubWindowAppControllerへのデータ渡しも担ってくれた。しかし案2では、中継役のAppDelegateがSubWindowAppControllerへデータを渡してくれない(渡したい相手のSubWindowAppControllerを知らないため)。
そのため、誰かが何かしらのタイミングで、AppDelegateに仮置きしているデータをSubWindowAppControllerにセットしなければならない。
「誰が」の観点はあまり問題でなく、特に目的がなければ SubWindowAppController自身でいい。
問題は「いつ」で、本来であればサブウインドウが作成(表示)された時と、テキスト入力が完了した時に、AppDelegateによる受け渡しが実現できなければならない。そのタイミングを一番簡単に合わせる方法は、案1でやったSubWindowControllerを使う方法だと思う。
なので、タイミングの周知をSubWindowControllerに頼ってデータ渡しはAppDelegateを使う、という合わせ技もありだが、そこまでするなら全て案1でええやんとなる。
ちなみに、案3も案2と同じこの問題を抱えている。
この問題の続きは案3の説明で。
■案3:クラス内グローバル変数
案3も、共通的に利用できるオブジェクトにデータを仮置きするという点では案2と変わらない。そのため、案2で説明した「いつデータを取り出すか」の問題も同様に存在する。
このプログラムにおいては、
①サブウインドウを作成時
②メインウインドウのテキストフィールドの編集完了時
の2つのタイミングでデータを仮置きオブジェクトから取り出せればいい。
受け手であるSubWindowAppControllerがNSTimerを使ったループでポーリングして取得する方法もあるが、あまりに力技なのでもう少し別の方法を考える。送り手であるAppControllerが何らかの手法でSubWindowAppControllerに伝えることができれば一番いい。その手法として、NSNotificationCenter を使った通知がある。
NSNotificationCenter を使えば、異なるオブジェクト間でイベント通知が可能になる。SubWindowAppControllerが通知を待ち受け、①と②を行った際にAppControllerが通知すれば、適切なタイミングに処理できる。
実際のプログラムはこちら。
GitHub - tnbinkttm203582/MultiWindowTest3: 異なるxibのオブジェクト間のデータ渡し 案3
このNSNotificationCenterを使った通知方法は、案2でも有効。
ただ、NSNotificationCenterの通知には、通知でオブジェクトを引数にできる。つまり、NSNotificationCenter単体でデータ渡しができるため、結局NSNotificationCenterを使うなら案2も案3もいらないのではと思わざるを得ない。もしかすると、プログラムによってはNSNotificationCenter+案2,3 という構成が効果的な場合もあるかもしれないが……。
■案4:NSNotificationCenter経由
案3で解説した通り、NSNotificationCenterでは通知と同時にオブジェクト渡しもできる。案3のサンプルプログラムのNSNotificationCenter処理を少し書き換えるだけでそれはできると思う。詳しい方法はNSNotificationCenterの使い方をリファレンス等で確認してほしい。
■まとめ
データ渡しのタイミングさえ気にしなければ、4通りの手法を取れることが分かった。タイミングが問題になるプログラムの場合は、案1か案4の処理が必要になる。
タイミングを気にしないのであれば、案2のAppDelegateを使う方法が一番簡単だった。ただAppDelegateは使い易いため、考えなしに実装していくと何でもかんでもここに書いてしまうそうなので、リソースや保守性で注意は必要だと感じた。何でもかんでも、の点でいえば案4のNSNotificationCenterによる通知もそうで、これも頼りすぎないようにしたい。
それぞれ一長一短があるので作りたいプログラムの設計に合わせて使っていきたい。